1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

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

This commit is contained in:
ed 2020-02-26 14:38:20 +00:00
parent 719a491740
commit 6a48f66cd4
2 changed files with 21 additions and 0 deletions

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).
*/

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;
};