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

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

Merge "AudioPolicy: Reuse SortedVector comparison from AudioProfile"

parents 88585f96 9de8bd18
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -31,7 +31,24 @@ typedef SortedVector<audio_channel_mask_t> ChannelsVector;
typedef Vector<audio_format_t> FormatVector;

template <typename T>
bool operator == (const SortedVector<T> &left, const SortedVector<T> &right);
bool operator== (const SortedVector<T> &left, const SortedVector<T> &right)
{
    if (left.size() != right.size()) {
        return false;
    }
    for (size_t index = 0; index < right.size(); index++) {
        if (left[index] != right[index]) {
            return false;
        }
    }
    return true;
}

template <typename T>
bool operator!= (const SortedVector<T> &left, const SortedVector<T> &right)
{
    return !(left == right);
}

class AudioProfile : public virtual RefBase
{
+0 −14
Original line number Diff line number Diff line
@@ -56,20 +56,6 @@ status_t AudioProfile::checkExact(uint32_t samplingRate, audio_channel_mask_t ch
    return BAD_VALUE;
}

template <typename T>
bool operator == (const SortedVector<T> &left, const SortedVector<T> &right)
{
    if (left.size() != right.size()) {
        return false;
    }
    for(size_t index = 0; index < right.size(); index++) {
        if (left[index] != right[index]) {
            return false;
        }
    }
    return true;
}

bool operator == (const AudioProfile &left, const AudioProfile &compareTo)
{
    return (left.getFormat() == compareTo.getFormat()) &&
+2 −16
Original line number Diff line number Diff line
@@ -3426,7 +3426,7 @@ status_t AudioPolicyManager::connectAudioSource(const sp<AudioSourceDescriptor>&
    return NO_ERROR;
}

status_t AudioPolicyManager::stopAudioSource(audio_patch_handle_t handle __unused)
status_t AudioPolicyManager::stopAudioSource(audio_patch_handle_t handle)
{
    sp<AudioSourceDescriptor> sourceDesc = mAudioSources.valueFor(handle);
    ALOGV("%s handle %d", __FUNCTION__, handle);
@@ -4637,20 +4637,6 @@ SortedVector<audio_io_handle_t> AudioPolicyManager::getOutputsForDevice(
    return outputs;
}

bool AudioPolicyManager::vectorsEqual(SortedVector<audio_io_handle_t>& outputs1,
                                      SortedVector<audio_io_handle_t>& outputs2)
{
    if (outputs1.size() != outputs2.size()) {
        return false;
    }
    for (size_t i = 0; i < outputs1.size(); i++) {
        if (outputs1[i] != outputs2[i]) {
            return false;
        }
    }
    return true;
}

void AudioPolicyManager::checkForDeviceAndOutputChanges()
{
    checkForDeviceAndOutputChanges([](){ return false; });
@@ -4691,7 +4677,7 @@ void AudioPolicyManager::checkOutputForStrategy(routing_strategy strategy)
        }
    }

    if (!vectorsEqual(srcOutputs,dstOutputs)) {
    if (srcOutputs != dstOutputs) {
        // get maximum latency of all source outputs to determine the minimum mute time guaranteeing
        // audio from invalidated tracks will be rendered when unmuting
        uint32_t maxLatency = 0;
+1 −2
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@
#include <AudioPolicyConfig.h>
#include <AudioPort.h>
#include <AudioPatch.h>
#include <AudioProfile.h>
#include <DeviceDescriptor.h>
#include <IOProfile.h>
#include <HwModule.h>
@@ -459,8 +460,6 @@ protected:

        SortedVector<audio_io_handle_t> getOutputsForDevice(audio_devices_t device,
                                                            const SwAudioOutputCollection& openOutputs);
        bool vectorsEqual(SortedVector<audio_io_handle_t>& outputs1,
                                           SortedVector<audio_io_handle_t>& outputs2);

        // mute/unmute strategies using an incompatible device combination
        // if muting, wait for the audio in pcm buffer to be drained before proceeding