summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHong Teng <hongteng@google.com>2011-10-05 17:26:34 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-10-05 17:26:34 -0700
commit7911553d968b6269cedb814f32e45c07fa4068f6 (patch)
tree5575bf024756441562c772e8aa68edbcad7fb451
parent4783a631d2ed6f589c6ee25502200af5dd7a476a (diff)
parent31195c759708e7e4889424bfe9bfd063f8a155d9 (diff)
downloadlibvideoeditor-7911553d968b6269cedb814f32e45c07fa4068f6.tar.gz
Merge "Fix for 5369981 Native crash : testPreviewWithEndAudioTrack functional test."
-rwxr-xr-xlvpp/PreviewPlayer.cpp22
-rwxr-xr-xlvpp/PreviewPlayer.h1
2 files changed, 20 insertions, 3 deletions
diff --git a/lvpp/PreviewPlayer.cpp b/lvpp/PreviewPlayer.cpp
index b63d0d2..1330c7f 100755
--- a/lvpp/PreviewPlayer.cpp
+++ b/lvpp/PreviewPlayer.cpp
@@ -342,7 +342,7 @@ status_t PreviewPlayer::play() {
Mutex::Autolock autoLock(mLock);
mFlags &= ~CACHE_UNDERRUN;
-
+ mFlags &= ~INFORMED_AV_EOS;
return play_l();
}
@@ -481,8 +481,24 @@ void PreviewPlayer::onStreamDone() {
//This lock is used to syncronize onStreamDone() in PreviewPlayer and
//stopPreview() in PreviewController
Mutex::Autolock autoLock(mLockControl);
- notifyListener_l(MEDIA_PLAYBACK_COMPLETE);
-
+ /* Make sure PreviewPlayer only notifies MEDIA_PLAYBACK_COMPLETE once for each clip!
+ * It happens twice in following scenario.
+ * To make the clips in preview storyboard are played and switched smoothly,
+ * PreviewController uses two PreviewPlayer instances and one AudioPlayer.
+ * The two PreviewPlayer use the same AudioPlayer to play the audio,
+ * and change the audio source of the AudioPlayer.
+ * If the audio source of current playing clip and next clip are dummy
+ * audio source(image or video without audio), it will not change the audio source
+ * to avoid the "audio glitch", and keep using the current audio source.
+ * When the video of current clip reached the EOS, PreviewPlayer will set EOS flag
+ * for video and audio, and it will notify MEDIA_PLAYBACK_COMPLETE.
+ * But the audio(dummy audio source) is still playing(for next clip),
+ * and when it reached the EOS, and video reached EOS,
+ * PreviewPlayer will notify MEDIA_PLAYBACK_COMPLETE again. */
+ if (!(mFlags & INFORMED_AV_EOS)) {
+ notifyListener_l(MEDIA_PLAYBACK_COMPLETE);
+ mFlags |= INFORMED_AV_EOS;
+ }
mFlags |= AT_EOS;
LOGV("onStreamDone end");
return;
diff --git a/lvpp/PreviewPlayer.h b/lvpp/PreviewPlayer.h
index c6fb62b..16dcca2 100755
--- a/lvpp/PreviewPlayer.h
+++ b/lvpp/PreviewPlayer.h
@@ -95,6 +95,7 @@ private:
AUDIO_AT_EOS = 256,
VIDEO_AT_EOS = 512,
AUTO_LOOPING = 1024,
+ INFORMED_AV_EOS = 2048,
};
void cancelPlayerEvents(bool keepBufferingGoing = false);