diff options
author | Rajneesh Chowdury <rajneeshc@google.com> | 2011-02-25 22:59:46 -0800 |
---|---|---|
committer | Rajneesh Chowdury <rajneeshc@google.com> | 2011-02-27 19:17:14 -0800 |
commit | b6e2b5cc5b71986b06cbd9c471b63eb5878a7aea (patch) | |
tree | 46980f2b15011a079199d1065d81b554985f191d | |
parent | a5872f770c50da1db555d53e062a9896ea4321d5 (diff) | |
download | frameworks_av-b6e2b5cc5b71986b06cbd9c471b63eb5878a7aea.zip frameworks_av-b6e2b5cc5b71986b06cbd9c471b63eb5878a7aea.tar.gz frameworks_av-b6e2b5cc5b71986b06cbd9c471b63eb5878a7aea.tar.bz2 |
Fix for memory leak with single audio player instance
Change-Id: Idb0d24ac1a4fbe21c5f63871a4c7da2beb90e516
-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; } |