summaryrefslogtreecommitdiff
path: root/src/audio/audio_decoder.cpp
diff options
context:
space:
mode:
authorailurux <ailuruxx@gmail.com>2024-02-15 16:12:07 +1100
committerailurux <ailuruxx@gmail.com>2024-02-15 16:12:07 +1100
commit62f6179abe24339c2e5b7350528afbcad4c52067 (patch)
treed14f0b35ef601d0877ced507c5560236da666218 /src/audio/audio_decoder.cpp
parente466522c25758670da335195d60a5d599ed56177 (diff)
downloadtangara-fw-62f6179abe24339c2e5b7350528afbcad4c52067.tar.gz
Added offset for track seeking, wav impl. only rn
Diffstat (limited to 'src/audio/audio_decoder.cpp')
-rw-r--r--src/audio/audio_decoder.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/audio/audio_decoder.cpp b/src/audio/audio_decoder.cpp
index b0a973d9..02cf27e3 100644
--- a/src/audio/audio_decoder.cpp
+++ b/src/audio/audio_decoder.cpp
@@ -51,9 +51,10 @@ static constexpr std::size_t kCodecBufferLength =
drivers::kI2SBufferLengthFrames * sizeof(sample::Sample);
Timer::Timer(std::shared_ptr<Track> t,
- const codecs::ICodec::OutputFormat& format)
+ const codecs::ICodec::OutputFormat& format,
+ uint32_t current_seconds)
: track_(t),
- current_seconds_(0),
+ current_seconds_(current_seconds),
current_sample_in_second_(0),
samples_per_second_(format.sample_rate_hz * format.num_channels),
total_duration_seconds_(format.total_samples.value_or(0) /
@@ -131,7 +132,7 @@ auto Decoder::BeginDecoding(std::shared_ptr<TaggedStream> stream) -> bool {
return false;
}
- auto open_res = codec_->OpenStream(stream);
+ auto open_res = codec_->OpenStream(stream, stream->Offset());
if (open_res.has_error()) {
ESP_LOGE(kTag, "codec failed to start: %s",
codecs::ICodec::ErrorString(open_res.error()).c_str());
@@ -147,6 +148,7 @@ auto Decoder::BeginDecoding(std::shared_ptr<TaggedStream> stream) -> bool {
ESP_LOGI(kTag, "stream started ok");
events::Audio().Dispatch(internal::InputFileOpened{});
+ // TODO: How does this need to change?
auto tags = std::make_shared<Track>(Track{
.tags = stream->tags(),
.db_info = {},
@@ -155,7 +157,8 @@ auto Decoder::BeginDecoding(std::shared_ptr<TaggedStream> stream) -> bool {
});
timer_.reset(new Timer(tags, open_res.value()));
- PlaybackUpdate ev{.seconds_elapsed = 0, .track = tags};
+ // TODO: How does *this?* need to change?
+ PlaybackUpdate ev{.seconds_elapsed = stream->Offset(), .track = tags};
events::Audio().Dispatch(ev);
events::Ui().Dispatch(ev);