Merge "audiopolicy: Check open outputs count before closing."
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