Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 18a79124 authored by Jaideep Sharma's avatar Jaideep Sharma Committed by Eric Laurent
Browse files

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
parent b3ce4482
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -100,6 +100,7 @@ class MediaPlayerService : public BnMediaPlayerService
        virtual audio_session_t getSessionId() const;
        virtual uint32_t        getSampleRate() const;
        virtual int64_t         getBufferDurationInUs() const;
        virtual audio_output_flags_t getFlags() const { return mFlags; }

        virtual status_t        open(
                uint32_t sampleRate, int channelCount, audio_channel_mask_t channelMask,
+1 −0
Original line number Diff line number Diff line
@@ -108,6 +108,7 @@ public:
        virtual audio_stream_type_t getAudioStreamType() const = 0;
        virtual uint32_t    getSampleRate() const = 0;
        virtual int64_t     getBufferDurationInUs() const = 0;
        virtual audio_output_flags_t getFlags() const = 0;

        // If no callback is specified, use the "write" API below to submit
        // audio data.
+6 −4
Original line number Diff line number Diff line
@@ -871,10 +871,12 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
            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(&currentPositionUs) != OK) {
                        currentPositionUs = mPreviousSeekTimeUs;