summaryrefslogtreecommitdiffstats
path: root/media/libstagefright
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2011-01-11 15:05:28 -0800
committerAndreas Huber <andih@google.com>2011-01-11 15:05:28 -0800
commit145e68fc778275963189b02a1adcbe27cce4d769 (patch)
tree91addc4557024a25d8ba64efc79b821be5ca1877 /media/libstagefright
parent0ecfbd1cf37dbfb44d19c27351f5769309ac028d (diff)
downloadframeworks_av-145e68fc778275963189b02a1adcbe27cce4d769.zip
frameworks_av-145e68fc778275963189b02a1adcbe27cce4d769.tar.gz
frameworks_av-145e68fc778275963189b02a1adcbe27cce4d769.tar.bz2
Increase cache size and low-watermark threshold, also
MediaPlayer now sends out MEDIA_INFO,MEDIA_INFO_VIDEO_TRACK_LAGGING messages to the JAVA client informing it how much (if at all) the video lags behind audio (arg2 is the media delay in ms). Change-Id: I6933f573d8597a35112e4b5ee0fcb826a7f6ddd1 related-to-bug: 3335220
Diffstat (limited to 'media/libstagefright')
-rw-r--r--media/libstagefright/AwesomePlayer.cpp38
-rw-r--r--media/libstagefright/NuCachedSource2.cpp4
-rw-r--r--media/libstagefright/include/AwesomePlayer.h4
-rw-r--r--media/libstagefright/include/NuCachedSource2.h4
4 files changed, 46 insertions, 4 deletions
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp
index 914e409..4cfe28e 100644
--- a/media/libstagefright/AwesomePlayer.cpp
+++ b/media/libstagefright/AwesomePlayer.cpp
@@ -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);
@@ -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());
@@ -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) {
@@ -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) {
@@ -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;
diff --git a/media/libstagefright/NuCachedSource2.cpp b/media/libstagefright/NuCachedSource2.cpp
index 110fb03..cdf4270 100644
--- a/media/libstagefright/NuCachedSource2.cpp
+++ b/media/libstagefright/NuCachedSource2.cpp
@@ -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);
@@ -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);
diff --git a/media/libstagefright/include/AwesomePlayer.h b/media/libstagefright/include/AwesomePlayer.h
index 17b83c1..130ad82 100644
--- a/media/libstagefright/include/AwesomePlayer.h
+++ b/media/libstagefright/include/AwesomePlayer.h
@@ -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;
@@ -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;
@@ -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);
diff --git a/media/libstagefright/include/NuCachedSource2.h b/media/libstagefright/include/NuCachedSource2.h
index 78719c1..aa320fc 100644
--- a/media/libstagefright/include/NuCachedSource2.h
+++ b/media/libstagefright/include/NuCachedSource2.h
@@ -55,8 +55,8 @@ private:
enum {
kPageSize = 65536,
- kHighWaterThreshold = 5 * 1024 * 1024,
- kLowWaterThreshold = 1024 * 1024,
+ kHighWaterThreshold = 20 * 1024 * 1024,
+ kLowWaterThreshold = 4 * 1024 * 1024,
// Read data after a 15 sec timeout whether we're actively
// fetching or not.