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

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

Merge "audio policy: fix camera shutter sound" into qt-dev

parents a37a0d12 22fcda29
Loading
Loading
Loading
Loading
+1 −14
Original line number 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 engineStream = 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;
    return mProductStrategies.getStreamTypeForAttributes(attr);
}

audio_attributes_t EngineBase::getAttributesForStreamType(audio_stream_type_t stream) const
+13 −0
Original line number 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
    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
    // to be removed when the problem is handled by system UI
    uint32_t delayMs = 0;
@@ -910,6 +916,13 @@ status_t AudioPolicyManager::getAudioAttributes(audio_attributes_t *dstAttr,
        }
        *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;
}