From dc912367ae5b4a50b1dc7198c2cb0b4b2e7420bc Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Tue, 7 Sep 2021 16:17:31 -0400 Subject: [PATCH] Cortex: SpecializeTo() once more before creating the operation. If the incoming node is still pretty generic, we have to specialize the input format to the output format in order to not be left with wildcards. Additionally, ensure that the frame sizes match up. MultiAudioNode silently rejects buffers that are not sized precisely as it wants them, so we need to attempt to have equivalent frame counts on either end. --- src/apps/cortex/addons/common/AudioFilterNode.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/apps/cortex/addons/common/AudioFilterNode.cpp b/src/apps/cortex/addons/common/AudioFilterNode.cpp index 0f6cb3b670..79a3a76b59 100644 --- a/src/apps/cortex/addons/common/AudioFilterNode.cpp +++ b/src/apps/cortex/addons/common/AudioFilterNode.cpp @@ -424,7 +424,19 @@ status_t AudioFilterNode::AcceptFormat( return err; // if an output connection has been made, try to create an operation - if(m_output.destination != media_destination::null) { + if (m_output.destination != media_destination::null) { + // Further specialize the format, in case of any remaining wildcards. + // Special case for buffer size: make sure we use the same frame count. + const bool setFrameSize = ioFormat->u.raw_audio.buffer_size + == media_raw_audio_format::wildcard.buffer_size; + ioFormat->SpecializeTo(&m_output.format); + if (setFrameSize) { + ioFormat->u.raw_audio.buffer_size = + bytes_per_frame(ioFormat->u.raw_audio) + * (m_output.format.u.raw_audio.buffer_size + / bytes_per_frame(m_output.format.u.raw_audio)); + } + ASSERT(m_opFactory); IAudioOp* op = m_opFactory->createOp( this,