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

Commit 95d1dbd6 authored by Vlad Popa's avatar Vlad Popa Committed by Android (Google) Code Review
Browse files

Merge "Add playback mute notifications for mmap tracks"

parents cc1be7e5 ec1788e7
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -647,6 +647,8 @@ aaudio_result_t AudioStreamInternal::onEventFromServer(AAudioServiceMessage *mes
            if (getState() == AAUDIO_STREAM_STATE_STARTING) {
                setState(AAUDIO_STREAM_STATE_STARTED);
            }
            mPlayerBase->triggerPortIdUpdate(static_cast<audio_port_handle_t>(
                                                 message->event.dataLong));
            break;
        case AAUDIO_SERVICE_EVENT_PAUSED:
            ALOGD("%s - got AAUDIO_SERVICE_EVENT_PAUSED", __func__);
+14 −0
Original line number Diff line number Diff line
@@ -58,6 +58,20 @@ void PlayerBase::init(player_type_t playerType, audio_usage_t usage, audio_sessi
    }
}

void PlayerBase::triggerPortIdUpdate(audio_port_handle_t portId) const {
    if (mAudioManager == nullptr) {
        ALOGE("%s: no audio service, player %d will not update portId %d",
              __func__,
              mPIId,
              portId);
        return;
    }

    if (mPIId != PLAYER_PIID_INVALID && portId != AUDIO_PORT_HANDLE_NONE) {
        mAudioManager->playerEvent(mPIId, android::PLAYER_UPDATE_PORT_ID, portId);
    }
}

void PlayerBase::baseDestroy() {
    serviceReleasePlayer();
    if (mAudioManager != 0) {
+4 −1
Original line number Diff line number Diff line
@@ -53,6 +53,10 @@ public:

            void baseUpdateDeviceId(audio_port_handle_t deviceId);

            /**
             * Updates the mapping in the AudioService between portId and piid
             */
            void triggerPortIdUpdate(audio_port_handle_t portId) const;
protected:

            void init(player_type_t playerType, audio_usage_t usage, audio_session_t sessionId);
@@ -74,7 +78,6 @@ protected:
    // player interface ID, uniquely identifies the player in the system
    // effectively const after PlayerBase::init().
    audio_unique_id_t mPIId;

private:
            // report events to AudioService
            void servicePlayerEvent(player_state_t event, audio_port_handle_t deviceId);
+15 −0
Original line number Diff line number Diff line
@@ -54,6 +54,14 @@ public:
            bool        getAndSetSilencedNotified_l() { bool silencedNotified = mSilencedNotified;
                                                        mSilencedNotified = true;
                                                        return silencedNotified; }

    /**
     * Updates the mute state and notifies the audio service. Call this only when holding player
     * thread lock.
     */
    void processMuteEvent_l(const sp<IAudioManager>& audioManager,
                            mute_state_t muteState)
                            REQUIRES(AudioFlinger::MmapPlaybackThread::mLock);
private:
    friend class MmapThread;

@@ -71,5 +79,12 @@ private:
    pid_t mPid;
    bool  mSilenced;            // protected by MMapThread::mLock
    bool  mSilencedNotified;    // protected by MMapThread::mLock

    // TODO: replace PersistableBundle with own struct
    // access these two variables only when holding player thread lock.
    std::unique_ptr<os::PersistableBundle> mMuteEventExtras
            GUARDED_BY(AudioFlinger::MmapPlaybackThread::mLock);
    mute_state_t mMuteState
            GUARDED_BY(AudioFlinger::MmapPlaybackThread::mLock);
};  // end of Track
+8 −0
Original line number Diff line number Diff line
@@ -10465,6 +10465,14 @@ void AudioFlinger::MmapPlaybackThread::processVolume_l()
        }
        for (const sp<MmapTrack> &track : mActiveTracks) {
            track->setMetadataHasChanged();
            track->processMuteEvent_l(mAudioFlinger->getOrCreateAudioManager(),
                /*muteState=*/{mMasterMute,
                               mStreamVolume == 0.f,
                               mStreamMute,
                               // TODO(b/241533526): adjust logic to include mute from AppOps
                               false /*muteFromPlaybackRestricted*/,
                               false /*muteFromClientVolume*/,
                               false /*muteFromVolumeShaper*/});
        }
    }
}
Loading