diff options
| author | ailurux <ailuruxx@gmail.com> | 2024-07-16 01:23:43 +0000 |
|---|---|---|
| committer | cooljqln <cooljqln@noreply.codeberg.org> | 2024-07-16 01:23:43 +0000 |
| commit | 0a271d786be4cc1a1691fa38f184a091721a5251 (patch) | |
| tree | 9239449971dc9b9c8a261f1fd8076f0b03f57da8 /src/tangara/audio/audio_fsm.cpp | |
| parent | 24fde7af0cc411e897e28ba4612105c4aa9bee18 (diff) | |
| download | tangara-fw-0a271d786be4cc1a1691fa38f184a091721a5251.tar.gz | |
daniel/playlist-queue (#83)
Reviewed-on: https://codeberg.org/cool-tech-zone/tangara-fw/pulls/83
Reviewed-by: cooljqln <cooljqln@noreply.codeberg.org>
Co-authored-by: ailurux <ailuruxx@gmail.com>
Co-committed-by: ailurux <ailuruxx@gmail.com>
Diffstat (limited to 'src/tangara/audio/audio_fsm.cpp')
| -rw-r--r-- | src/tangara/audio/audio_fsm.cpp | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/tangara/audio/audio_fsm.cpp b/src/tangara/audio/audio_fsm.cpp index fbc38f97..65261d75 100644 --- a/src/tangara/audio/audio_fsm.cpp +++ b/src/tangara/audio/audio_fsm.cpp @@ -96,9 +96,7 @@ void AudioState::react(const QueueUpdate& ev) { }; auto current = sServices->track_queue().current(); - if (current) { - cmd.new_track = *current; - } + cmd.new_track = current; switch (ev.reason) { case QueueUpdate::kExplicitUpdate: @@ -176,18 +174,21 @@ void AudioState::react(const internal::DecodingFinished& ev) { sServices->bg_worker().Dispatch<void>([=]() { auto& queue = sServices->track_queue(); auto current = queue.current(); - if (!current) { + if (std::holds_alternative<std::monostate>(current)) { return; } auto db = sServices->database().lock(); if (!db) { return; } - auto path = db->getTrackPath(*current); - if (!path) { - return; + std::string path; + if (std::holds_alternative<std::string>(current)) { + path = std::get<std::string>(current); + } else if (std::holds_alternative<database::TrackId>(current)) { + auto tid = std::get<database::TrackId>(current); + path = db->getTrackPath(tid).value_or(""); } - if (*path == ev.track->uri) { + if (path == ev.track->uri) { queue.finish(); } }); @@ -449,6 +450,9 @@ void Standby::react(const system_fsm::SdStateChanged& ev) { return; } + // Open the queue file + sServices->track_queue().open(); + // Restore the currently playing file before restoring the queue. This way, // we can fall back to restarting the queue's current track if there's any // issue restoring the current file. |
