summaryrefslogtreecommitdiffstats
path: root/media/libstagefright
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2010-09-28 12:02:35 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-09-28 12:02:35 -0700
commitbe0450619528e65eebfa1d7eab78fde757d094cc (patch)
tree08bd4cd3f2b9784e6fcbfb0ae0c6590f48534fd1 /media/libstagefright
parent4769f57948455277d0670ef18f64824ca5d894c1 (diff)
parent2b359ed5b5ba4775609c13408b2cf1336c2cc45b (diff)
downloadframeworks_base-be0450619528e65eebfa1d7eab78fde757d094cc.zip
frameworks_base-be0450619528e65eebfa1d7eab78fde757d094cc.tar.gz
frameworks_base-be0450619528e65eebfa1d7eab78fde757d094cc.tar.bz2
Merge "Instead of constantly polling the AudioPlayer to see if it reached EOS or finished seeking, initiate the notification from the AudioPlayer when the event happens." into gingerbread
Diffstat (limited to 'media/libstagefright')
-rw-r--r--media/libstagefright/AudioPlayer.cpp16
-rw-r--r--media/libstagefright/AwesomePlayer.cpp16
-rw-r--r--media/libstagefright/include/AwesomePlayer.h3
3 files changed, 27 insertions, 8 deletions
diff --git a/media/libstagefright/AudioPlayer.cpp b/media/libstagefright/AudioPlayer.cpp
index c27cfc8..47a385d 100644
--- a/media/libstagefright/AudioPlayer.cpp
+++ b/media/libstagefright/AudioPlayer.cpp
@@ -27,9 +27,13 @@
#include <media/stagefright/MediaSource.h>
#include <media/stagefright/MetaData.h>
+#include "include/AwesomePlayer.h"
+
namespace android {
-AudioPlayer::AudioPlayer(const sp<MediaPlayerBase::AudioSink> &audioSink)
+AudioPlayer::AudioPlayer(
+ const sp<MediaPlayerBase::AudioSink> &audioSink,
+ AwesomePlayer *observer)
: mAudioTrack(NULL),
mInputBuffer(NULL),
mSampleRate(0),
@@ -45,7 +49,8 @@ AudioPlayer::AudioPlayer(const sp<MediaPlayerBase::AudioSink> &audioSink)
mIsFirstBuffer(false),
mFirstBufferResult(OK),
mFirstBuffer(NULL),
- mAudioSink(audioSink) {
+ mAudioSink(audioSink),
+ mObserver(observer) {
}
AudioPlayer::~AudioPlayer() {
@@ -301,6 +306,9 @@ size_t AudioPlayer::fillBuffer(void *data, size_t size) {
}
mSeeking = false;
+ if (mObserver) {
+ mObserver->postAudioSeekComplete();
+ }
}
}
@@ -323,6 +331,10 @@ size_t AudioPlayer::fillBuffer(void *data, size_t size) {
Mutex::Autolock autoLock(mLock);
if (err != OK) {
+ if (mObserver && !mReachedEOS) {
+ mObserver->postAudioEOS();
+ }
+
mReachedEOS = true;
mFinalStatus = err;
break;
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp
index 8507afc..12022bd 100644
--- a/media/libstagefright/AwesomePlayer.cpp
+++ b/media/libstagefright/AwesomePlayer.cpp
@@ -639,7 +639,7 @@ status_t AwesomePlayer::play_l() {
if (mAudioSource != NULL) {
if (mAudioPlayer == NULL) {
if (mAudioSink != NULL) {
- mAudioPlayer = new AudioPlayer(mAudioSink);
+ mAudioPlayer = new AudioPlayer(mAudioSink, this);
mAudioPlayer->setSource(mAudioSource);
// We've already started the MediaSource in order to enable
@@ -666,8 +666,6 @@ status_t AwesomePlayer::play_l() {
} else {
mAudioPlayer->resume();
}
-
- postCheckAudioStatusEvent_l();
}
if (mTimeSource == NULL && mAudioPlayer == NULL) {
@@ -1169,7 +1167,7 @@ void AwesomePlayer::postCheckAudioStatusEvent_l() {
return;
}
mAudioStatusEventPending = true;
- mQueue.postEventWithDelay(mCheckAudioStatusEvent, 100000ll);
+ mQueue.postEvent(mCheckAudioStatusEvent);
}
void AwesomePlayer::onCheckAudioStatus() {
@@ -1200,8 +1198,6 @@ void AwesomePlayer::onCheckAudioStatus() {
mFlags |= FIRST_FRAME;
postStreamDoneEvent_l(finalStatus);
}
-
- postCheckAudioStatusEvent_l();
}
status_t AwesomePlayer::prepare() {
@@ -1662,5 +1658,13 @@ uint32_t AwesomePlayer::flags() const {
return mExtractorFlags;
}
+void AwesomePlayer::postAudioEOS() {
+ postCheckAudioStatusEvent_l();
+}
+
+void AwesomePlayer::postAudioSeekComplete() {
+ postCheckAudioStatusEvent_l();
+}
+
} // namespace android
diff --git a/media/libstagefright/include/AwesomePlayer.h b/media/libstagefright/include/AwesomePlayer.h
index 1f3946c..600faca 100644
--- a/media/libstagefright/include/AwesomePlayer.h
+++ b/media/libstagefright/include/AwesomePlayer.h
@@ -92,6 +92,9 @@ struct AwesomePlayer {
// This is a mask of MediaExtractor::Flags.
uint32_t flags() const;
+ void postAudioEOS();
+ void postAudioSeekComplete();
+
private:
friend struct AwesomeEvent;