From 326cc42a63ec1bd8ff4e62da44658e8facd181c2 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Tue, 13 Aug 2024 16:25:47 +1000 Subject: [PATCH 1/3] Don't spuriously report that the current track has changed Fixes the last track in the queue repeating forever --- src/tangara/audio/track_queue.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/tangara/audio/track_queue.cpp b/src/tangara/audio/track_queue.cpp index 91bdda39..5d730a09 100644 --- a/src/tangara/audio/track_queue.cpp +++ b/src/tangara/audio/track_queue.cpp @@ -242,6 +242,8 @@ auto TrackQueue::next(Reason r) -> void { { const std::unique_lock lock(mutex_); + auto pos = position_; + if (shuffle_) { shuffle_->next(); position_ = shuffle_->current(); @@ -250,7 +252,9 @@ auto TrackQueue::next(Reason r) -> void { position_++; } } + goTo(position_); + changed = pos != position_; } notifyChanged(changed, r); From 9c56261122a98245c8e6e7e9f1c94a8b683f8832 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Thu, 15 Aug 2024 10:26:26 +1000 Subject: [PATCH 2/3] Delay DB reindexing slightly This helps with boot time by preventing a ton of disk I/O before the UI has had a chance to load. --- src/tangara/system_fsm/running.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/tangara/system_fsm/running.cpp b/src/tangara/system_fsm/running.cpp index f9bca074..07166e2f 100644 --- a/src/tangara/system_fsm/running.cpp +++ b/src/tangara/system_fsm/running.cpp @@ -188,6 +188,10 @@ auto Running::mountStorage() -> void { // mounted card. if (sServices->nvs().DbAutoIndex()) { sServices->bg_worker().Dispatch([&]() { + // Delay the index update for a bit, since we don't want to cause a lot + // of disk contention immediately after mounting (especially when we've + // just booted), or else we risk slowing down stuff like UI loading. + vTaskDelay(pdMS_TO_TICKS(6000)); auto db = sServices->database().lock(); if (!db) { return; From 493f8e1200f73a921bf06a51fd1e6689396151ea Mon Sep 17 00:00:00 2001 From: jacqueline Date: Thu, 15 Aug 2024 11:44:49 +1000 Subject: [PATCH 3/3] Don't break early from clearing PcmBuffer --- src/drivers/pcm_buffer.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/drivers/pcm_buffer.cpp b/src/drivers/pcm_buffer.cpp index 142a6376..25762c50 100644 --- a/src/drivers/pcm_buffer.cpp +++ b/src/drivers/pcm_buffer.cpp @@ -71,11 +71,6 @@ auto PcmBuffer::clear() -> void { if (data) { vRingbufferReturnItem(ringbuf_, data); received_ += bytes_cleared / sizeof(int16_t); - } else { - // Defensively guard against looping forever if for some reason the - // buffer isn't draining. - ESP_LOGW(kTag, "PcmBuffer not draining"); - break; } } }