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

Commit 523ae416 authored by Dhanalakshmi Siddani's avatar Dhanalakshmi Siddani Committed by Gerrit - the friendly Code Review server
Browse files

Audio: Fix for audio loss on switching between speaker and USB headset

 - snd device reference count is not decremented when usb headset is
   unplugged, because touch tone is still active on usb headset.
   So when usb is plugged again device routing is not triggered as
   present and prev devices are same
 - Fix is to route audio to speaker as soon as usb headset is
   disconnected

   CRs-Fixed: 630425

Change-Id: Idfa37478fa19cd5a1c75c7e1d2f77b4dc02b311a
parent a593da0c
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -1400,13 +1400,14 @@ static int out_set_parameters(struct audio_stream *stream, const char *kvpairs)
        pthread_mutex_lock(&adev->lock);

        /*
         * When HDMI cable is unplugged the music playback is paused and
         * the policy manager sends routing=0. But the audioflinger
         * continues to write data until standby time (3sec).
         * As the HDMI core is turned off, the write gets blocked.
         * When HDMI cable is unplugged/usb hs is disconnected the
         * music playback is paused and the policy manager sends routing=0
         * But the audioflingercontinues to write data until standby time
         * (3sec). As the HDMI core is turned off, the write gets blocked.
         * Avoid this by routing audio to speaker until standby.
         */
        if (out->devices == AUDIO_DEVICE_OUT_AUX_DIGITAL &&
        if ((out->devices == AUDIO_DEVICE_OUT_AUX_DIGITAL ||
                out->devices == AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET) &&
                val == AUDIO_DEVICE_NONE) {
            val = AUDIO_DEVICE_OUT_SPEAKER;
        }