summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2011-12-15 16:17:04 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-12-15 16:17:04 -0800
commit079123ee3d2e20bbc17a7ddbd96ca46bed27898f (patch)
tree452b1e2ab8e52c04819242c5517c5ed242c2ccdd /services
parent26fa039c3752eaaf74d1be53d9795f48e9f43de3 (diff)
parentf3990f2cc8fd824ae52a880a7b22248e1bdfb192 (diff)
downloadframeworks_av-079123ee3d2e20bbc17a7ddbd96ca46bed27898f.zip
frameworks_av-079123ee3d2e20bbc17a7ddbd96ca46bed27898f.tar.gz
frameworks_av-079123ee3d2e20bbc17a7ddbd96ca46bed27898f.tar.bz2
Merge "Improve resistance to leaks for ConfigEvent"
Diffstat (limited to 'services')
-rw-r--r--services/audioflinger/AudioFlinger.cpp13
-rw-r--r--services/audioflinger/AudioFlinger.h2
2 files changed, 7 insertions, 8 deletions
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index fb8091f..ee9f4b7 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -1066,9 +1066,9 @@ void AudioFlinger::ThreadBase::sendConfigEvent(int event, int param)
// sendConfigEvent_l() must be called with ThreadBase::mLock held
void AudioFlinger::ThreadBase::sendConfigEvent_l(int event, int param)
{
- ConfigEvent *configEvent = new ConfigEvent();
- configEvent->mEvent = event;
- configEvent->mParam = param;
+ ConfigEvent configEvent;
+ configEvent.mEvent = event;
+ configEvent.mParam = param;
mConfigEvents.add(configEvent);
ALOGV("sendConfigEvent() num events %d event %d, param %d", mConfigEvents.size(), event, param);
mWaitWorkCV.signal();
@@ -1079,15 +1079,14 @@ void AudioFlinger::ThreadBase::processConfigEvents()
mLock.lock();
while(!mConfigEvents.isEmpty()) {
ALOGV("processConfigEvents() remaining events %d", mConfigEvents.size());
- ConfigEvent *configEvent = mConfigEvents[0];
+ ConfigEvent configEvent = mConfigEvents[0];
mConfigEvents.removeAt(0);
// release mLock before locking AudioFlinger mLock: lock order is always
// AudioFlinger then ThreadBase to avoid cross deadlock
mLock.unlock();
mAudioFlinger->mLock.lock();
- audioConfigChanged_l(configEvent->mEvent, configEvent->mParam);
+ audioConfigChanged_l(configEvent.mEvent, configEvent.mParam);
mAudioFlinger->mLock.unlock();
- delete configEvent;
mLock.lock();
}
mLock.unlock();
@@ -1134,7 +1133,7 @@ status_t AudioFlinger::ThreadBase::dumpBase(int fd, const Vector<String16>& args
snprintf(buffer, SIZE, " Index event param\n");
result.append(buffer);
for (size_t i = 0; i < mConfigEvents.size(); i++) {
- snprintf(buffer, SIZE, " %02d %02d %d\n", i, mConfigEvents[i]->mEvent, mConfigEvents[i]->mParam);
+ snprintf(buffer, SIZE, " %02d %02d %d\n", i, mConfigEvents[i].mEvent, mConfigEvents[i].mParam);
result.append(buffer);
}
result.append("\n");
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index d9928ac..9707cf4 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -547,7 +547,7 @@ private:
Condition mParamCond;
Vector<String8> mNewParameters;
status_t mParamStatus;
- Vector<ConfigEvent *> mConfigEvents;
+ Vector<ConfigEvent> mConfigEvents;
bool mStandby;
int mId;
bool mExiting;