Loading media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp +18 −1 Original line number Diff line number Diff line Loading @@ -107,6 +107,7 @@ NuPlayer::Renderer::Renderer( mNotifyCompleteVideo(false), mSyncQueues(false), mPaused(false), mPauseDrainAudioAllowedUs(0), mVideoSampleReceived(false), mVideoRenderingStarted(false), mVideoRenderingStartGeneration(0), Loading Loading @@ -645,6 +646,14 @@ void NuPlayer::Renderer::postDrainAudioQueue_l(int64_t delayUs) { return; } // FIXME: if paused, wait until AudioTrack stop() is complete before delivering data. if (mPaused) { const int64_t diffUs = mPauseDrainAudioAllowedUs - ALooper::GetNowUs(); if (diffUs > delayUs) { delayUs = diffUs; } } mDrainAudioQueuePending = true; sp<AMessage> msg = new AMessage(kWhatDrainAudioQueue, this); msg->setInt32("drainGeneration", mAudioDrainGeneration); Loading Loading @@ -1371,8 +1380,16 @@ void NuPlayer::Renderer::onFlush(const sp<AMessage> &msg) { mAudioSink->flush(); // Call stop() to signal to the AudioSink to completely fill the // internal buffer before resuming playback. // FIXME: this is ignored after flush(). mAudioSink->stop(); if (!mPaused) { if (mPaused) { // Race condition: if renderer is paused and audio sink is stopped, // we need to make sure that the audio track buffer fully drains // before delivering data. // FIXME: remove this if we can detect if stop() is complete. const int delayUs = 2 * 50 * 1000; // (2 full mixer thread cycles at 50ms) mPauseDrainAudioAllowedUs = ALooper::GetNowUs() + delayUs; } else { mAudioSink->start(); } mNumFramesWritten = 0; Loading media/libmediaplayerservice/nuplayer/NuPlayerRenderer.h +1 −0 Original line number Diff line number Diff line Loading @@ -171,6 +171,7 @@ private: // modified on only renderer's thread. bool mPaused; int64_t mPauseDrainAudioAllowedUs; // time when we can drain/deliver audio in pause mode. bool mVideoSampleReceived; bool mVideoRenderingStarted; Loading Loading
media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp +18 −1 Original line number Diff line number Diff line Loading @@ -107,6 +107,7 @@ NuPlayer::Renderer::Renderer( mNotifyCompleteVideo(false), mSyncQueues(false), mPaused(false), mPauseDrainAudioAllowedUs(0), mVideoSampleReceived(false), mVideoRenderingStarted(false), mVideoRenderingStartGeneration(0), Loading Loading @@ -645,6 +646,14 @@ void NuPlayer::Renderer::postDrainAudioQueue_l(int64_t delayUs) { return; } // FIXME: if paused, wait until AudioTrack stop() is complete before delivering data. if (mPaused) { const int64_t diffUs = mPauseDrainAudioAllowedUs - ALooper::GetNowUs(); if (diffUs > delayUs) { delayUs = diffUs; } } mDrainAudioQueuePending = true; sp<AMessage> msg = new AMessage(kWhatDrainAudioQueue, this); msg->setInt32("drainGeneration", mAudioDrainGeneration); Loading Loading @@ -1371,8 +1380,16 @@ void NuPlayer::Renderer::onFlush(const sp<AMessage> &msg) { mAudioSink->flush(); // Call stop() to signal to the AudioSink to completely fill the // internal buffer before resuming playback. // FIXME: this is ignored after flush(). mAudioSink->stop(); if (!mPaused) { if (mPaused) { // Race condition: if renderer is paused and audio sink is stopped, // we need to make sure that the audio track buffer fully drains // before delivering data. // FIXME: remove this if we can detect if stop() is complete. const int delayUs = 2 * 50 * 1000; // (2 full mixer thread cycles at 50ms) mPauseDrainAudioAllowedUs = ALooper::GetNowUs() + delayUs; } else { mAudioSink->start(); } mNumFramesWritten = 0; Loading
media/libmediaplayerservice/nuplayer/NuPlayerRenderer.h +1 −0 Original line number Diff line number Diff line Loading @@ -171,6 +171,7 @@ private: // modified on only renderer's thread. bool mPaused; int64_t mPauseDrainAudioAllowedUs; // time when we can drain/deliver audio in pause mode. bool mVideoSampleReceived; bool mVideoRenderingStarted; Loading