nuplayer: handle setPlaybackSettings on direct tracks.
setPlaybackSettings (playback rate) is not supported
on an AudioSink opened with DIRECT flag.
Query the sink for the flags it was opened with and
restart audio when setPlaybackSettings gets called on
an AudioSink which was opened with DIRECT flag
for unsupported playback rates.
Bug: 111196161
Test: manual audio smoke tests.
Change-Id: Ibfeb9ae32ccece003ebc48201ea5d9eeba3fad6e
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
index 47362ef..344ee0b 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
@@ -871,10 +871,12 @@
readFromAMessage(msg, &rate);
status_t err = OK;
if (mRenderer != NULL) {
- // AudioSink allows only 1.f and 0.f for offload mode.
- // For other speed, switch to non-offload mode.
- if (mOffloadAudio && ((rate.mSpeed != 0.f && rate.mSpeed != 1.f)
- || rate.mPitch != 1.f)) {
+ // AudioSink allows only 1.f and 0.f for offload and direct modes.
+ // For other speeds, restart audio to fallback to supported paths
+ bool audioDirectOutput = (mAudioSink->getFlags() & AUDIO_OUTPUT_FLAG_DIRECT) != 0;
+ if ((mOffloadAudio || audioDirectOutput) &&
+ ((rate.mSpeed != 0.f && rate.mSpeed != 1.f) || rate.mPitch != 1.f)) {
+
int64_t currentPositionUs;
if (getCurrentPosition(¤tPositionUs) != OK) {
currentPositionUs = mPreviousSeekTimeUs;