Browse Source

Android: Added a JUCE_USE_ANDROID_OBOE_STABILIZED_CALLBACK config flag to juce_audio_devices to enable the use of oboe::StabilizedCallback

tags/2021-05-28
ed 5 years ago
parent
commit
6a48f66cd4
2 changed files with 21 additions and 0 deletions
  1. +9
    -0
      modules/juce_audio_devices/juce_audio_devices.h
  2. +12
    -0
      modules/juce_audio_devices/native/juce_android_Oboe.cpp

+ 9
- 0
modules/juce_audio_devices/juce_audio_devices.h View File

@@ -143,6 +143,15 @@
#define JUCE_USE_ANDROID_OBOE 0
#endif
/** Config: JUCE_USE_OBOE_STABILIZED_CALLBACK
If JUCE_USE_ANDROID_OBOE is enabled, enabling this will wrap output audio
streams in the oboe::StabilizedCallback class. This class attempts to keep
the CPU spinning to avoid it being scaled down on certain devices.
*/
#ifndef JUCE_USE_ANDROID_OBOE_STABILIZED_CALLBACK
#define JUCE_USE_ANDROID_OBOE_STABILIZED_CALLBACK 0
#endif
/** Config: JUCE_USE_ANDROID_OPENSLES
Enables OpenSLES devices (Android only).
*/


+ 12
- 0
modules/juce_audio_devices/native/juce_android_Oboe.cpp View File

@@ -513,7 +513,16 @@ private:
builder.setFormat (format);
builder.setSampleRate (newSampleRate);
builder.setPerformanceMode (oboe::PerformanceMode::LowLatency);
#if JUCE_USE_ANDROID_OBOE_STABILIZED_CALLBACK
if (newCallback != nullptr)
{
stabilizedCallback = std::make_unique<oboe::StabilizedCallback> (newCallback);
builder.setCallback (stabilizedCallback.get());
}
#else
builder.setCallback (newCallback);
#endif
JUCE_OBOE_LOG (String ("Preparing Oboe stream with params:")
+ "\nAAudio supported = " + String (int (builder.isAAudioSupported()))
@@ -564,6 +573,9 @@ private:
}
oboe::AudioStream* stream = nullptr;
#if JUCE_USE_ANDROID_OBOE_STABILIZED_CALLBACK
std::unique_ptr<oboe::StabilizedCallback> stabilizedCallback;
#endif
oboe::Result openResult;
};


Loading…
Cancel
Save