summaryrefslogtreecommitdiffstats
path: root/services/audiopolicy/AudioPolicyService.cpp
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2014-05-06 15:35:34 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-05-06 15:35:34 +0000
commit7ebe2c64dea42a3fd4de34ccb877d23b7a4e8076 (patch)
treeaba8cbdf008c711cc6e11109e5b15f9f47ac4e52 /services/audiopolicy/AudioPolicyService.cpp
parentdfa829c3ca81fcd2eecaabfff630ac0f41453731 (diff)
parent711719885d7563068579abf347c366cf6bc906f5 (diff)
downloadframeworks_av-7ebe2c64dea42a3fd4de34ccb877d23b7a4e8076.zip
frameworks_av-7ebe2c64dea42a3fd4de34ccb877d23b7a4e8076.tar.gz
frameworks_av-7ebe2c64dea42a3fd4de34ccb877d23b7a4e8076.tar.bz2
am 71171988: am f655acf1: am 8fb04d47: Merge "Fix memory leak when filtering commands in insertCommand_l()"
* commit '711719885d7563068579abf347c366cf6bc906f5': Fix memory leak when filtering commands in insertCommand_l()
Diffstat (limited to 'services/audiopolicy/AudioPolicyService.cpp')
-rw-r--r--services/audiopolicy/AudioPolicyService.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/services/audiopolicy/AudioPolicyService.cpp b/services/audiopolicy/AudioPolicyService.cpp
index 4a708a0..918c25c 100644
--- a/services/audiopolicy/AudioPolicyService.cpp
+++ b/services/audiopolicy/AudioPolicyService.cpp
@@ -270,6 +270,10 @@ AudioPolicyService::AudioCommandThread::~AudioCommandThread()
if (!mAudioCommands.isEmpty()) {
release_wake_lock(mName.string());
}
+ for (size_t k=0; k < mAudioCommands.size(); k++) {
+ delete mAudioCommands[k]->mParam;
+ delete mAudioCommands[k];
+ }
mAudioCommands.clear();
delete mpToneGenerator;
}
@@ -441,7 +445,7 @@ void AudioPolicyService::AudioCommandThread::startToneCommand(ToneGenerator::ton
ToneData *data = new ToneData();
data->mType = type;
data->mStream = stream;
- command->mParam = (void *)data;
+ command->mParam = data;
Mutex::Autolock _l(mLock);
insertCommand_l(command);
ALOGV("AudioCommandThread() adding tone start type %d, stream %d", type, stream);
@@ -542,7 +546,7 @@ void AudioPolicyService::AudioCommandThread::stopOutputCommand(audio_io_handle_t
data->mIO = output;
data->mStream = stream;
data->mSession = session;
- command->mParam = (void *)data;
+ command->mParam = data;
Mutex::Autolock _l(mLock);
insertCommand_l(command);
ALOGV("AudioCommandThread() adding stop output %d", output);
@@ -555,7 +559,7 @@ void AudioPolicyService::AudioCommandThread::releaseOutputCommand(audio_io_handl
command->mCommand = RELEASE_OUTPUT;
ReleaseOutputData *data = new ReleaseOutputData();
data->mIO = output;
- command->mParam = (void *)data;
+ command->mParam = data;
Mutex::Autolock _l(mLock);
insertCommand_l(command);
ALOGV("AudioCommandThread() adding release output %d", output);
@@ -644,6 +648,10 @@ void AudioPolicyService::AudioCommandThread::insertCommand_l(AudioCommand *comma
for (size_t k = i + 1; k < mAudioCommands.size(); k++) {
if (mAudioCommands[k] == removedCommands[j]) {
ALOGV("suppressing command: %d", mAudioCommands[k]->mCommand);
+ // for commands that are not filtered,
+ // command->mParam is deleted in threadLoop
+ delete mAudioCommands[k]->mParam;
+ delete mAudioCommands[k];
mAudioCommands.removeAt(k);
break;
}