mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-07 03:57:07 +03:00
catchup with cspot "official" - release
This commit is contained in:
@@ -1,3 +1,6 @@
|
|||||||
|
2023-10.07
|
||||||
|
- catchup with official cspot
|
||||||
|
|
||||||
2023-10-06
|
2023-10-06
|
||||||
- fix cspot PREV on first track, NEXT on last track and normal ending
|
- fix cspot PREV on first track, NEXT on last track and normal ending
|
||||||
- use DMA_AUTO for SPI
|
- use DMA_AUTO for SPI
|
||||||
|
|||||||
@@ -101,11 +101,10 @@ class BellLogger : public bell::AbstractLogger {
|
|||||||
gmt_time = localtime(&now_time);
|
gmt_time = localtime(&now_time);
|
||||||
std::cout << std::put_time(gmt_time, "[%H:%M:%S") << '.'
|
std::cout << std::put_time(gmt_time, "[%H:%M:%S") << '.'
|
||||||
<< std::setfill('0') << std::setw(3) << nowMs.count() << "] ";
|
<< std::setfill('0') << std::setw(3) << nowMs.count() << "] ";
|
||||||
}
|
} else {
|
||||||
else {
|
gmt_time = gmtime(&now_time);
|
||||||
gmt_time = gmtime(&now_time);
|
std::cout << std::put_time(gmt_time, "[%Y-%m-%d %H:%M:%S") << '.'
|
||||||
std::cout << std::put_time(gmt_time, "[%Y-%m-%d %H:%M:%S") << '.'
|
<< std::setfill('0') << std::setw(3) << nowMs.count() << "] ";
|
||||||
<< std::setfill('0') << std::setw(3) << nowMs.count() << "] ";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ struct TrackReference;
|
|||||||
class TrackPlayer : bell::Task {
|
class TrackPlayer : bell::Task {
|
||||||
public:
|
public:
|
||||||
// Callback types
|
// Callback types
|
||||||
typedef std::function<void(std::shared_ptr<QueuedTrack>, bool)> TrackLoadedCallback;
|
typedef std::function<void(std::shared_ptr<QueuedTrack>, bool)>
|
||||||
|
TrackLoadedCallback;
|
||||||
typedef std::function<size_t(uint8_t*, size_t, std::string_view)>
|
typedef std::function<size_t(uint8_t*, size_t, std::string_view)>
|
||||||
DataCallback;
|
DataCallback;
|
||||||
typedef std::function<void()> EOFCallback;
|
typedef std::function<void()> EOFCallback;
|
||||||
|
|||||||
@@ -31,8 +31,10 @@ SpircHandler::SpircHandler(std::shared_ptr<cspot::Context> ctx) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
auto trackLoadedCallback = [this](std::shared_ptr<QueuedTrack> track, bool paused = false) {
|
auto trackLoadedCallback = [this](std::shared_ptr<QueuedTrack> track,
|
||||||
playbackState->setPlaybackState(paused ? PlaybackState::State::Paused : PlaybackState::State::Playing);
|
bool paused = false) {
|
||||||
|
playbackState->setPlaybackState(paused ? PlaybackState::State::Paused
|
||||||
|
: PlaybackState::State::Playing);
|
||||||
playbackState->updatePositionMs(track->requestedPosition);
|
playbackState->updatePositionMs(track->requestedPosition);
|
||||||
|
|
||||||
this->notify();
|
this->notify();
|
||||||
@@ -78,9 +80,9 @@ void SpircHandler::subscribeToMercury() {
|
|||||||
void SpircHandler::loadTrackFromURI(const std::string& uri) {}
|
void SpircHandler::loadTrackFromURI(const std::string& uri) {}
|
||||||
|
|
||||||
void SpircHandler::notifyAudioEnded() {
|
void SpircHandler::notifyAudioEnded() {
|
||||||
playbackState->updatePositionMs(0);
|
playbackState->updatePositionMs(0);
|
||||||
notify();
|
notify();
|
||||||
trackPlayer->resetState(true);
|
trackPlayer->resetState(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpircHandler::notifyAudioReachedPlayback() {
|
void SpircHandler::notifyAudioReachedPlayback() {
|
||||||
@@ -234,7 +236,7 @@ void SpircHandler::notify() {
|
|||||||
this->sendCmd(MessageType_kMessageTypeNotify);
|
this->sendCmd(MessageType_kMessageTypeNotify);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpircHandler::skipSong(TrackQueue::SkipDirection dir) {
|
bool SpircHandler::skipSong(TrackQueue::SkipDirection dir) {
|
||||||
bool skipped = trackQueue->skipTrack(dir);
|
bool skipped = trackQueue->skipTrack(dir);
|
||||||
|
|
||||||
// Reset track state
|
// Reset track state
|
||||||
|
|||||||
@@ -510,9 +510,9 @@ bool TrackQueue::queueNextTrack(int offset, uint32_t positionMs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// in case we re-queue current track, make sure position is updated (0)
|
// in case we re-queue current track, make sure position is updated (0)
|
||||||
if (offset == 0 && preloadedTracks.size() &&
|
if (offset == 0 && preloadedTracks.size() &&
|
||||||
preloadedTracks[0]->ref == currentTracks[currentTracksIndex]) {
|
preloadedTracks[0]->ref == currentTracks[currentTracksIndex]) {
|
||||||
preloadedTracks.pop_front();
|
preloadedTracks.pop_front();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (offset <= 0) {
|
if (offset <= 0) {
|
||||||
@@ -527,51 +527,53 @@ bool TrackQueue::queueNextTrack(int offset, uint32_t positionMs) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool TrackQueue::skipTrack(SkipDirection dir, bool expectNotify) {
|
bool TrackQueue::skipTrack(SkipDirection dir, bool expectNotify) {
|
||||||
bool skipped = true;
|
bool skipped = true;
|
||||||
std::scoped_lock lock(tracksMutex);
|
std::scoped_lock lock(tracksMutex);
|
||||||
|
|
||||||
if (dir == SkipDirection::PREV) {
|
if (dir == SkipDirection::PREV) {
|
||||||
uint64_t position = !playbackState->innerFrame.state.has_position_ms ? 0 :
|
uint64_t position =
|
||||||
playbackState->innerFrame.state.position_ms +
|
!playbackState->innerFrame.state.has_position_ms
|
||||||
ctx->timeProvider->getSyncedTimestamp() -
|
? 0
|
||||||
playbackState->innerFrame.state.position_measured_at;
|
: playbackState->innerFrame.state.position_ms +
|
||||||
|
ctx->timeProvider->getSyncedTimestamp() -
|
||||||
|
playbackState->innerFrame.state.position_measured_at;
|
||||||
|
|
||||||
if (currentTracksIndex > 0 && position < 3000) {
|
if (currentTracksIndex > 0 && position < 3000) {
|
||||||
queueNextTrack(-1);
|
queueNextTrack(-1);
|
||||||
|
|
||||||
if (preloadedTracks.size() > MAX_TRACKS_PRELOAD) {
|
if (preloadedTracks.size() > MAX_TRACKS_PRELOAD) {
|
||||||
preloadedTracks.pop_back();
|
preloadedTracks.pop_back();
|
||||||
}
|
|
||||||
|
|
||||||
currentTracksIndex--;
|
|
||||||
} else {
|
|
||||||
queueNextTrack(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
currentTracksIndex--;
|
||||||
} else {
|
} else {
|
||||||
if (currentTracks.size() > currentTracksIndex + 1) {
|
queueNextTrack(0);
|
||||||
preloadedTracks.pop_front();
|
|
||||||
|
|
||||||
if (!queueNextTrack(preloadedTracks.size() + 1)) {
|
|
||||||
CSPOT_LOG(info, "Failed to queue next track");
|
|
||||||
}
|
|
||||||
|
|
||||||
currentTracksIndex++;
|
|
||||||
} else {
|
|
||||||
skipped = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (currentTracks.size() > currentTracksIndex + 1) {
|
||||||
|
preloadedTracks.pop_front();
|
||||||
|
|
||||||
if (skipped) {
|
if (!queueNextTrack(preloadedTracks.size() + 1)) {
|
||||||
// Update frame data
|
CSPOT_LOG(info, "Failed to queue next track");
|
||||||
playbackState->innerFrame.state.playing_track_index = currentTracksIndex;
|
}
|
||||||
|
|
||||||
if (expectNotify) {
|
currentTracksIndex++;
|
||||||
// Reset position to zero
|
} else {
|
||||||
notifyPending = true;
|
skipped = false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return skipped;
|
if (skipped) {
|
||||||
|
// Update frame data
|
||||||
|
playbackState->innerFrame.state.playing_track_index = currentTracksIndex;
|
||||||
|
|
||||||
|
if (expectNotify) {
|
||||||
|
// Reset position to zero
|
||||||
|
notifyPending = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return skipped;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TrackQueue::hasTracks() {
|
bool TrackQueue::hasTracks() {
|
||||||
|
|||||||
Reference in New Issue
Block a user