Skip to content

Commit e2fb519

Browse files
Jeff BrownAndroid (Google) Code Review
authored andcommitted
Merge "Swap remote submix initialization order." into jb-mr1-dev
2 parents 7109aad + c9bd4ca commit e2fb519

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

services/java/com/android/server/display/WifiDisplayController.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ final class WifiDisplayController implements DumpUtils.Dump {
129129
// True if RTSP has connected.
130130
private boolean mRemoteDisplayConnected;
131131

132+
// True if the remote submix is enabled.
133+
private boolean mRemoteSubmixOn;
134+
132135
public WifiDisplayController(Context context, Handler handler, Listener listener) {
133136
mContext = context;
134137
mHandler = handler;
@@ -160,6 +163,7 @@ public void dump(PrintWriter pw) {
160163
pw.println("mRemoteDisplay=" + mRemoteDisplay);
161164
pw.println("mRemoteDisplayInterface=" + mRemoteDisplayInterface);
162165
pw.println("mRemoteDisplayConnected=" + mRemoteDisplayConnected);
166+
pw.println("mRemoteSubmixOn=" + mRemoteSubmixOn);
163167

164168
pw.println("mKnownWifiDisplayPeers: size=" + mKnownWifiDisplayPeers.size());
165169
for (WifiP2pDevice device : mKnownWifiDisplayPeers) {
@@ -390,16 +394,14 @@ private void updateConnection() {
390394
Slog.i(TAG, "Stopped listening for RTSP connection on " + mRemoteDisplayInterface
391395
+ " from Wifi display: " + mConnectedDevice.deviceName);
392396

393-
if (mRemoteDisplayConnected) {
394-
mAudioManager.setRemoteSubmixOn(false, REMOTE_SUBMIX_ADDRESS);
395-
}
396-
397397
mRemoteDisplay.dispose();
398398
mRemoteDisplay = null;
399399
mRemoteDisplayInterface = null;
400400
mRemoteDisplayConnected = false;
401401
mHandler.removeCallbacks(mRtspTimeout);
402402

403+
setRemoteSubmixOn(false);
404+
403405
mHandler.post(new Runnable() {
404406
@Override
405407
public void run() {
@@ -527,6 +529,8 @@ public void onFailure(int reason) {
527529
return; // done
528530
}
529531

532+
setRemoteSubmixOn(true);
533+
530534
final WifiP2pDevice oldDevice = mConnectedDevice;
531535
final int port = getPortNumber(mConnectedDevice);
532536
final String iface = addr.getHostAddress() + ":" + port;
@@ -545,8 +549,6 @@ public void onDisplayConnected(final Surface surface,
545549
mRemoteDisplayConnected = true;
546550
mHandler.removeCallbacks(mRtspTimeout);
547551

548-
mAudioManager.setRemoteSubmixOn(true, REMOTE_SUBMIX_ADDRESS);
549-
550552
final WifiDisplay display = createWifiDisplay(mConnectedDevice);
551553
mHandler.post(new Runnable() {
552554
@Override
@@ -583,6 +585,13 @@ public void onDisplayError(int error) {
583585
}
584586
}
585587

588+
private void setRemoteSubmixOn(boolean on) {
589+
if (mRemoteSubmixOn != on) {
590+
mRemoteSubmixOn = on;
591+
mAudioManager.setRemoteSubmixOn(on, REMOTE_SUBMIX_ADDRESS);
592+
}
593+
}
594+
586595
private void handleStateChanged(boolean enabled) {
587596
if (mWifiP2pEnabled != enabled) {
588597
mWifiP2pEnabled = enabled;

0 commit comments

Comments
 (0)