}
/**
- * @hide
- * Signals whether remote submix audio rerouting is enabled.
- */
- public void setRemoteSubmixOn(boolean on, int address) {
- IAudioService service = getService();
- try {
- service.setRemoteSubmixOn(on, address);
- } catch (RemoteException e) {
- Log.e(TAG, "Dead object in setRemoteSubmixOn", e);
- }
- }
-
- /**
* Sets audio routing to the wired headset on or off.
*
* @param on set <var>true</var> to route audio to/from wired
private static final int MSG_PERSIST_MASTER_VOLUME_MUTE = 12;
private static final int MSG_REPORT_NEW_ROUTES = 13;
private static final int MSG_SET_FORCE_BT_A2DP_USE = 14;
- private static final int MSG_SET_RSX_CONNECTION_STATE = 15; // change remote submix connection
private static final int MSG_CHECK_MUSIC_ACTIVE = 16;
private static final int MSG_BROADCAST_AUDIO_BECOMING_NOISY = 17;
private static final int MSG_CONFIGURE_SAFE_MEDIA_VOLUME = 18;
}
};
- /** see AudioManager.setRemoteSubmixOn(boolean on) */
- public void setRemoteSubmixOn(boolean on, int address) {
- sendMsg(mAudioHandler, MSG_SET_RSX_CONNECTION_STATE,
- SENDMSG_REPLACE /* replace with QUEUE when multiple addresses are supported */,
- on ? 1 : 0 /*arg1*/,
- address /*arg2*/,
- null/*obj*/, 0/*delay*/);
- }
-
- private void onSetRsxConnectionState(int available, int address) {
- AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_IN_REMOTE_SUBMIX,
- available == 1 ?
- AudioSystem.DEVICE_STATE_AVAILABLE : AudioSystem.DEVICE_STATE_UNAVAILABLE,
- String.valueOf(address) /*device_address*/);
- AudioSystem.setDeviceConnectionState(AudioSystem.DEVICE_OUT_REMOTE_SUBMIX,
- available == 1 ?
- AudioSystem.DEVICE_STATE_AVAILABLE : AudioSystem.DEVICE_STATE_UNAVAILABLE,
- String.valueOf(address) /*device_address*/);
- }
-
private void onCheckMusicActive() {
synchronized (mSafeMediaVolumeState) {
if (mSafeMediaVolumeState == SAFE_MEDIA_VOLUME_INACTIVE) {
break;
}
- case MSG_SET_RSX_CONNECTION_STATE:
- onSetRsxConnectionState(msg.arg1/*available*/, msg.arg2/*address*/);
- break;
-
case MSG_CHECK_MUSIC_ACTIVE:
onCheckMusicActive();
break;
private static final int CONNECT_MAX_RETRIES = 3;
private static final int CONNECT_RETRY_DELAY_MILLIS = 500;
- // A unique token to identify the remote submix that is managed by Wifi display.
- // It must match what the media server uses when it starts recording the submix
- // for transmission. We use 0 although the actual value is currently ignored.
- private static final int REMOTE_SUBMIX_ADDRESS = 0;
-
private final Context mContext;
private final Handler mHandler;
private final Listener mListener;
private final WifiP2pManager mWifiP2pManager;
private final Channel mWifiP2pChannel;
- private final AudioManager mAudioManager;
-
private boolean mWifiP2pEnabled;
private boolean mWfdEnabled;
private boolean mWfdEnabling;
// True if RTSP has connected.
private boolean mRemoteDisplayConnected;
- // True if the remote submix is enabled.
- private boolean mRemoteSubmixOn;
-
// The information we have most recently told WifiDisplayAdapter about.
private WifiDisplay mAdvertisedDisplay;
private Surface mAdvertisedDisplaySurface;
mWifiP2pManager = (WifiP2pManager)context.getSystemService(Context.WIFI_P2P_SERVICE);
mWifiP2pChannel = mWifiP2pManager.initialize(context, handler.getLooper(), null);
- mAudioManager = (AudioManager)context.getSystemService(Context.AUDIO_SERVICE);
-
IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION);
intentFilter.addAction(WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION);
pw.println("mRemoteDisplay=" + mRemoteDisplay);
pw.println("mRemoteDisplayInterface=" + mRemoteDisplayInterface);
pw.println("mRemoteDisplayConnected=" + mRemoteDisplayConnected);
- pw.println("mRemoteSubmixOn=" + mRemoteSubmixOn);
pw.println("mAdvertisedDisplay=" + mAdvertisedDisplay);
pw.println("mAdvertisedDisplaySurface=" + mAdvertisedDisplaySurface);
pw.println("mAdvertisedDisplayWidth=" + mAdvertisedDisplayWidth);
mHandler.removeCallbacks(mRtspTimeout);
mWifiP2pManager.setMiracastMode(WifiP2pManager.MIRACAST_DISABLED);
- setRemoteSubmixOn(false);
unadvertiseDisplay();
// continue to next step
return; // done
}
- setRemoteSubmixOn(true);
mWifiP2pManager.setMiracastMode(WifiP2pManager.MIRACAST_SOURCE);
final WifiP2pDevice oldDevice = mConnectedDevice;
}
}
- private void setRemoteSubmixOn(boolean on) {
- if (mRemoteSubmixOn != on) {
- mRemoteSubmixOn = on;
- mAudioManager.setRemoteSubmixOn(on, REMOTE_SUBMIX_ADDRESS);
- }
- }
-
private void handleStateChanged(boolean enabled) {
mWifiP2pEnabled = enabled;
updateWfdEnableState();