Skip to content

Commit

Permalink
Bind emergency AAudio
Browse files Browse the repository at this point in the history
  • Loading branch information
fgnm committed Dec 7, 2023
1 parent a9fe9d4 commit 403b12b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/main/java/games/rednblack/miniaudio/MiniAudio.java
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,27 @@ public void setupAndroid(Object assetManager) {
#endif
*/

/**
* Emergency recovery function for AAudio. This backend appears to be buggy on many Android versions.
* When exceptions are raised and current platform is Android with AAudio backend calling this function
* will most likely recover the engine to its normal state.
*
* <a href="https://github.com/rednblackgames/gdx-miniaudio/issues/1">...</a>
*/
public void resetAAudio() {
int result = jniResetAAudio();
if (result != MAResult.MA_SUCCESS) {
throw new MiniAudioException("Unable to reset AAudio device", result);
}
}

private native int jniResetAAudio();/*
#if defined(MA_ANDROID)
if (ma_android_sdk_version() >= MA_AAUDIO_MIN_ANDROID_SDK_VERSION) return ma_device_reinit__aaudio(&device, device.type);
#endif
return MA_API_NOT_FOUND;
*/

/**
* Dispose Engine resources
*/
Expand Down

0 comments on commit 403b12b

Please sign in to comment.