diff options
| author | cooljqln <cooljqln@noreply.codeberg.org> | 2024-09-19 04:44:16 +0000 |
|---|---|---|
| committer | cooljqln <cooljqln@noreply.codeberg.org> | 2024-09-19 04:44:16 +0000 |
| commit | 1eddfe97d9398215d4512785c669cf7cc94b6223 (patch) | |
| tree | 6b7223e9c0e677705ec3ccfd5846f8fe0cdebeb1 /src/tangara/audio/track_queue.cpp | |
| parent | 9aa77ec5ad369cd7d5ca46d475df29d971416a73 (diff) | |
| parent | 7f43d4d1265ce7f456b36f51987c812d35bcd616 (diff) | |
| download | tangara-fw-1eddfe97d9398215d4512785c669cf7cc94b6223.tar.gz | |
Merge pull request 'daniel/persistent-positions' (#104) from daniel/persistent-positions into main
Reviewed-on: https://codeberg.org/cool-tech-zone/tangara-fw/pulls/104
Reviewed-by: cooljqln <cooljqln@noreply.codeberg.org>
Diffstat (limited to 'src/tangara/audio/track_queue.cpp')
| -rw-r--r-- | src/tangara/audio/track_queue.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/tangara/audio/track_queue.cpp b/src/tangara/audio/track_queue.cpp index 2c1faf96..ff24637b 100644 --- a/src/tangara/audio/track_queue.cpp +++ b/src/tangara/audio/track_queue.cpp @@ -85,6 +85,16 @@ auto notifyChanged(bool current_changed, Reason reason) -> void { events::Audio().Dispatch(ev); } +auto notifyPlayFrom(uint32_t start_from_position) -> void { + QueueUpdate ev{ + .current_changed = true, + .reason = Reason::kExplicitUpdate, + .seek_to_second = start_from_position, + }; + events::Ui().Dispatch(ev); + events::Audio().Dispatch(ev); +} + TrackQueue::TrackQueue(tasks::WorkerPool& bg_worker, database::Handle db) : mutex_(), bg_worker_(bg_worker), @@ -109,6 +119,17 @@ auto TrackQueue::current() const -> TrackItem { return val; } +auto TrackQueue::playFromPosition(const std::string& filepath, + uint32_t position) -> void { + clear(); + { + const std::unique_lock<std::shared_mutex> lock(mutex_); + playlist_.append(filepath); + updateShuffler(true); + } + notifyPlayFrom(position); +} + auto TrackQueue::currentPosition() const -> size_t { const std::shared_lock<std::shared_mutex> lock(mutex_); return position_; @@ -245,7 +266,7 @@ auto TrackQueue::currentPosition(size_t position) -> bool { goTo(position); } - // If we're explicitly setting the position, we want to treat it as though + // If we're explicitly setting the position, we want to treat it as though // the current track has changed, even if the position was the same notifyChanged(true, Reason::kExplicitUpdate); return true; |
