diff options
| author | jacqueline <me@jacqueline.id.au> | 2024-02-20 11:56:24 +1100 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2024-02-20 11:56:24 +1100 |
| commit | 79be8a8e6eda4521297384a6da38c1a2cf101ccc (patch) | |
| tree | 2e7174ad5d1f7a5201925b8403aecb81e19ad107 /src | |
| parent | 403bd4672c1aa0bd5f0ac8e6da700bfb1aec9768 (diff) | |
| parent | 3f6256f9e6a0e02267e582710de1eb1426223470 (diff) | |
| download | tangara-fw-79be8a8e6eda4521297384a6da38c1a2cf101ccc.tar.gz | |
Merge branch 'main' of codeberg.org:cool-tech-zone/tangara-fw
Diffstat (limited to 'src')
| -rw-r--r-- | src/audio/track_queue.cpp | 57 |
1 files changed, 35 insertions, 22 deletions
diff --git a/src/audio/track_queue.cpp b/src/audio/track_queue.cpp index 534da10c..b75230fc 100644 --- a/src/audio/track_queue.cpp +++ b/src/audio/track_queue.cpp @@ -200,39 +200,52 @@ auto TrackQueue::append(Item i) -> void { } auto TrackQueue::next() -> void { - const std::unique_lock<std::shared_mutex> lock(mutex_); - if (shuffle_) { - shuffle_->next(); - pos_ = shuffle_->current(); - } else { - if (pos_ + 1 >= tracks_.size()) { - if (replay_) { - pos_ = 0; - } + bool changed = true; + + { + const std::unique_lock<std::shared_mutex> lock(mutex_); + if (shuffle_) { + shuffle_->next(); + pos_ = shuffle_->current(); } else { - pos_++; + if (pos_ + 1 >= tracks_.size()) { + if (replay_) { + pos_ = 0; + } else { + pos_ = tracks_.size(); + changed = false; + } + } else { + pos_++; + } } } - notifyChanged(true); + notifyChanged(changed); } auto TrackQueue::previous() -> void { - const std::unique_lock<std::shared_mutex> lock(mutex_); - if (shuffle_) { - shuffle_->prev(); - pos_ = shuffle_->current(); - } else { - if (pos_ == 0) { - if (repeat_) { - pos_ = tracks_.size() - 1; - } + bool changed = true; + + { + const std::unique_lock<std::shared_mutex> lock(mutex_); + if (shuffle_) { + shuffle_->prev(); + pos_ = shuffle_->current(); } else { - pos_--; + if (pos_ == 0) { + if (repeat_) { + pos_ = tracks_.size() - 1; + } else { + changed = false; + } + } else { + pos_--; + } } } - notifyChanged(true); + notifyChanged(changed); } auto TrackQueue::finish() -> void { |
