summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2014-08-28 15:32:53 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-08-28 15:32:54 +0000
commit47f64f2ed14839a00b3b148d490dc0394282eb54 (patch)
treed3112e02518a611d7e9e421c49848ca319fa73cf /services
parent01b9256a1358110ed718c1a83c2a1808d4afbb92 (diff)
parent05b90f833337ab5f7b16509e5f1d339a04eb5bf6 (diff)
downloadframeworks_av-47f64f2ed14839a00b3b148d490dc0394282eb54.zip
frameworks_av-47f64f2ed14839a00b3b148d490dc0394282eb54.tar.gz
frameworks_av-47f64f2ed14839a00b3b148d490dc0394282eb54.tar.bz2
Merge "audio policy: remove audio patch when closing input or output" into lmp-dev
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 b643eac..569dc46 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 6712eb7..57e015e 100644
--- a/services/audiopolicy/AudioPolicyManager.h
+++ b/services/audiopolicy/AudioPolicyManager.h
@@ -649,6 +649,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...