mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Android: Fixed large buffer sizes on some devices
Requesting a callback when opening an Oboe device is required on some devices to get a FAST stream, so pass a dummy callback object to the temporary stream used when querying the device buffer size in order to get the best available.
This commit is contained in:
parent
32b9b1e9db
commit
99bce8a3a8
1 changed files with 10 additions and 1 deletions
|
|
@ -383,6 +383,15 @@ private:
|
|||
{
|
||||
auto bufferSizeHint = AndroidHighPerformanceAudioHelpers::getNativeBufferSizeHint();
|
||||
|
||||
// providing a callback is required on some devices to get a FAST track, so we pass an
|
||||
// empty one to the temp stream to get the best available buffer size
|
||||
struct DummyCallback : public oboe::AudioStreamCallback
|
||||
{
|
||||
oboe::DataCallbackResult onAudioReady (oboe::AudioStream*, void*, int32_t) override { return oboe::DataCallbackResult::Stop; }
|
||||
};
|
||||
|
||||
DummyCallback callback;
|
||||
|
||||
// NB: Exclusive mode could be rejected if a device is already opened in that mode, so to get
|
||||
// reliable results, only use this function when a device is closed.
|
||||
// We initially try to open a stream with a buffer size returned from
|
||||
|
|
@ -395,7 +404,7 @@ private:
|
|||
getAndroidSDKVersion() >= 21 ? oboe::AudioFormat::Float : oboe::AudioFormat::I16,
|
||||
(int) AndroidHighPerformanceAudioHelpers::getNativeSampleRate(),
|
||||
bufferSizeHint,
|
||||
nullptr);
|
||||
&callback);
|
||||
|
||||
if (auto* nativeStream = tempStream.getNativeStream())
|
||||
return nativeStream->getFramesPerBurst();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue