Loading media/libaudioclient/AudioSystem.cpp +19 −0 Original line number Diff line number Diff line Loading @@ -70,6 +70,7 @@ std::set<audio_error_callback> AudioSystem::gAudioErrorCallbacks; dynamic_policy_callback AudioSystem::gDynPolicyCallback = NULL; record_config_callback AudioSystem::gRecordConfigCallback = NULL; routing_callback AudioSystem::gRoutingCallback = NULL; vol_range_init_req_callback AudioSystem::gVolRangeInitReqCallback = NULL; // Required to be held while calling into gSoundTriggerCaptureStateListener. class CaptureStateListenerImpl; Loading Loading @@ -781,6 +782,11 @@ status_t AudioSystem::AudioFlingerClient::removeAudioDeviceCallback( gRoutingCallback = cb; } /*static*/ void AudioSystem::setVolInitReqCallback(vol_range_init_req_callback cb) { Mutex::Autolock _l(gLock); gVolRangeInitReqCallback = cb; } // client singleton for AudioPolicyService binder interface // protected by gLockAPS sp<IAudioPolicyService> AudioSystem::gAudioPolicyService; Loading Loading @@ -2574,6 +2580,19 @@ Status AudioSystem::AudioPolicyServiceClient::onRoutingUpdated() { return Status::ok(); } Status AudioSystem::AudioPolicyServiceClient::onVolumeRangeInitRequest() { vol_range_init_req_callback cb = NULL; { Mutex::Autolock _l(AudioSystem::gLock); cb = gVolRangeInitReqCallback; } if (cb != NULL) { cb(); } return Status::ok(); } void AudioSystem::AudioPolicyServiceClient::binderDied(const wp<IBinder>& who __unused) { { Mutex::Autolock _l(mLock); Loading media/libaudioclient/aidl/android/media/IAudioPolicyServiceClient.aidl +3 −0 Original line number Diff line number Diff line Loading @@ -46,4 +46,7 @@ oneway interface IAudioPolicyServiceClient { AudioSource source); /** Notifies a change of audio routing */ void onRoutingUpdated(); /** Notifies a request for volume index ranges to be reset after they were observed as invalid */ void onVolumeRangeInitRequest(); } media/libaudioclient/include/media/AudioSystem.h +4 −0 Original line number Diff line number Diff line Loading @@ -77,6 +77,7 @@ typedef void (*record_config_callback)(int event, audio_patch_handle_t patchHandle, audio_source_t source); typedef void (*routing_callback)(); typedef void (*vol_range_init_req_callback)(); class IAudioFlinger; class String8; Loading Loading @@ -154,6 +155,7 @@ public: static void setDynPolicyCallback(dynamic_policy_callback cb); static void setRecordConfigCallback(record_config_callback); static void setRoutingCallback(routing_callback cb); static void setVolInitReqCallback(vol_range_init_req_callback cb); // Sets the binder to use for accessing the AudioFlinger service. This enables the system server // to grant specific isolated processes access to the audio system. Currently used only for the Loading Loading @@ -736,6 +738,7 @@ private: int32_t patchHandle, media::audio::common::AudioSource source) override; binder::Status onRoutingUpdated(); binder::Status onVolumeRangeInitRequest(); private: Mutex mLock; Loading Loading @@ -763,6 +766,7 @@ private: static dynamic_policy_callback gDynPolicyCallback; static record_config_callback gRecordConfigCallback; static routing_callback gRoutingCallback; static vol_range_init_req_callback gVolRangeInitReqCallback; static size_t gInBuffSize; // previous parameters for recording buffer size queries Loading services/audiopolicy/AudioPolicyInterface.h +4 −0 Original line number Diff line number Diff line Loading @@ -533,6 +533,10 @@ public: virtual void onRoutingUpdated() = 0; // Used to notify AudioService that an error was encountering when reading // the volume ranges, and that they should be re-initialized virtual void onVolumeRangeInitRequest() = 0; // Used to notify the sound trigger module that an audio capture is about to // take place. This should typically result in any active recognition // sessions to be preempted on modules that do not support sound trigger Loading services/audiopolicy/managerdefault/AudioPolicyManager.cpp +11 −2 Original line number Diff line number Diff line Loading @@ -2118,11 +2118,15 @@ status_t AudioPolicyManager::startSource(const sp<SwAudioOutputDescriptor>& outp // apply volume rules for current stream and device if necessary auto &curves = getVolumeCurves(client->attributes()); checkAndSetVolume(curves, client->volumeSource(), if (NO_ERROR != checkAndSetVolume(curves, client->volumeSource(), curves.getVolumeIndex(outputDesc->devices().types()), outputDesc, outputDesc->devices().types(), 0 /*delay*/, outputDesc->useHwGain() /*force*/); outputDesc->useHwGain() /*force*/)) { // request AudioService to reinitialize the volume curves asynchronously ALOGE("checkAndSetVolume failed, requesting volume range init"); mpClientInterface->onVolumeRangeInitRequest(); }; // update the outputs if starting an output with a stream that can affect notification // routing Loading Loading @@ -7290,6 +7294,11 @@ status_t AudioPolicyManager::checkAndSetVolume(IVolumeCurves &curves, deviceTypes = outputDesc->devices().types(); } if (curves.getVolumeIndexMin() < 0 || curves.getVolumeIndexMax() < 0) { ALOGE("invalid volume index range"); return BAD_VALUE; } float volumeDb = computeVolume(curves, volumeSource, index, deviceTypes); if (outputDesc->isFixedVolume(deviceTypes) || // Force VoIP volume to max for bluetooth SCO device except if muted Loading Loading
media/libaudioclient/AudioSystem.cpp +19 −0 Original line number Diff line number Diff line Loading @@ -70,6 +70,7 @@ std::set<audio_error_callback> AudioSystem::gAudioErrorCallbacks; dynamic_policy_callback AudioSystem::gDynPolicyCallback = NULL; record_config_callback AudioSystem::gRecordConfigCallback = NULL; routing_callback AudioSystem::gRoutingCallback = NULL; vol_range_init_req_callback AudioSystem::gVolRangeInitReqCallback = NULL; // Required to be held while calling into gSoundTriggerCaptureStateListener. class CaptureStateListenerImpl; Loading Loading @@ -781,6 +782,11 @@ status_t AudioSystem::AudioFlingerClient::removeAudioDeviceCallback( gRoutingCallback = cb; } /*static*/ void AudioSystem::setVolInitReqCallback(vol_range_init_req_callback cb) { Mutex::Autolock _l(gLock); gVolRangeInitReqCallback = cb; } // client singleton for AudioPolicyService binder interface // protected by gLockAPS sp<IAudioPolicyService> AudioSystem::gAudioPolicyService; Loading Loading @@ -2574,6 +2580,19 @@ Status AudioSystem::AudioPolicyServiceClient::onRoutingUpdated() { return Status::ok(); } Status AudioSystem::AudioPolicyServiceClient::onVolumeRangeInitRequest() { vol_range_init_req_callback cb = NULL; { Mutex::Autolock _l(AudioSystem::gLock); cb = gVolRangeInitReqCallback; } if (cb != NULL) { cb(); } return Status::ok(); } void AudioSystem::AudioPolicyServiceClient::binderDied(const wp<IBinder>& who __unused) { { Mutex::Autolock _l(mLock); Loading
media/libaudioclient/aidl/android/media/IAudioPolicyServiceClient.aidl +3 −0 Original line number Diff line number Diff line Loading @@ -46,4 +46,7 @@ oneway interface IAudioPolicyServiceClient { AudioSource source); /** Notifies a change of audio routing */ void onRoutingUpdated(); /** Notifies a request for volume index ranges to be reset after they were observed as invalid */ void onVolumeRangeInitRequest(); }
media/libaudioclient/include/media/AudioSystem.h +4 −0 Original line number Diff line number Diff line Loading @@ -77,6 +77,7 @@ typedef void (*record_config_callback)(int event, audio_patch_handle_t patchHandle, audio_source_t source); typedef void (*routing_callback)(); typedef void (*vol_range_init_req_callback)(); class IAudioFlinger; class String8; Loading Loading @@ -154,6 +155,7 @@ public: static void setDynPolicyCallback(dynamic_policy_callback cb); static void setRecordConfigCallback(record_config_callback); static void setRoutingCallback(routing_callback cb); static void setVolInitReqCallback(vol_range_init_req_callback cb); // Sets the binder to use for accessing the AudioFlinger service. This enables the system server // to grant specific isolated processes access to the audio system. Currently used only for the Loading Loading @@ -736,6 +738,7 @@ private: int32_t patchHandle, media::audio::common::AudioSource source) override; binder::Status onRoutingUpdated(); binder::Status onVolumeRangeInitRequest(); private: Mutex mLock; Loading Loading @@ -763,6 +766,7 @@ private: static dynamic_policy_callback gDynPolicyCallback; static record_config_callback gRecordConfigCallback; static routing_callback gRoutingCallback; static vol_range_init_req_callback gVolRangeInitReqCallback; static size_t gInBuffSize; // previous parameters for recording buffer size queries Loading
services/audiopolicy/AudioPolicyInterface.h +4 −0 Original line number Diff line number Diff line Loading @@ -533,6 +533,10 @@ public: virtual void onRoutingUpdated() = 0; // Used to notify AudioService that an error was encountering when reading // the volume ranges, and that they should be re-initialized virtual void onVolumeRangeInitRequest() = 0; // Used to notify the sound trigger module that an audio capture is about to // take place. This should typically result in any active recognition // sessions to be preempted on modules that do not support sound trigger Loading
services/audiopolicy/managerdefault/AudioPolicyManager.cpp +11 −2 Original line number Diff line number Diff line Loading @@ -2118,11 +2118,15 @@ status_t AudioPolicyManager::startSource(const sp<SwAudioOutputDescriptor>& outp // apply volume rules for current stream and device if necessary auto &curves = getVolumeCurves(client->attributes()); checkAndSetVolume(curves, client->volumeSource(), if (NO_ERROR != checkAndSetVolume(curves, client->volumeSource(), curves.getVolumeIndex(outputDesc->devices().types()), outputDesc, outputDesc->devices().types(), 0 /*delay*/, outputDesc->useHwGain() /*force*/); outputDesc->useHwGain() /*force*/)) { // request AudioService to reinitialize the volume curves asynchronously ALOGE("checkAndSetVolume failed, requesting volume range init"); mpClientInterface->onVolumeRangeInitRequest(); }; // update the outputs if starting an output with a stream that can affect notification // routing Loading Loading @@ -7290,6 +7294,11 @@ status_t AudioPolicyManager::checkAndSetVolume(IVolumeCurves &curves, deviceTypes = outputDesc->devices().types(); } if (curves.getVolumeIndexMin() < 0 || curves.getVolumeIndexMax() < 0) { ALOGE("invalid volume index range"); return BAD_VALUE; } float volumeDb = computeVolume(curves, volumeSource, index, deviceTypes); if (outputDesc->isFixedVolume(deviceTypes) || // Force VoIP volume to max for bluetooth SCO device except if muted Loading