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

This commit is contained in:
Andreas Huber
2010-06-10 12:43:53 -07:00
committed by Android Git Automerger
3 changed files with 31 additions and 1 deletions

View File

@@ -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();

View File

@@ -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;

View File

@@ -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(