From af7a70450e3ceaaf291aa09b9383b50b879759d9 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Wed, 28 Aug 2024 15:30:25 +1000 Subject: Support adding filepaths to the track queue --- src/tangara/audio/track_queue.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/tangara/audio/track_queue.cpp') 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(i)) { + auto& path = std::get(i); + if (!path.empty()) { + { + const std::unique_lock lock(mutex_); + playlist_.append(std::get(i)); + updateShuffler(was_queue_empty); + } + notifyChanged(current_changed, Reason::kExplicitUpdate); + } } else if (std::holds_alternative(i)) { // Iterators can be very large, and retrieving items from them often // requires disk i/o. Handle them asynchronously so that inserting them -- cgit v1.2.3