mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-09 21:17:18 +03:00
try to fix misc cspot issues + silence network manager log
This commit is contained in:
@@ -5,8 +5,13 @@
|
||||
static size_t vorbisReadCb(void *ptr, size_t size, size_t nmemb, ChunkedAudioStream *self)
|
||||
{
|
||||
size_t readSize = 0;
|
||||
while (readSize < nmemb * size && self->byteStream->position() < self->byteStream->size()) {
|
||||
readSize += self->byteStream->read((uint8_t *) ptr + readSize, (size * nmemb) - readSize);
|
||||
while (readSize < nmemb * size && self->byteStream->position() < self->byteStream->size() && self->isRunning) {
|
||||
size_t bytes = self->byteStream->read((uint8_t *) ptr + readSize, (size * nmemb) - readSize);
|
||||
if (bytes <= 0) {
|
||||
CSPOT_LOG(info, "unexpected end/error of stream");
|
||||
return readSize;
|
||||
}
|
||||
readSize += bytes;
|
||||
}
|
||||
return readSize;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,6 @@ std::shared_ptr<AudioChunk> MercuryManager::fetchAudioChunk(std::vector<uint8_t>
|
||||
this->session->shanConn->sendPacket(static_cast<uint8_t>(MercuryType::AUDIO_CHUNK_REQUEST_COMMAND), buffer);
|
||||
|
||||
// Used for broken connection detection
|
||||
CSPOT_LOG(info, "requesting Chunk %hu", this->audioChunkSequence - 1);
|
||||
this->lastRequestTimestamp = this->timeProvider->getSyncedTimestamp();
|
||||
return this->audioChunkManager->registerNewChunk(this->audioChunkSequence - 1, audioKey, startPos, endPos);
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ void Player::runTask()
|
||||
}
|
||||
else
|
||||
{
|
||||
usleep(10000);
|
||||
usleep(20000);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -147,7 +147,7 @@ void Player::cancelCurrentTrack()
|
||||
}
|
||||
}
|
||||
|
||||
void Player::handleLoad(std::shared_ptr<TrackReference> trackReference, std::function<void()>& trackLoadedCallback, uint32_t position_ms, bool isPaused)
|
||||
void Player::handleLoad(std::shared_ptr<TrackReference> trackReference, std::function<void(bool)>& trackLoadedCallback, uint32_t position_ms, bool isPaused)
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(loadTrackMutex);
|
||||
|
||||
@@ -166,7 +166,9 @@ void Player::handleLoad(std::shared_ptr<TrackReference> trackReference, std::fun
|
||||
|
||||
this->nextTrack->trackInfoReceived = this->trackChanged;
|
||||
this->nextTrack->loadedTrackCallback = [this, framesCallback, trackLoadedCallback]() {
|
||||
trackLoadedCallback();
|
||||
bool needFlush = currentTrack != nullptr && currentTrack->audioStream != nullptr && currentTrack->audioStream->isRunning;
|
||||
cancelCurrentTrack();
|
||||
trackLoadedCallback(needFlush);
|
||||
|
||||
this->nextTrackMutex.lock();
|
||||
this->nextTrack->audioStream->streamFinishedCallback = this->endOfFileCallback;
|
||||
@@ -175,7 +177,6 @@ void Player::handleLoad(std::shared_ptr<TrackReference> trackReference, std::fun
|
||||
this->nextTrack->loaded = true;
|
||||
this->nextTrackMutex.unlock();
|
||||
|
||||
cancelCurrentTrack();
|
||||
};
|
||||
this->nextTrackMutex.unlock();
|
||||
}
|
||||
|
||||
@@ -190,10 +190,10 @@ void SpircController::handleFrame(std::vector<uint8_t> &data) {
|
||||
void SpircController::loadTrack(uint32_t position_ms, bool isPaused) {
|
||||
sendEvent(CSpotEventType::LOAD, (int) position_ms);
|
||||
state->setPlaybackState(PlaybackState::Loading);
|
||||
std::function<void()> loadedLambda = [=]() {
|
||||
std::function<void(bool)> loadedLambda = [=](bool needFlush) {
|
||||
// Loading finished, notify that playback started
|
||||
setPause(isPaused, false);
|
||||
sendEvent(CSpotEventType::PLAYBACK_START);
|
||||
sendEvent(CSpotEventType::PLAYBACK_START, needFlush);
|
||||
};
|
||||
|
||||
player->handleLoad(state->getCurrentTrack(), loadedLambda, position_ms,
|
||||
|
||||
@@ -106,7 +106,7 @@ void SpotifyTrack::trackInformationCallback(std::unique_ptr<MercuryResponse> res
|
||||
altIndex++;
|
||||
CSPOT_LOG(info, "Trying alternative %d", altIndex);
|
||||
|
||||
if(altIndex > trackInfo.alternative_count) {
|
||||
if(altIndex >= trackInfo.alternative_count) {
|
||||
// no alternatives for song
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user