From 39609a0a6d95d003b0f237e6c139b070b4df7071 Mon Sep 17 00:00:00 2001 From: Andy Hung Date: Thu, 3 Sep 2015 16:38:38 -0700 Subject: AudioTrack: Skip callback EVENT_STREAM_END on DEAD_OBJECT. Send only EVENT_NEW_IAUDIOTRACK to initiate teardown. Bug: 23750452 Change-Id: Ib5dcd578b5b6a6a1d91a03e58ef8da0acd994243 --- media/libmedia/AudioTrack.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'media/libmedia') diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp index ab3d66a..d17f7ae 100644 --- a/media/libmedia/AudioTrack.cpp +++ b/media/libmedia/AudioTrack.cpp @@ -1852,7 +1852,11 @@ nsecs_t AudioTrack::processAudioBuffer() case NO_ERROR: case DEAD_OBJECT: case TIMED_OUT: - mCbf(EVENT_STREAM_END, mUserData, NULL); + if (status != DEAD_OBJECT) { + // for DEAD_OBJECT, we do not send a EVENT_STREAM_END after stop(); + // instead, the application should handle the EVENT_NEW_IAUDIOTRACK. + mCbf(EVENT_STREAM_END, mUserData, NULL); + } { AutoMutex lock(mLock); // The previously assigned value of waitStreamEnd is no longer valid, -- cgit v1.1 From 954ca45ac30539a49f179580b667b0ab1056d113 Mon Sep 17 00:00:00 2001 From: Andy Hung Date: Wed, 9 Sep 2015 14:39:02 -0700 Subject: For static obtainBuffer(), do not set mUnreleased if acknowledging flush. static audio tracks use obtainBuffer() to update position in start(). Bug: 22938515 Change-Id: I8ae32f6cce4d122386d2cf8982e158049b04ba9a --- media/libmedia/AudioTrackShared.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'media/libmedia') diff --git a/media/libmedia/AudioTrackShared.cpp b/media/libmedia/AudioTrackShared.cpp index 6a51a76..caa84fb 100644 --- a/media/libmedia/AudioTrackShared.cpp +++ b/media/libmedia/AudioTrackShared.cpp @@ -932,7 +932,7 @@ ssize_t StaticAudioTrackServerProxy::pollPosition() return (ssize_t) mState.mPosition; } -status_t StaticAudioTrackServerProxy::obtainBuffer(Buffer* buffer, bool ackFlush __unused) +status_t StaticAudioTrackServerProxy::obtainBuffer(Buffer* buffer, bool ackFlush) { if (mIsShutdown) { buffer->mFrameCount = 0; @@ -970,7 +970,9 @@ status_t StaticAudioTrackServerProxy::obtainBuffer(Buffer* buffer, bool ackFlush // it is always larger or equal to avail. LOG_ALWAYS_FATAL_IF(mFramesReady < (int64_t) avail); buffer->mNonContig = mFramesReady == INT64_MAX ? SIZE_MAX : clampToSize(mFramesReady - avail); - mUnreleased = avail; + if (!ackFlush) { + mUnreleased = avail; + } return NO_ERROR; } -- cgit v1.1 From 606fbc1030d686bf1f8dc03d14a79342aca2ca41 Mon Sep 17 00:00:00 2001 From: Glenn Kasten Date: Thu, 22 Oct 2015 15:28:15 -0700 Subject: Workaround for busy wait bug Underlying bug 25195759 is not yet fixed. Bug: 24263351 Change-Id: I04b644246640054d38c8de79e0eb80fcbfef0e48 --- media/libmedia/AudioTrack.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'media/libmedia') diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp index d17f7ae..ff5fe1d 100644 --- a/media/libmedia/AudioTrack.cpp +++ b/media/libmedia/AudioTrack.cpp @@ -1980,7 +1980,8 @@ nsecs_t AudioTrack::processAudioBuffer() if (err != NO_ERROR) { if (err == TIMED_OUT || err == WOULD_BLOCK || err == -EINTR || (isOffloaded() && (err == DEAD_OBJECT))) { - return 0; + // FIXME bug 25195759 + return 1000000; } ALOGE("Error %d obtaining an audio buffer, giving up.", err); return NS_NEVER; -- cgit v1.1