From e79ee6494c2a1f2d3b1f1b1393ca85beee41a29d Mon Sep 17 00:00:00 2001 From: Steve Kondik Date: Fri, 31 Jan 2014 22:08:54 +0800 Subject: stagefright: Squashed commit of pause/resume features Add 2 APIs (suspend/resume) in MediaPlayer - API:suspend() will just pause the player and release all the decoders to replace release() which will release the whole player - API:resume() will just init the decoders again, then start() will be called to restart streaming playback - Add a check in AwesomePlayer::onVideoEvent() to make sure the first seek operation will always seek to the next i-frame Change-Id: Ie4c82906a2a056378119921a656128ebdc1007c4 audio: Add pause support for hardware omx component - ADSP doesn't enter sleep state after wma playback is paused and power suspended. - No support for NT session pause in case of hardware component. NT session need to be paused to put ADSP into power collapse. - Add support of pause in stagefright to ensure device enters suspend mode. Also add intermediate states to avoid concurrency issues between read and pause. Change-Id: I41b946b8c8805e6ee303646b63513b5b16514ef6 libstagefright: Drain input buffer on resume - Buffers returned from codec in paused state are not drained. When codec is resumed these buffers are not drained until the next flush, and may cause timed out issue. - Added change to drain input buffers for sw decoders when resuming. Change-Id: Ida2ab1d5dc3a1910accdd6fb89548262a912d8e7 CRs-Fixed: 569585, 574967 libstagefright: camcorder pause-resume implementation - Add pause resume feature in camcorder app. So that user can pause recording and resume later which results in a single recorded clip. Change-Id: Id19c45ae5bb85265aa4d5304b160ebf119d9575a libstagefright: support pause/resume for timelapse recording Modify the timestamp calculation mechanism in CameraSourceTimeLapse in order to support pause/resume. Change-Id: Icb02ea798b0b807ffb7ada2d1ef5b2414b74edfb --- media/libstagefright/AudioSource.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'media/libstagefright/AudioSource.cpp') diff --git a/media/libstagefright/AudioSource.cpp b/media/libstagefright/AudioSource.cpp index dc9c37b..db08476 100644 --- a/media/libstagefright/AudioSource.cpp +++ b/media/libstagefright/AudioSource.cpp @@ -58,7 +58,8 @@ AudioSource::AudioSource( mPrevSampleTimeUs(0), mFirstSampleTimeUs(-1ll), mNumFramesReceived(0), - mNumClientOwnedBuffers(0) { + mNumClientOwnedBuffers(0), + mRecPaused(false) { ALOGV("sampleRate: %u, outSampleRate: %u, channelCount: %u", sampleRate, outSampleRate, channelCount); CHECK(channelCount == 1 || channelCount == 2 || channelCount == 6); @@ -109,6 +110,11 @@ status_t AudioSource::initCheck() const { status_t AudioSource::start(MetaData *params) { Mutex::Autolock autoLock(mLock); + if (mRecPaused) { + mRecPaused = false; + return OK; + } + if (mStarted) { return UNKNOWN_ERROR; } @@ -138,6 +144,12 @@ status_t AudioSource::start(MetaData *params) { return err; } +status_t AudioSource::pause() { + ALOGV("AudioSource::Pause"); + mRecPaused = true; + return OK; +} + void AudioSource::releaseQueuedFrames_l() { ALOGV("releaseQueuedFrames_l"); List::iterator it; @@ -368,6 +380,14 @@ status_t AudioSource::dataCallback(const AudioRecord::Buffer& audioBuffer) { } void AudioSource::queueInputBuffer_l(MediaBuffer *buffer, int64_t timeUs) { + if (mRecPaused) { + if (!mBuffersReceived.empty()) { + releaseQueuedFrames_l(); + } + buffer->release(); + return; + } + const size_t bufferSize = buffer->range_length(); const size_t frameSize = mRecord->frameSize(); const int64_t timestampUs = -- cgit v1.1