@@ -82,34 +82,38 @@ Result DataConversionFlowGraph::configure(AudioStream *sourceStream, AudioStream
8282 AudioFormat sourceFormat = sourceStream->getFormat ();
8383 int32_t sourceChannelCount = sourceStream->getChannelCount ();
8484 int32_t sourceSampleRate = sourceStream->getSampleRate ();
85+ int32_t sourceFramesPerCallback = sourceStream->getFramesPerCallback ();
8586
8687 AudioFormat sinkFormat = sinkStream->getFormat ();
8788 int32_t sinkChannelCount = sinkStream->getChannelCount ();
8889 int32_t sinkSampleRate = sinkStream->getSampleRate ();
90+ int32_t sinkFramesPerCallback = sinkStream->getFramesPerCallback ();
8991
90- LOGI (" %s() flowgraph converts channels: %d to %d, format: %d to %d, rate: %d to %d, qual = %d" ,
92+ LOGI (" %s() flowgraph converts channels: %d to %d, format: %d to %d"
93+ " , rate: %d to %d, cbsize: %d to %d, qual = %d" ,
9194 __func__,
9295 sourceChannelCount, sinkChannelCount,
9396 sourceFormat, sinkFormat,
9497 sourceSampleRate, sinkSampleRate,
98+ sourceFramesPerCallback, sinkFramesPerCallback,
9599 sourceStream->getSampleRateConversionQuality ());
96100
97- int32_t framesPerCallback = (sourceStream->getFramesPerCallback () == kUnspecified )
98- ? sourceStream->getFramesPerBurst ()
99- : sourceStream->getFramesPerCallback ();
100101 // Source
101102 // IF OUTPUT and using a callback then call back to the app using a SourceCaller.
102103 // OR IF INPUT and NOT using a callback then read from the child stream using a SourceCaller.
103104 if ((sourceStream->getCallback () != nullptr && isOutput)
104105 || (sourceStream->getCallback () == nullptr && isInput)) {
106+ int32_t actualSourceFramesPerCallback = (sourceFramesPerCallback == kUnspecified )
107+ ? sourceStream->getFramesPerBurst ()
108+ : sourceFramesPerCallback;
105109 switch (sourceFormat) {
106110 case AudioFormat::Float:
107111 mSourceCaller = std::make_unique<SourceFloatCaller>(sourceChannelCount,
108- framesPerCallback );
112+ actualSourceFramesPerCallback );
109113 break ;
110114 case AudioFormat::I16:
111115 mSourceCaller = std::make_unique<SourceI16Caller>(sourceChannelCount,
112- framesPerCallback );
116+ actualSourceFramesPerCallback );
113117 break ;
114118 default :
115119 LOGE (" %s() Unsupported source caller format = %d" , __func__, sourceFormat);
@@ -132,8 +136,11 @@ Result DataConversionFlowGraph::configure(AudioStream *sourceStream, AudioStream
132136 return Result::ErrorIllegalArgument;
133137 }
134138 if (isInput) {
139+ int32_t actualSinkFramesPerCallback = (sinkFramesPerCallback == kUnspecified )
140+ ? sinkStream->getFramesPerBurst ()
141+ : sinkFramesPerCallback;
135142 // The BlockWriter is after the Sink so use the SinkStream size.
136- mBlockWriter .open (framesPerCallback * sinkStream->getBytesPerFrame ());
143+ mBlockWriter .open (actualSinkFramesPerCallback * sinkStream->getBytesPerFrame ());
137144 mAppBuffer = std::make_unique<uint8_t []>(
138145 kDefaultBufferSize * sinkStream->getBytesPerFrame ());
139146 }
@@ -158,7 +165,7 @@ Result DataConversionFlowGraph::configure(AudioStream *sourceStream, AudioStream
158165
159166 // Sample Rate conversion
160167 if (sourceSampleRate != sinkSampleRate) {
161- // Create a resample to do the math.
168+ // Create a resampler to do the math.
162169 mResampler .reset (MultiChannelResampler::make (lastOutput->getSamplesPerFrame (),
163170 sourceSampleRate,
164171 sinkSampleRate,
0 commit comments