summaryrefslogtreecommitdiff
path: root/src/audio
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-09-28 08:29:55 +1000
committerjacqueline <me@jacqueline.id.au>2023-09-28 08:29:55 +1000
commitf09ba5ffd53bf7d28e0dc516c00a8f69ca7efae9 (patch)
treeaffce5567186d8944686afd824bf4ee4f7ee4d2d /src/audio
parentf168bfab7698f28492c7693263525945a26cbcc8 (diff)
downloadtangara-fw-f09ba5ffd53bf7d28e0dc516c00a8f69ca7efae9.tar.gz
Use bindey for databinding instead of hand rolling ui updates
Diffstat (limited to 'src/audio')
-rw-r--r--src/audio/audio_decoder.cpp1
-rw-r--r--src/audio/fatfs_audio_input.cpp7
-rw-r--r--src/audio/track_queue.cpp5
3 files changed, 10 insertions, 3 deletions
diff --git a/src/audio/audio_decoder.cpp b/src/audio/audio_decoder.cpp
index 7751bf37..86394a37 100644
--- a/src/audio/audio_decoder.cpp
+++ b/src/audio/audio_decoder.cpp
@@ -103,6 +103,7 @@ void Decoder::Main() {
for (;;) {
if (source_->HasNewStream() || !stream_) {
std::shared_ptr<codecs::IStream> new_stream = source_->NextStream();
+ ESP_LOGI(kTag, "decoder has new stream");
if (new_stream && BeginDecoding(new_stream)) {
stream_ = new_stream;
} else {
diff --git a/src/audio/fatfs_audio_input.cpp b/src/audio/fatfs_audio_input.cpp
index f71f0463..6039ff9d 100644
--- a/src/audio/fatfs_audio_input.cpp
+++ b/src/audio/fatfs_audio_input.cpp
@@ -34,6 +34,7 @@
#include "future_fetcher.hpp"
#include "tag_parser.hpp"
#include "tasks.hpp"
+#include "track.hpp"
#include "types.hpp"
static const char* kTag = "SRC";
@@ -118,13 +119,13 @@ auto FatfsAudioInput::NextStream() -> std::shared_ptr<codecs::IStream> {
auto FatfsAudioInput::OpenFile(const std::pmr::string& path) -> bool {
ESP_LOGI(kTag, "opening file %s", path.c_str());
- database::TrackTags tags;
- if (!tag_parser_.ReadAndParseTags(path, &tags)) {
+ auto tags = tag_parser_.ReadAndParseTags(path);
+ if (!tags) {
ESP_LOGE(kTag, "failed to read tags");
return false;
}
- auto stream_type = ContainerToStreamType(tags.encoding());
+ auto stream_type = ContainerToStreamType(tags->encoding());
if (!stream_type.has_value()) {
ESP_LOGE(kTag, "couldn't match container to stream");
return false;
diff --git a/src/audio/track_queue.cpp b/src/audio/track_queue.cpp
index 6f17ad33..b1cacc00 100644
--- a/src/audio/track_queue.cpp
+++ b/src/audio/track_queue.cpp
@@ -19,6 +19,8 @@
namespace audio {
+static constexpr char kTag[] = "tracks";
+
TrackQueue::TrackQueue() {}
auto TrackQueue::GetCurrent() const -> std::optional<database::TrackId> {
@@ -202,6 +204,9 @@ auto TrackQueue::Previous() -> void {
auto TrackQueue::Clear() -> void {
const std::lock_guard<std::mutex> lock(mutex_);
+ if (enqueued_.empty() && played_.empty()) {
+ return;
+ }
QueueUpdate ev{.current_changed = !enqueued_.empty()};
played_.clear();
enqueued_.clear();