| OLD | NEW |
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 144 |
| 145 // Store current audio state so we can restore it when close() is called. | 145 // Store current audio state so we can restore it when close() is called. |
| 146 savedAudioMode = audioManager.getMode(); | 146 savedAudioMode = audioManager.getMode(); |
| 147 savedIsSpeakerPhoneOn = audioManager.isSpeakerphoneOn(); | 147 savedIsSpeakerPhoneOn = audioManager.isSpeakerphoneOn(); |
| 148 savedIsMicrophoneMute = audioManager.isMicrophoneMute(); | 148 savedIsMicrophoneMute = audioManager.isMicrophoneMute(); |
| 149 | 149 |
| 150 // Request audio focus before making any device switch. | 150 // Request audio focus before making any device switch. |
| 151 audioManager.requestAudioFocus(null, AudioManager.STREAM_VOICE_CALL, | 151 audioManager.requestAudioFocus(null, AudioManager.STREAM_VOICE_CALL, |
| 152 AudioManager.AUDIOFOCUS_GAIN_TRANSIENT); | 152 AudioManager.AUDIOFOCUS_GAIN_TRANSIENT); |
| 153 | 153 |
| 154 // Start by setting RINGTONE as default audio mode. The native WebRTC | 154 // Start by setting MODE_IN_COMMUNICATION as default audio mode. It is |
| 155 // audio layer will switch to COMMUNICATION mode when the first streaming | 155 // required to be in this mode when playout and/or recording starts for |
| 156 // session starts and return to RINGTONE mode when all streaming stops. | 156 // best possible VoIP performance. |
| 157 audioManager.setMode(AudioManager.MODE_RINGTONE); | 157 // TODO(henrika): we migh want to start with RINGTONE mode here instead. |
| 158 audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION); |
| 158 | 159 |
| 159 // Always disable microphone mute during a WebRTC call. | 160 // Always disable microphone mute during a WebRTC call. |
| 160 setMicrophoneMute(false); | 161 setMicrophoneMute(false); |
| 161 | 162 |
| 162 // Do initial selection of audio device. This setting can later be changed | 163 // Do initial selection of audio device. This setting can later be changed |
| 163 // either by adding/removing a wired headset or by covering/uncovering the | 164 // either by adding/removing a wired headset or by covering/uncovering the |
| 164 // proximity sensor. | 165 // proximity sensor. |
| 165 updateAudioDeviceState(hasWiredHeadset()); | 166 updateAudioDeviceState(hasWiredHeadset()); |
| 166 | 167 |
| 167 // Register receiver for broadcast intents related to adding/removing a | 168 // Register receiver for broadcast intents related to adding/removing a |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 Log.e(TAG, "Invalid device list"); | 364 Log.e(TAG, "Invalid device list"); |
| 364 } | 365 } |
| 365 | 366 |
| 366 if (onStateChangeListener != null) { | 367 if (onStateChangeListener != null) { |
| 367 // Run callback to notify a listening client. The client can then | 368 // Run callback to notify a listening client. The client can then |
| 368 // use public getters to query the new state. | 369 // use public getters to query the new state. |
| 369 onStateChangeListener.run(); | 370 onStateChangeListener.run(); |
| 370 } | 371 } |
| 371 } | 372 } |
| 372 } | 373 } |
| OLD | NEW |