mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Android: Fixed an issue when opening mono output streams in Oboe
This commit is contained in:
parent
b3ad34fa80
commit
5d920ade5c
1 changed files with 23 additions and 25 deletions
|
|
@ -42,7 +42,7 @@ struct OboeAudioIODeviceBufferHelpers<int16>
|
|||
|
||||
static constexpr int bitDepth() { return 16; }
|
||||
|
||||
static void referAudioBufferDirectlyToOboeIfPossible (int16*, AudioBuffer<float>&, int) {}
|
||||
static bool referAudioBufferDirectlyToOboeIfPossible (int16*, AudioBuffer<float>&, int) { return false; }
|
||||
|
||||
static void convertFromOboe (const int16* srcInterleaved, AudioBuffer<float>& audioBuffer, int numSamples)
|
||||
{
|
||||
|
|
@ -78,20 +78,21 @@ struct OboeAudioIODeviceBufferHelpers<float>
|
|||
|
||||
static constexpr int bitDepth() { return 32; }
|
||||
|
||||
static void referAudioBufferDirectlyToOboeIfPossible (float* nativeBuffer, AudioBuffer<float>& audioBuffer, int numSamples)
|
||||
static bool referAudioBufferDirectlyToOboeIfPossible (float* nativeBuffer, AudioBuffer<float>& audioBuffer, int numSamples)
|
||||
{
|
||||
if (audioBuffer.getNumChannels() == 1)
|
||||
{
|
||||
audioBuffer.setDataToReferTo (&nativeBuffer, 1, numSamples);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static void convertFromOboe (const float* srcInterleaved, AudioBuffer<float>& audioBuffer, int numSamples)
|
||||
{
|
||||
// No need to convert, we instructed the buffer to point to the src data directly already
|
||||
if (audioBuffer.getNumChannels() == 1)
|
||||
{
|
||||
jassert (audioBuffer.getWritePointer (0) == srcInterleaved);
|
||||
return;
|
||||
}
|
||||
jassert (audioBuffer.getWritePointer (0) != srcInterleaved);
|
||||
|
||||
for (int i = 0; i < audioBuffer.getNumChannels(); ++i)
|
||||
{
|
||||
|
|
@ -107,11 +108,7 @@ struct OboeAudioIODeviceBufferHelpers<float>
|
|||
static void convertToOboe (const AudioBuffer<float>& audioBuffer, float* dstInterleaved, int numSamples)
|
||||
{
|
||||
// No need to convert, we instructed the buffer to point to the src data directly already
|
||||
if (audioBuffer.getNumChannels() == 1)
|
||||
{
|
||||
jassert (audioBuffer.getReadPointer (0) == dstInterleaved);
|
||||
return;
|
||||
}
|
||||
jassert (audioBuffer.getReadPointer (0) != dstInterleaved);
|
||||
|
||||
for (int i = 0; i < audioBuffer.getNumChannels(); ++i)
|
||||
{
|
||||
|
|
@ -769,7 +766,6 @@ private:
|
|||
// only output stream should be the master stream receiving callbacks
|
||||
jassert (stream->getDirection() == oboe::Direction::Output && stream == outputStream->getNativeStream());
|
||||
|
||||
//-----------------
|
||||
// Read input from Oboe
|
||||
inputStreamSampleBuffer.clear();
|
||||
inputStreamNativeBuffer.calloc (static_cast<size_t> (numInputChannels * bufferSize));
|
||||
|
|
@ -789,11 +785,13 @@ private:
|
|||
|
||||
if (result)
|
||||
{
|
||||
OboeAudioIODeviceBufferHelpers<SampleType>::referAudioBufferDirectlyToOboeIfPossible (inputStreamNativeBuffer.get(),
|
||||
inputStreamSampleBuffer,
|
||||
result.value());
|
||||
auto referringDirectlyToOboeData = OboeAudioIODeviceBufferHelpers<SampleType>
|
||||
::referAudioBufferDirectlyToOboeIfPossible (inputStreamNativeBuffer.get(),
|
||||
inputStreamSampleBuffer,
|
||||
result.value());
|
||||
|
||||
OboeAudioIODeviceBufferHelpers<SampleType>::convertFromOboe (inputStreamNativeBuffer.get(), inputStreamSampleBuffer, result.value());
|
||||
if (! referringDirectlyToOboeData)
|
||||
OboeAudioIODeviceBufferHelpers<SampleType>::convertFromOboe (inputStreamNativeBuffer.get(), inputStreamSampleBuffer, result.value());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -804,24 +802,24 @@ private:
|
|||
inputLatency = getLatencyFor (*inputStream);
|
||||
}
|
||||
|
||||
//-----------------
|
||||
// Setup output buffer
|
||||
outputStreamSampleBuffer.clear();
|
||||
auto referringDirectlyToOboeData = OboeAudioIODeviceBufferHelpers<SampleType>
|
||||
::referAudioBufferDirectlyToOboeIfPossible (static_cast<SampleType*> (audioData),
|
||||
outputStreamSampleBuffer,
|
||||
numFrames);
|
||||
|
||||
OboeAudioIODeviceBufferHelpers<SampleType>::referAudioBufferDirectlyToOboeIfPossible (static_cast<SampleType*> (audioData),
|
||||
outputStreamSampleBuffer,
|
||||
numFrames);
|
||||
if (! referringDirectlyToOboeData)
|
||||
outputStreamSampleBuffer.clear();
|
||||
|
||||
//-----------------
|
||||
// Process
|
||||
// NB: the number of samples read from the input can potentially differ from numFrames.
|
||||
owner.process (inputStreamSampleBuffer.getArrayOfReadPointers(), numInputChannels,
|
||||
outputStreamSampleBuffer.getArrayOfWritePointers(), numOutputChannels,
|
||||
numFrames);
|
||||
|
||||
//-----------------
|
||||
// Write output to Oboe
|
||||
OboeAudioIODeviceBufferHelpers<SampleType>::convertToOboe (outputStreamSampleBuffer, static_cast<SampleType*> (audioData), numFrames);
|
||||
if (! referringDirectlyToOboeData)
|
||||
OboeAudioIODeviceBufferHelpers<SampleType>::convertToOboe (outputStreamSampleBuffer, static_cast<SampleType*> (audioData), numFrames);
|
||||
|
||||
if (isOutputLatencyDetectionSupported)
|
||||
outputLatency = getLatencyFor (*outputStream);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue