Loading media/libaudioclient/AudioSystem.cpp +31 −8 Original line number Diff line number Diff line Loading @@ -71,6 +71,25 @@ class CaptureStateListenerImpl; Mutex gSoundTriggerCaptureStateListenerLock; sp<CaptureStateListenerImpl> gSoundTriggerCaptureStateListener = nullptr; // Binder for the AudioFlinger service that's passed to this client process from the system server. // This allows specific isolated processes to access the audio system. Currently used only for the // HotwordDetectionService. sp<IBinder> gAudioFlingerBinder = nullptr; void AudioSystem::setAudioFlingerBinder(const sp<IBinder>& audioFlinger) { if (audioFlinger->getInterfaceDescriptor() != media::IAudioFlingerService::descriptor) { ALOGE("setAudioFlingerBinder: received a binder of type %s", String8(audioFlinger->getInterfaceDescriptor()).string()); return; } Mutex::Autolock _l(gLock); if (gAudioFlinger != nullptr) { ALOGW("setAudioFlingerBinder: ignoring; AudioFlinger connection already established."); return; } gAudioFlingerBinder = audioFlinger; } // establish binder interface to AudioFlinger service const sp<IAudioFlinger> AudioSystem::get_audio_flinger() { sp<IAudioFlinger> af; Loading @@ -79,8 +98,11 @@ const sp<IAudioFlinger> AudioSystem::get_audio_flinger() { { Mutex::Autolock _l(gLock); if (gAudioFlinger == 0) { sp<IServiceManager> sm = defaultServiceManager(); sp<IBinder> binder; if (gAudioFlingerBinder != nullptr) { binder = gAudioFlingerBinder; } else { sp<IServiceManager> sm = defaultServiceManager(); do { binder = sm->getService(String16(IAudioFlinger::DEFAULT_SERVICE_NAME)); if (binder != 0) Loading @@ -88,6 +110,7 @@ const sp<IAudioFlinger> AudioSystem::get_audio_flinger() { ALOGW("AudioFlinger not published, waiting..."); usleep(500000); // 0.5 s } while (true); } if (gAudioFlingerClient == NULL) { gAudioFlingerClient = new AudioFlingerClient(); } else { Loading media/libaudioclient/include/media/AudioSystem.h +5 −0 Original line number Diff line number Diff line Loading @@ -148,6 +148,11 @@ public: static void setRecordConfigCallback(record_config_callback); static void setRoutingCallback(routing_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 // HotwordDetectionService. static void setAudioFlingerBinder(const sp<IBinder>& audioFlinger); // helper function to obtain AudioFlinger service handle static const sp<IAudioFlinger> get_audio_flinger(); Loading Loading
media/libaudioclient/AudioSystem.cpp +31 −8 Original line number Diff line number Diff line Loading @@ -71,6 +71,25 @@ class CaptureStateListenerImpl; Mutex gSoundTriggerCaptureStateListenerLock; sp<CaptureStateListenerImpl> gSoundTriggerCaptureStateListener = nullptr; // Binder for the AudioFlinger service that's passed to this client process from the system server. // This allows specific isolated processes to access the audio system. Currently used only for the // HotwordDetectionService. sp<IBinder> gAudioFlingerBinder = nullptr; void AudioSystem::setAudioFlingerBinder(const sp<IBinder>& audioFlinger) { if (audioFlinger->getInterfaceDescriptor() != media::IAudioFlingerService::descriptor) { ALOGE("setAudioFlingerBinder: received a binder of type %s", String8(audioFlinger->getInterfaceDescriptor()).string()); return; } Mutex::Autolock _l(gLock); if (gAudioFlinger != nullptr) { ALOGW("setAudioFlingerBinder: ignoring; AudioFlinger connection already established."); return; } gAudioFlingerBinder = audioFlinger; } // establish binder interface to AudioFlinger service const sp<IAudioFlinger> AudioSystem::get_audio_flinger() { sp<IAudioFlinger> af; Loading @@ -79,8 +98,11 @@ const sp<IAudioFlinger> AudioSystem::get_audio_flinger() { { Mutex::Autolock _l(gLock); if (gAudioFlinger == 0) { sp<IServiceManager> sm = defaultServiceManager(); sp<IBinder> binder; if (gAudioFlingerBinder != nullptr) { binder = gAudioFlingerBinder; } else { sp<IServiceManager> sm = defaultServiceManager(); do { binder = sm->getService(String16(IAudioFlinger::DEFAULT_SERVICE_NAME)); if (binder != 0) Loading @@ -88,6 +110,7 @@ const sp<IAudioFlinger> AudioSystem::get_audio_flinger() { ALOGW("AudioFlinger not published, waiting..."); usleep(500000); // 0.5 s } while (true); } if (gAudioFlingerClient == NULL) { gAudioFlingerClient = new AudioFlingerClient(); } else { Loading
media/libaudioclient/include/media/AudioSystem.h +5 −0 Original line number Diff line number Diff line Loading @@ -148,6 +148,11 @@ public: static void setRecordConfigCallback(record_config_callback); static void setRoutingCallback(routing_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 // HotwordDetectionService. static void setAudioFlingerBinder(const sp<IBinder>& audioFlinger); // helper function to obtain AudioFlinger service handle static const sp<IAudioFlinger> get_audio_flinger(); Loading