hal: Update output device to speaker on USB disconnect
If USB device is disconnected and reconnected quickly and
music playback is started, there is a race condition where
sound device and audio route for USB are not being disabled
and reenabled. This results in no audio on USB.
Unplugging and replugging the USB device without disabling
USB sound device leaves the driver in a bad state.
AudioPolicyManager sends routing to speaker on a disconnect
which causes a device switch. USB sound device is disabled in
audio HAL and reference count is set to zero.
In failure scenario, audio HAL does not receive routing to
speaker. Policy manager sends routing to USB as the device is
now available. Since USB sound device is already active, it is
not reenabled.
Fix this problem by selecting speaker on receiving a USB device
disconnect. This results in a device switch as soon as USB is
disconnected and USB sound device is disabled.
Bug: 111315812
Test: repro steps in bug.
Change-Id: I7fb0813792ea95f9d47da96a57ab3b3895a47776
1 file changed