summaryrefslogtreecommitdiff
path: root/src/tangara/audio/track_queue.cpp
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2024-08-28 15:30:25 +1000
committerjacqueline <me@jacqueline.id.au>2024-08-28 15:30:25 +1000
commitaf7a70450e3ceaaf291aa09b9383b50b879759d9 (patch)
treebe024b6eb3373035407182efa41a6a587bb98a7d /src/tangara/audio/track_queue.cpp
parent9145722b08b9c648e41d6b36f83bebbd106efc1e (diff)
downloadtangara-fw-af7a70450e3ceaaf291aa09b9383b50b879759d9.tar.gz
Support adding filepaths to the track queue
Diffstat (limited to 'src/tangara/audio/track_queue.cpp')
-rw-r--r--src/tangara/audio/track_queue.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/tangara/audio/track_queue.cpp b/src/tangara/audio/track_queue.cpp
index 6fa5511c..cc4770ae 100644
--- a/src/tangara/audio/track_queue.cpp
+++ b/src/tangara/audio/track_queue.cpp
@@ -161,12 +161,6 @@ auto TrackQueue::getFilepath(database::TrackId id)
return db->getTrackPath(id);
}
-// TODO WIP: Atm only appends are allowed, this will only ever append regardless
-// of what index is given. But it is kept like this for compatability for now.
-auto TrackQueue::insert(Item i, size_t index) -> void {
- append(i);
-}
-
auto TrackQueue::append(Item i) -> void {
bool was_queue_empty;
bool current_changed;
@@ -186,6 +180,16 @@ auto TrackQueue::append(Item i) -> void {
updateShuffler(was_queue_empty);
}
notifyChanged(current_changed, Reason::kExplicitUpdate);
+ } else if (std::holds_alternative<std::string>(i)) {
+ auto& path = std::get<std::string>(i);
+ if (!path.empty()) {
+ {
+ const std::unique_lock<std::shared_mutex> lock(mutex_);
+ playlist_.append(std::get<std::string>(i));
+ updateShuffler(was_queue_empty);
+ }
+ notifyChanged(current_changed, Reason::kExplicitUpdate);
+ }
} else if (std::holds_alternative<database::TrackIterator>(i)) {
// Iterators can be very large, and retrieving items from them often
// requires disk i/o. Handle them asynchronously so that inserting them