@@ -151,6 +151,8 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
151151 private static final int MSG_SET_WIRED_DEVICE_CONNECTION_STATE = 21 ;
152152 private static final int MSG_SET_A2DP_CONNECTION_STATE = 22 ;
153153 // end of messages handled under wakelock
154+ private static final int MSG_SET_RSX_CONNECTION_STATE = 23 ; // change remote submix connection
155+ private static final int MSG_SET_FORCE_RSX_USE = 24 ; // force remote submix audio routing
154156
155157 // flags for MSG_PERSIST_VOLUME indicating if current and/or last audible volume should be
156158 // persisted
@@ -2109,6 +2111,33 @@ public void onServiceDisconnected(int profile) {
21092111 }
21102112 };
21112113
2114+ /** see AudioManager.setRemoteSubmixOn(boolean on) */
2115+ public void setRemoteSubmixOn (boolean on , int address ) {
2116+ sendMsg (mAudioHandler , MSG_SET_RSX_CONNECTION_STATE ,
2117+ SENDMSG_REPLACE /* replace with QUEUE when multiple addresses are supported */ ,
2118+ on ? 1 : 0 /*arg1*/ ,
2119+ address /*arg2*/ ,
2120+ null /*obj*/ , 0 /*delay*/ );
2121+
2122+ // Note that we are currently forcing use of remote submix as soon as corresponding device
2123+ // is made available
2124+ sendMsg (mAudioHandler , MSG_SET_FORCE_RSX_USE , SENDMSG_REPLACE ,
2125+ AudioSystem .FOR_MEDIA ,
2126+ on ? AudioSystem .FORCE_REMOTE_SUBMIX : AudioSystem .FORCE_NONE ,
2127+ null /*obj*/ , 0 /*delay*/ );
2128+ }
2129+
2130+ private void onSetRsxConnectionState (int available , int address ) {
2131+ AudioSystem .setDeviceConnectionState (AudioSystem .DEVICE_IN_REMOTE_SUBMIX ,
2132+ available == 1 ?
2133+ AudioSystem .DEVICE_STATE_AVAILABLE : AudioSystem .DEVICE_STATE_UNAVAILABLE ,
2134+ String .valueOf (address ) /*device_address*/ );
2135+ AudioSystem .setDeviceConnectionState (AudioSystem .DEVICE_OUT_REMOTE_SUBMIX ,
2136+ available == 1 ?
2137+ AudioSystem .DEVICE_STATE_AVAILABLE : AudioSystem .DEVICE_STATE_UNAVAILABLE ,
2138+ String .valueOf (address ) /*device_address*/ );
2139+ }
2140+
21122141 ///////////////////////////////////////////////////////////////////////////
21132142 // Internal methods
21142143 ///////////////////////////////////////////////////////////////////////////
@@ -3072,6 +3101,7 @@ public void handleMessage(Message msg) {
30723101
30733102 case MSG_SET_FORCE_USE :
30743103 case MSG_SET_FORCE_BT_A2DP_USE :
3104+ case MSG_SET_FORCE_RSX_USE :
30753105 setForceUse (msg .arg1 , msg .arg2 );
30763106 break ;
30773107
@@ -3134,6 +3164,10 @@ public void handleMessage(Message msg) {
31343164 onRegisterVolumeObserverForRcc (msg .arg1 /* rccId */ ,
31353165 (IRemoteVolumeObserver )msg .obj /* rvo */ );
31363166 break ;
3167+
3168+ case MSG_SET_RSX_CONNECTION_STATE :
3169+ onSetRsxConnectionState (msg .arg1 /*available*/ , msg .arg2 /*address*/ );
3170+ break ;
31373171 }
31383172 }
31393173 }
0 commit comments