android: make sure all AudioMode operations run in the audio thread

This commit is contained in:
Saúl Ibarra Corretgé 2020-03-11 14:58:42 +01:00 committed by Saúl Ibarra Corretgé
parent d2e6d57be8
commit 05a8591110
1 changed files with 14 additions and 4 deletions

View File

@ -198,7 +198,12 @@ class AudioModeModule extends ReactContextBaseJavaModule {
*/
@Override
public void initialize() {
setAudioDeviceHandler();
runInAudioThread(new Runnable() {
@Override
public void run() {
setAudioDeviceHandler();
}
});
}
private void setAudioDeviceHandler() {
@ -292,9 +297,14 @@ class AudioModeModule extends ReactContextBaseJavaModule {
* @param use Boolean indicator of where it should be used or not.
*/
@ReactMethod
public void setUseConnectionService(boolean use) {
useConnectionService_ = use;
setAudioDeviceHandler();
public void setUseConnectionService(final boolean use) {
runInAudioThread(new Runnable() {
@Override
public void run() {
useConnectionService_ = use;
setAudioDeviceHandler();
}
});
}
/**