Add remote submix direct paths

Explicitly reject remote submix non PCM input or output streams.

Bug: 311830316
Test: atest VtsHalAudioCoreTargetTest
Change-Id: I3da9282d0f4ecb91dea65f784294e94436765538
This commit is contained in:
Dean Wheatley 2023-10-24 11:23:49 +11:00
parent 435d7f42a2
commit ce9767a966
2 changed files with 49 additions and 6 deletions

View file

@ -32,6 +32,7 @@ using aidl::android::media::audio::common::AudioDeviceType;
using aidl::android::media::audio::common::AudioFormatDescription;
using aidl::android::media::audio::common::AudioFormatType;
using aidl::android::media::audio::common::AudioGainConfig;
using aidl::android::media::audio::common::AudioInputFlags;
using aidl::android::media::audio::common::AudioIoFlags;
using aidl::android::media::audio::common::AudioOutputFlags;
using aidl::android::media::audio::common::AudioPort;
@ -321,20 +322,25 @@ std::unique_ptr<Configuration> getPrimaryConfiguration() {
//
// Mix ports:
// * "r_submix output", maximum 10 opened streams, maximum 10 active streams
// - profile PCM 16-bit; STEREO; 8000, 11025, 16000, 32000, 44100, 48000
// - profile PCM 16-bit; STEREO; 8000, 11025, 16000, 32000, 44100, 48000, 192000
// * "r_submix input", maximum 10 opened streams, maximum 10 active streams
// - profile PCM 16-bit; STEREO; 8000, 11025, 16000, 32000, 44100, 48000
// - profile PCM 16-bit; STEREO; 8000, 11025, 16000, 32000, 44100, 48000, 192000
// * "r_submix output direct", DIRECT|IEC958_NONAUDIO, 1 max open, 1 max active
// - profile PCM 16-bit; STEREO; 8000, 11025, 16000, 32000, 44100, 48000, 192000
// * "r_submix input direct", DIRECT, 1 max open, 1 max active
// - profile PCM 16-bit; STEREO; 8000, 11025, 16000, 32000, 44100, 48000, 192000
//
// Routes:
// "r_submix output" -> "Remote Submix Out"
// "Remote Submix In" -> "r_submix input"
// "r_submix output", "r_submix output direct" -> "Remote Submix Out"
// "Remote Submix In" -> "r_submix input", "r_submix input direct"
//
std::unique_ptr<Configuration> getRSubmixConfiguration() {
static const Configuration configuration = []() {
Configuration c;
const std::vector<AudioProfile> remoteSubmixPcmAudioProfiles{
createProfile(PcmType::INT_16_BIT, {AudioChannelLayout::LAYOUT_STEREO},
{8000, 11025, 16000, 32000, 44100, 48000})};
{8000, 11025, 16000, 32000, 44100, 48000, 192000})};
// Device ports
@ -359,13 +365,41 @@ std::unique_ptr<Configuration> getRSubmixConfiguration() {
rsubmixOutMix.profiles = remoteSubmixPcmAudioProfiles;
c.ports.push_back(rsubmixOutMix);
// Adding a DIRECT flag to rsubmixInMix breaks the mixer paths, so we need separate
// non direct and direct paths. It is added because for IEC61937 encapsulated over PCM, we
// need the DIRECT and IEC958_NONAUDIO flags as AudioFlinger adds them.
AudioPort rsubmixOutDirectMix =
createPort(c.nextPortId++, "r_submix output direct",
makeBitPositionFlagMask({
AudioOutputFlags::DIRECT,
AudioOutputFlags::IEC958_NONAUDIO}),
false /* isInput */,
createPortMixExt(1 /* maxOpenStreamCount */,
1 /* maxActiveStreamCount */));
rsubmixOutDirectMix.profiles = remoteSubmixPcmAudioProfiles;
c.ports.push_back(rsubmixOutDirectMix);
AudioPort rsubmixInMix =
createPort(c.nextPortId++, "r_submix input", 0, true, createPortMixExt(10, 10));
rsubmixInMix.profiles = remoteSubmixPcmAudioProfiles;
c.ports.push_back(rsubmixInMix);
c.routes.push_back(createRoute({rsubmixOutMix}, rsubmixOutDevice));
// Adding a DIRECT flag to rsubmixInMix breaks the capture paths, so we need separate
// non direct and direct paths. It is added because for IEC61937 encapsulated over PCM, we
// need the DIRECT flag for the capability so AudioFlinger can find a DIRECT input match.
AudioPort rsubmixInDirectMix =
createPort(c.nextPortId++, "r_submix input direct",
makeBitPositionFlagMask({AudioInputFlags::DIRECT}),
true /* isInput */,
createPortMixExt(1 /* maxOpenStreamCount */,
1 /* maxActiveStreamCount */));
rsubmixInDirectMix.profiles = remoteSubmixPcmAudioProfiles;
c.ports.push_back(rsubmixInDirectMix);
c.routes.push_back(createRoute(
{rsubmixOutMix, rsubmixOutDirectMix}, rsubmixOutDevice));
c.routes.push_back(createRoute({rsubmixInDevice}, rsubmixInMix));
c.routes.push_back(createRoute({rsubmixInDevice}, rsubmixInDirectMix));
return c;
}();

View file

@ -27,6 +27,7 @@
using aidl::android::hardware::audio::common::SinkMetadata;
using aidl::android::hardware::audio::common::SourceMetadata;
using aidl::android::media::audio::common::AudioFormatType;
using aidl::android::media::audio::common::AudioOffloadInfo;
using aidl::android::media::audio::common::AudioPort;
using aidl::android::media::audio::common::AudioPortConfig;
@ -47,6 +48,10 @@ ndk::ScopedAStatus ModuleRemoteSubmix::setMicMute(bool in_mute __unused) {
ndk::ScopedAStatus ModuleRemoteSubmix::createInputStream(
StreamContext&& context, const SinkMetadata& sinkMetadata,
const std::vector<MicrophoneInfo>& microphones, std::shared_ptr<StreamIn>* result) {
if (context.getFormat().type != AudioFormatType::PCM) {
LOG(DEBUG) << __func__ << ": not supported for format " << context.getFormat().toString();
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
return createStreamInstance<StreamInRemoteSubmix>(result, std::move(context), sinkMetadata,
microphones);
}
@ -54,6 +59,10 @@ ndk::ScopedAStatus ModuleRemoteSubmix::createInputStream(
ndk::ScopedAStatus ModuleRemoteSubmix::createOutputStream(
StreamContext&& context, const SourceMetadata& sourceMetadata,
const std::optional<AudioOffloadInfo>& offloadInfo, std::shared_ptr<StreamOut>* result) {
if (context.getFormat().type != AudioFormatType::PCM) {
LOG(DEBUG) << __func__ << ": not supported for format " << context.getFormat().toString();
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
return createStreamInstance<StreamOutRemoteSubmix>(result, std::move(context), sourceMetadata,
offloadInfo);
}