mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-11 22:17:17 +03:00
update CSpot + clear audio buffer when changing track
This commit is contained in:
@@ -18,6 +18,7 @@ public:
|
||||
|
||||
uint16_t volume;
|
||||
std::string deviceName;
|
||||
std::string apOverride;
|
||||
AudioFormat format;
|
||||
};
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
extern char deviceId[];
|
||||
|
||||
// Hardcoded information sent to spotify servers
|
||||
const char * const informationString = "cspot";
|
||||
const char * const brandName = "corn";
|
||||
const char * const versionString = "cspot-1.0";
|
||||
const char * const informationString = "cspot-player";
|
||||
const char * const brandName = "cspot";
|
||||
const char * const versionString = "cspot-1.1";
|
||||
const char * const protocolVersion = "2.7.1";
|
||||
const char * const defaultDeviceName = "CSpot";
|
||||
const char * const swVersion = "1.0.0";
|
||||
|
||||
@@ -69,7 +69,6 @@ private:
|
||||
std::unique_ptr<WrappedSemaphore> queueSemaphore;
|
||||
unsigned long long lastRequestTimestamp = -1;
|
||||
unsigned long long lastPingTimestamp = -1;
|
||||
std::atomic<bool> isRunning = false;
|
||||
uint64_t sequenceId;
|
||||
uint32_t audioKeySequence;
|
||||
audioKeyCallback keyCallback;
|
||||
@@ -78,10 +77,11 @@ private:
|
||||
public:
|
||||
MercuryManager(std::unique_ptr<Session> session);
|
||||
~MercuryManager();
|
||||
std::atomic<bool> isRunning = false;
|
||||
voidCallback reconnectedCallback;
|
||||
uint16_t audioChunkSequence;
|
||||
std::shared_ptr<TimeProvider> timeProvider;
|
||||
std::string countryCode;
|
||||
char countryCode[2];
|
||||
|
||||
bool timeoutHandler();
|
||||
uint64_t execute(MercuryType method, std::string uri, mercuryCallback &callback, mercuryCallback &subscription, mercuryParts &payload);
|
||||
|
||||
@@ -14,17 +14,17 @@
|
||||
#include "SpotifyTrack.h"
|
||||
#include "AudioSink.h"
|
||||
#include <mutex>
|
||||
#include "Queue.h"
|
||||
#include "Task.h"
|
||||
|
||||
class Player : public bell::Task {
|
||||
private:
|
||||
std::shared_ptr<MercuryManager> manager;
|
||||
std::shared_ptr<SpotifyTrack> currentTrack = nullptr;
|
||||
SpotifyTrack *currentTrack = nullptr;
|
||||
SpotifyTrack *nextTrack = nullptr;
|
||||
std::shared_ptr<AudioSink> audioSink;
|
||||
std::mutex loadTrackMutex;
|
||||
// @TODO: Use some actual structure here
|
||||
bell::Queue<std::shared_ptr<SpotifyTrack>> trackQueue;
|
||||
WrappedMutex nextTrackMutex;
|
||||
WrappedMutex currentTrackMutex;
|
||||
void runTask();
|
||||
|
||||
public:
|
||||
|
||||
@@ -24,6 +24,7 @@ enum class CSpotEventType {
|
||||
PREV,
|
||||
SEEK,
|
||||
LOAD,
|
||||
PLAYBACK_START
|
||||
};
|
||||
|
||||
struct CSpotEvent {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "NanoPBHelper.h"
|
||||
#include "protobuf/metadata.pb.h"
|
||||
#include <cassert>
|
||||
#include <atomic>
|
||||
|
||||
struct TrackInfo {
|
||||
std::string name;
|
||||
@@ -33,8 +34,8 @@ private:
|
||||
void trackInformationCallback(std::unique_ptr<MercuryResponse> response, uint32_t position_ms, bool isPaused);
|
||||
void episodeInformationCallback(std::unique_ptr<MercuryResponse> response, uint32_t position_ms, bool isPaused);
|
||||
void requestAudioKey(std::vector<uint8_t> fileId, std::vector<uint8_t> trackId, int32_t trackDuration, uint32_t position_ms, bool isPaused);
|
||||
bool countryListContains(std::string countryList, std::string country);
|
||||
bool canPlayTrack();
|
||||
bool countryListContains(char *countryList, char *country);
|
||||
bool canPlayTrack(int altIndex);
|
||||
Track trackInfo;
|
||||
Episode episodeInfo;
|
||||
|
||||
@@ -45,6 +46,7 @@ public:
|
||||
SpotifyTrack(std::shared_ptr<MercuryManager> manager, std::shared_ptr<TrackReference> trackRef, uint32_t position_ms, bool isPaused);
|
||||
~SpotifyTrack();
|
||||
uint64_t reqSeqNum = -1;
|
||||
std::atomic<bool> loaded = false;
|
||||
std::function<void()> loadedTrackCallback;
|
||||
std::unique_ptr<ChunkedAudioStream> audioStream;
|
||||
trackChangedCallback trackInfoReceived;
|
||||
|
||||
@@ -18,8 +18,6 @@ public:
|
||||
TrackReference(TrackRef *ref);
|
||||
~TrackReference();
|
||||
|
||||
TrackRef* ref;
|
||||
|
||||
std::vector<uint8_t> gid;
|
||||
|
||||
bool isEpisode = false;
|
||||
@@ -32,4 +30,4 @@ public:
|
||||
std::string getMercuryRequestUri();
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user