Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not use AAudio unless running on Android 8.1 or higher #51

Merged
merged 1 commit into from
Feb 6, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/aaudio/AudioStreamAAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@

#include <assert.h>
#include <stdint.h>
#include <stdlib.h>

#include "aaudio/AAudioLoader.h"
#include "aaudio/AudioStreamAAudio.h"
#include "common/OboeDebug.h"
#include "oboe/Utilities.h"

#ifdef __ANDROID__
#include <sys/system_properties.h>
#endif


using namespace oboe;
Expand Down Expand Up @@ -89,7 +93,22 @@ AudioStreamAAudio::~AudioStreamAAudio()
delete[] mShortCallbackBuffer;
}

static bool isRunningOnAndroid8_1OrHigher() {
#ifdef __ANDROID__
char sdk[PROP_VALUE_MAX] = {0};
if (__system_property_get("ro.build.version.sdk", sdk) != 0) {
return atoi(sdk) >= 27; // SDK Level 27 is Android Oreo 8.1
}
#endif
return false;
}

bool AudioStreamAAudio::isSupported() {
if (!isRunningOnAndroid8_1OrHigher()) {
// See https://github.com/google/oboe/issues/40,
// AAudio is not stable enough on Android 8.0.
return false;
}
mLibLoader = AAudioLoader::getInstance();
int openResult = mLibLoader->open();
return openResult == 0;
Expand Down Expand Up @@ -380,4 +399,4 @@ Result AudioStreamAAudio::getTimestamp(clockid_t clockId,
}
}

} // namespace oboe
} // namespace oboe