mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 07:15:46 +00:00
Bug 860760 - Pause OMX media sources when playback is paused. r=sotaro, r=cdouble
OMXCodec needs to now when the stream is paused. Otherwise it will prevent the device from lowering its power state when idle.
This commit is contained in:
parent
26436acb5c
commit
2d313efb2c
@ -331,5 +331,18 @@ nsresult MediaOmxReader::GetBuffered(mozilla::dom::TimeRanges* aBuffered, int64_
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void MediaOmxReader::OnDecodeThreadFinish() {
|
||||
if (mOmxDecoder.get()) {
|
||||
mOmxDecoder->Pause();
|
||||
}
|
||||
}
|
||||
|
||||
void MediaOmxReader::OnDecodeThreadStart() {
|
||||
if (mOmxDecoder.get()) {
|
||||
nsresult result = mOmxDecoder->Play();
|
||||
NS_ASSERTION(result == NS_OK, "OmxDecoder should be in play state to continue decoding");
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
|
@ -57,6 +57,10 @@ public:
|
||||
MetadataTags** aTags);
|
||||
virtual nsresult Seek(int64_t aTime, int64_t aStartTime, int64_t aEndTime, int64_t aCurrentTime);
|
||||
virtual nsresult GetBuffered(mozilla::dom::TimeRanges* aBuffered, int64_t aStartTime);
|
||||
|
||||
virtual void OnDecodeThreadStart() MOZ_OVERRIDE;
|
||||
|
||||
virtual void OnDecodeThreadFinish() MOZ_OVERRIDE;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -141,6 +141,7 @@ OmxDecoder::OmxDecoder(MediaResource *aResource,
|
||||
mVideoBuffer(nullptr),
|
||||
mAudioBuffer(nullptr),
|
||||
mIsVideoSeeking(false),
|
||||
mPaused(false),
|
||||
mAudioMetadataRead(false)
|
||||
{
|
||||
}
|
||||
@ -666,3 +667,32 @@ void OmxDecoder::ReleaseAllPendingVideoBuffersLocked()
|
||||
}
|
||||
mPendingVideoBuffers.clear();
|
||||
}
|
||||
|
||||
nsresult OmxDecoder::Play() {
|
||||
if (!mPaused) {
|
||||
return NS_OK;
|
||||
}
|
||||
if (mVideoSource.get() && mVideoSource->start() != OK) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
if (mAudioSource.get()&& mAudioSource->start() != OK) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
mPaused = false;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void OmxDecoder::Pause() {
|
||||
if (mPaused) {
|
||||
return;
|
||||
}
|
||||
if (mVideoSource.get()) {
|
||||
mVideoSource->pause();
|
||||
}
|
||||
|
||||
if (mAudioSource.get()) {
|
||||
mAudioSource->pause();
|
||||
}
|
||||
mPaused = true;
|
||||
}
|
||||
|
@ -132,6 +132,10 @@ class OmxDecoder : public RefBase {
|
||||
bool ToVideoFrame(VideoFrame *aFrame, int64_t aTimeUs, void *aData, size_t aSize, bool aKeyFrame);
|
||||
bool ToAudioFrame(AudioFrame *aFrame, int64_t aTimeUs, void *aData, size_t aDataOffset, size_t aSize,
|
||||
int32_t aAudioChannels, int32_t aAudioSampleRate);
|
||||
|
||||
//True if decoder is in a paused state
|
||||
bool mPaused;
|
||||
|
||||
public:
|
||||
OmxDecoder(MediaResource *aResource, AbstractMediaDecoder *aDecoder);
|
||||
~OmxDecoder();
|
||||
@ -172,6 +176,12 @@ public:
|
||||
}
|
||||
|
||||
bool ReleaseVideoBuffer(MediaBuffer *aBuffer);
|
||||
|
||||
//Change decoder into a playing state
|
||||
nsresult Play();
|
||||
|
||||
//Change decoder into a paused state
|
||||
void Pause();
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user