diff options
author | Eric Laurent <elaurent@google.com> | 2015-07-09 14:52:47 -0700 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2015-07-10 10:58:41 -0700 |
commit | 7c1ec5f038e63a5eb8b04434577c25bc23f5f410 (patch) | |
tree | f6b8feda43ba0bb6666171b57318ad3cea48a45e /services/audioflinger/AudioFlinger.cpp | |
parent | 54c0659b9efa72d11997c590c4d377c44789c7fd (diff) | |
download | frameworks_av-7c1ec5f038e63a5eb8b04434577c25bc23f5f410.zip frameworks_av-7c1ec5f038e63a5eb8b04434577c25bc23f5f410.tar.gz frameworks_av-7c1ec5f038e63a5eb8b04434577c25bc23f5f410.tar.bz2 |
audio: several fixes in audio routing callbacks
- audio policy:
Force device change to ensure new audio patch creation
upon first track activity on a given output.
Fix function device_distinguishes_on_address() which could mistake
some output device with remote submix input device.
- audio flinger:
Reduce number of binder calls upon new client registration by only
sending ioConfigChanged() callbacks to newly registered client.
Fix first patch after output thread creation not triggering an
ioConfigChanged() callback.
-audio system:
Force client registration upon routing callback installation to force
new ioConfigChanged() callback from audio flinger.
Bug: 22381136.
Change-Id: Ieb0d9f92f563a40552eb31bc0499c8ac65f78ce4
Diffstat (limited to 'services/audioflinger/AudioFlinger.cpp')
-rw-r--r-- | services/audioflinger/AudioFlinger.cpp | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp index 52fce34..8f1e050 100644 --- a/services/audioflinger/AudioFlinger.cpp +++ b/services/audioflinger/AudioFlinger.cpp @@ -1252,11 +1252,9 @@ void AudioFlinger::registerClient(const sp<IAudioFlingerClient>& client) if (client == 0) { return; } - bool clientAdded = false; + pid_t pid = IPCThreadState::self()->getCallingPid(); { Mutex::Autolock _cl(mClientLock); - - pid_t pid = IPCThreadState::self()->getCallingPid(); if (mNotificationClients.indexOfKey(pid) < 0) { sp<NotificationClient> notificationClient = new NotificationClient(this, client, @@ -1267,22 +1265,19 @@ void AudioFlinger::registerClient(const sp<IAudioFlingerClient>& client) sp<IBinder> binder = IInterface::asBinder(client); binder->linkToDeath(notificationClient); - clientAdded = true; } } // mClientLock should not be held here because ThreadBase::sendIoConfigEvent() will lock the // ThreadBase mutex and the locking order is ThreadBase::mLock then AudioFlinger::mClientLock. - if (clientAdded) { - // the config change is always sent from playback or record threads to avoid deadlock - // with AudioSystem::gLock - for (size_t i = 0; i < mPlaybackThreads.size(); i++) { - mPlaybackThreads.valueAt(i)->sendIoConfigEvent(AUDIO_OUTPUT_OPENED); - } + // the config change is always sent from playback or record threads to avoid deadlock + // with AudioSystem::gLock + for (size_t i = 0; i < mPlaybackThreads.size(); i++) { + mPlaybackThreads.valueAt(i)->sendIoConfigEvent(AUDIO_OUTPUT_OPENED, pid); + } - for (size_t i = 0; i < mRecordThreads.size(); i++) { - mRecordThreads.valueAt(i)->sendIoConfigEvent(AUDIO_INPUT_OPENED); - } + for (size_t i = 0; i < mRecordThreads.size(); i++) { + mRecordThreads.valueAt(i)->sendIoConfigEvent(AUDIO_INPUT_OPENED, pid); } } @@ -1316,12 +1311,15 @@ void AudioFlinger::removeNotificationClient(pid_t pid) } void AudioFlinger::ioConfigChanged(audio_io_config_event event, - const sp<AudioIoDescriptor>& ioDesc) + const sp<AudioIoDescriptor>& ioDesc, + pid_t pid) { Mutex::Autolock _l(mClientLock); size_t size = mNotificationClients.size(); for (size_t i = 0; i < size; i++) { - mNotificationClients.valueAt(i)->audioFlingerClient()->ioConfigChanged(event, ioDesc); + if ((pid == 0) || (mNotificationClients.keyAt(i) == pid)) { + mNotificationClients.valueAt(i)->audioFlingerClient()->ioConfigChanged(event, ioDesc); + } } } |