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

Commit a03910b2 authored by Eric Laurent's avatar Eric Laurent Committed by Android (Google) Code Review
Browse files

Merge "audio policy: fix merging error for commit 112b0af8."

parents 93ec0d71 20eb3a43
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -71,7 +71,6 @@ public:
    virtual void toAudioPort(struct audio_port *port) const;
    virtual void toAudioPort(struct audio_port *port) const;


    virtual void importAudioPort(const sp<AudioPort> port);
    virtual void importAudioPort(const sp<AudioPort> port);
    void clearCapabilities() { mProfiles.clearProfiles(); }


    void addAudioProfile(const sp<AudioProfile> &profile) { mProfiles.add(profile); }
    void addAudioProfile(const sp<AudioProfile> &profile) { mProfiles.add(profile); }


+27 −28
Original line number Original line Diff line number Diff line
@@ -258,7 +258,6 @@ public:
        if (dynamicFormatProfile == 0) {
        if (dynamicFormatProfile == 0) {
            return;
            return;
        }
        }
        clearProfiles();
        for (size_t i = 0; i < formats.size(); i++) {
        for (size_t i = 0; i < formats.size(); i++) {
            sp<AudioProfile> profile = new AudioProfile(formats[i],
            sp<AudioProfile> profile = new AudioProfile(formats[i],
                                                        dynamicFormatProfile->getChannels(),
                                                        dynamicFormatProfile->getChannels(),
@@ -270,6 +269,33 @@ public:
        }
        }
    }
    }


    void clearProfiles()
    {
        for (size_t i = size(); i != 0; ) {
            sp<AudioProfile> profile = itemAt(--i);
            if (profile->isDynamicFormat() && profile->hasValidFormat()) {
                removeAt(i);
                continue;
            }
            profile->clear();
        }
    }

    void dump(int fd, int spaces) const
    {
        const size_t SIZE = 256;
        char buffer[SIZE];

        snprintf(buffer, SIZE, "%*s- Profiles:\n", spaces, "");
        write(fd, buffer, strlen(buffer));
        for (size_t i = 0; i < size(); i++) {
            snprintf(buffer, SIZE, "%*sProfile %zu:", spaces + 4, "", i);
            write(fd, buffer, strlen(buffer));
            itemAt(i)->dump(fd, spaces + 8);
        }
    }

private:
    void setSampleRatesFor(const SampleRateVector &sampleRates, audio_format_t format)
    void setSampleRatesFor(const SampleRateVector &sampleRates, audio_format_t format)
    {
    {
        for (size_t i = 0; i < size(); i++) {
        for (size_t i = 0; i < size(); i++) {
@@ -308,33 +334,6 @@ public:
        }
        }
    }
    }


    void clearProfiles()
    {
        for (size_t i = size(); i != 0; ) {
            sp<AudioProfile> profile = itemAt(--i);
            if (profile->isDynamicFormat() && profile->hasValidFormat()) {
                removeAt(i);
                continue;
            }
            profile->clear();
        }
    }

    void dump(int fd, int spaces) const
    {
        const size_t SIZE = 256;
        char buffer[SIZE];

        snprintf(buffer, SIZE, "%*s- Profiles:\n", spaces, "");
        write(fd, buffer, strlen(buffer));
        for (size_t i = 0; i < size(); i++) {
            snprintf(buffer, SIZE, "%*sProfile %zu:", spaces + 4, "", i);
            write(fd, buffer, strlen(buffer));
            itemAt(i)->dump(fd, spaces + 8);
        }
    }

private:
    sp<AudioProfile> getProfileFor(audio_format_t format) const
    sp<AudioProfile> getProfileFor(audio_format_t format) const
    {
    {
        for (size_t i = 0; i < size(); i++) {
        for (size_t i = 0; i < size(); i++) {
+8 −5
Original line number Original line Diff line number Diff line
@@ -3472,7 +3472,7 @@ status_t AudioPolicyManager::checkOutputsForDevice(const sp<DeviceDescriptor> de


    if (audio_device_is_digital(device)) {
    if (audio_device_is_digital(device)) {
        // erase all current sample rates, formats and channel masks
        // erase all current sample rates, formats and channel masks
        devDesc->clearCapabilities();
        devDesc->clearAudioProfiles();
    }
    }


    if (state == AUDIO_POLICY_DEVICE_STATE_AVAILABLE) {
    if (state == AUDIO_POLICY_DEVICE_STATE_AVAILABLE) {
@@ -3717,7 +3717,7 @@ status_t AudioPolicyManager::checkInputsForDevice(const sp<DeviceDescriptor> dev


    if (audio_device_is_digital(device)) {
    if (audio_device_is_digital(device)) {
        // erase all current sample rates, formats and channel masks
        // erase all current sample rates, formats and channel masks
        devDesc->clearCapabilities();
        devDesc->clearAudioProfiles();
    }
    }


    if (state == AUDIO_POLICY_DEVICE_STATE_AVAILABLE) {
    if (state == AUDIO_POLICY_DEVICE_STATE_AVAILABLE) {
@@ -5137,6 +5137,8 @@ void AudioPolicyManager::updateAudioProfiles(audio_io_handle_t ioHandle,


    for (size_t formatIndex = 0; formatIndex < supportedFormats.size(); formatIndex++) {
    for (size_t formatIndex = 0; formatIndex < supportedFormats.size(); formatIndex++) {
        audio_format_t format = supportedFormats[formatIndex];
        audio_format_t format = supportedFormats[formatIndex];
        ChannelsVector channelMasks;
        SampleRateVector samplingRates;
        AudioParameter requestedParameters;
        AudioParameter requestedParameters;
        requestedParameters.addInt(String8(AUDIO_PARAMETER_STREAM_FORMAT), format);
        requestedParameters.addInt(String8(AUDIO_PARAMETER_STREAM_FORMAT), format);


@@ -5147,7 +5149,7 @@ void AudioPolicyManager::updateAudioProfiles(audio_io_handle_t ioHandle,
            ALOGV("%s: supported sampling rates %s", __FUNCTION__, reply.string());
            ALOGV("%s: supported sampling rates %s", __FUNCTION__, reply.string());
            value = strpbrk((char *)reply.string(), "=");
            value = strpbrk((char *)reply.string(), "=");
            if (value != NULL) {
            if (value != NULL) {
                profiles.setSampleRatesFor(samplingRatesFromString(value + 1), format);
                samplingRates = samplingRatesFromString(value + 1);
            }
            }
        }
        }
        if (profiles.hasDynamicChannelsFor(format)) {
        if (profiles.hasDynamicChannelsFor(format)) {
@@ -5157,9 +5159,10 @@ void AudioPolicyManager::updateAudioProfiles(audio_io_handle_t ioHandle,
            ALOGV("%s: supported channel masks %s", __FUNCTION__, reply.string());
            ALOGV("%s: supported channel masks %s", __FUNCTION__, reply.string());
            value = strpbrk((char *)reply.string(), "=");
            value = strpbrk((char *)reply.string(), "=");
            if (value != NULL) {
            if (value != NULL) {
                profiles.setChannelsFor(channelMasksFromString(value + 1), format);
                channelMasks = channelMasksFromString(value + 1);
            }
            }
        }
        }
        profiles.addProfileFromHal(new AudioProfile(format, channelMasks, samplingRates));
    }
    }
}
}