From 3bcffa136909c1fb6e88ee4efd12ccac18360a85 Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Thu, 12 Jun 2014 18:38:45 -0700 Subject: force command flush after releasing a reference to shared memory After releasing a reference to a shared memory interface, IPCThreadState::self()->flushCommands() must be called to ensure that the corresponding reference is also cleared immediately in the remote process. Otherwise the binder implementaiton will not push the clear systematically causing the memory region not to be freed. See issues 10711502 and 2801375. Bug: 14057166. Change-Id: If55f36f00d452d6cf00cf83bd2fba1c8f3abcb57 --- media/libmedia/AudioRecord.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'media/libmedia/AudioRecord.cpp') diff --git a/media/libmedia/AudioRecord.cpp b/media/libmedia/AudioRecord.cpp index db61e85..50b444a 100644 --- a/media/libmedia/AudioRecord.cpp +++ b/media/libmedia/AudioRecord.cpp @@ -105,6 +105,8 @@ AudioRecord::~AudioRecord() } mAudioRecord->asBinder()->unlinkToDeath(mDeathNotifier, this); mAudioRecord.clear(); + mCblkMemory.clear(); + mBufferMemory.clear(); IPCThreadState::self()->flushCommands(); AudioSystem::releaseAudioSessionId(mSessionId, -1); } @@ -546,9 +548,10 @@ status_t AudioRecord::openRecord_l(size_t epoch) mDeathNotifier.clear(); } mAudioRecord = record; - mCblkMemory = iMem; mBufferMemory = bufferMem; + IPCThreadState::self()->flushCommands(); + mCblk = cblk; // note that temp is the (possibly revised) value of frameCount if (temp < frameCount || (frameCount == 0 && temp == 0)) { -- cgit v1.1