Skip to content

Commit

Permalink
android: fix initializing audio device handler modules too early
Browse files Browse the repository at this point in the history
When ConnectionService is used (the default) we were attaching the handlers too
early, and since attaching them requires that the RNConnectionService module is
loaded, it silently failed. Instead, use the initialize() method, which gets
called after all the Catalyst (aka native) modules have been loaded.
  • Loading branch information
saghul committed Nov 8, 2019
1 parent 5b99219 commit 6b716f8
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions android/sdk/src/main/java/org/jitsi/meet/sdk/AudioModeModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,6 @@ static boolean useConnectionService() {
*/
public AudioModeModule(ReactApplicationContext reactContext) {
super(reactContext);

setAudioDeviceHandler();
}

/**
Expand Down Expand Up @@ -193,6 +191,16 @@ public String getName() {
return NAME;
}

/**
* Initializes the audio device handler module. This function is called *after* all Catalyst
* modules have been created, and that's why we use it, because {@link AudioDeviceHandlerConnectionService}
* needs access to another Catalyst module, so doing this in the constructor would be too early.
*/
@Override
public void initialize() {
setAudioDeviceHandler();
}

private void setAudioDeviceHandler() {
if (audioDeviceHandler != null) {
audioDeviceHandler.stop();
Expand Down

0 comments on commit 6b716f8

Please sign in to comment.