diff options
author | Andreas Huber <andih@google.com> | 2009-11-19 15:01:45 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2009-11-19 15:01:45 -0800 |
commit | 8b49e97db9c46c63192989172ea03cd8751f2551 (patch) | |
tree | 72e94de4b14b0419be9ef0079ca347b129d7685c | |
parent | c5a605240115ad5eb8edcc7976c8083221754634 (diff) | |
parent | f854e0770207e93ef9d1bf6d50ed18537a107ca4 (diff) | |
download | frameworks_base-8b49e97db9c46c63192989172ea03cd8751f2551.zip frameworks_base-8b49e97db9c46c63192989172ea03cd8751f2551.tar.gz frameworks_base-8b49e97db9c46c63192989172ea03cd8751f2551.tar.bz2 |
am f854e077: Merge change I8134d6ed into eclair
Merge commit 'f854e0770207e93ef9d1bf6d50ed18537a107ca4' into eclair-plus-aosp
* commit 'f854e0770207e93ef9d1bf6d50ed18537a107ca4':
DO NOT MERGE: Instead of inserting semi-random delays after submission to surface flinger, delay releasing buffers to the next display time to avoid flickering.
-rw-r--r-- | include/media/stagefright/MediaPlayerImpl.h | 4 | ||||
-rw-r--r-- | media/libstagefright/MediaPlayerImpl.cpp | 58 |
2 files changed, 38 insertions, 24 deletions
diff --git a/include/media/stagefright/MediaPlayerImpl.h b/include/media/stagefright/MediaPlayerImpl.h index 53a2088..7adf836 100644 --- a/include/media/stagefright/MediaPlayerImpl.h +++ b/include/media/stagefright/MediaPlayerImpl.h @@ -112,7 +112,9 @@ private: MediaSource *makeShoutcastSource(const char *path); - void displayOrDiscardFrame(MediaBuffer *buffer, int64_t pts_us); + void displayOrDiscardFrame( + MediaBuffer **lastBuffer, MediaBuffer *buffer, int64_t pts_us); + void populateISurface(); void depopulateISurface(); void sendFrameToISurface(MediaBuffer *buffer); diff --git a/media/libstagefright/MediaPlayerImpl.cpp b/media/libstagefright/MediaPlayerImpl.cpp index 622ea7e..8300422 100644 --- a/media/libstagefright/MediaPlayerImpl.cpp +++ b/media/libstagefright/MediaPlayerImpl.cpp @@ -40,6 +40,13 @@ namespace android { +static void releaseBufferIfNonNULL(MediaBuffer **buffer) { + if (*buffer) { + (*buffer)->release(); + *buffer = NULL; + } +} + MediaPlayerImpl::MediaPlayerImpl(const char *uri) : mInitCheck(NO_INIT), mTimeSource(NULL), @@ -51,7 +58,7 @@ MediaPlayerImpl::MediaPlayerImpl(const char *uri) mPlaying(false), mPaused(false), mSeeking(false) { - LOGI("MediaPlayerImpl(%s)", uri); + LOGV("MediaPlayerImpl(%s)", uri); DataSource::RegisterDefaultSniffers(); status_t err = mClient.connect(); @@ -103,7 +110,7 @@ MediaPlayerImpl::MediaPlayerImpl(int fd, int64_t offset, int64_t length) mPlaying(false), mPaused(false), mSeeking(false) { - LOGI("MediaPlayerImpl(%d, %lld, %lld)", fd, offset, length); + LOGV("MediaPlayerImpl(%d, %lld, %lld)", fd, offset, length); DataSource::RegisterDefaultSniffers(); status_t err = mClient.connect(); @@ -140,7 +147,7 @@ MediaPlayerImpl::~MediaPlayerImpl() { } void MediaPlayerImpl::play() { - LOGI("play"); + LOGV("play"); if (mPlaying) { if (mPaused) { @@ -229,6 +236,8 @@ void MediaPlayerImpl::videoEntry() { bool firstFrame = true; bool eof = false; + MediaBuffer *lastBuffer = NULL; + status_t err = mVideoDecoder->start(); CHECK_EQ(err, OK); @@ -241,7 +250,9 @@ void MediaPlayerImpl::videoEntry() { { Mutex::Autolock autoLock(mLock); if (mSeeking) { - LOGI("seek-options to %lld", mSeekTimeUs); + releaseBufferIfNonNULL(&lastBuffer); + + LOGV("seek-options to %lld", mSeekTimeUs); options.setSeekTo(mSeekTimeUs); mSeeking = false; @@ -301,19 +312,21 @@ void MediaPlayerImpl::videoEntry() { firstFrame = false; } - displayOrDiscardFrame(buffer, pts_us); + displayOrDiscardFrame(&lastBuffer, buffer, pts_us); } + releaseBufferIfNonNULL(&lastBuffer); + mVideoDecoder->stop(); } void MediaPlayerImpl::displayOrDiscardFrame( + MediaBuffer **lastBuffer, MediaBuffer *buffer, int64_t pts_us) { for (;;) { if (!mPlaying || mPaused) { - buffer->release(); - buffer = NULL; - + releaseBufferIfNonNULL(lastBuffer); + *lastBuffer = buffer; return; } @@ -332,15 +345,13 @@ void MediaPlayerImpl::displayOrDiscardFrame( if (delay_us < -15000) { // We're late. - LOGI("we're late by %lld ms, dropping a frame\n", + LOGV("we're late by %lld ms, dropping a frame\n", -delay_us / 1000); - buffer->release(); - buffer = NULL; + releaseBufferIfNonNULL(lastBuffer); + *lastBuffer = buffer; return; } else if (delay_us > 100000) { - LOGI("we're much too early (by %lld ms)\n", - delay_us / 1000); usleep(100000); continue; } else if (delay_us > 0) { @@ -352,13 +363,14 @@ void MediaPlayerImpl::displayOrDiscardFrame( { Mutex::Autolock autoLock(mLock); + if (mVideoRenderer.get() != NULL) { sendFrameToISurface(buffer); } } - buffer->release(); - buffer = NULL; + releaseBufferIfNonNULL(lastBuffer); + *lastBuffer = buffer; } void MediaPlayerImpl::init() { @@ -410,7 +422,7 @@ void MediaPlayerImpl::init() { } void MediaPlayerImpl::setAudioSource(const sp<MediaSource> &source) { - LOGI("setAudioSource"); + LOGV("setAudioSource"); mAudioSource = source; sp<MetaData> meta = source->getFormat(); @@ -420,7 +432,7 @@ void MediaPlayerImpl::setAudioSource(const sp<MediaSource> &source) { } void MediaPlayerImpl::setVideoSource(const sp<MediaSource> &source) { - LOGI("setVideoSource"); + LOGV("setVideoSource"); mVideoSource = source; sp<MetaData> meta = source->getFormat(); @@ -441,7 +453,7 @@ void MediaPlayerImpl::setVideoSource(const sp<MediaSource> &source) { } void MediaPlayerImpl::setSurface(const sp<Surface> &surface) { - LOGI("setSurface %p", surface.get()); + LOGV("setSurface %p", surface.get()); Mutex::Autolock autoLock(mLock); depopulateISurface(); @@ -455,7 +467,7 @@ void MediaPlayerImpl::setSurface(const sp<Surface> &surface) { } void MediaPlayerImpl::setISurface(const sp<ISurface> &isurface) { - LOGI("setISurface %p", isurface.get()); + LOGV("setISurface %p", isurface.get()); Mutex::Autolock autoLock(mLock); depopulateISurface(); @@ -499,7 +511,7 @@ MediaSource *MediaPlayerImpl::makeShoutcastSource(const char *uri) { host = string(host, 0, colon - host.c_str()); } - LOGI("Connecting to host '%s', port %d, path '%s'", + LOGV("Connecting to host '%s', port %d, path '%s'", host.c_str(), port, path.c_str()); HTTPStream *http = new HTTPStream; @@ -533,7 +545,7 @@ MediaSource *MediaPlayerImpl::makeShoutcastSource(const char *uri) { http->disconnect(); - LOGI("Redirecting to %s\n", location.c_str()); + LOGV("Redirecting to %s\n", location.c_str()); host = string(location, 0, slashPos); @@ -588,7 +600,7 @@ int64_t MediaPlayerImpl::getPosition() { } status_t MediaPlayerImpl::seekTo(int64_t time) { - LOGI("seekTo %lld", time); + LOGV("seekTo %lld", time); if (mPaused) { return UNKNOWN_ERROR; @@ -651,7 +663,7 @@ void MediaPlayerImpl::sendFrameToISurface(MediaBuffer *buffer) { void MediaPlayerImpl::setAudioSink( const sp<MediaPlayerBase::AudioSink> &audioSink) { - LOGI("setAudioSink %p", audioSink.get()); + LOGV("setAudioSink %p", audioSink.get()); mAudioSink = audioSink; } |