Bläddra i källkod

fix(android) reset audio route after audio focus was lost

Looks like audio devices must be re-set after focus was lost and regained.
Otherwise some devices (tested on a Samsung Galaxy S9) are in a weird state
where the second microphone is not used when speakerphone is on.
master
Saúl Ibarra Corretgé 4 år sedan
förälder
incheckning
3725f698e4

+ 2
- 2
android/sdk/src/main/java/org/jitsi/meet/sdk/AudioDeviceHandlerGeneric.java Visa fil

63
     private AudioManager audioManager;
63
     private AudioManager audioManager;
64
 
64
 
65
     /**
65
     /**
66
-     * {@link Runnable} for running audio device detection the main thread.
66
+     * {@link Runnable} for running audio device detection in the audio thread.
67
      * This is only used on Android >= M.
67
      * This is only used on Android >= M.
68
      */
68
      */
69
     private final Runnable onAudioDeviceChangeRunner = new Runnable() {
69
     private final Runnable onAudioDeviceChangeRunner = new Runnable() {
145
                         // Some other application potentially stole our audio focus
145
                         // Some other application potentially stole our audio focus
146
                         // temporarily. Restore our mode.
146
                         // temporarily. Restore our mode.
147
                         if (audioFocusLost) {
147
                         if (audioFocusLost) {
148
-                            module.updateAudioRoute();
148
+                            module.resetAudioRoute();
149
                         }
149
                         }
150
                         audioFocusLost = false;
150
                         audioFocusLost = false;
151
                         break;
151
                         break;

+ 14
- 5
android/sdk/src/main/java/org/jitsi/meet/sdk/AudioModeModule.java Visa fil

256
                 if (mode != -1) {
256
                 if (mode != -1) {
257
                     JitsiMeetLogger.i(TAG + " User selected device set to: " + device);
257
                     JitsiMeetLogger.i(TAG + " User selected device set to: " + device);
258
                     userSelectedDevice = device;
258
                     userSelectedDevice = device;
259
-                    updateAudioRoute(mode);
259
+                    updateAudioRoute(mode, false);
260
                 }
260
                 }
261
             }
261
             }
262
         });
262
         });
282
                 boolean success;
282
                 boolean success;
283
 
283
 
284
                 try {
284
                 try {
285
-                    success = updateAudioRoute(mode);
285
+                    success = updateAudioRoute(mode, false);
286
                 } catch (Throwable e) {
286
                 } catch (Throwable e) {
287
                     success = false;
287
                     success = false;
288
                     JitsiMeetLogger.e(e, TAG + " Failed to update audio route for mode: " + mode);
288
                     JitsiMeetLogger.e(e, TAG + " Failed to update audio route for mode: " + mode);
321
      * @return {@code true} if the audio route was updated successfully;
321
      * @return {@code true} if the audio route was updated successfully;
322
      * {@code false}, otherwise.
322
      * {@code false}, otherwise.
323
      */
323
      */
324
-    private boolean updateAudioRoute(int mode) {
324
+    private boolean updateAudioRoute(int mode, boolean force) {
325
         JitsiMeetLogger.i(TAG + " Update audio route for mode: " + mode);
325
         JitsiMeetLogger.i(TAG + " Update audio route for mode: " + mode);
326
 
326
 
327
         if (!audioDeviceHandler.setMode(mode)) {
327
         if (!audioDeviceHandler.setMode(mode)) {
356
 
356
 
357
         // If the previously selected device and the current default one
357
         // If the previously selected device and the current default one
358
         // match, do nothing.
358
         // match, do nothing.
359
-        if (selectedDevice != null && selectedDevice.equals(audioDevice)) {
359
+        if (!force && selectedDevice != null && selectedDevice.equals(audioDevice)) {
360
             return true;
360
             return true;
361
         }
361
         }
362
 
362
 
421
      */
421
      */
422
     void updateAudioRoute() {
422
     void updateAudioRoute() {
423
         if (mode != -1) {
423
         if (mode != -1) {
424
-            updateAudioRoute(mode);
424
+            updateAudioRoute(mode, false);
425
+        }
426
+    }
427
+
428
+    /**
429
+     * Re-sets the current audio route. Needed when focus is lost and regained.
430
+     */
431
+    void resetAudioRoute() {
432
+        if (mode != -1) {
433
+            updateAudioRoute(mode, true);
425
         }
434
         }
426
     }
435
     }
427
 
436
 

Laddar…
Avbryt
Spara