Reland Volume buttons in AppRTCDemo should affect output audio volume (part I).
Second attempt to land https://webrtc-codereview.appspot.com/32399004/ TBR=perkj@webrtc.org BUG= Review URL: https://webrtc-codereview.appspot.com/30919004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7657 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
		| @@ -34,7 +34,6 @@ import android.content.DialogInterface; | ||||
| import android.content.Intent; | ||||
| import android.content.pm.ActivityInfo; | ||||
| import android.graphics.Color; | ||||
| import android.media.AudioManager; | ||||
| import android.net.Uri; | ||||
| import android.opengl.GLSurfaceView; | ||||
| import android.os.Bundle; | ||||
| @@ -72,6 +71,7 @@ public class AppRTCDemoActivity extends Activity | ||||
|   private PeerConnectionClient pc; | ||||
|   private AppRTCClient appRtcClient = new GAERTCClient(this, this); | ||||
|   private AppRTCSignalingParameters appRtcParameters; | ||||
|   private AppRTCAudioManager audioManager = null; | ||||
|   private View rootView; | ||||
|   private View menuBar; | ||||
|   private GLSurfaceView videoView; | ||||
| @@ -187,15 +187,9 @@ public class AppRTCDemoActivity extends Activity | ||||
|     hudView.setVisibility(View.INVISIBLE); | ||||
|     addContentView(hudView, hudLayout); | ||||
|  | ||||
|     AudioManager audioManager = | ||||
|         ((AudioManager) getSystemService(AUDIO_SERVICE)); | ||||
|     // TODO(fischman): figure out how to do this Right(tm) and remove the | ||||
|     // suppression. | ||||
|     @SuppressWarnings("deprecation") | ||||
|     boolean isWiredHeadsetOn = audioManager.isWiredHeadsetOn(); | ||||
|     audioManager.setMode(isWiredHeadsetOn ? | ||||
|         AudioManager.MODE_IN_CALL : AudioManager.MODE_IN_COMMUNICATION); | ||||
|     audioManager.setSpeakerphoneOn(!isWiredHeadsetOn); | ||||
|     // Create and audio manager that will take care of audio routing, | ||||
|     // audio modes, audio device enumeration etc. | ||||
|     audioManager = AppRTCAudioManager.create(this); | ||||
|  | ||||
|     final Intent intent = getIntent(); | ||||
|     Uri url = intent.getData(); | ||||
| @@ -253,6 +247,10 @@ public class AppRTCDemoActivity extends Activity | ||||
|   @Override | ||||
|   protected void onDestroy() { | ||||
|     disconnect(); | ||||
|     if (audioManager != null) { | ||||
|       audioManager.close(); | ||||
|       audioManager = null; | ||||
|     } | ||||
|     super.onDestroy(); | ||||
|   } | ||||
|  | ||||
| @@ -360,6 +358,12 @@ public class AppRTCDemoActivity extends Activity | ||||
|   // All events are called from UI thread. | ||||
|   @Override | ||||
|   public void onConnectedToRoom(final AppRTCSignalingParameters params) { | ||||
|     if (audioManager != null) { | ||||
|       // Store existing audio settings and change audio mode to | ||||
|       // MODE_IN_COMMUNICATION for best possible VoIP performance. | ||||
|       logAndToast("Initializing the audio manager..."); | ||||
|       audioManager.init(); | ||||
|     } | ||||
|     appRtcParameters = params; | ||||
|     abortUnless(PeerConnectionFactory.initializeAndroidGlobals( | ||||
|       this, true, true, VideoRendererGui.getEGLContext()), | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 henrika@webrtc.org
					henrika@webrtc.org