audiopolicy: Check open outputs count before closing.
- In compress offload session subsystem restart triggers
invalidaton. For direct or compress session NuPlayer
is notified as track cant be restored and it restarts
session with direct attributes which fails again as sound
card is offline and output descriptor is closed on this
failed attempt. While closing the output descriptor its
open count is checked and if its less than 1 its logged
as fatal.
- Fix is to avoid closing of output descriptor if its
not opened successfully.
Change-Id: I0456edcbdea483a5620a33aca5d4da2b93b04589
diff --git a/policy_hal/AudioPolicyManager.cpp b/policy_hal/AudioPolicyManager.cpp
index cb7db23..830ebe1 100644
--- a/policy_hal/AudioPolicyManager.cpp
+++ b/policy_hal/AudioPolicyManager.cpp
@@ -1795,7 +1795,8 @@
"format %d %d, channel mask %04x %04x", output, config->sample_rate,
outputDesc->mSamplingRate, config->format, outputDesc->mFormat,
channelMask, outputDesc->mChannelMask);
- if (output != AUDIO_IO_HANDLE_NONE) {
+ //Only close o/p descriptor if successfully opened
+ if (status == NO_ERROR) {
outputDesc->close();
}
// fall back to mixer output if possible when the direct output could not be open