summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--media/libstagefright/AwesomePlayer.cpp66
-rw-r--r--media/libstagefright/include/AwesomePlayer.h4
-rw-r--r--services/audioflinger/AudioMixer.cpp2
3 files changed, 42 insertions, 30 deletions
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp
index a777558..5a43c6a 100644
--- a/media/libstagefright/AwesomePlayer.cpp
+++ b/media/libstagefright/AwesomePlayer.cpp
@@ -765,6 +765,8 @@ status_t AwesomePlayer::play() {
}
status_t AwesomePlayer::play_l() {
+ mFlags &= ~SEEK_PREVIEW;
+
if (mFlags & PLAYING) {
return OK;
}
@@ -1078,6 +1080,11 @@ status_t AwesomePlayer::seekTo_l(int64_t timeUs) {
notifyListener_l(MEDIA_SEEK_COMPLETE);
mSeekNotificationSent = true;
+
+ if ((mFlags & PREPARED) && mVideoSource != NULL) {
+ mFlags |= SEEK_PREVIEW;
+ postVideoEvent_l();
+ }
}
return OK;
@@ -1180,7 +1187,7 @@ status_t AwesomePlayer::initVideoDecoder(uint32_t flags) {
}
void AwesomePlayer::finishSeekIfNecessary(int64_t videoTimeUs) {
- if (!mSeeking) {
+ if (!mSeeking || (mFlags & SEEK_PREVIEW)) {
return;
}
@@ -1227,7 +1234,8 @@ void AwesomePlayer::onVideoEvent() {
mVideoBuffer = NULL;
}
- if (mCachedSource != NULL && mAudioSource != NULL) {
+ if (mCachedSource != NULL && mAudioSource != NULL
+ && !(mFlags & SEEK_PREVIEW)) {
// We're going to seek the video source first, followed by
// the audio source.
// In order to avoid jumps in the DataSource offset caused by
@@ -1321,41 +1329,36 @@ void AwesomePlayer::onVideoEvent() {
mTimeSourceDeltaUs = realTimeUs - mediaTimeUs;
}
- int64_t nowUs = ts->getRealTimeUs() - mTimeSourceDeltaUs;
-
- int64_t latenessUs = nowUs - timeUs;
-
- if (wasSeeking) {
+ if (!wasSeeking && mRTPSession == NULL) {
// Let's display the first frame after seeking right away.
- latenessUs = 0;
- }
-
- if (mRTPSession != NULL) {
// We'll completely ignore timestamps for gtalk videochat
// and we'll play incoming video as fast as we get it.
- latenessUs = 0;
- }
- if (latenessUs > 40000) {
- // We're more than 40ms late.
- LOGV("we're late by %lld us (%.2f secs)", latenessUs, latenessUs / 1E6);
- if ( mSinceLastDropped > FRAME_DROP_FREQ)
- {
- LOGV("we're late by %lld us (%.2f secs) dropping one after %d frames", latenessUs, latenessUs / 1E6, mSinceLastDropped);
- mSinceLastDropped = 0;
- mVideoBuffer->release();
- mVideoBuffer = NULL;
+ int64_t nowUs = ts->getRealTimeUs() - mTimeSourceDeltaUs;
- postVideoEvent_l();
- return;
+ int64_t latenessUs = nowUs - timeUs;
+
+ if (latenessUs > 40000) {
+ // We're more than 40ms late.
+ LOGV("we're late by %lld us (%.2f secs)", latenessUs, latenessUs / 1E6);
+ if ( mSinceLastDropped > FRAME_DROP_FREQ)
+ {
+ LOGV("we're late by %lld us (%.2f secs) dropping one after %d frames", latenessUs, latenessUs / 1E6, mSinceLastDropped);
+ mSinceLastDropped = 0;
+ mVideoBuffer->release();
+ mVideoBuffer = NULL;
+
+ postVideoEvent_l();
+ return;
+ }
}
- }
- if (latenessUs < -10000) {
- // We're more than 10ms early.
+ if (latenessUs < -10000) {
+ // We're more than 10ms early.
- postVideoEvent_l(10000);
- return;
+ postVideoEvent_l(10000);
+ return;
+ }
}
if (mVideoRendererIsPreview || mVideoRenderer == NULL) {
@@ -1372,6 +1375,11 @@ void AwesomePlayer::onVideoEvent() {
mVideoBuffer->release();
mVideoBuffer = NULL;
+ if (wasSeeking && (mFlags & SEEK_PREVIEW)) {
+ mFlags &= ~SEEK_PREVIEW;
+ return;
+ }
+
postVideoEvent_l();
}
diff --git a/media/libstagefright/include/AwesomePlayer.h b/media/libstagefright/include/AwesomePlayer.h
index 41ef181..3021359 100644
--- a/media/libstagefright/include/AwesomePlayer.h
+++ b/media/libstagefright/include/AwesomePlayer.h
@@ -119,6 +119,10 @@ private:
// sufficient data to begin playback and finish the preparation phase
// for good.
PREPARING_CONNECTED = 2048,
+
+ // We're triggering a single video event to display the first frame
+ // after the seekpoint.
+ SEEK_PREVIEW = 4096,
};
mutable Mutex mLock;
diff --git a/services/audioflinger/AudioMixer.cpp b/services/audioflinger/AudioMixer.cpp
index 8aaa325..433f1f7 100644
--- a/services/audioflinger/AudioMixer.cpp
+++ b/services/audioflinger/AudioMixer.cpp
@@ -975,7 +975,6 @@ void AudioMixer::process__genericResampling(state_t* state)
{
int32_t* const outTemp = state->outputTemp;
const size_t size = sizeof(int32_t) * MAX_NUM_CHANNELS * state->frameCount;
- memset(outTemp, 0, size);
size_t numFrames = state->frameCount;
@@ -997,6 +996,7 @@ void AudioMixer::process__genericResampling(state_t* state)
}
e0 &= ~(e1);
int32_t *out = t1.mainBuffer;
+ memset(outTemp, 0, size);
while (e1) {
const int i = 31 - __builtin_clz(e1);
e1 &= ~(1<<i);