Loading media/java/android/media/MediaPlayer.java +3 −3 Original line number Diff line number Diff line Loading @@ -1300,9 +1300,9 @@ public class MediaPlayer return; case MEDIA_INFO: // For PV specific code values (msg.arg2) look in // opencore/pvmi/pvmf/include/pvmf_return_codes.h if (msg.arg1 != MEDIA_INFO_VIDEO_TRACK_LAGGING) { Log.i(TAG, "Info (" + msg.arg1 + "," + msg.arg2 + ")"); } if (mOnInfoListener != null) { mOnInfoListener.onInfo(mMediaPlayer, msg.arg1, msg.arg2); } Loading media/libmedia/mediaplayer.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -607,7 +607,9 @@ void MediaPlayer::notify(int msg, int ext1, int ext2) case MEDIA_INFO: // ext1: Media framework error code. // ext2: Implementation dependant error code. if (ext1 != MEDIA_INFO_VIDEO_TRACK_LAGGING) { LOGW("info/warning (%d, %d)", ext1, ext2); } break; case MEDIA_SEEK_COMPLETE: LOGV("Received seek complete"); Loading media/libstagefright/AwesomePlayer.cpp +38 −0 Original line number Diff line number Diff line Loading @@ -179,6 +179,8 @@ AwesomePlayer::AwesomePlayer() mStreamDoneEventPending = false; mBufferingEvent = new AwesomeEvent(this, &AwesomePlayer::onBufferingUpdate); mBufferingEventPending = false; mVideoLagEvent = new AwesomeEvent(this, &AwesomePlayer::onVideoLagUpdate); mVideoEventPending = false; mCheckAudioStatusEvent = new AwesomeEvent( this, &AwesomePlayer::onCheckAudioStatus); Loading @@ -205,6 +207,8 @@ void AwesomePlayer::cancelPlayerEvents(bool keepBufferingGoing) { mStreamDoneEventPending = false; mQueue.cancelEvent(mCheckAudioStatusEvent->eventID()); mAudioStatusEventPending = false; mQueue.cancelEvent(mVideoLagEvent->eventID()); mVideoLagEventPending = false; if (!keepBufferingGoing) { mQueue.cancelEvent(mBufferingEvent->eventID()); Loading Loading @@ -530,6 +534,28 @@ void AwesomePlayer::ensureCacheIsFetching_l() { } } void AwesomePlayer::onVideoLagUpdate() { Mutex::Autolock autoLock(mLock); if (!mVideoLagEventPending) { return; } mVideoLagEventPending = false; int64_t audioTimeUs = mAudioPlayer->getMediaTimeUs(); int64_t videoLateByUs = audioTimeUs - mVideoTimeUs; if (videoLateByUs > 300000ll) { LOGV("video late by %lld ms.", videoLateByUs / 1000ll); notifyListener_l( MEDIA_INFO, MEDIA_INFO_VIDEO_TRACK_LAGGING, videoLateByUs / 1000ll); } postVideoLagEvent_l(); } void AwesomePlayer::onBufferingUpdate() { Mutex::Autolock autoLock(mLock); if (!mBufferingEventPending) { Loading Loading @@ -788,6 +814,10 @@ status_t AwesomePlayer::play_l() { if (mVideoSource != NULL) { // Kick off video playback postVideoEvent_l(); if (mAudioSource != NULL && mVideoSource != NULL) { postVideoLagEvent_l(); } } if (deferredAudioSeek) { Loading Loading @@ -1347,6 +1377,14 @@ void AwesomePlayer::postBufferingEvent_l() { mQueue.postEventWithDelay(mBufferingEvent, 1000000ll); } void AwesomePlayer::postVideoLagEvent_l() { if (mVideoLagEventPending) { return; } mVideoLagEventPending = true; mQueue.postEventWithDelay(mVideoLagEvent, 1000000ll); } void AwesomePlayer::postCheckAudioStatusEvent_l() { if (mAudioStatusEventPending) { return; Loading media/libstagefright/NuCachedSource2.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -348,7 +348,7 @@ void NuCachedSource2::restartPrefetcherIfNecessary_l( ssize_t NuCachedSource2::readAt(off64_t offset, void *data, size_t size) { Mutex::Autolock autoSerializer(mSerializer); LOGV("readAt offset %ld, size %d", offset, size); LOGV("readAt offset %lld, size %d", offset, size); Mutex::Autolock autoLock(mLock); Loading Loading @@ -408,7 +408,7 @@ size_t NuCachedSource2::approxDataRemaining_l(bool *eos) { } ssize_t NuCachedSource2::readInternal(off64_t offset, void *data, size_t size) { LOGV("readInternal offset %ld size %d", offset, size); LOGV("readInternal offset %lld size %d", offset, size); Mutex::Autolock autoLock(mLock); Loading media/libstagefright/include/AwesomePlayer.h +4 −0 Original line number Diff line number Diff line Loading @@ -173,6 +173,8 @@ private: bool mBufferingEventPending; sp<TimedEventQueue::Event> mCheckAudioStatusEvent; bool mAudioStatusEventPending; sp<TimedEventQueue::Event> mVideoLagEvent; bool mVideoLagEventPending; sp<TimedEventQueue::Event> mAsyncPrepareEvent; Condition mPreparedCondition; Loading @@ -184,6 +186,7 @@ private: void postBufferingEvent_l(); void postStreamDoneEvent_l(status_t status); void postCheckAudioStatusEvent_l(); void postVideoLagEvent_l(); status_t play_l(); MediaBuffer *mVideoBuffer; Loading Loading @@ -233,6 +236,7 @@ private: void onPrepareAsyncEvent(); void abortPrepare(status_t err); void finishAsyncPrepare_l(); void onVideoLagUpdate(); bool getCachedDuration_l(int64_t *durationUs, bool *eos); Loading Loading
media/java/android/media/MediaPlayer.java +3 −3 Original line number Diff line number Diff line Loading @@ -1300,9 +1300,9 @@ public class MediaPlayer return; case MEDIA_INFO: // For PV specific code values (msg.arg2) look in // opencore/pvmi/pvmf/include/pvmf_return_codes.h if (msg.arg1 != MEDIA_INFO_VIDEO_TRACK_LAGGING) { Log.i(TAG, "Info (" + msg.arg1 + "," + msg.arg2 + ")"); } if (mOnInfoListener != null) { mOnInfoListener.onInfo(mMediaPlayer, msg.arg1, msg.arg2); } Loading
media/libmedia/mediaplayer.cpp +3 −1 Original line number Diff line number Diff line Loading @@ -607,7 +607,9 @@ void MediaPlayer::notify(int msg, int ext1, int ext2) case MEDIA_INFO: // ext1: Media framework error code. // ext2: Implementation dependant error code. if (ext1 != MEDIA_INFO_VIDEO_TRACK_LAGGING) { LOGW("info/warning (%d, %d)", ext1, ext2); } break; case MEDIA_SEEK_COMPLETE: LOGV("Received seek complete"); Loading
media/libstagefright/AwesomePlayer.cpp +38 −0 Original line number Diff line number Diff line Loading @@ -179,6 +179,8 @@ AwesomePlayer::AwesomePlayer() mStreamDoneEventPending = false; mBufferingEvent = new AwesomeEvent(this, &AwesomePlayer::onBufferingUpdate); mBufferingEventPending = false; mVideoLagEvent = new AwesomeEvent(this, &AwesomePlayer::onVideoLagUpdate); mVideoEventPending = false; mCheckAudioStatusEvent = new AwesomeEvent( this, &AwesomePlayer::onCheckAudioStatus); Loading @@ -205,6 +207,8 @@ void AwesomePlayer::cancelPlayerEvents(bool keepBufferingGoing) { mStreamDoneEventPending = false; mQueue.cancelEvent(mCheckAudioStatusEvent->eventID()); mAudioStatusEventPending = false; mQueue.cancelEvent(mVideoLagEvent->eventID()); mVideoLagEventPending = false; if (!keepBufferingGoing) { mQueue.cancelEvent(mBufferingEvent->eventID()); Loading Loading @@ -530,6 +534,28 @@ void AwesomePlayer::ensureCacheIsFetching_l() { } } void AwesomePlayer::onVideoLagUpdate() { Mutex::Autolock autoLock(mLock); if (!mVideoLagEventPending) { return; } mVideoLagEventPending = false; int64_t audioTimeUs = mAudioPlayer->getMediaTimeUs(); int64_t videoLateByUs = audioTimeUs - mVideoTimeUs; if (videoLateByUs > 300000ll) { LOGV("video late by %lld ms.", videoLateByUs / 1000ll); notifyListener_l( MEDIA_INFO, MEDIA_INFO_VIDEO_TRACK_LAGGING, videoLateByUs / 1000ll); } postVideoLagEvent_l(); } void AwesomePlayer::onBufferingUpdate() { Mutex::Autolock autoLock(mLock); if (!mBufferingEventPending) { Loading Loading @@ -788,6 +814,10 @@ status_t AwesomePlayer::play_l() { if (mVideoSource != NULL) { // Kick off video playback postVideoEvent_l(); if (mAudioSource != NULL && mVideoSource != NULL) { postVideoLagEvent_l(); } } if (deferredAudioSeek) { Loading Loading @@ -1347,6 +1377,14 @@ void AwesomePlayer::postBufferingEvent_l() { mQueue.postEventWithDelay(mBufferingEvent, 1000000ll); } void AwesomePlayer::postVideoLagEvent_l() { if (mVideoLagEventPending) { return; } mVideoLagEventPending = true; mQueue.postEventWithDelay(mVideoLagEvent, 1000000ll); } void AwesomePlayer::postCheckAudioStatusEvent_l() { if (mAudioStatusEventPending) { return; Loading
media/libstagefright/NuCachedSource2.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -348,7 +348,7 @@ void NuCachedSource2::restartPrefetcherIfNecessary_l( ssize_t NuCachedSource2::readAt(off64_t offset, void *data, size_t size) { Mutex::Autolock autoSerializer(mSerializer); LOGV("readAt offset %ld, size %d", offset, size); LOGV("readAt offset %lld, size %d", offset, size); Mutex::Autolock autoLock(mLock); Loading Loading @@ -408,7 +408,7 @@ size_t NuCachedSource2::approxDataRemaining_l(bool *eos) { } ssize_t NuCachedSource2::readInternal(off64_t offset, void *data, size_t size) { LOGV("readInternal offset %ld size %d", offset, size); LOGV("readInternal offset %lld size %d", offset, size); Mutex::Autolock autoLock(mLock); Loading
media/libstagefright/include/AwesomePlayer.h +4 −0 Original line number Diff line number Diff line Loading @@ -173,6 +173,8 @@ private: bool mBufferingEventPending; sp<TimedEventQueue::Event> mCheckAudioStatusEvent; bool mAudioStatusEventPending; sp<TimedEventQueue::Event> mVideoLagEvent; bool mVideoLagEventPending; sp<TimedEventQueue::Event> mAsyncPrepareEvent; Condition mPreparedCondition; Loading @@ -184,6 +186,7 @@ private: void postBufferingEvent_l(); void postStreamDoneEvent_l(status_t status); void postCheckAudioStatusEvent_l(); void postVideoLagEvent_l(); status_t play_l(); MediaBuffer *mVideoBuffer; Loading Loading @@ -233,6 +236,7 @@ private: void onPrepareAsyncEvent(); void abortPrepare(status_t err); void finishAsyncPrepare_l(); void onVideoLagUpdate(); bool getCachedDuration_l(int64_t *durationUs, bool *eos); Loading