Loading services/audiopolicy/service/AudioPolicyService.cpp +26 −3 Original line number Original line Diff line number Diff line Loading @@ -1801,6 +1801,7 @@ bool AudioPolicyService::AudioCommandThread::threadLoop() ++numTimesBecameEmpty; ++numTimesBecameEmpty; } } mLastCommand = command; mLastCommand = command; status_t createAudioPatchStatus; switch (command->mCommand) { switch (command->mCommand) { case SET_VOLUME: { case SET_VOLUME: { Loading Loading @@ -1858,10 +1859,11 @@ bool AudioPolicyService::AudioCommandThread::threadLoop() ALOGV("AudioCommandThread() processing create audio patch"); ALOGV("AudioCommandThread() processing create audio patch"); sp<IAudioFlinger> af = AudioSystem::get_audio_flinger(); sp<IAudioFlinger> af = AudioSystem::get_audio_flinger(); if (af == 0) { if (af == 0) { command->mStatus = PERMISSION_DENIED; createAudioPatchStatus = PERMISSION_DENIED; } else { } else { ul.unlock(); ul.unlock(); command->mStatus = af->createAudioPatch(&data->mPatch, &data->mHandle); createAudioPatchStatus = af->createAudioPatch(&data->mPatch, &data->mHandle); ul.lock(); ul.lock(); } } } break; } break; Loading Loading @@ -2030,8 +2032,28 @@ bool AudioPolicyService::AudioCommandThread::threadLoop() { { audio_utils::lock_guard _l(command->mMutex); audio_utils::lock_guard _l(command->mMutex); if (command->mWaitStatus) { if (command->mWaitStatus) { if (command->mCommand == CREATE_AUDIO_PATCH) { command->mStatus = createAudioPatchStatus; } command->mWaitStatus = false; command->mWaitStatus = false; command->mCond.notify_one(); command->mCond.notify_one(); } else if (command->mCommand == CREATE_AUDIO_PATCH && command->mStatus == TIMED_OUT && createAudioPatchStatus == NO_ERROR) { // Because of special handling in insertCommand_l() the CREATE_AUDIO_PATCH // command wait status can be only false in case timeout (see TIMED_OUT) // happened. CreateAudioPatchData *createData = (CreateAudioPatchData *)command->mParam.get(); ALOGW("AudioCommandThread() no caller awaiting for handle(%d) after \ processing create audio patch, going to release it", createData->mHandle); sp<AudioCommand> releaseCommand = new AudioCommand(); releaseCommand->mCommand = RELEASE_AUDIO_PATCH; ReleaseAudioPatchData *releaseData = new ReleaseAudioPatchData(); releaseData->mHandle = createData->mHandle; releaseCommand->mParam = releaseData; insertCommand_l(releaseCommand, 0); } } } } waitTime = -1; waitTime = -1; Loading Loading @@ -2549,7 +2571,8 @@ void AudioPolicyService::AudioCommandThread::insertCommand_l(sp<AudioCommand>& c // Disable wait for status if delay is not 0. // Disable wait for status if delay is not 0. // Except for create audio patch command because the returned patch handle // Except for create audio patch command because the returned patch handle // is needed by audio policy manager // is needed by audio policy manager. Audio patch created after timeout // (see TIMED_OUT) will be released from threadLoop(). if (delayMs != 0 && command->mCommand != CREATE_AUDIO_PATCH) { if (delayMs != 0 && command->mCommand != CREATE_AUDIO_PATCH) { command->mWaitStatus = false; command->mWaitStatus = false; } } Loading Loading
services/audiopolicy/service/AudioPolicyService.cpp +26 −3 Original line number Original line Diff line number Diff line Loading @@ -1801,6 +1801,7 @@ bool AudioPolicyService::AudioCommandThread::threadLoop() ++numTimesBecameEmpty; ++numTimesBecameEmpty; } } mLastCommand = command; mLastCommand = command; status_t createAudioPatchStatus; switch (command->mCommand) { switch (command->mCommand) { case SET_VOLUME: { case SET_VOLUME: { Loading Loading @@ -1858,10 +1859,11 @@ bool AudioPolicyService::AudioCommandThread::threadLoop() ALOGV("AudioCommandThread() processing create audio patch"); ALOGV("AudioCommandThread() processing create audio patch"); sp<IAudioFlinger> af = AudioSystem::get_audio_flinger(); sp<IAudioFlinger> af = AudioSystem::get_audio_flinger(); if (af == 0) { if (af == 0) { command->mStatus = PERMISSION_DENIED; createAudioPatchStatus = PERMISSION_DENIED; } else { } else { ul.unlock(); ul.unlock(); command->mStatus = af->createAudioPatch(&data->mPatch, &data->mHandle); createAudioPatchStatus = af->createAudioPatch(&data->mPatch, &data->mHandle); ul.lock(); ul.lock(); } } } break; } break; Loading Loading @@ -2030,8 +2032,28 @@ bool AudioPolicyService::AudioCommandThread::threadLoop() { { audio_utils::lock_guard _l(command->mMutex); audio_utils::lock_guard _l(command->mMutex); if (command->mWaitStatus) { if (command->mWaitStatus) { if (command->mCommand == CREATE_AUDIO_PATCH) { command->mStatus = createAudioPatchStatus; } command->mWaitStatus = false; command->mWaitStatus = false; command->mCond.notify_one(); command->mCond.notify_one(); } else if (command->mCommand == CREATE_AUDIO_PATCH && command->mStatus == TIMED_OUT && createAudioPatchStatus == NO_ERROR) { // Because of special handling in insertCommand_l() the CREATE_AUDIO_PATCH // command wait status can be only false in case timeout (see TIMED_OUT) // happened. CreateAudioPatchData *createData = (CreateAudioPatchData *)command->mParam.get(); ALOGW("AudioCommandThread() no caller awaiting for handle(%d) after \ processing create audio patch, going to release it", createData->mHandle); sp<AudioCommand> releaseCommand = new AudioCommand(); releaseCommand->mCommand = RELEASE_AUDIO_PATCH; ReleaseAudioPatchData *releaseData = new ReleaseAudioPatchData(); releaseData->mHandle = createData->mHandle; releaseCommand->mParam = releaseData; insertCommand_l(releaseCommand, 0); } } } } waitTime = -1; waitTime = -1; Loading Loading @@ -2549,7 +2571,8 @@ void AudioPolicyService::AudioCommandThread::insertCommand_l(sp<AudioCommand>& c // Disable wait for status if delay is not 0. // Disable wait for status if delay is not 0. // Except for create audio patch command because the returned patch handle // Except for create audio patch command because the returned patch handle // is needed by audio policy manager // is needed by audio policy manager. Audio patch created after timeout // (see TIMED_OUT) will be released from threadLoop(). if (delayMs != 0 && command->mCommand != CREATE_AUDIO_PATCH) { if (delayMs != 0 && command->mCommand != CREATE_AUDIO_PATCH) { command->mWaitStatus = false; command->mWaitStatus = false; } } Loading