diff options
author | Rajneesh Chowdury <rajneeshc@google.com> | 2011-02-28 09:09:15 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-02-28 09:09:15 -0800 |
commit | 4a0c72fc4d823826d71282f5c75261ad0d50f0e4 (patch) | |
tree | 46980f2b15011a079199d1065d81b554985f191d | |
parent | 4938a42280d1aab3f00179a0de9778a61fca0123 (diff) | |
parent | b6e2b5cc5b71986b06cbd9c471b63eb5878a7aea (diff) | |
download | frameworks_av-4a0c72fc4d823826d71282f5c75261ad0d50f0e4.zip frameworks_av-4a0c72fc4d823826d71282f5c75261ad0d50f0e4.tar.gz frameworks_av-4a0c72fc4d823826d71282f5c75261ad0d50f0e4.tar.bz2 |
Merge "Fix for memory leak with single audio player instance"
-rw-r--r-- | libvideoeditor/lvpp/PreviewPlayer.cpp | 5 | ||||
-rwxr-xr-x | libvideoeditor/lvpp/VideoEditorAudioPlayer.cpp | 23 |
2 files changed, 27 insertions, 1 deletions
diff --git a/libvideoeditor/lvpp/PreviewPlayer.cpp b/libvideoeditor/lvpp/PreviewPlayer.cpp index 8a3576c..d538eae 100644 --- a/libvideoeditor/lvpp/PreviewPlayer.cpp +++ b/libvideoeditor/lvpp/PreviewPlayer.cpp @@ -526,6 +526,11 @@ status_t PreviewPlayer::setAudioPlayer(AudioPlayer *audioPlayer) { DummyAudioSource *pDummyAudioSource = (DummyAudioSource*)pMediaSrc; //Increment the duration of audio source pDummyAudioSource->setDuration((int64_t)((mPlayEndTimeMsec)*1000)); + + // Stop the new audio source + // since we continue using old source + LOGV("setAudioPlayer: stop new audio source"); + mAudioSource->stop(); } } } diff --git a/libvideoeditor/lvpp/VideoEditorAudioPlayer.cpp b/libvideoeditor/lvpp/VideoEditorAudioPlayer.cpp index f33bd0a..3c9ffa3 100755 --- a/libvideoeditor/lvpp/VideoEditorAudioPlayer.cpp +++ b/libvideoeditor/lvpp/VideoEditorAudioPlayer.cpp @@ -64,6 +64,28 @@ VideoEditorAudioPlayer::~VideoEditorAudioPlayer() { } void VideoEditorAudioPlayer::setSource(const sp<MediaSource> &source) { Mutex::Autolock autoLock(mLock); + + // Before setting source, stop any existing source. + // Make sure to release any buffer we hold onto so that the + // source is able to stop(). + + if (mFirstBuffer != NULL) { + mFirstBuffer->release(); + mFirstBuffer = NULL; + } + + if (mInputBuffer != NULL) { + LOGV("VideoEditorAudioPlayer releasing input buffer."); + + mInputBuffer->release(); + mInputBuffer = NULL; + } + + if (mSource != NULL) { + mSource->stop(); + mSource.clear(); + } + mSource = source; mReachedEOS = false; } @@ -79,7 +101,6 @@ void VideoEditorAudioPlayer::setObserver(AwesomePlayer *observer) { mObserver = observer; } - bool VideoEditorAudioPlayer::isStarted() { return mStarted; } |