From 2c9add7250b8fa0590f6106fc837510549f76367 Mon Sep 17 00:00:00 2001 From: Ramjee Singh Date: Mon, 29 Apr 2019 16:10:27 +0530 Subject: 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 --- policy_hal/AudioPolicyManager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 @@ audio_io_handle_t AudioPolicyManagerCustom::getOutputForDevices( "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 -- cgit v1.2.3