summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2014-08-27 15:32:29 -0700
committerEric Laurent <elaurent@google.com>2014-08-27 18:17:08 -0700
commit05b90f833337ab5f7b16509e5f1d339a04eb5bf6 (patch)
treed78fd01541fe617b2ef1753dade9955463d5f006 /services
parent9dd4a2ddd7caf8cbe50d8a76e0ec3e0274d2bce6 (diff)
downloadframeworks_av-05b90f833337ab5f7b16509e5f1d339a04eb5bf6.zip
frameworks_av-05b90f833337ab5f7b16509e5f1d339a04eb5bf6.tar.gz
frameworks_av-05b90f833337ab5f7b16509e5f1d339a04eb5bf6.tar.bz2
audio policy: remove audio patch when closing input or output
Make sure that an audio patch having an output as source or input as sink is removed when this input or output is closed. Bug: 17303725. Change-Id: I234d54a25ce0b579eeeafdcfda3a0594f048768c
Diffstat (limited to 'services')
-rw-r--r--services/audiopolicy/AudioPolicyManager.cpp51
-rw-r--r--services/audiopolicy/AudioPolicyManager.h3
2 files changed, 51 insertions, 3 deletions
diff --git a/services/audiopolicy/AudioPolicyManager.cpp b/services/audiopolicy/AudioPolicyManager.cpp
index 14fdec5..cd8d0de 100644
--- a/services/audiopolicy/AudioPolicyManager.cpp
+++ b/services/audiopolicy/AudioPolicyManager.cpp
@@ -1454,19 +1454,31 @@ void AudioPolicyManager::releaseInput(audio_io_handle_t input,
return;
}
- mpClientInterface->closeInput(input);
- mInputs.removeItem(input);
- nextAudioPortGeneration();
+ closeInput(input);
mpClientInterface->onAudioPortListUpdate();
ALOGV("releaseInput() exit");
}
void AudioPolicyManager::closeAllInputs() {
+ bool patchRemoved = false;
+
for(size_t input_index = 0; input_index < mInputs.size(); input_index++) {
+ sp<AudioInputDescriptor> inputDesc = mInputs.valueAt(input_index);
+ ssize_t patch_index = mAudioPatches.indexOfKey(inputDesc->mPatchHandle);
+ if (patch_index >= 0) {
+ sp<AudioPatch> patchDesc = mAudioPatches.valueAt(patch_index);
+ status_t status = mpClientInterface->releaseAudioPatch(patchDesc->mAfPatchHandle, 0);
+ mAudioPatches.removeItemsAt(patch_index);
+ patchRemoved = true;
+ }
mpClientInterface->closeInput(mInputs.keyAt(input_index));
}
mInputs.clear();
nextAudioPortGeneration();
+
+ if (patchRemoved) {
+ mpClientInterface->onAudioPatchListUpdate();
+ }
}
void AudioPolicyManager::initStreamVolume(audio_stream_type_t stream,
@@ -3497,6 +3509,16 @@ void AudioPolicyManager::closeOutput(audio_io_handle_t output)
}
}
+ nextAudioPortGeneration();
+
+ ssize_t index = mAudioPatches.indexOfKey(outputDesc->mPatchHandle);
+ if (index >= 0) {
+ sp<AudioPatch> patchDesc = mAudioPatches.valueAt(index);
+ status_t status = mpClientInterface->releaseAudioPatch(patchDesc->mAfPatchHandle, 0);
+ mAudioPatches.removeItemsAt(index);
+ mpClientInterface->onAudioPatchListUpdate();
+ }
+
AudioParameter param;
param.add(String8("closing"), String8("true"));
mpClientInterface->setParameters(output, param.toString());
@@ -3504,7 +3526,30 @@ void AudioPolicyManager::closeOutput(audio_io_handle_t output)
mpClientInterface->closeOutput(output);
mOutputs.removeItem(output);
mPreviousOutputs = mOutputs;
+}
+
+void AudioPolicyManager::closeInput(audio_io_handle_t input)
+{
+ ALOGV("closeInput(%d)", input);
+
+ sp<AudioInputDescriptor> inputDesc = mInputs.valueFor(input);
+ if (inputDesc == NULL) {
+ ALOGW("closeInput() unknown input %d", input);
+ return;
+ }
+
nextAudioPortGeneration();
+
+ ssize_t index = mAudioPatches.indexOfKey(inputDesc->mPatchHandle);
+ if (index >= 0) {
+ sp<AudioPatch> patchDesc = mAudioPatches.valueAt(index);
+ status_t status = mpClientInterface->releaseAudioPatch(patchDesc->mAfPatchHandle, 0);
+ mAudioPatches.removeItemsAt(index);
+ mpClientInterface->onAudioPatchListUpdate();
+ }
+
+ mpClientInterface->closeInput(input);
+ mInputs.removeItem(input);
}
SortedVector<audio_io_handle_t> AudioPolicyManager::getOutputsForDevice(audio_devices_t device,
diff --git a/services/audiopolicy/AudioPolicyManager.h b/services/audiopolicy/AudioPolicyManager.h
index e3e3172..158a202 100644
--- a/services/audiopolicy/AudioPolicyManager.h
+++ b/services/audiopolicy/AudioPolicyManager.h
@@ -646,6 +646,9 @@ protected:
// close an output and its companion duplicating output.
void closeOutput(audio_io_handle_t output);
+ // close an input.
+ void closeInput(audio_io_handle_t input);
+
// checks and if necessary changes outputs used for all strategies.
// must be called every time a condition that affects the output choice for a given strategy
// changes: connected device, phone state, force use...