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

Commit eb02770c authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "audiopolicy: Implement API for querying A2DP offload formats"

parents acbd8561 11029ad0
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -1337,6 +1337,13 @@ bool AudioSystem::isHapticPlaybackSupported()
    return aps->isHapticPlaybackSupported();
}

status_t AudioSystem::getHwOffloadEncodingFormatsSupportedForA2DP(
                                std::vector<audio_format_t> *formats)
{
    const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
    if (aps == 0) return PERMISSION_DENIED;
    return aps->getHwOffloadEncodingFormatsSupportedForA2DP(formats);
}

// ---------------------------------------------------------------------------

+42 −2
Original line number Diff line number Diff line
@@ -92,6 +92,7 @@ enum {
    IS_HAPTIC_PLAYBACK_SUPPORTED,
    SET_UID_DEVICE_AFFINITY,
    REMOVE_UID_DEVICE_AFFINITY,
    GET_OFFLOAD_FORMATS_A2DP
};

#define MAX_ITEMS_PER_LIST 1024
@@ -888,6 +889,29 @@ public:
        return reply.readInt32();
    }

    virtual status_t getHwOffloadEncodingFormatsSupportedForA2DP(
                std::vector<audio_format_t> *formats)
    {
        if (formats == NULL) {
            return BAD_VALUE;
        }

        Parcel data, reply;
        data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
        status_t status = remote()->transact(GET_OFFLOAD_FORMATS_A2DP, data, &reply);
        if (status != NO_ERROR || (status = (status_t)reply.readInt32()) != NO_ERROR) {
            return status;
        }

        size_t list_size = reply.readUint32();

        for (size_t i = 0; i < list_size; i++) {
            formats->push_back(static_cast<audio_format_t>(reply.readInt32()));
        }
        return NO_ERROR;
    }


     virtual status_t addStreamDefaultEffect(const effect_uuid_t *type,
                                            const String16& opPackageName,
                                            const effect_uuid_t *uuid,
@@ -1100,7 +1124,8 @@ status_t BnAudioPolicyService::onTransact(
        case SET_ASSISTANT_UID:
        case SET_A11Y_SERVICES_UIDS:
        case SET_UID_DEVICE_AFFINITY:
        case REMOVE_UID_DEVICE_AFFINITY: {
        case REMOVE_UID_DEVICE_AFFINITY:
        case GET_OFFLOAD_FORMATS_A2DP: {
            if (!isServiceUid(IPCThreadState::self()->getCallingUid())) {
                ALOGW("%s: transaction %d received from PID %d unauthorized UID %d",
                      __func__, code, IPCThreadState::self()->getCallingPid(),
@@ -1754,6 +1779,21 @@ status_t BnAudioPolicyService::onTransact(
            return NO_ERROR;
        }

        case GET_OFFLOAD_FORMATS_A2DP: {
            CHECK_INTERFACE(IAudioPolicyService, data, reply);
            std::vector<audio_format_t> encodingFormats;
            status_t status = getHwOffloadEncodingFormatsSupportedForA2DP(&encodingFormats);
            reply->writeInt32(status);
            if (status != NO_ERROR) {
                return NO_ERROR;
            }
            reply->writeUint32(static_cast<uint32_t>(encodingFormats.size()));
            for (size_t i = 0; i < encodingFormats.size(); i++)
                reply->writeInt32(static_cast<int32_t>(encodingFormats[i]));
            return NO_ERROR;
        }


        case ADD_STREAM_DEFAULT_EFFECT: {
            CHECK_INTERFACE(IAudioPolicyService, data, reply);
            effect_uuid_t type;
+3 −0
Original line number Diff line number Diff line
@@ -344,6 +344,9 @@ public:

    static status_t getMicrophones(std::vector<media::MicrophoneInfo> *microphones);

    static status_t getHwOffloadEncodingFormatsSupportedForA2DP(
                                    std::vector<audio_format_t> *formats);

    // numSurroundFormats holds the maximum number of formats and bool value allowed in the array.
    // When numSurroundFormats is 0, surroundFormats and surroundFormatsEnabled will not be
    // populated. The actual number of surround formats should be returned at numSurroundFormats.
+2 −0
Original line number Diff line number Diff line
@@ -188,6 +188,8 @@ public:
                                        audio_format_t *surroundFormats,
                                        bool *surroundFormatsEnabled,
                                        bool reported) = 0;
    virtual status_t getHwOffloadEncodingFormatsSupportedForA2DP(
                                        std::vector<audio_format_t> *formats) = 0;
    virtual status_t setSurroundFormatEnabled(audio_format_t audioFormat, bool enabled) = 0;

    virtual status_t setAssistantUid(uid_t uid) = 0;
+3 −0
Original line number Diff line number Diff line
@@ -236,6 +236,9 @@ public:

    virtual bool     isHapticPlaybackSupported() = 0;

    virtual status_t getHwOffloadEncodingFormatsSupportedForA2DP(
                std::vector<audio_format_t> *formats) = 0;

    virtual void     setAppState(uid_t uid, app_state_t state);
};

Loading