Fix spurious stream starts
This commit is contained in:
@@ -142,7 +142,6 @@ auto AudioDecoder::Process(const std::vector<InputStream>& inputs,
|
||||
// before starting to process data.
|
||||
// TODO(jacqueline): Pass through seek info here?
|
||||
if (!has_prepared_output_ && !output->prepare(*current_output_format_)) {
|
||||
ESP_LOGI(kTag, "waiting for buffer to become free");
|
||||
return;
|
||||
}
|
||||
has_prepared_output_ = true;
|
||||
@@ -156,12 +155,9 @@ auto AudioDecoder::Process(const std::vector<InputStream>& inputs,
|
||||
// The codec ran out of input during processing. This is expected to
|
||||
// happen throughout the stream.
|
||||
if (res.second.error() == codecs::ICodec::Error::kOutOfInput) {
|
||||
ESP_LOGI(kTag, "codec needs more data");
|
||||
has_input_remaining_ = false;
|
||||
has_samples_to_send_ = false;
|
||||
if (input->is_producer_finished()) {
|
||||
ESP_LOGI(kTag, "codec is all done.");
|
||||
|
||||
// We're out of data, and so is the producer. Nothing left to be done
|
||||
// with the input stream.
|
||||
input->mark_consumer_finished();
|
||||
|
||||
@@ -134,7 +134,6 @@ auto FatfsAudioInput::Process(const std::vector<InputStream>& inputs,
|
||||
}
|
||||
|
||||
if (!has_prepared_output_ && !output->prepare(*current_format_)) {
|
||||
ESP_LOGI(kTag, "waiting for buffer to free up");
|
||||
return;
|
||||
}
|
||||
has_prepared_output_ = true;
|
||||
@@ -156,7 +155,6 @@ auto FatfsAudioInput::Process(const std::vector<InputStream>& inputs,
|
||||
output->add(size);
|
||||
|
||||
if (size < max_size || f_eof(¤t_file_)) {
|
||||
ESP_LOGI(kTag, "file finished. closing.");
|
||||
f_close(¤t_file_);
|
||||
is_file_open_ = false;
|
||||
has_prepared_output_ = false;
|
||||
|
||||
@@ -30,6 +30,9 @@ void InputStream::consume(std::size_t bytes) const {
|
||||
|
||||
void InputStream::mark_consumer_finished() const {
|
||||
raw_->info->is_consumer_finished = true;
|
||||
if (is_producer_finished()) {
|
||||
raw_->info->format = std::monostate();
|
||||
}
|
||||
}
|
||||
|
||||
bool InputStream::is_producer_finished() const {
|
||||
@@ -71,6 +74,9 @@ cpp::span<std::byte> OutputStream::data() const {
|
||||
|
||||
void OutputStream::mark_producer_finished() const {
|
||||
raw_->info->is_producer_finished = true;
|
||||
if (is_consumer_finished()) {
|
||||
raw_->info->format = std::monostate();
|
||||
}
|
||||
}
|
||||
|
||||
bool OutputStream::is_consumer_finished() const {
|
||||
|
||||
Reference in New Issue
Block a user