Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c9bd4ca0 authored by Jeff Brown's avatar Jeff Brown
Browse files

Swap remote submix initialization order.

Need to turn the submix on before connecting and off
after disconnecting.

Change-Id: I53389c3b61e6d663855accd0461eed42a67d9d2b
parent a41d5db2
Loading
Loading
Loading
Loading
+15 −6
Original line number Diff line number Diff line
@@ -129,6 +129,9 @@ final class WifiDisplayController implements DumpUtils.Dump {
    // True if RTSP has connected.
    private boolean mRemoteDisplayConnected;

    // True if the remote submix is enabled.
    private boolean mRemoteSubmixOn;

    public WifiDisplayController(Context context, Handler handler, Listener listener) {
        mContext = context;
        mHandler = handler;
@@ -160,6 +163,7 @@ final class WifiDisplayController implements DumpUtils.Dump {
        pw.println("mRemoteDisplay=" + mRemoteDisplay);
        pw.println("mRemoteDisplayInterface=" + mRemoteDisplayInterface);
        pw.println("mRemoteDisplayConnected=" + mRemoteDisplayConnected);
        pw.println("mRemoteSubmixOn=" + mRemoteSubmixOn);

        pw.println("mKnownWifiDisplayPeers: size=" + mKnownWifiDisplayPeers.size());
        for (WifiP2pDevice device : mKnownWifiDisplayPeers) {
@@ -390,16 +394,14 @@ final class WifiDisplayController implements DumpUtils.Dump {
            Slog.i(TAG, "Stopped listening for RTSP connection on " + mRemoteDisplayInterface
                    + " from Wifi display: " + mConnectedDevice.deviceName);

            if (mRemoteDisplayConnected) {
                mAudioManager.setRemoteSubmixOn(false, REMOTE_SUBMIX_ADDRESS);
            }

            mRemoteDisplay.dispose();
            mRemoteDisplay = null;
            mRemoteDisplayInterface = null;
            mRemoteDisplayConnected = false;
            mHandler.removeCallbacks(mRtspTimeout);

            setRemoteSubmixOn(false);

            mHandler.post(new Runnable() {
                @Override
                public void run() {
@@ -527,6 +529,8 @@ final class WifiDisplayController implements DumpUtils.Dump {
                return; // done
            }

            setRemoteSubmixOn(true);

            final WifiP2pDevice oldDevice = mConnectedDevice;
            final int port = getPortNumber(mConnectedDevice);
            final String iface = addr.getHostAddress() + ":" + port;
@@ -545,8 +549,6 @@ final class WifiDisplayController implements DumpUtils.Dump {
                        mRemoteDisplayConnected = true;
                        mHandler.removeCallbacks(mRtspTimeout);

                        mAudioManager.setRemoteSubmixOn(true, REMOTE_SUBMIX_ADDRESS);

                        final WifiDisplay display = createWifiDisplay(mConnectedDevice);
                        mHandler.post(new Runnable() {
                            @Override
@@ -583,6 +585,13 @@ final class WifiDisplayController implements DumpUtils.Dump {
        }
    }

    private void setRemoteSubmixOn(boolean on) {
        if (mRemoteSubmixOn != on) {
            mRemoteSubmixOn = on;
            mAudioManager.setRemoteSubmixOn(on, REMOTE_SUBMIX_ADDRESS);
        }
    }

    private void handleStateChanged(boolean enabled) {
        if (mWifiP2pEnabled != enabled) {
            mWifiP2pEnabled = enabled;