summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2024-04-11 16:38:34 +1000
committerjacqueline <me@jacqueline.id.au>2024-04-11 16:38:34 +1000
commitf580928cbab797e4e8a3eae5ae1c0b18b8066066 (patch)
treeaa932b016a14504bc9e8eb6bd916416a5d52fee1 /src
parent3276d113fcae2a73a1df6a32af73556a3a78b21f (diff)
downloadtangara-fw-f580928cbab797e4e8a3eae5ae1c0b18b8066066.tar.gz
Remember the source of the previous track when opening a new one
Diffstat (limited to 'src')
-rw-r--r--src/audio/audio_fsm.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/audio/audio_fsm.cpp b/src/audio/audio_fsm.cpp
index a8f1260f..91ba7df0 100644
--- a/src/audio/audio_fsm.cpp
+++ b/src/audio/audio_fsm.cpp
@@ -123,6 +123,16 @@ void AudioState::react(const QueueUpdate& ev) {
}
void AudioState::react(const SetTrack& ev) {
+ // Remember the current track if there is one, since we need to preserve some
+ // of the state if it turns out this SetTrack event corresponds to seeking
+ // within the current track.
+ std::string prev_uri;
+ bool prev_from_queue = false;
+ if (sCurrentTrack) {
+ prev_uri = sCurrentTrack->uri;
+ prev_from_queue = sCurrentTrackIsFromQueue;
+ }
+
if (ev.transition == SetTrack::Transition::kHardCut) {
sCurrentTrack.reset();
sCurrentSamples = 0;
@@ -158,6 +168,11 @@ void AudioState::react(const SetTrack& ev) {
}
if (path) {
+ if (*path == prev_uri) {
+ // This was a seek or replay within the same track; don't forget where
+ // the track originally came from.
+ sNextTrackIsFromQueue = prev_from_queue;
+ }
sFileSource->SetPath(*path, seek_to);
} else {
sFileSource->SetPath();