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

Commit 22fcda29 authored by Eric Laurent's avatar Eric Laurent
Browse files

audio policy: fix camera shutter sound

Fix regression in camera shutter sound when system stream
volume is 0.

Bug: 132696227
Test: repro steps in bug.
Test: regressions when camera sound is enforced
Change-Id: I76b4a5ee041f97c5f771c003bf4f99327d797096
parent 4fc900d7
Loading
Loading
Loading
Loading
+1 −14
Original line number Original line Diff line number Diff line
@@ -70,20 +70,7 @@ product_strategy_t EngineBase::getProductStrategyForAttributes(const audio_attri


audio_stream_type_t EngineBase::getStreamTypeForAttributes(const audio_attributes_t &attr) const
audio_stream_type_t EngineBase::getStreamTypeForAttributes(const audio_attributes_t &attr) const
{
{
    audio_stream_type_t engineStream = mProductStrategies.getStreamTypeForAttributes(attr);
    return mProductStrategies.getStreamTypeForAttributes(attr);
    // ensure the audibility flag for sonification is honored for stream types
    // Note this is typically implemented in the product strategy configuration files, but is
    //   duplicated here for safety.
    if (attr.usage == AUDIO_USAGE_ASSISTANCE_SONIFICATION
            && ((attr.flags & AUDIO_FLAG_AUDIBILITY_ENFORCED) != 0)) {
        engineStream = AUDIO_STREAM_ENFORCED_AUDIBLE;
    }
    // ensure the ENFORCED_AUDIBLE stream type reflects the "force use" setting:
    if ((getForceUse(AUDIO_POLICY_FORCE_FOR_SYSTEM) != AUDIO_POLICY_FORCE_SYSTEM_ENFORCED)
            && (engineStream == AUDIO_STREAM_ENFORCED_AUDIBLE)) {
        return AUDIO_STREAM_SYSTEM;
    }
    return engineStream;
}
}


audio_attributes_t EngineBase::getAttributesForStreamType(audio_stream_type_t stream) const
audio_attributes_t EngineBase::getAttributesForStreamType(audio_stream_type_t stream) const
+13 −0
Original line number Original line Diff line number Diff line
@@ -777,6 +777,12 @@ void AudioPolicyManager::setForceUse(audio_policy_force_use_t usage,
    // check for device and output changes triggered by new force usage
    // check for device and output changes triggered by new force usage
    checkForDeviceAndOutputChanges();
    checkForDeviceAndOutputChanges();


    // force client reconnection to reevaluate flag AUDIO_FLAG_AUDIBILITY_ENFORCED
    if (usage == AUDIO_POLICY_FORCE_FOR_SYSTEM) {
        mpClientInterface->invalidateStream(AUDIO_STREAM_SYSTEM);
        mpClientInterface->invalidateStream(AUDIO_STREAM_ENFORCED_AUDIBLE);
    }

    //FIXME: workaround for truncated touch sounds
    //FIXME: workaround for truncated touch sounds
    // to be removed when the problem is handled by system UI
    // to be removed when the problem is handled by system UI
    uint32_t delayMs = 0;
    uint32_t delayMs = 0;
@@ -910,6 +916,13 @@ status_t AudioPolicyManager::getAudioAttributes(audio_attributes_t *dstAttr,
        }
        }
        *dstAttr = mEngine->getAttributesForStreamType(srcStream);
        *dstAttr = mEngine->getAttributesForStreamType(srcStream);
    }
    }

    // Only honor audibility enforced when required. The client will be
    // forced to reconnect if the forced usage changes.
    if (mEngine->getForceUse(AUDIO_POLICY_FORCE_FOR_SYSTEM) != AUDIO_POLICY_FORCE_SYSTEM_ENFORCED) {
        dstAttr->flags &= ~AUDIO_FLAG_AUDIBILITY_ENFORCED;
    }

    return NO_ERROR;
    return NO_ERROR;
}
}