From ef8d404b15e6d32506617a95aa3161fbe59ecdaf Mon Sep 17 00:00:00 2001 From: jacqueline Date: Mon, 30 Jan 2023 15:52:54 +1100 Subject: Continue ironing out i2s pipeline still at least one heap corruption issue, plus the i2s write method seems to block forever :/ --- src/audio/i2s_audio_output.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/audio/i2s_audio_output.cpp') diff --git a/src/audio/i2s_audio_output.cpp b/src/audio/i2s_audio_output.cpp index f499d50f..bfc88588 100644 --- a/src/audio/i2s_audio_output.cpp +++ b/src/audio/i2s_audio_output.cpp @@ -48,7 +48,8 @@ auto I2SAudioOutput::ProcessStreamInfo(const StreamInfo& info) -> cpp::result { // TODO(jacqueline): probs do something with the channel hey - if (!info.bits_per_sample && !info.sample_rate) { + if (!info.bits_per_sample || !info.sample_rate) { + ESP_LOGE(kTag, "audio stream missing bits or sample rate"); return cpp::fail(UNSUPPORTED_STREAM); } @@ -67,6 +68,7 @@ auto I2SAudioOutput::ProcessStreamInfo(const StreamInfo& info) bps = drivers::AudioDac::BPS_32; break; default: + ESP_LOGE(kTag, "dropping stream with unknown bps"); return cpp::fail(UNSUPPORTED_STREAM); } @@ -79,6 +81,7 @@ auto I2SAudioOutput::ProcessStreamInfo(const StreamInfo& info) sample_rate = drivers::AudioDac::SAMPLE_RATE_48; break; default: + ESP_LOGE(kTag, "dropping stream with unknown rate"); return cpp::fail(UNSUPPORTED_STREAM); } @@ -93,11 +96,13 @@ auto I2SAudioOutput::ProcessChunk(const cpp::span& chunk) SetSoftMute(false); // TODO(jacqueline): write smaller parts with a small delay so that we can // be responsive to pause and seek commands. - return dac_->WriteData(chunk, portMAX_DELAY); + std::size_t bytes_written = dac_->WriteData(chunk, portMAX_DELAY); + ESP_LOGI(kTag, "played %u bytes", bytes_written); + return 0; } auto I2SAudioOutput::Process() -> cpp::result { - // TODO(jacqueline): Consider powering down the dac completely maybe? + // TODO(jacqueline): Play the stream in smaller sections return {}; } -- cgit v1.2.3