summaryrefslogtreecommitdiff
path: root/src/tangara/audio
diff options
context:
space:
mode:
authorailurux <ailuruxx@gmail.com>2024-08-29 15:20:22 +1000
committerailurux <ailuruxx@gmail.com>2024-08-29 15:20:22 +1000
commit96a224c0df4f647b3e5dbbcbbedad3a1d38470ba (patch)
tree8960865293dde6f9844b7b1a42d5775d5dceceb2 /src/tangara/audio
parent3421bd652c39b253872e43d3b6e43664bd0b66e2 (diff)
downloadtangara-fw-96a224c0df4f647b3e5dbbcbbedad3a1d38470ba.tar.gz
Lua API improvements and fixes
Co-authored-by: jacqueline <me@jacqueline.id.au>
Diffstat (limited to 'src/tangara/audio')
-rw-r--r--src/tangara/audio/track_queue.cpp15
-rw-r--r--src/tangara/audio/track_queue.hpp1
2 files changed, 16 insertions, 0 deletions
diff --git a/src/tangara/audio/track_queue.cpp b/src/tangara/audio/track_queue.cpp
index cc4770ae..2c1faf96 100644
--- a/src/tangara/audio/track_queue.cpp
+++ b/src/tangara/audio/track_queue.cpp
@@ -236,6 +236,21 @@ auto TrackQueue::next() -> void {
next(Reason::kExplicitUpdate);
}
+auto TrackQueue::currentPosition(size_t position) -> bool {
+ {
+ const std::shared_lock<std::shared_mutex> lock(mutex_);
+ if (position >= totalSize()) {
+ return false;
+ }
+ goTo(position);
+ }
+
+ // 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;
+}
+
auto TrackQueue::goTo(size_t position) -> void {
position_ = position;
if (opened_playlist_) {
diff --git a/src/tangara/audio/track_queue.hpp b/src/tangara/audio/track_queue.hpp
index 1d25568d..a8d1dc3a 100644
--- a/src/tangara/audio/track_queue.hpp
+++ b/src/tangara/audio/track_queue.hpp
@@ -73,6 +73,7 @@ class TrackQueue {
auto current() const -> TrackItem;
auto currentPosition() const -> size_t;
+ auto currentPosition(size_t position) -> bool;
auto totalSize() const -> size_t;
auto open() -> bool;
auto openPlaylist(const std::string& playlist_file, bool notify = true)