diff options
author | Dheeraj Sharma <dheerajs@google.com> | 2011-02-13 20:31:27 -0800 |
---|---|---|
committer | Dheeraj Sharma <dheerajs@google.com> | 2011-02-13 20:31:27 -0800 |
commit | 5bc7fb407ce1bab13d4a4a67d34a1a3192ee3186 (patch) | |
tree | 327451bf39c8fd202f0a9f17c55583379b5d3eff /libvideoeditor/lvpp | |
parent | 1845894d33736c8e17df6b88874bbd4e5a73977a (diff) | |
download | frameworks_av-5bc7fb407ce1bab13d4a4a67d34a1a3192ee3186.zip frameworks_av-5bc7fb407ce1bab13d4a4a67d34a1a3192ee3186.tar.gz frameworks_av-5bc7fb407ce1bab13d4a4a67d34a1a3192ee3186.tar.bz2 |
Fix for issue : 3450195 Adapt to the recent changes of awesome player in video editor preview player
Change-Id: Ibd15264837dab32464fb90e75cf6d3d323cbbae3
Diffstat (limited to 'libvideoeditor/lvpp')
-rw-r--r-- | libvideoeditor/lvpp/PreviewPlayer.cpp | 87 | ||||
-rw-r--r-- | libvideoeditor/lvpp/PreviewPlayer.h | 3 | ||||
-rwxr-xr-x | libvideoeditor/lvpp/VideoEditorAudioPlayer.cpp | 1 |
3 files changed, 68 insertions, 23 deletions
diff --git a/libvideoeditor/lvpp/PreviewPlayer.cpp b/libvideoeditor/lvpp/PreviewPlayer.cpp index 0892ce7..8a75119 100644 --- a/libvideoeditor/lvpp/PreviewPlayer.cpp +++ b/libvideoeditor/lvpp/PreviewPlayer.cpp @@ -182,6 +182,7 @@ PreviewPlayer::PreviewPlayer() mLastVideoBuffer = NULL; mSuspensionState = NULL; mEffectsSettings = NULL; + mVeAudioPlayer = NULL; mAudioMixStoryBoardTS = 0; mCurrentMediaBeginCutTime = 0; mCurrentMediaVolumeValue = 0; @@ -471,8 +472,38 @@ status_t PreviewPlayer::play() { return play_l(); } +status_t PreviewPlayer::startAudioPlayer_l() { + CHECK(!(mFlags & AUDIO_RUNNING)); + + if (mAudioSource == NULL || mAudioPlayer == NULL) { + return OK; + } + + if (!(mFlags & AUDIOPLAYER_STARTED)) { + mFlags |= AUDIOPLAYER_STARTED; + + // We've already started the MediaSource in order to enable + // the prefetcher to read its data. + status_t err = mVeAudioPlayer->start( + true /* sourceAlreadyStarted */); + + if (err != OK) { + notifyListener_l(MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, err); + return err; + } + } else { + mVeAudioPlayer->resume(); + } + + mFlags |= AUDIO_RUNNING; + + mWatchForAudioEOS = true; + + return OK; +} + status_t PreviewPlayer::play_l() { -VideoEditorAudioPlayer *mVePlayer; + if (mFlags & PLAYING) { return OK; } @@ -496,44 +527,41 @@ VideoEditorAudioPlayer *mVePlayer; if (mAudioSink != NULL) { mAudioPlayer = new VideoEditorAudioPlayer(mAudioSink, this); - mVePlayer = + mVeAudioPlayer = (VideoEditorAudioPlayer*)mAudioPlayer; mAudioPlayer->setSource(mAudioSource); - mVePlayer->setAudioMixSettings( + mVeAudioPlayer->setAudioMixSettings( mPreviewPlayerAudioMixSettings); - mVePlayer->setAudioMixPCMFileHandle( + mVeAudioPlayer->setAudioMixPCMFileHandle( mAudioMixPCMFileHandle); - mVePlayer->setAudioMixStoryBoardSkimTimeStamp( + mVeAudioPlayer->setAudioMixStoryBoardSkimTimeStamp( mAudioMixStoryBoardTS, mCurrentMediaBeginCutTime, mCurrentMediaVolumeValue); - // We've already started the MediaSource in order to enable - // the prefetcher to read its data. - status_t err = mVePlayer->start( - true /* sourceAlreadyStarted */); - - if (err != OK) { - delete mAudioPlayer; - mAudioPlayer = NULL; - - mFlags &= ~(PLAYING | FIRST_FRAME); - return err; - } - - mTimeSource = mVePlayer; //mAudioPlayer; + mTimeSource = mVeAudioPlayer; //mAudioPlayer; deferredAudioSeek = true; mWatchForAudioSeekComplete = false; mWatchForAudioEOS = true; } - } else { - mVePlayer->resume(); - } + } + + CHECK(!(mFlags & AUDIO_RUNNING)); + if (mVideoSource == NULL) { + status_t err = startAudioPlayer_l(); + + if (err != OK) { + delete mAudioPlayer; + mAudioPlayer = NULL; + mFlags &= ~(PLAYING | FIRST_FRAME); + return err; + } + } } if (mTimeSource == NULL && mAudioPlayer == NULL) { @@ -761,8 +789,9 @@ void PreviewPlayer::onVideoEvent() { // locations, we'll "pause" the audio source, causing it to // stop reading input data until a subsequent seek. - if (mAudioPlayer != NULL) { + if (mAudioPlayer != NULL && (mFlags & AUDIO_RUNNING)) { mAudioPlayer->pause(); + mFlags &= ~AUDIO_RUNNING; } mAudioSource->pause(); } @@ -862,6 +891,13 @@ void PreviewPlayer::onVideoEvent() { bool wasSeeking = mSeeking; finishSeekIfNecessary(timeUs); + if (mAudioPlayer != NULL && !(mFlags & (AUDIO_RUNNING))) { + status_t err = startAudioPlayer_l(); + if (err != OK) { + LOGE("Starting the audio player failed w/ err %d", err); + return; + } + } TimeSource *ts = (mFlags & AUDIO_AT_EOS) ? &mSystemTimeSource : mTimeSource; @@ -1743,6 +1779,11 @@ M4OSA_ERR PreviewPlayer::doVideoPostProcessing() { status_t PreviewPlayer::readFirstVideoFrame() { LOGV("PreviewPlayer::readFirstVideoFrame"); + if (mFlags & SEEK_PREVIEW) { + mFlags &= ~SEEK_PREVIEW; + return OK; + } + if (!mVideoBuffer) { MediaSource::ReadOptions options; if (mSeeking) { diff --git a/libvideoeditor/lvpp/PreviewPlayer.h b/libvideoeditor/lvpp/PreviewPlayer.h index 564c014..e06836e 100644 --- a/libvideoeditor/lvpp/PreviewPlayer.h +++ b/libvideoeditor/lvpp/PreviewPlayer.h @@ -128,6 +128,7 @@ private: static bool ContinuePreparation(void *cookie); void onPrepareAsyncEvent(); void finishAsyncPrepare_l(); + status_t startAudioPlayer_l(); sp<PreviewPlayerRenderer> mVideoRenderer; @@ -218,6 +219,8 @@ private: status_t prepare_l(); status_t prepareAsync_l(); + VideoEditorAudioPlayer *mVeAudioPlayer; + PreviewPlayer(const PreviewPlayer &); PreviewPlayer &operator=(const PreviewPlayer &); }; diff --git a/libvideoeditor/lvpp/VideoEditorAudioPlayer.cpp b/libvideoeditor/lvpp/VideoEditorAudioPlayer.cpp index e699fbe..48d43b4 100755 --- a/libvideoeditor/lvpp/VideoEditorAudioPlayer.cpp +++ b/libvideoeditor/lvpp/VideoEditorAudioPlayer.cpp @@ -38,6 +38,7 @@ VideoEditorAudioPlayer::VideoEditorAudioPlayer( LOGV("VideoEditorAudioPlayer"); mBGAudioPCMFileHandle = NULL; + mAudioProcess = NULL; mBGAudioPCMFileLength = 0; mBGAudioPCMFileTrimmedLength = 0; mBGAudioPCMFileDuration = 0; |