From acccd822f0147147dd8b16f059578df073c088c2 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Mon, 19 Jun 2023 15:36:43 +1000 Subject: back to back flac playback is working :) --- src/audio/stream_info.cpp | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'src/audio/stream_info.cpp') diff --git a/src/audio/stream_info.cpp b/src/audio/stream_info.cpp index 8fc31530..2337b3a3 100644 --- a/src/audio/stream_info.cpp +++ b/src/audio/stream_info.cpp @@ -28,8 +28,12 @@ void InputStream::consume(std::size_t bytes) const { raw_->info->bytes_in_stream = new_data.size_bytes(); } -void InputStream::mark_incomplete() const { - raw_->is_incomplete = true; +void InputStream::mark_consumer_finished() const { + raw_->info->is_consumer_finished = true; +} + +bool InputStream::is_producer_finished() const { + return raw_->info->is_producer_finished; } const StreamInfo& InputStream::info() const { @@ -46,17 +50,12 @@ void OutputStream::add(std::size_t bytes) const { } bool OutputStream::prepare(const StreamInfo::Format& new_format) { - if (std::holds_alternative(raw_->info->format)) { - raw_->info->format = new_format; - raw_->info->bytes_in_stream = 0; - return true; - } - if (new_format == raw_->info->format) { - return true; - } - if (raw_->is_incomplete) { + if (std::holds_alternative(raw_->info->format) || + raw_->info->is_consumer_finished) { raw_->info->format = new_format; raw_->info->bytes_in_stream = 0; + raw_->info->is_producer_finished = false; + raw_->info->is_consumer_finished = false; return true; } return false; @@ -70,8 +69,12 @@ cpp::span OutputStream::data() const { return raw_->data.subspan(raw_->info->bytes_in_stream); } -bool OutputStream::is_incomplete() const { - return raw_->is_incomplete; +void OutputStream::mark_producer_finished() const { + raw_->info->is_producer_finished = true; +} + +bool OutputStream::is_consumer_finished() const { + return raw_->info->is_consumer_finished; } } // namespace audio -- cgit v1.2.3