diff options
author | Eric Laurent <elaurent@google.com> | 2013-10-18 13:03:34 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2013-10-18 13:03:34 -0700 |
commit | 6a7327f110b86613e6e8c7de105c49803acacc1d (patch) | |
tree | d1d175d63235d698e88ab4b3e24881b5654b70cf /services | |
parent | 9138d32050411c04cc45c25094352cf8b6e01df9 (diff) | |
parent | 6edd8ca5b7e3d169db4314d2b994bc9d48e9e082 (diff) | |
download | frameworks_av-6a7327f110b86613e6e8c7de105c49803acacc1d.zip frameworks_av-6a7327f110b86613e6e8c7de105c49803acacc1d.tar.gz frameworks_av-6a7327f110b86613e6e8c7de105c49803acacc1d.tar.bz2 |
am 6edd8ca5: am 6a51d7ed: audioflinger: fix track terminated before playing
* commit '6edd8ca5b7e3d169db4314d2b994bc9d48e9e082':
audioflinger: fix track terminated before playing
Diffstat (limited to 'services')
-rw-r--r-- | services/audioflinger/Threads.cpp | 19 | ||||
-rw-r--r-- | services/audioflinger/Threads.h | 4 |
2 files changed, 10 insertions, 13 deletions
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp index 6edb493..44384b8 100644 --- a/services/audioflinger/Threads.cpp +++ b/services/audioflinger/Threads.cpp @@ -3894,15 +3894,11 @@ AudioFlinger::OffloadThread::OffloadThread(const sp<AudioFlinger>& audioFlinger, : DirectOutputThread(audioFlinger, output, id, device, OFFLOAD), mHwPaused(false), mFlushPending(false), - mPausedBytesRemaining(0) + mPausedBytesRemaining(0), + mPreviousTrack(NULL) { } -AudioFlinger::OffloadThread::~OffloadThread() -{ - mPreviousTrack.clear(); -} - void AudioFlinger::OffloadThread::threadLoop_exit() { if (mFlushPending || mHwPaused) { @@ -3938,7 +3934,7 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::OffloadThread::prepareTr Track* const track = t.get(); audio_track_cblk_t* cblk = track->cblk(); if (mPreviousTrack != NULL) { - if (t != mPreviousTrack) { + if (t.get() != mPreviousTrack) { // Flush any data still being written from last track mBytesRemaining = 0; if (mPausedBytesRemaining) { @@ -3953,7 +3949,7 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::OffloadThread::prepareTr } } } - mPreviousTrack = t; + mPreviousTrack = t.get(); bool last = (i == (count - 1)); if (track->isPausing()) { track->setPaused(); @@ -4018,7 +4014,8 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::OffloadThread::prepareTr // has been written ALOGV("OffloadThread: underrun and STOPPING_1 -> draining, STOPPING_2"); track->mState = TrackBase::STOPPING_2; // so presentation completes after drain - if (last) { + // do not drain if no data was ever sent to HAL (mStandby == true) + if (last && !mStandby) { sleepTime = 0; standbyTime = systemTime() + standbyDelay; mixerStatus = MIXER_DRAIN_TRACK; @@ -4032,8 +4029,8 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::OffloadThread::prepareTr } } } else if (track->isStopping_2()) { - // Drain has completed, signal presentation complete - if (!(mDrainSequence & 1) || !last) { + // Drain has completed or we are in standby, signal presentation complete + if (!(mDrainSequence & 1) || !last || mStandby) { track->mState = TrackBase::STOPPED; size_t audioHALFrames = (mOutput->stream->get_latency(mOutput->stream)*mSampleRate) / 1000; diff --git a/services/audioflinger/Threads.h b/services/audioflinger/Threads.h index 6c01bb9..4ccbb10 100644 --- a/services/audioflinger/Threads.h +++ b/services/audioflinger/Threads.h @@ -737,7 +737,7 @@ public: OffloadThread(const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output, audio_io_handle_t id, uint32_t device); - virtual ~OffloadThread(); + virtual ~OffloadThread() {}; protected: // threadLoop snippets @@ -757,7 +757,7 @@ private: bool mFlushPending; size_t mPausedWriteLength; // length in bytes of write interrupted by pause size_t mPausedBytesRemaining; // bytes still waiting in mixbuffer after resume - sp<Track> mPreviousTrack; // used to detect track switch + Track *mPreviousTrack; // used to detect track switch }; class AsyncCallbackThread : public Thread { |