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

Commit 05ddca50 authored by Glenn Kasten's avatar Glenn Kasten Committed by Eric Laurent
Browse files

AudioPolicy: capture sample rate 0 is route-specific default

Bug: 25641253
Bug: 21019153
Change-Id: I7d193640572c08ab5e5f1ecfc8ad6d31635967dd
parent db52e5e3
Loading
Loading
Loading
Loading
+5 −2
Original line number Original line Diff line number Diff line
@@ -22,11 +22,14 @@ static const audio_format_t gDynamicFormat = AUDIO_FORMAT_DEFAULT;


// For mixed output and inputs, the policy will use max mixer sampling rates.
// For mixed output and inputs, the policy will use max mixer sampling rates.
// Do not limit sampling rate otherwise
// Do not limit sampling rate otherwise
#define MAX_MIXER_SAMPLING_RATE 192000
#define SAMPLE_RATE_HZ_MAX 192000

// Used when a client opens a capture stream, without specifying a desired sample rate.
#define SAMPLE_RATE_HZ_DEFAULT 48000


// For mixed output and inputs, the policy will use max mixer channel count.
// For mixed output and inputs, the policy will use max mixer channel count.
// Do not limit channel count otherwise
// Do not limit channel count otherwise
#define MAX_MIXER_CHANNEL_COUNT 8
#define MAX_MIXER_CHANNEL_COUNT FCC_8


/**
/**
 * A device mask for all audio input devices that are considered "virtual" when evaluating
 * A device mask for all audio input devices that are considered "virtual" when evaluating
+1 −1
Original line number Original line Diff line number Diff line
@@ -39,7 +39,7 @@ public:
    // For a Profile aka MixPort, tag name and name are equivalent.
    // For a Profile aka MixPort, tag name and name are equivalent.
    virtual const String8 getTagName() const { return getName(); }
    virtual const String8 getTagName() const { return getName(); }


    // This method is used for both output and input.
    // This method is used for input and direct output, and is not used for other output.
    // If parameter updatedSamplingRate is non-NULL, it is assigned the actual sample rate.
    // If parameter updatedSamplingRate is non-NULL, it is assigned the actual sample rate.
    // For input, flags is interpreted as audio_input_flags_t.
    // For input, flags is interpreted as audio_input_flags_t.
    // TODO: merge audio_output_flags_t and audio_input_flags_t.
    // TODO: merge audio_output_flags_t and audio_input_flags_t.
+1 −1
Original line number Original line Diff line number Diff line
@@ -165,7 +165,7 @@ void AudioPort::pickSamplingRate(uint32_t &pickedRate,const SampleRateVector &sa
        }
        }
        pickedRate = (samplingRate == UINT_MAX) ? 0 : samplingRate;
        pickedRate = (samplingRate == UINT_MAX) ? 0 : samplingRate;
    } else {
    } else {
        uint32_t maxRate = MAX_MIXER_SAMPLING_RATE;
        uint32_t maxRate = SAMPLE_RATE_HZ_MAX;


        // For mixed output and inputs, use max mixer sampling rates. Do not
        // For mixed output and inputs, use max mixer sampling rates. Do not
        // limit sampling rate otherwise
        // limit sampling rate otherwise
+3 −0
Original line number Original line Diff line number Diff line
@@ -63,10 +63,13 @@ bool operator == (const AudioProfile &left, const AudioProfile &compareTo)
status_t AudioProfile::checkCompatibleSamplingRate(uint32_t samplingRate,
status_t AudioProfile::checkCompatibleSamplingRate(uint32_t samplingRate,
                                                   uint32_t &updatedSamplingRate) const
                                                   uint32_t &updatedSamplingRate) const
{
{
    ALOG_ASSERT(samplingRate > 0);

    if (mSamplingRates.isEmpty()) {
    if (mSamplingRates.isEmpty()) {
        updatedSamplingRate = samplingRate;
        updatedSamplingRate = samplingRate;
        return NO_ERROR;
        return NO_ERROR;
    }
    }

    // Search for the closest supported sampling rate that is above (preferred)
    // Search for the closest supported sampling rate that is above (preferred)
    // or below (acceptable) the desired sampling rate, within a permitted ratio.
    // or below (acceptable) the desired sampling rate, within a permitted ratio.
    // The sampling rates are sorted in ascending order.
    // The sampling rates are sorted in ascending order.
+2 −2
Original line number Original line Diff line number Diff line
@@ -55,8 +55,8 @@ bool IOProfile::isCompatibleProfile(audio_devices_t device,
        }
        }
    }
    }


    if (samplingRate == 0 || !audio_is_valid_format(format) ||
    if (!audio_is_valid_format(format) ||
            (isPlaybackThread && (!audio_is_output_channel(channelMask))) ||
            (isPlaybackThread && (samplingRate == 0 || !audio_is_output_channel(channelMask))) ||
            (isRecordThread && (!audio_is_input_channel(channelMask)))) {
            (isRecordThread && (!audio_is_input_channel(channelMask)))) {
         return false;
         return false;
    }
    }
Loading