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

Commit 39934ead authored by Eric Laurent's avatar Eric Laurent Committed by Mikhail Naganov
Browse files

audio policy: add audio policy ready flag.

The audio policy ready flag indicates that audio policy manager
intialization is done and that audioflinger can call back
into audio policy service without risk of deadlocking because the
service is not published yet.

Bug: 188502620
Test: boot and kill native audioserver process.

Change-Id: I671ed0aadd0c51342be5b57d1afb7577da6a7fa9
(cherry picked from commit d66d7a15)
Merged-In: I671ed0aadd0c51342be5b57d1afb7577da6a7fa9
parent 80dfa914
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -480,6 +480,12 @@ status_t AudioSystem::systemReady() {
    return af->systemReady();
}

status_t AudioSystem::audioPolicyReady() {
    const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
    if (af == 0) return NO_INIT;
    return af->audioPolicyReady();
}

status_t AudioSystem::getFrameCountHAL(audio_io_handle_t ioHandle,
                                       size_t* frameCount) {
    const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
+9 −0
Original line number Diff line number Diff line
@@ -715,6 +715,10 @@ status_t AudioFlingerClientAdapter::systemReady() {
    return statusTFromBinderStatus(mDelegate->systemReady());
}

status_t AudioFlingerClientAdapter::audioPolicyReady() {
    return statusTFromBinderStatus(mDelegate->audioPolicyReady());
}

size_t AudioFlingerClientAdapter::frameCountHAL(audio_io_handle_t ioHandle) const {
    auto result = [&]() -> ConversionResult<size_t> {
        int32_t ioHandleAidl = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(ioHandle));
@@ -1189,6 +1193,11 @@ Status AudioFlingerServerAdapter::systemReady() {
    return Status::fromStatusT(mDelegate->systemReady());
}

Status AudioFlingerServerAdapter::audioPolicyReady() {
    mDelegate->audioPolicyReady();
    return Status::ok();
}

Status AudioFlingerServerAdapter::frameCountHAL(int32_t ioHandle, int64_t* _aidl_return) {
    audio_io_handle_t ioHandleLegacy = VALUE_OR_RETURN_BINDER(
            aidl2legacy_int32_t_audio_io_handle_t(ioHandle));
+3 −0
Original line number Diff line number Diff line
@@ -197,6 +197,9 @@ interface IAudioFlingerService {
    /* Indicate JAVA services are ready (scheduling, power management ...) */
    oneway void systemReady();

    /* Indicate audio policy service is ready */
    oneway void audioPolicyReady();

    // Returns the number of frames per audio HAL buffer.
    long frameCountHAL(int /* audio_io_handle_t */ ioHandle);

+3 −0
Original line number Diff line number Diff line
@@ -225,6 +225,9 @@ public:
    // Indicate JAVA services are ready (scheduling, power management ...)
    static status_t systemReady();

    // Indicate audio policy service is ready
    static status_t audioPolicyReady();

    // Returns the number of frames per audio HAL buffer.
    // Corresponds to audio_stream->get_buffer_size()/audio_stream_in_frame_size() for input.
    // See also getFrameCount().
+7 −0
Original line number Diff line number Diff line
@@ -329,6 +329,9 @@ public:
    /* Indicate JAVA services are ready (scheduling, power management ...) */
    virtual status_t systemReady() = 0;

    // Indicate audio policy service is ready
    virtual status_t audioPolicyReady() = 0;

    // Returns the number of frames per audio HAL buffer.
    virtual size_t frameCountHAL(audio_io_handle_t ioHandle) const = 0;

@@ -432,6 +435,8 @@ public:
    status_t setAudioPortConfig(const struct audio_port_config* config) override;
    audio_hw_sync_t getAudioHwSyncForSession(audio_session_t sessionId) override;
    status_t systemReady() override;
    status_t audioPolicyReady() override;

    size_t frameCountHAL(audio_io_handle_t ioHandle) const override;
    status_t getMicrophones(std::vector<media::MicrophoneInfo>* microphones) override;
    status_t setAudioHalPids(const std::vector<pid_t>& pids) override;
@@ -514,6 +519,7 @@ public:
            SET_AUDIO_PORT_CONFIG = media::BnAudioFlingerService::TRANSACTION_setAudioPortConfig,
            GET_AUDIO_HW_SYNC_FOR_SESSION = media::BnAudioFlingerService::TRANSACTION_getAudioHwSyncForSession,
            SYSTEM_READY = media::BnAudioFlingerService::TRANSACTION_systemReady,
            AUDIO_POLICY_READY = media::BnAudioFlingerService::TRANSACTION_audioPolicyReady,
            FRAME_COUNT_HAL = media::BnAudioFlingerService::TRANSACTION_frameCountHAL,
            GET_MICROPHONES = media::BnAudioFlingerService::TRANSACTION_getMicrophones,
            SET_MASTER_BALANCE = media::BnAudioFlingerService::TRANSACTION_setMasterBalance,
@@ -624,6 +630,7 @@ public:
    Status setAudioPortConfig(const media::AudioPortConfig& config) override;
    Status getAudioHwSyncForSession(int32_t sessionId, int32_t* _aidl_return) override;
    Status systemReady() override;
    Status audioPolicyReady() override;
    Status frameCountHAL(int32_t ioHandle, int64_t* _aidl_return) override;
    Status getMicrophones(std::vector<media::MicrophoneInfoData>* _aidl_return) override;
    Status setAudioHalPids(const std::vector<int32_t>& pids) override;
Loading