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

Commit 0141bbe6 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes I5e12b2c7,Ic79effb1

* changes:
  [audiopolicy][managerdefault] Filter unknown stream for volume settings
  [AudioPolicy][engine][Strategy] fallback on music stream
parents fb4a4553 5992b18e
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -73,10 +73,18 @@ bool ProductStrategy::matches(const audio_attributes_t attr) const
audio_stream_type_t ProductStrategy::getStreamTypeForAttributes(
        const audio_attributes_t &attr) const
{
    const auto iter = std::find_if(begin(mAttributesVector), end(mAttributesVector),
    const auto &iter = std::find_if(begin(mAttributesVector), end(mAttributesVector),
                                   [&attr](const auto &supportedAttr) {
        return AudioProductStrategy::attributesMatches(supportedAttr.mAttributes, attr); });
    return iter != end(mAttributesVector) ? iter->mStream : AUDIO_STREAM_DEFAULT;
    if (iter == end(mAttributesVector)) {
        return AUDIO_STREAM_DEFAULT;
    }
    audio_stream_type_t streamType = iter->mStream;
    ALOGW_IF(streamType == AUDIO_STREAM_DEFAULT,
             "%s: Strategy %s supporting attributes %s has not stream type associated"
             "fallback on MUSIC. Do not use stream volume API", __func__, mName.c_str(),
             toString(attr).c_str());
    return streamType != AUDIO_STREAM_DEFAULT ? streamType : AUDIO_STREAM_MUSIC;
}

audio_attributes_t ProductStrategy::getAttributesForStreamType(audio_stream_type_t streamType) const
+5 −1
Original line number Diff line number Diff line
@@ -2441,6 +2441,10 @@ status_t AudioPolicyManager::setStreamVolumeIndex(audio_stream_type_t stream,
                                                  audio_devices_t device)
{
    auto attributes = mEngine->getAttributesForStreamType(stream);
    if (attributes == AUDIO_ATTRIBUTES_INITIALIZER) {
        ALOGW("%s: no group for stream %s, bailing out", __func__, toString(stream).c_str());
        return NO_ERROR;
    }
    ALOGV("%s: stream %s attributes=%s", __func__,
          toString(stream).c_str(), toString(attributes).c_str());
    return setVolumeIndexForAttributes(attributes, index, device);
@@ -5937,7 +5941,7 @@ void AudioPolicyManager::applyStreamVolumes(const sp<AudioOutputDescriptor>& out
                                            int delayMs,
                                            bool force)
{
    ALOGVV("applyStreamVolumes() for device %08x", device);
    ALOGVV("applyStreamVolumes() for device %s", dumpDeviceTypes(deviceTypes).c_str());
    for (const auto &volumeGroup : mEngine->getVolumeGroups()) {
        auto &curves = getVolumeCurves(toVolumeSource(volumeGroup));
        checkAndSetVolume(curves, toVolumeSource(volumeGroup),