diff options
author | Eric Laurent <elaurent@google.com> | 2014-07-28 17:26:49 -0700 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2014-07-28 18:10:29 -0700 |
commit | 4dc680607181e6a76f4e91a39366c4f5dfb7b03e (patch) | |
tree | 5212b6ff474b8ef68a68cb1cf144f54e5348de77 /services/audiopolicy/AudioPolicyManager.cpp | |
parent | d530d415e60373caf875a37d2d747a51470ee45c (diff) | |
download | frameworks_av-4dc680607181e6a76f4e91a39366c4f5dfb7b03e.zip frameworks_av-4dc680607181e6a76f4e91a39366c4f5dfb7b03e.tar.gz frameworks_av-4dc680607181e6a76f4e91a39366c4f5dfb7b03e.tar.bz2 |
audio policy: pass session ID to capture activity methods
Indicate the audio session ID when calling getInput(),
startInput(), stopInput(), releaseInput().
Bug: 12378680.
Change-Id: I763793752f93e2f4e1445a5ab217c895af011038
Diffstat (limited to 'services/audiopolicy/AudioPolicyManager.cpp')
-rw-r--r-- | services/audiopolicy/AudioPolicyManager.cpp | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/services/audiopolicy/AudioPolicyManager.cpp b/services/audiopolicy/AudioPolicyManager.cpp index 7fd9b3a..37f8513 100644 --- a/services/audiopolicy/AudioPolicyManager.cpp +++ b/services/audiopolicy/AudioPolicyManager.cpp @@ -1062,12 +1062,12 @@ audio_io_handle_t AudioPolicyManager::getInput(audio_source_t inputSource, uint32_t samplingRate, audio_format_t format, audio_channel_mask_t channelMask, - audio_in_acoustics_t acoustics, + audio_session_t session, audio_input_flags_t flags) { - ALOGV("getInput() inputSource %d, samplingRate %d, format %d, channelMask %x, acoustics %x, " + ALOGV("getInput() inputSource %d, samplingRate %d, format %d, channelMask %x, session %d, " "flags %#x", - inputSource, samplingRate, format, channelMask, acoustics, flags); + inputSource, samplingRate, format, channelMask, session, flags); audio_devices_t device = getDeviceForInputSource(inputSource); @@ -1142,13 +1142,15 @@ audio_io_handle_t AudioPolicyManager::getInput(audio_source_t inputSource, inputDesc->mFormat = format; inputDesc->mChannelMask = channelMask; inputDesc->mDevice = device; + inputDesc->mSessions.add(session); addInput(input, inputDesc); mpClientInterface->onAudioPortListUpdate(); return input; } -status_t AudioPolicyManager::startInput(audio_io_handle_t input) +status_t AudioPolicyManager::startInput(audio_io_handle_t input, + audio_session_t session) { ALOGV("startInput() input %d", input); ssize_t index = mInputs.indexOfKey(input); @@ -1158,6 +1160,12 @@ status_t AudioPolicyManager::startInput(audio_io_handle_t input) } sp<AudioInputDescriptor> inputDesc = mInputs.valueAt(index); + index = inputDesc->mSessions.indexOf(session); + if (index < 0) { + ALOGW("startInput() unknown session %d on input %d", session, input); + return BAD_VALUE; + } + // virtual input devices are compatible with other input devices if (!isVirtualInputDevice(inputDesc->mDevice)) { @@ -1170,8 +1178,8 @@ status_t AudioPolicyManager::startInput(audio_io_handle_t input) sp<AudioInputDescriptor> activeDesc = mInputs.valueFor(activeInput); if (activeDesc->mInputSource == AUDIO_SOURCE_HOTWORD) { ALOGW("startInput(%d) preempting low-priority input %d", input, activeInput); - stopInput(activeInput); - releaseInput(activeInput); + stopInput(activeInput, activeDesc->mSessions.itemAt(0)); + releaseInput(activeInput, activeDesc->mSessions.itemAt(0)); } else { ALOGE("startInput(%d) failed: other input %d already started", input, activeInput); return INVALID_OPERATION; @@ -1196,7 +1204,8 @@ status_t AudioPolicyManager::startInput(audio_io_handle_t input) return NO_ERROR; } -status_t AudioPolicyManager::stopInput(audio_io_handle_t input) +status_t AudioPolicyManager::stopInput(audio_io_handle_t input, + audio_session_t session) { ALOGV("stopInput() input %d", input); ssize_t index = mInputs.indexOfKey(input); @@ -1206,6 +1215,12 @@ status_t AudioPolicyManager::stopInput(audio_io_handle_t input) } sp<AudioInputDescriptor> inputDesc = mInputs.valueAt(index); + index = inputDesc->mSessions.indexOf(session); + if (index < 0) { + ALOGW("stopInput() unknown session %d on input %d", session, input); + return BAD_VALUE; + } + if (inputDesc->mRefCount == 0) { ALOGW("stopInput() input %d already stopped", input); return INVALID_OPERATION; @@ -1225,7 +1240,8 @@ status_t AudioPolicyManager::stopInput(audio_io_handle_t input) return NO_ERROR; } -void AudioPolicyManager::releaseInput(audio_io_handle_t input) +void AudioPolicyManager::releaseInput(audio_io_handle_t input, + audio_session_t session) { ALOGV("releaseInput() %d", input); ssize_t index = mInputs.indexOfKey(input); @@ -1235,6 +1251,13 @@ void AudioPolicyManager::releaseInput(audio_io_handle_t input) } sp<AudioInputDescriptor> inputDesc = mInputs.valueAt(index); ALOG_ASSERT(inputDesc != 0); + + index = inputDesc->mSessions.indexOf(session); + if (index < 0) { + ALOGW("releaseInput() unknown session %d on input %d", session, input); + return; + } + inputDesc->mSessions.remove(session); if (inputDesc->mOpenRefCount == 0) { ALOGW("releaseInput() invalid open ref count %d", inputDesc->mOpenRefCount); return; |