summaryrefslogtreecommitdiff
path: root/src/tangara/audio/track_queue.cpp
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2024-08-26 13:50:39 +1000
committerjacqueline <me@jacqueline.id.au>2024-08-26 13:50:39 +1000
commit91f26afa755e4efd2dcb97f6010f0ceb226e91f2 (patch)
tree2369897ef140c80ba68b3f16b568428fdfb7076b /src/tangara/audio/track_queue.cpp
parent275ade5d13f8e49e89ed14c7acff6644f5c644a1 (diff)
parente1b21492103b96488bd82b7cfc8c764dca701cea (diff)
downloadtangara-fw-91f26afa755e4efd2dcb97f6010f0ceb226e91f2.tar.gz
Merge branch 'main' of codeberg.org:cool-tech-zone/tangara-fw
Diffstat (limited to 'src/tangara/audio/track_queue.cpp')
-rw-r--r--src/tangara/audio/track_queue.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/tangara/audio/track_queue.cpp b/src/tangara/audio/track_queue.cpp
index ecf33c74..761ea09a 100644
--- a/src/tangara/audio/track_queue.cpp
+++ b/src/tangara/audio/track_queue.cpp
@@ -137,14 +137,16 @@ auto TrackQueue::open() -> bool {
return playlist_.open();
}
-auto TrackQueue::openPlaylist(const std::string& playlist_file) -> bool {
+auto TrackQueue::openPlaylist(const std::string& playlist_file, bool notify) -> bool {
opened_playlist_.emplace(playlist_file);
auto res = opened_playlist_->open();
if (!res) {
return false;
}
updateShuffler(true);
- notifyChanged(true, Reason::kExplicitUpdate);
+ if (notify) {
+ notifyChanged(true, Reason::kExplicitUpdate);
+ }
return true;
}
@@ -371,7 +373,7 @@ auto TrackQueue::serialise() -> std::string {
}
TrackQueue::QueueParseClient::QueueParseClient(TrackQueue& queue)
- : queue_(queue), state_(State::kInit), i_(0) {}
+ : queue_(queue), state_(State::kInit), i_(0), position_to_set_(0) {}
cppbor::ParseClient* TrackQueue::QueueParseClient::item(
std::unique_ptr<cppbor::Item>& item,
@@ -400,10 +402,11 @@ cppbor::ParseClient* TrackQueue::QueueParseClient::item(
i_ = 0;
} else if (item->type() == cppbor::UINT) {
auto val = item->asUint()->unsignedValue();
- queue_.goTo(val);
+ // Save the position so we can apply it later when we have finished serialising
+ position_to_set_ = val;
} else if (item->type() == cppbor::TSTR) {
auto val = item->asTstr();
- queue_.openPlaylist(val->value());
+ queue_.openPlaylist(val->value(), false);
} else if (item->type() == cppbor::SIMPLE) {
bool val = item->asBool()->value();
if (i_ == 0) {
@@ -448,6 +451,7 @@ cppbor::ParseClient* TrackQueue::QueueParseClient::itemEnd(
if (state_ == State::kInit) {
state_ = State::kFinished;
} else if (state_ == State::kRoot) {
+ queue_.goTo(position_to_set_);
state_ = State::kFinished;
} else if (state_ == State::kMetadata) {
if (item->type() == cppbor::ARRAY) {