summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2010-06-10 12:43:53 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-06-10 12:43:53 -0700
commitfee87d7b4e60d7541aa2cb0d31f5bdf4ca9e6475 (patch)
treef94969e4209f62a98cb94e77cff144aeae210547
parentbca5a95ed7019605228d16c7cf583880c74a516d (diff)
parent80737bac407a36e99267f65fe162b8e282822af4 (diff)
downloadframeworks_av-fee87d7b4e60d7541aa2cb0d31f5bdf4ca9e6475.zip
frameworks_av-fee87d7b4e60d7541aa2cb0d31f5bdf4ca9e6475.tar.gz
frameworks_av-fee87d7b4e60d7541aa2cb0d31f5bdf4ca9e6475.tar.bz2
am c90e35c1: am 8d300280: Merge "Support "pausing" of MediaSources with the effect that they no longer pull on their upstream source until a subsequent read-with-seek." into kraken
-rw-r--r--include/media/stagefright/MediaSource.h8
-rw-r--r--include/media/stagefright/OMXCodec.h4
-rw-r--r--media/libstagefright/OMXCodec.cpp20
3 files changed, 31 insertions, 1 deletions
diff --git a/include/media/stagefright/MediaSource.h b/include/media/stagefright/MediaSource.h
index 96d57e7..9cc94c8 100644
--- a/include/media/stagefright/MediaSource.h
+++ b/include/media/stagefright/MediaSource.h
@@ -20,6 +20,7 @@
#include <sys/types.h>
+#include <media/stagefright/MediaErrors.h>
#include <utils/RefBase.h>
namespace android {
@@ -83,6 +84,13 @@ struct MediaSource : public RefBase {
int64_t mLatenessUs;
};
+ // Causes this source to suspend pulling data from its upstream source
+ // until a subsequent read-with-seek. Currently only supported by
+ // OMXCodec.
+ virtual status_t pause() {
+ return ERROR_UNSUPPORTED;
+ }
+
protected:
virtual ~MediaSource();
diff --git a/include/media/stagefright/OMXCodec.h b/include/media/stagefright/OMXCodec.h
index 3fbb469..c95fc02 100644
--- a/include/media/stagefright/OMXCodec.h
+++ b/include/media/stagefright/OMXCodec.h
@@ -52,6 +52,8 @@ struct OMXCodec : public MediaSource,
virtual status_t read(
MediaBuffer **buffer, const ReadOptions *options = NULL);
+ virtual status_t pause();
+
void on_message(const omx_message &msg);
// from MediaBufferObserver
@@ -144,6 +146,8 @@ private:
Mutex mLock;
Condition mAsyncCompletion;
+ bool mPaused;
+
// A list of indices into mPortStatus[kPortIndexOutput] filled with data.
List<size_t> mFilledBuffers;
Condition mBufferFilled;
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
index 14682af..6be41b4 100644
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -1145,7 +1145,8 @@ OMXCodec::OMXCodec(
mNoMoreOutputData(false),
mOutputPortSettingsHaveChanged(false),
mSeekTimeUs(-1),
- mLeftOverBuffer(NULL) {
+ mLeftOverBuffer(NULL),
+ mPaused(false) {
mPortStatus[kPortIndexInput] = ENABLED;
mPortStatus[kPortIndexOutput] = ENABLED;
@@ -1735,6 +1736,9 @@ void OMXCodec::onCmdComplete(OMX_COMMANDTYPE cmd, OMX_U32 data) {
CODEC_LOGV("Finished flushing both ports, now continuing from"
" seek-time.");
+ // We implicitly resume pulling on our upstream source.
+ mPaused = false;
+
drainInputBuffers();
fillOutputBuffers();
}
@@ -2034,6 +2038,10 @@ void OMXCodec::drainInputBuffer(BufferInfo *info) {
return;
}
+ if (mPaused) {
+ return;
+ }
+
status_t err;
bool signalEOS = false;
@@ -2554,6 +2562,7 @@ status_t OMXCodec::start(MetaData *) {
mOutputPortSettingsHaveChanged = false;
mSeekTimeUs = -1;
mFilledBuffers.clear();
+ mPaused = false;
return init();
}
@@ -2660,6 +2669,7 @@ status_t OMXCodec::read(
// There's no reason to trigger the code below, there's
// nothing to flush yet.
seeking = false;
+ mPaused = false;
}
drainInputBuffers();
@@ -3220,6 +3230,14 @@ void OMXCodec::initOutputFormat(const sp<MetaData> &inputFormat) {
}
}
+status_t OMXCodec::pause() {
+ Mutex::Autolock autoLock(mLock);
+
+ mPaused = true;
+
+ return OK;
+}
+
////////////////////////////////////////////////////////////////////////////////
status_t QueryCodecs(