summaryrefslogtreecommitdiff
path: root/src/audio/fatfs_audio_input.cpp
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-12-07 16:57:05 +1100
committerjacqueline <me@jacqueline.id.au>2023-12-07 17:00:30 +1100
commit3f7f199cb940c8d5f6d48f77fd59971adffe49ef (patch)
treeaa22162e46c5e9ccce4c7ee8537b493f437664d9 /src/audio/fatfs_audio_input.cpp
parent009f69c929eb1d1b65d75b0937fbf3b8de5d9148 (diff)
downloadtangara-fw-3f7f199cb940c8d5f6d48f77fd59971adffe49ef.tar.gz
Remove pre-iterator concepts
- No more IndexRecord/Result/dbGetPage nonsense - Queue is just track ids - i am so tired and have so much to do
Diffstat (limited to 'src/audio/fatfs_audio_input.cpp')
-rw-r--r--src/audio/fatfs_audio_input.cpp32
1 files changed, 9 insertions, 23 deletions
diff --git a/src/audio/fatfs_audio_input.cpp b/src/audio/fatfs_audio_input.cpp
index 5594718f..58d5852f 100644
--- a/src/audio/fatfs_audio_input.cpp
+++ b/src/audio/fatfs_audio_input.cpp
@@ -50,23 +50,19 @@ FatfsAudioInput::FatfsAudioInput(database::ITagParser& tag_parser,
bg_worker_(bg_worker),
new_stream_mutex_(),
new_stream_(),
- has_new_stream_(false),
- pending_path_() {}
+ has_new_stream_(false) {}
FatfsAudioInput::~FatfsAudioInput() {}
-auto FatfsAudioInput::SetPath(std::future<std::optional<std::pmr::string>> fut)
- -> void {
- std::lock_guard<std::mutex> guard{new_stream_mutex_};
- pending_path_.reset(
- new database::FutureFetcher<std::optional<std::pmr::string>>(
- std::move(fut)));
-
- has_new_stream_ = true;
- has_new_stream_.notify_one();
+auto FatfsAudioInput::SetPath(std::optional<std::string> path) -> void {
+ if (path) {
+ SetPath(*path);
+ } else {
+ SetPath();
+ }
}
-auto FatfsAudioInput::SetPath(const std::pmr::string& path) -> void {
+auto FatfsAudioInput::SetPath(const std::string& path) -> void {
std::lock_guard<std::mutex> guard{new_stream_mutex_};
if (OpenFile(path)) {
has_new_stream_ = true;
@@ -96,16 +92,6 @@ auto FatfsAudioInput::NextStream() -> std::shared_ptr<TaggedStream> {
continue;
}
- // If the path is a future, then wait for it to complete.
- if (pending_path_) {
- auto res = pending_path_->Result();
- pending_path_.reset();
-
- if (res && *res) {
- OpenFile(**res);
- }
- }
-
if (new_stream_ == nullptr) {
continue;
}
@@ -117,7 +103,7 @@ auto FatfsAudioInput::NextStream() -> std::shared_ptr<TaggedStream> {
}
}
-auto FatfsAudioInput::OpenFile(const std::pmr::string& path) -> bool {
+auto FatfsAudioInput::OpenFile(const std::string& path) -> bool {
ESP_LOGI(kTag, "opening file %s", path.c_str());
auto tags = tag_parser_.ReadAndParseTags(path);