From a60e9a209ed7dbeaa563b3145904038064615432 Mon Sep 17 00:00:00 2001 From: Jean-Michel Trivi Date: Thu, 15 Nov 2018 16:13:36 -0800 Subject: [PATCH] AudioTrack offload: fix EVENT_STREAM_END not called If the track thread is paused, EVENT_STREAM_END will not delivered for offload. This event is required for PRESENTATION_END to be delivered for Java AudioTrack offload. Bug: 86837964 Test: cts-tradefed run cts -m CtsMediaTestCases -t android.media.cts.AudioTrackOffloadTest Change-Id: I491cdb0a6faa69e5c37139c0364b5c9079ff1f14 --- media/libaudioclient/AudioTrack.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/media/libaudioclient/AudioTrack.cpp b/media/libaudioclient/AudioTrack.cpp index 8b35a85444..96fccaee88 100644 --- a/media/libaudioclient/AudioTrack.cpp +++ b/media/libaudioclient/AudioTrack.cpp @@ -810,6 +810,13 @@ void AudioTrack::stop() if (t != 0) { if (!isOffloaded_l()) { t->pause(); + } else if (mTransfer == TRANSFER_SYNC_NOTIF_CALLBACK) { + const sp t = mAudioTrackThread; + if (t != 0) { + // causes wake up of the playback thread, that will callback the client for + // EVENT_STREAM_END in processAudioBuffer() + t->wake(); + } } } else { setpriority(PRIO_PROCESS, 0, mPreviousPriority);