summaryrefslogtreecommitdiffstats
path: root/media/libmedia/AudioTrack.cpp
diff options
context:
space:
mode:
authorYamit Mehta <ymehta@codeaurora.org>2015-07-20 12:50:58 +0530
committerLinux Build Service Account <lnxbuild@localhost>2015-10-06 03:24:17 -0600
commit88801f57e848bddc03fbd6dbd6376a5467cc1d44 (patch)
tree3be4f8bb57e17e59c26dd55008fb5b9056a3e711 /media/libmedia/AudioTrack.cpp
parentaf0860c625c041dedb15db7247ff81c8e294bee4 (diff)
downloadframeworks_av-88801f57e848bddc03fbd6dbd6376a5467cc1d44.zip
frameworks_av-88801f57e848bddc03fbd6dbd6376a5467cc1d44.tar.gz
frameworks_av-88801f57e848bddc03fbd6dbd6376a5467cc1d44.tar.bz2
audioTrack: Handle track invalidate on wait for stream done
If a track invalidate is called while waiting for a stream done, AudioCallback handler is notified with event EVENT_STREAM_END. This might cause substantial data loss for offload playback. Try to recreate the track if needed. Change-Id: Ie663c85e92588ddfd8d633f4bf5024f9fa4f5c2e
Diffstat (limited to 'media/libmedia/AudioTrack.cpp')
-rw-r--r--media/libmedia/AudioTrack.cpp60
1 files changed, 30 insertions, 30 deletions
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index 444f4d8..f9eb496 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -1829,6 +1829,36 @@ nsecs_t AudioTrack::processAudioBuffer()
// get anchor time to account for callbacks.
const nsecs_t timeBeforeCallbacks = systemTime();
+ // perform callbacks while unlocked
+ if (newUnderrun) {
+ mCbf(EVENT_UNDERRUN, mUserData, NULL);
+ }
+ while (loopCountNotifications > 0) {
+ mCbf(EVENT_LOOP_END, mUserData, NULL);
+ --loopCountNotifications;
+ }
+ if (flags & CBLK_BUFFER_END) {
+ mCbf(EVENT_BUFFER_END, mUserData, NULL);
+ }
+ if (markerReached) {
+ mCbf(EVENT_MARKER, mUserData, &markerPosition);
+ }
+ while (newPosCount > 0) {
+ size_t temp = newPosition;
+ mCbf(EVENT_NEW_POS, mUserData, &temp);
+ newPosition += updatePeriod;
+ newPosCount--;
+ }
+
+ if (mObservedSequence != sequence) {
+ mObservedSequence = sequence;
+ mCbf(EVENT_NEW_IAUDIOTRACK, mUserData, NULL);
+ // for offloaded tracks, just wait for the upper layers to recreate the track
+ if (isOffloadedOrDirect()) {
+ return NS_INACTIVE;
+ }
+ }
+
if (waitStreamEnd) {
// FIXME: Instead of blocking in proxy->waitStreamEndDone(), Callback thread
// should wait on proxy futex and handle CBLK_STREAM_END_DONE within this function
@@ -1863,36 +1893,6 @@ nsecs_t AudioTrack::processAudioBuffer()
return 0;
}
- // perform callbacks while unlocked
- if (newUnderrun) {
- mCbf(EVENT_UNDERRUN, mUserData, NULL);
- }
- while (loopCountNotifications > 0) {
- mCbf(EVENT_LOOP_END, mUserData, NULL);
- --loopCountNotifications;
- }
- if (flags & CBLK_BUFFER_END) {
- mCbf(EVENT_BUFFER_END, mUserData, NULL);
- }
- if (markerReached) {
- mCbf(EVENT_MARKER, mUserData, &markerPosition);
- }
- while (newPosCount > 0) {
- size_t temp = newPosition;
- mCbf(EVENT_NEW_POS, mUserData, &temp);
- newPosition += updatePeriod;
- newPosCount--;
- }
-
- if (mObservedSequence != sequence) {
- mObservedSequence = sequence;
- mCbf(EVENT_NEW_IAUDIOTRACK, mUserData, NULL);
- // for offloaded tracks, just wait for the upper layers to recreate the track
- if (isOffloadedOrDirect()) {
- return NS_INACTIVE;
- }
- }
-
// if inactive, then don't run me again until re-started
if (!active) {
return NS_INACTIVE;