summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2013-09-11 09:14:16 -0700
committerGlenn Kasten <gkasten@google.com>2013-09-11 12:47:29 -0700
commit0c72b24f91c68442eb374bd1b338c394105b8262 (patch)
treed5b7396b593f2157fead8f0c5c41d45c1c236009 /services
parent6220f993541b0317e6ace3c410dd35a8d76e30bc (diff)
downloadframeworks_av-0c72b24f91c68442eb374bd1b338c394105b8262.zip
frameworks_av-0c72b24f91c68442eb374bd1b338c394105b8262.tar.gz
frameworks_av-0c72b24f91c68442eb374bd1b338c394105b8262.tar.bz2
Fix AudioTrack shared memory leak
Bug: 2801375 Change-Id: I50e15164fe310f69ea019dca5b49171a02bc6992
Diffstat (limited to 'services')
-rw-r--r--services/audioflinger/PlaybackTracks.h5
-rw-r--r--services/audioflinger/Tracks.cpp10
2 files changed, 14 insertions, 1 deletions
diff --git a/services/audioflinger/PlaybackTracks.h b/services/audioflinger/PlaybackTracks.h
index 0308b99..f7ad6b1 100644
--- a/services/audioflinger/PlaybackTracks.h
+++ b/services/audioflinger/PlaybackTracks.h
@@ -117,7 +117,10 @@ protected:
enum {FS_INVALID, FS_FILLING, FS_FILLED, FS_ACTIVE};
mutable uint8_t mFillingUpStatus;
int8_t mRetryCount;
- const sp<IMemory> mSharedBuffer;
+
+ // see comment at AudioFlinger::PlaybackThread::Track::~Track for why this can't be const
+ sp<IMemory> mSharedBuffer;
+
bool mResetDone;
const audio_stream_type_t mStreamType;
int mName; // track name on the normal mixer,
diff --git a/services/audioflinger/Tracks.cpp b/services/audioflinger/Tracks.cpp
index 6002aa3..cd54950 100644
--- a/services/audioflinger/Tracks.cpp
+++ b/services/audioflinger/Tracks.cpp
@@ -364,6 +364,16 @@ AudioFlinger::PlaybackThread::Track::Track(
AudioFlinger::PlaybackThread::Track::~Track()
{
ALOGV("PlaybackThread::Track destructor");
+
+ // The destructor would clear mSharedBuffer,
+ // but it will not push the decremented reference count,
+ // leaving the client's IMemory dangling indefinitely.
+ // This prevents that leak.
+ if (mSharedBuffer != 0) {
+ mSharedBuffer.clear();
+ // flush the binder command buffer
+ IPCThreadState::self()->flushCommands();
+ }
}
void AudioFlinger::PlaybackThread::Track::destroy()