diff options
author | Andreas Huber <andih@google.com> | 2011-10-26 15:23:31 -0700 |
---|---|---|
committer | Andreas Huber <andih@google.com> | 2011-10-26 15:23:31 -0700 |
commit | e96e84b577244d74f79a449d720b0f8224b4b937 (patch) | |
tree | b1d32fccb06922b07736649748bc075577a651d4 /media | |
parent | 3c5b65c95ea4814cbf9c0a3904a9ee13cf41d5c3 (diff) | |
download | frameworks_base-e96e84b577244d74f79a449d720b0f8224b4b937.zip frameworks_base-e96e84b577244d74f79a449d720b0f8224b4b937.tar.gz frameworks_base-e96e84b577244d74f79a449d720b0f8224b4b937.tar.bz2 |
Properly report that we're no longer playing after receiving event
MEDIA_PLAYBACK_COMPLETE or MEDIA_ERROR.
Change-Id: I03eeba751d3728adb33d9c66de4c7444a91696f3
Diffstat (limited to 'media')
-rw-r--r-- | media/libmediaplayerservice/nuplayer/NuPlayer.cpp | 2 | ||||
-rw-r--r-- | media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp | 17 | ||||
-rw-r--r-- | media/libmediaplayerservice/nuplayer/NuPlayerDriver.h | 2 |
3 files changed, 17 insertions, 4 deletions
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp index 4c710b4..7cdb76c 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp @@ -796,7 +796,7 @@ void NuPlayer::notifyListener(int msg, int ext1, int ext2) { return; } - driver->sendEvent(msg, ext1, ext2); + driver->notifyListener(msg, ext1, ext2); } void NuPlayer::flushDecoder(bool audio, bool needShutdown) { diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp index b1e917d..452ba99 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp +++ b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp @@ -35,6 +35,7 @@ NuPlayerDriver::NuPlayerDriver() mNumFramesDropped(0), mLooper(new ALooper), mState(UNINITIALIZED), + mAtEOS(false), mStartupSeekTimeUs(-1) { mLooper->setName("NuPlayerDriver Looper"); @@ -106,7 +107,7 @@ status_t NuPlayerDriver::prepare() { } status_t NuPlayerDriver::prepareAsync() { - sendEvent(MEDIA_PREPARED); + notifyListener(MEDIA_PREPARED); return OK; } @@ -117,6 +118,7 @@ status_t NuPlayerDriver::start() { return INVALID_OPERATION; case STOPPED: { + mAtEOS = false; mPlayer->start(); if (mStartupSeekTimeUs >= 0) { @@ -173,7 +175,7 @@ status_t NuPlayerDriver::pause() { } bool NuPlayerDriver::isPlaying() { - return mState == PLAYING; + return mState == PLAYING && !mAtEOS; } status_t NuPlayerDriver::seekTo(int msec) { @@ -190,6 +192,7 @@ status_t NuPlayerDriver::seekTo(int msec) { case PLAYING: case PAUSED: { + mAtEOS = false; mPlayer->seekToAsync(seekTimeUs); break; } @@ -291,7 +294,7 @@ void NuPlayerDriver::notifyPosition(int64_t positionUs) { } void NuPlayerDriver::notifySeekComplete() { - sendEvent(MEDIA_SEEK_COMPLETE); + notifyListener(MEDIA_SEEK_COMPLETE); } void NuPlayerDriver::notifyFrameStats( @@ -320,4 +323,12 @@ status_t NuPlayerDriver::dump(int fd, const Vector<String16> &args) const { return OK; } +void NuPlayerDriver::notifyListener(int msg, int ext1, int ext2) { + if (msg == MEDIA_PLAYBACK_COMPLETE || msg == MEDIA_ERROR) { + mAtEOS = true; + } + + sendEvent(msg, ext1, ext2); +} + } // namespace android diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.h b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.h index 181c37d..aaa3de0 100644 --- a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.h +++ b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.h @@ -67,6 +67,7 @@ struct NuPlayerDriver : public MediaPlayerInterface { void notifyPosition(int64_t positionUs); void notifySeekComplete(); void notifyFrameStats(int64_t numFramesTotal, int64_t numFramesDropped); + void notifyListener(int msg, int ext1 = 0, int ext2 = 0); protected: virtual ~NuPlayerDriver(); @@ -95,6 +96,7 @@ private: }; State mState; + bool mAtEOS; int64_t mStartupSeekTimeUs; |