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

Commit c387f2b7 authored by Dhananjay Kumar's avatar Dhananjay Kumar Committed by Wei Jia
Browse files

NuPlayer : send the correct streaming info while opening audio sink

 -For any offload playback NuPlayerRenderer always open the audio sink
  with isStreaming info as true.
 -Pass the streaming info to the NuPlayerRenderer while opening audio
  sink
Test: cts tests
Bug:36051644
Author: Preetam Singh Ranawat <apranawat@codeaurora.org>
Change-Id: I249e6769ef4587917a13b0225d049a3923544d16
(cherry picked from commit b2444b392d0d5de4118d37a24f4351f9de5c215d)
parent 34bc4d97
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -1619,7 +1619,8 @@ void NuPlayer::tryOpenAudioSinkForOffload(
    // is possible; otherwise the decoders call the renderer openAudioSink directly.

    status_t err = mRenderer->openAudioSink(
            format, true /* offloadOnly */, hasVideo, AUDIO_OUTPUT_FLAG_NONE, &mOffloadAudio);
            format, true /* offloadOnly */, hasVideo,
            AUDIO_OUTPUT_FLAG_NONE, &mOffloadAudio, mSource->isStreaming());
    if (err != OK) {
        // Any failure we turn off mOffloadAudio.
        mOffloadAudio = false;
+2 −1
Original line number Diff line number Diff line
@@ -773,7 +773,8 @@ void NuPlayer::Decoder::handleOutputFormatChange(const sp<AMessage> &format) {
        sp<AMessage> reply = new AMessage(kWhatAudioOutputFormatChanged, this);
        reply->setInt32("generation", mBufferGeneration);
        mRenderer->changeAudioFormat(
                format, false /* offloadOnly */, hasVideo, flags, reply);
                format, false /* offloadOnly */, hasVideo,
                flags, mSource->isStreaming(), reply);
    }
}

+1 −1
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ void NuPlayer::DecoderPassThrough::onConfigure(const sp<AMessage> &format) {
    // format is different.
    status_t err = mRenderer->openAudioSink(
            format, true /* offloadOnly */, hasVideo,
            AUDIO_OUTPUT_FLAG_NONE /* flags */, NULL /* isOffloaded */);
            AUDIO_OUTPUT_FLAG_NONE /* flags */, NULL /* isOffloaded */, mSource->isStreaming());
    if (err != OK) {
        handleError(err);
    }
+16 −5
Original line number Diff line number Diff line
@@ -397,12 +397,14 @@ status_t NuPlayer::Renderer::openAudioSink(
        bool offloadOnly,
        bool hasVideo,
        uint32_t flags,
        bool *isOffloaded) {
        bool *isOffloaded,
        bool isStreaming) {
    sp<AMessage> msg = new AMessage(kWhatOpenAudioSink, this);
    msg->setMessage("format", format);
    msg->setInt32("offload-only", offloadOnly);
    msg->setInt32("has-video", hasVideo);
    msg->setInt32("flags", flags);
    msg->setInt32("isStreaming", isStreaming);

    sp<AMessage> response;
    status_t postStatus = msg->postAndAwaitResponse(&response);
@@ -430,12 +432,14 @@ void NuPlayer::Renderer::changeAudioFormat(
        bool offloadOnly,
        bool hasVideo,
        uint32_t flags,
        bool isStreaming,
        const sp<AMessage> &notify) {
    sp<AMessage> meta = new AMessage;
    meta->setMessage("format", format);
    meta->setInt32("offload-only", offloadOnly);
    meta->setInt32("has-video", hasVideo);
    meta->setInt32("flags", flags);
    meta->setInt32("isStreaming", isStreaming);

    sp<AMessage> msg = new AMessage(kWhatChangeAudioFormat, this);
    msg->setInt32("queueGeneration", getQueueGeneration(true /* audio */));
@@ -460,7 +464,10 @@ void NuPlayer::Renderer::onMessageReceived(const sp<AMessage> &msg) {
            uint32_t flags;
            CHECK(msg->findInt32("flags", (int32_t *)&flags));

            status_t err = onOpenAudioSink(format, offloadOnly, hasVideo, flags);
            uint32_t isStreaming;
            CHECK(msg->findInt32("isStreaming", (int32_t *)&isStreaming));

            status_t err = onOpenAudioSink(format, offloadOnly, hasVideo, flags, isStreaming);

            sp<AMessage> response = new AMessage;
            response->setInt32("err", err);
@@ -1838,7 +1845,8 @@ status_t NuPlayer::Renderer::onOpenAudioSink(
        const sp<AMessage> &format,
        bool offloadOnly,
        bool hasVideo,
        uint32_t flags) {
        uint32_t flags,
        bool isStreaming) {
    ALOGV("openAudioSink: offloadOnly(%d) offloadingAudio(%d)",
            offloadOnly, offloadingAudio());
    bool audioSinkChanged = false;
@@ -1891,7 +1899,7 @@ status_t NuPlayer::Renderer::onOpenAudioSink(
            offloadInfo.stream_type = AUDIO_STREAM_MUSIC;
            offloadInfo.bit_rate = avgBitRate;
            offloadInfo.has_video = hasVideo;
            offloadInfo.is_streaming = true;
            offloadInfo.is_streaming = isStreaming;

            if (memcmp(&mCurrentOffloadInfo, &offloadInfo, sizeof(offloadInfo)) == 0) {
                ALOGV("openAudioSink: no change in offload mode");
@@ -2043,7 +2051,10 @@ void NuPlayer::Renderer::onChangeAudioFormat(
    uint32_t flags;
    CHECK(meta->findInt32("flags", (int32_t *)&flags));

    status_t err = onOpenAudioSink(format, offloadOnly, hasVideo, flags);
    uint32_t isStreaming;
    CHECK(meta->findInt32("isStreaming", (int32_t *)&isStreaming));

    status_t err = onOpenAudioSink(format, offloadOnly, hasVideo, flags, isStreaming);

    if (err != OK) {
        notify->setInt32("err", err);
+5 −2
Original line number Diff line number Diff line
@@ -76,7 +76,8 @@ struct NuPlayer::Renderer : public AHandler {
            bool offloadOnly,
            bool hasVideo,
            uint32_t flags,
            bool *isOffloaded);
            bool *isOffloaded,
            bool isStreaming);
    void closeAudioSink();

    // re-open audio sink after all pending audio buffers played.
@@ -85,6 +86,7 @@ struct NuPlayer::Renderer : public AHandler {
            bool offloadOnly,
            bool hasVideo,
            uint32_t flags,
            bool isStreaming,
            const sp<AMessage> &notify);

    enum {
@@ -267,7 +269,8 @@ private:
            const sp<AMessage> &format,
            bool offloadOnly,
            bool hasVideo,
            uint32_t flags);
            uint32_t flags,
            bool isStreaming);
    void onCloseAudioSink();
    void onChangeAudioFormat(const sp<AMessage> &meta, const sp<AMessage> &notify);