Loading media/libaudioclient/AudioPolicy.cpp +2 −2 Original line number Original line Diff line number Diff line Loading @@ -85,7 +85,7 @@ status_t AudioMix::readFromParcel(Parcel *parcel) mDeviceType = (audio_devices_t) parcel->readInt32(); mDeviceType = (audio_devices_t) parcel->readInt32(); mDeviceAddress = parcel->readString8(); mDeviceAddress = parcel->readString8(); mCbFlags = (uint32_t)parcel->readInt32(); mCbFlags = (uint32_t)parcel->readInt32(); mAllowPrivilegedPlaybackCapture = parcel->readBool(); mAllowPrivilegedMediaPlaybackCapture = parcel->readBool(); mVoiceCommunicationCaptureAllowed = parcel->readBool(); mVoiceCommunicationCaptureAllowed = parcel->readBool(); size_t size = (size_t)parcel->readInt32(); size_t size = (size_t)parcel->readInt32(); if (size > MAX_CRITERIA_PER_MIX) { if (size > MAX_CRITERIA_PER_MIX) { Loading @@ -110,7 +110,7 @@ status_t AudioMix::writeToParcel(Parcel *parcel) const parcel->writeInt32(mDeviceType); parcel->writeInt32(mDeviceType); parcel->writeString8(mDeviceAddress); parcel->writeString8(mDeviceAddress); parcel->writeInt32(mCbFlags); parcel->writeInt32(mCbFlags); parcel->writeBool(mAllowPrivilegedPlaybackCapture); parcel->writeBool(mAllowPrivilegedMediaPlaybackCapture); parcel->writeBool(mVoiceCommunicationCaptureAllowed); parcel->writeBool(mVoiceCommunicationCaptureAllowed); size_t size = mCriteria.size(); size_t size = mCriteria.size(); if (size > MAX_CRITERIA_PER_MIX) { if (size > MAX_CRITERIA_PER_MIX) { Loading media/libaudioclient/include/media/AudioPolicy.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -120,7 +120,7 @@ public: String8 mDeviceAddress; String8 mDeviceAddress; uint32_t mCbFlags; // flags indicating which callbacks to use, see kCbFlag* uint32_t mCbFlags; // flags indicating which callbacks to use, see kCbFlag* /** Ignore the AUDIO_FLAG_NO_MEDIA_PROJECTION */ /** Ignore the AUDIO_FLAG_NO_MEDIA_PROJECTION */ bool mAllowPrivilegedPlaybackCapture = false; bool mAllowPrivilegedMediaPlaybackCapture = false; /** Indicates if the caller can capture voice communication output */ /** Indicates if the caller can capture voice communication output */ bool mVoiceCommunicationCaptureAllowed = false; bool mVoiceCommunicationCaptureAllowed = false; }; }; Loading services/audiopolicy/common/managerdefinitions/src/AudioPolicyMix.cpp +12 −11 Original line number Original line Diff line number Diff line Loading @@ -208,22 +208,23 @@ AudioPolicyMixCollection::MixMatchStatus AudioPolicyMixCollection::mixMatch( // Loopback render mixes are created from a public API and thus restricted // Loopback render mixes are created from a public API and thus restricted // to non sensible audio that have not opted out. // to non sensible audio that have not opted out. if (is_mix_loopback_render(mix->mRouteFlags)) { if (is_mix_loopback_render(mix->mRouteFlags)) { auto hasFlag = [](auto flags, auto flag) { return (flags & flag) == flag; }; if (!(attributes.usage == AUDIO_USAGE_UNKNOWN || if (hasFlag(attributes.flags, AUDIO_FLAG_NO_SYSTEM_CAPTURE)) { attributes.usage == AUDIO_USAGE_MEDIA || attributes.usage == AUDIO_USAGE_GAME || attributes.usage == AUDIO_USAGE_VOICE_COMMUNICATION)) { return MixMatchStatus::NO_MATCH; return MixMatchStatus::NO_MATCH; } } if (!mix->mAllowPrivilegedPlaybackCapture && auto hasFlag = [](auto flags, auto flag) { return (flags & flag) == flag; }; hasFlag(attributes.flags, AUDIO_FLAG_NO_MEDIA_PROJECTION)) { if (hasFlag(attributes.flags, AUDIO_FLAG_NO_SYSTEM_CAPTURE)) { return MixMatchStatus::NO_MATCH; return MixMatchStatus::NO_MATCH; } } if (attributes.usage == AUDIO_USAGE_VOICE_COMMUNICATION && !mix->mVoiceCommunicationCaptureAllowed) { if (attributes.usage == AUDIO_USAGE_VOICE_COMMUNICATION) { if (!mix->mVoiceCommunicationCaptureAllowed) { return MixMatchStatus::NO_MATCH; return MixMatchStatus::NO_MATCH; } } if (!(attributes.usage == AUDIO_USAGE_UNKNOWN || } else if (!mix->mAllowPrivilegedMediaPlaybackCapture && attributes.usage == AUDIO_USAGE_MEDIA || hasFlag(attributes.flags, AUDIO_FLAG_NO_MEDIA_PROJECTION)) { attributes.usage == AUDIO_USAGE_GAME || attributes.usage == AUDIO_USAGE_VOICE_COMMUNICATION)) { return MixMatchStatus::NO_MATCH; return MixMatchStatus::NO_MATCH; } } } } Loading services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -1241,7 +1241,7 @@ status_t AudioPolicyService::registerPolicyMixes(const Vector<AudioMix>& mixes, return mix.mVoiceCommunicationCaptureAllowed; }); return mix.mVoiceCommunicationCaptureAllowed; }); bool needCaptureMediaOutput = std::any_of(mixes.begin(), mixes.end(), [](auto& mix) { bool needCaptureMediaOutput = std::any_of(mixes.begin(), mixes.end(), [](auto& mix) { return mix.mAllowPrivilegedPlaybackCapture; }); return mix.mAllowPrivilegedMediaPlaybackCapture; }); const uid_t callingUid = IPCThreadState::self()->getCallingUid(); const uid_t callingUid = IPCThreadState::self()->getCallingUid(); const pid_t callingPid = IPCThreadState::self()->getCallingPid(); const pid_t callingPid = IPCThreadState::self()->getCallingPid(); Loading Loading
media/libaudioclient/AudioPolicy.cpp +2 −2 Original line number Original line Diff line number Diff line Loading @@ -85,7 +85,7 @@ status_t AudioMix::readFromParcel(Parcel *parcel) mDeviceType = (audio_devices_t) parcel->readInt32(); mDeviceType = (audio_devices_t) parcel->readInt32(); mDeviceAddress = parcel->readString8(); mDeviceAddress = parcel->readString8(); mCbFlags = (uint32_t)parcel->readInt32(); mCbFlags = (uint32_t)parcel->readInt32(); mAllowPrivilegedPlaybackCapture = parcel->readBool(); mAllowPrivilegedMediaPlaybackCapture = parcel->readBool(); mVoiceCommunicationCaptureAllowed = parcel->readBool(); mVoiceCommunicationCaptureAllowed = parcel->readBool(); size_t size = (size_t)parcel->readInt32(); size_t size = (size_t)parcel->readInt32(); if (size > MAX_CRITERIA_PER_MIX) { if (size > MAX_CRITERIA_PER_MIX) { Loading @@ -110,7 +110,7 @@ status_t AudioMix::writeToParcel(Parcel *parcel) const parcel->writeInt32(mDeviceType); parcel->writeInt32(mDeviceType); parcel->writeString8(mDeviceAddress); parcel->writeString8(mDeviceAddress); parcel->writeInt32(mCbFlags); parcel->writeInt32(mCbFlags); parcel->writeBool(mAllowPrivilegedPlaybackCapture); parcel->writeBool(mAllowPrivilegedMediaPlaybackCapture); parcel->writeBool(mVoiceCommunicationCaptureAllowed); parcel->writeBool(mVoiceCommunicationCaptureAllowed); size_t size = mCriteria.size(); size_t size = mCriteria.size(); if (size > MAX_CRITERIA_PER_MIX) { if (size > MAX_CRITERIA_PER_MIX) { Loading
media/libaudioclient/include/media/AudioPolicy.h +1 −1 Original line number Original line Diff line number Diff line Loading @@ -120,7 +120,7 @@ public: String8 mDeviceAddress; String8 mDeviceAddress; uint32_t mCbFlags; // flags indicating which callbacks to use, see kCbFlag* uint32_t mCbFlags; // flags indicating which callbacks to use, see kCbFlag* /** Ignore the AUDIO_FLAG_NO_MEDIA_PROJECTION */ /** Ignore the AUDIO_FLAG_NO_MEDIA_PROJECTION */ bool mAllowPrivilegedPlaybackCapture = false; bool mAllowPrivilegedMediaPlaybackCapture = false; /** Indicates if the caller can capture voice communication output */ /** Indicates if the caller can capture voice communication output */ bool mVoiceCommunicationCaptureAllowed = false; bool mVoiceCommunicationCaptureAllowed = false; }; }; Loading
services/audiopolicy/common/managerdefinitions/src/AudioPolicyMix.cpp +12 −11 Original line number Original line Diff line number Diff line Loading @@ -208,22 +208,23 @@ AudioPolicyMixCollection::MixMatchStatus AudioPolicyMixCollection::mixMatch( // Loopback render mixes are created from a public API and thus restricted // Loopback render mixes are created from a public API and thus restricted // to non sensible audio that have not opted out. // to non sensible audio that have not opted out. if (is_mix_loopback_render(mix->mRouteFlags)) { if (is_mix_loopback_render(mix->mRouteFlags)) { auto hasFlag = [](auto flags, auto flag) { return (flags & flag) == flag; }; if (!(attributes.usage == AUDIO_USAGE_UNKNOWN || if (hasFlag(attributes.flags, AUDIO_FLAG_NO_SYSTEM_CAPTURE)) { attributes.usage == AUDIO_USAGE_MEDIA || attributes.usage == AUDIO_USAGE_GAME || attributes.usage == AUDIO_USAGE_VOICE_COMMUNICATION)) { return MixMatchStatus::NO_MATCH; return MixMatchStatus::NO_MATCH; } } if (!mix->mAllowPrivilegedPlaybackCapture && auto hasFlag = [](auto flags, auto flag) { return (flags & flag) == flag; }; hasFlag(attributes.flags, AUDIO_FLAG_NO_MEDIA_PROJECTION)) { if (hasFlag(attributes.flags, AUDIO_FLAG_NO_SYSTEM_CAPTURE)) { return MixMatchStatus::NO_MATCH; return MixMatchStatus::NO_MATCH; } } if (attributes.usage == AUDIO_USAGE_VOICE_COMMUNICATION && !mix->mVoiceCommunicationCaptureAllowed) { if (attributes.usage == AUDIO_USAGE_VOICE_COMMUNICATION) { if (!mix->mVoiceCommunicationCaptureAllowed) { return MixMatchStatus::NO_MATCH; return MixMatchStatus::NO_MATCH; } } if (!(attributes.usage == AUDIO_USAGE_UNKNOWN || } else if (!mix->mAllowPrivilegedMediaPlaybackCapture && attributes.usage == AUDIO_USAGE_MEDIA || hasFlag(attributes.flags, AUDIO_FLAG_NO_MEDIA_PROJECTION)) { attributes.usage == AUDIO_USAGE_GAME || attributes.usage == AUDIO_USAGE_VOICE_COMMUNICATION)) { return MixMatchStatus::NO_MATCH; return MixMatchStatus::NO_MATCH; } } } } Loading
services/audiopolicy/service/AudioPolicyInterfaceImpl.cpp +1 −1 Original line number Original line Diff line number Diff line Loading @@ -1241,7 +1241,7 @@ status_t AudioPolicyService::registerPolicyMixes(const Vector<AudioMix>& mixes, return mix.mVoiceCommunicationCaptureAllowed; }); return mix.mVoiceCommunicationCaptureAllowed; }); bool needCaptureMediaOutput = std::any_of(mixes.begin(), mixes.end(), [](auto& mix) { bool needCaptureMediaOutput = std::any_of(mixes.begin(), mixes.end(), [](auto& mix) { return mix.mAllowPrivilegedPlaybackCapture; }); return mix.mAllowPrivilegedMediaPlaybackCapture; }); const uid_t callingUid = IPCThreadState::self()->getCallingUid(); const uid_t callingUid = IPCThreadState::self()->getCallingUid(); const pid_t callingPid = IPCThreadState::self()->getCallingPid(); const pid_t callingPid = IPCThreadState::self()->getCallingPid(); Loading