audio: fix problem of routing device 0 after A2DP play
This patch avoids abnormal operation in AudioStreamOutALSA::write().
When BT device is turned On/Off, if routing device is 0, then pcm open
will be failed.
- A variable "mDevices" is set to "0" when device is switched to BT A2DP
from speaker during playing music.
- If variable "mDevices" is "0", when PCM data is writing to buffer
in A2DP stream, then a routing device is set "no device".
- And when device is switched to ALSA stream, and PCM open will be failed.
This causes media crash as killing ALSA.
Change-Id: Id416bed3f59bfbe857b2a9fd504f3f18746fb4cd
diff --git a/alsa_sound/AudioStreamOutALSA.cpp b/alsa_sound/AudioStreamOutALSA.cpp
index eb0949e..be6951e 100644
--- a/alsa_sound/AudioStreamOutALSA.cpp
+++ b/alsa_sound/AudioStreamOutALSA.cpp
@@ -165,8 +165,9 @@
mHandle->module->route(mHandle, mDevices , mParent->mode());
#endif
} else {
-
- mHandle->module->route(mHandle, mDevices , mParent->mode());
+ if (!mDevices)
+ mDevices = mParent->mCurDevice;
+ mHandle->module->route(mHandle, mDevices , mParent->mode());
}
if (!strcmp(mHandle->useCase, SND_USE_CASE_VERB_HIFI) ||
!strcmp(mHandle->useCase, SND_USE_CASE_VERB_HIFI_LOWLATENCY_MUSIC) ||