WebRTCDemo: clean the error message due to API clean up and add ability to route the audio through all three outputs, headset/earpiece/loudspeaker

BUG=3366
TEST=Manual Test
R=fischman@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/17559004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@6207 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
braveyao@webrtc.org 2014-05-21 03:37:45 +00:00
parent 49a6a27bf0
commit 1a79bb8d30

View File

@ -22,6 +22,7 @@ import android.content.IntentFilter;
import android.hardware.Camera.CameraInfo;
import android.hardware.Camera;
import android.hardware.SensorManager;
import android.media.AudioManager;
import android.os.Environment;
import android.util.Log;
import android.view.OrientationEventListener;
@ -194,6 +195,10 @@ public class MediaEngine implements VideoDecodeEncodeObserver {
}
};
orientationListener.enable();
// Set audio mode to communication
AudioManager audioManager =
((AudioManager) context.getSystemService(Context.AUDIO_SERVICE));
audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
// Listen to headset being plugged in/out.
IntentFilter receiverFilter = new IntentFilter(Intent.ACTION_HEADSET_PLUG);
headsetListener = new BroadcastReceiver() {
@ -423,8 +428,9 @@ public class MediaEngine implements VideoDecodeEncodeObserver {
private void updateAudioOutput() {
boolean useSpeaker = !headsetPluggedIn && speakerEnabled;
check(voe.setLoudspeakerStatus(useSpeaker) == 0,
"Failed updating loudspeaker");
AudioManager audioManager =
((AudioManager) context.getSystemService(Context.AUDIO_SERVICE));
audioManager.setSpeakerphoneOn(useSpeaker);
}
public void startViE() {