|
|
@ -199,7 +199,7 @@ auto WavDecoder::OpenStream(std::shared_ptr<IStream> input,uint32_t offset) |
|
|
|
return cpp::fail(Error::kUnsupportedFormat); |
|
|
|
return cpp::fail(Error::kUnsupportedFormat); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
auto data_offset = offset * samples_per_second * bits_per_sample; |
|
|
|
int64_t data_offset = offset * samples_per_second * bytes_per_sample_; |
|
|
|
|
|
|
|
|
|
|
|
// Seek track to start of data
|
|
|
|
// Seek track to start of data
|
|
|
|
input->SeekTo(data_chunk_index + 8 + data_offset, IStream::SeekFrom::kStartOfStream); |
|
|
|
input->SeekTo(data_chunk_index + 8 + data_offset, IStream::SeekFrom::kStartOfStream); |
|
|
@ -218,6 +218,7 @@ auto WavDecoder::DecodeTo(cpp::span<sample::Sample> output) |
|
|
|
|
|
|
|
|
|
|
|
buffer_.ConsumeBytes([&](cpp::span<std::byte> buf) -> size_t { |
|
|
|
buffer_.ConsumeBytes([&](cpp::span<std::byte> buf) -> size_t { |
|
|
|
size_t bytes_read = buf.size_bytes(); |
|
|
|
size_t bytes_read = buf.size_bytes(); |
|
|
|
|
|
|
|
ESP_LOGI(kTag, "Bytes read: %d", bytes_read); |
|
|
|
size_t frames_read = |
|
|
|
size_t frames_read = |
|
|
|
bytes_read / bytes_per_sample_ / output_format_.num_channels; |
|
|
|
bytes_read / bytes_per_sample_ / output_format_.num_channels; |
|
|
|
|
|
|
|
|
|
|
@ -243,6 +244,11 @@ auto WavDecoder::DecodeTo(cpp::span<sample::Sample> output) |
|
|
|
return samples_written * bytes_per_sample_; |
|
|
|
return samples_written * bytes_per_sample_; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ESP_LOGI(kTag, "Samples written %d", samples_written); |
|
|
|
|
|
|
|
if (is_eof) { |
|
|
|
|
|
|
|
ESP_LOGI(kTag, "EOF"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return OutputInfo{.samples_written = samples_written, |
|
|
|
return OutputInfo{.samples_written = samples_written, |
|
|
|
.is_stream_finished = samples_written == 0 && is_eof}; |
|
|
|
.is_stream_finished = samples_written == 0 && is_eof}; |
|
|
|
} |
|
|
|
} |
|
|
|