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:
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <media/stagefright/MediaErrors.h>
|
||||||
#include <utils/RefBase.h>
|
#include <utils/RefBase.h>
|
||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
@@ -83,6 +84,13 @@ struct MediaSource : public RefBase {
|
|||||||
int64_t mLatenessUs;
|
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:
|
protected:
|
||||||
virtual ~MediaSource();
|
virtual ~MediaSource();
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,8 @@ struct OMXCodec : public MediaSource,
|
|||||||
virtual status_t read(
|
virtual status_t read(
|
||||||
MediaBuffer **buffer, const ReadOptions *options = NULL);
|
MediaBuffer **buffer, const ReadOptions *options = NULL);
|
||||||
|
|
||||||
|
virtual status_t pause();
|
||||||
|
|
||||||
void on_message(const omx_message &msg);
|
void on_message(const omx_message &msg);
|
||||||
|
|
||||||
// from MediaBufferObserver
|
// from MediaBufferObserver
|
||||||
@@ -144,6 +146,8 @@ private:
|
|||||||
Mutex mLock;
|
Mutex mLock;
|
||||||
Condition mAsyncCompletion;
|
Condition mAsyncCompletion;
|
||||||
|
|
||||||
|
bool mPaused;
|
||||||
|
|
||||||
// A list of indices into mPortStatus[kPortIndexOutput] filled with data.
|
// A list of indices into mPortStatus[kPortIndexOutput] filled with data.
|
||||||
List<size_t> mFilledBuffers;
|
List<size_t> mFilledBuffers;
|
||||||
Condition mBufferFilled;
|
Condition mBufferFilled;
|
||||||
|
|||||||
@@ -1145,7 +1145,8 @@ OMXCodec::OMXCodec(
|
|||||||
mNoMoreOutputData(false),
|
mNoMoreOutputData(false),
|
||||||
mOutputPortSettingsHaveChanged(false),
|
mOutputPortSettingsHaveChanged(false),
|
||||||
mSeekTimeUs(-1),
|
mSeekTimeUs(-1),
|
||||||
mLeftOverBuffer(NULL) {
|
mLeftOverBuffer(NULL),
|
||||||
|
mPaused(false) {
|
||||||
mPortStatus[kPortIndexInput] = ENABLED;
|
mPortStatus[kPortIndexInput] = ENABLED;
|
||||||
mPortStatus[kPortIndexOutput] = 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"
|
CODEC_LOGV("Finished flushing both ports, now continuing from"
|
||||||
" seek-time.");
|
" seek-time.");
|
||||||
|
|
||||||
|
// We implicitly resume pulling on our upstream source.
|
||||||
|
mPaused = false;
|
||||||
|
|
||||||
drainInputBuffers();
|
drainInputBuffers();
|
||||||
fillOutputBuffers();
|
fillOutputBuffers();
|
||||||
}
|
}
|
||||||
@@ -2034,6 +2038,10 @@ void OMXCodec::drainInputBuffer(BufferInfo *info) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mPaused) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
status_t err;
|
status_t err;
|
||||||
|
|
||||||
bool signalEOS = false;
|
bool signalEOS = false;
|
||||||
@@ -2554,6 +2562,7 @@ status_t OMXCodec::start(MetaData *) {
|
|||||||
mOutputPortSettingsHaveChanged = false;
|
mOutputPortSettingsHaveChanged = false;
|
||||||
mSeekTimeUs = -1;
|
mSeekTimeUs = -1;
|
||||||
mFilledBuffers.clear();
|
mFilledBuffers.clear();
|
||||||
|
mPaused = false;
|
||||||
|
|
||||||
return init();
|
return init();
|
||||||
}
|
}
|
||||||
@@ -2660,6 +2669,7 @@ status_t OMXCodec::read(
|
|||||||
// There's no reason to trigger the code below, there's
|
// There's no reason to trigger the code below, there's
|
||||||
// nothing to flush yet.
|
// nothing to flush yet.
|
||||||
seeking = false;
|
seeking = false;
|
||||||
|
mPaused = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
drainInputBuffers();
|
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(
|
status_t QueryCodecs(
|
||||||
|
|||||||
Reference in New Issue
Block a user