Merge changes from topic "upstream-audio-aidl-hal"

* changes:
  Explicitly depend on V1 of android.media.audio.common.types
  Explicitly depend on audio.common-V1
  audio HAL: initial VTS tests
  audio HAL: Minimal example implementation
  audio HAL: Initial AIDL interfaces
This commit is contained in:
Treehugger Robot 2022-08-22 20:25:37 +00:00 committed by Gerrit Code Review
commit 2468ff5608
31 changed files with 3544 additions and 0 deletions

View file

@ -64,3 +64,28 @@ aidl_interface {
],
}
aidl_interface {
name: "android.hardware.audio.core",
vendor_available: true,
srcs: [
"android/hardware/audio/core/AudioPatch.aidl",
"android/hardware/audio/core/AudioRoute.aidl",
"android/hardware/audio/core/IConfig.aidl",
"android/hardware/audio/core/IModule.aidl",
"android/hardware/audio/core/IStreamIn.aidl",
"android/hardware/audio/core/IStreamOut.aidl",
],
imports: [
"android.hardware.audio.common-V1",
"android.media.audio.common.types-V1",
],
stability: "vintf",
backend: {
java: {
platform_apis: true,
},
},
versions: [
],
}

View file

@ -0,0 +1,40 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
// two cases:
// 1). this is a frozen version file - do not edit this in any case.
// 2). this is a 'current' file. If you make a backwards compatible change to
// the interface (from the latest frozen version), the build system will
// prompt you to update this file with `m <name>-update-api`.
//
// You must not make a backward incompatible change to any AIDL file built
// with the aidl_interface module type with versions property set. The module
// type is used to build AIDL files in a way that they can be used across
// independently updatable components of the system. If a device is shipped
// with such a backward incompatible change, it has a high risk of breaking
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.audio.core;
@JavaDerive(equals=true, toString=true) @VintfStability
parcelable AudioPatch {
int id;
int[] sourcePortConfigIds;
int[] sinkPortConfigIds;
}

View file

@ -0,0 +1,40 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
// two cases:
// 1). this is a frozen version file - do not edit this in any case.
// 2). this is a 'current' file. If you make a backwards compatible change to
// the interface (from the latest frozen version), the build system will
// prompt you to update this file with `m <name>-update-api`.
//
// You must not make a backward incompatible change to any AIDL file built
// with the aidl_interface module type with versions property set. The module
// type is used to build AIDL files in a way that they can be used across
// independently updatable components of the system. If a device is shipped
// with such a backward incompatible change, it has a high risk of breaking
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.audio.core;
@JavaDerive(equals=true, toString=true) @VintfStability
parcelable AudioRoute {
int[] sourcePortIds;
int sinkPortId;
boolean isExclusive;
}

View file

@ -0,0 +1,37 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
// two cases:
// 1). this is a frozen version file - do not edit this in any case.
// 2). this is a 'current' file. If you make a backwards compatible change to
// the interface (from the latest frozen version), the build system will
// prompt you to update this file with `m <name>-update-api`.
//
// You must not make a backward incompatible change to any AIDL file built
// with the aidl_interface module type with versions property set. The module
// type is used to build AIDL files in a way that they can be used across
// independently updatable components of the system. If a device is shipped
// with such a backward incompatible change, it has a high risk of breaking
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.audio.core;
@VintfStability
interface IConfig {
}

View file

@ -0,0 +1,48 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
// two cases:
// 1). this is a frozen version file - do not edit this in any case.
// 2). this is a 'current' file. If you make a backwards compatible change to
// the interface (from the latest frozen version), the build system will
// prompt you to update this file with `m <name>-update-api`.
//
// You must not make a backward incompatible change to any AIDL file built
// with the aidl_interface module type with versions property set. The module
// type is used to build AIDL files in a way that they can be used across
// independently updatable components of the system. If a device is shipped
// with such a backward incompatible change, it has a high risk of breaking
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.audio.core;
@VintfStability
interface IModule {
android.hardware.audio.core.AudioPatch[] getAudioPatches();
android.media.audio.common.AudioPort getAudioPort(int portId);
android.media.audio.common.AudioPortConfig[] getAudioPortConfigs();
android.media.audio.common.AudioPort[] getAudioPorts();
android.hardware.audio.core.AudioRoute[] getAudioRoutes();
android.hardware.audio.core.IStreamIn openInputStream(int portConfigId, in android.hardware.audio.common.SinkMetadata sinkMetadata);
android.hardware.audio.core.IStreamOut openOutputStream(int portConfigId, in android.hardware.audio.common.SourceMetadata sourceMetadata, in @nullable android.media.audio.common.AudioOffloadInfo offloadInfo);
android.hardware.audio.core.AudioPatch setAudioPatch(in android.hardware.audio.core.AudioPatch requested);
boolean setAudioPortConfig(in android.media.audio.common.AudioPortConfig requested, out android.media.audio.common.AudioPortConfig suggested);
void resetAudioPatch(int patchId);
void resetAudioPortConfig(int portConfigId);
}

View file

@ -0,0 +1,39 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
// two cases:
// 1). this is a frozen version file - do not edit this in any case.
// 2). this is a 'current' file. If you make a backwards compatible change to
// the interface (from the latest frozen version), the build system will
// prompt you to update this file with `m <name>-update-api`.
//
// You must not make a backward incompatible change to any AIDL file built
// with the aidl_interface module type with versions property set. The module
// type is used to build AIDL files in a way that they can be used across
// independently updatable components of the system. If a device is shipped
// with such a backward incompatible change, it has a high risk of breaking
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.audio.core;
@VintfStability
interface IStreamIn {
void close();
void updateMetadata(in android.hardware.audio.common.SinkMetadata sinkMetadata);
}

View file

@ -0,0 +1,39 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE. //
///////////////////////////////////////////////////////////////////////////////
// This file is a snapshot of an AIDL file. Do not edit it manually. There are
// two cases:
// 1). this is a frozen version file - do not edit this in any case.
// 2). this is a 'current' file. If you make a backwards compatible change to
// the interface (from the latest frozen version), the build system will
// prompt you to update this file with `m <name>-update-api`.
//
// You must not make a backward incompatible change to any AIDL file built
// with the aidl_interface module type with versions property set. The module
// type is used to build AIDL files in a way that they can be used across
// independently updatable components of the system. If a device is shipped
// with such a backward incompatible change, it has a high risk of breaking
// later when a module using the interface is updated, e.g., Mainline modules.
package android.hardware.audio.core;
@VintfStability
interface IStreamOut {
void close();
void updateMetadata(in android.hardware.audio.common.SourceMetadata sourceMetadata);
}

View file

@ -0,0 +1,40 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.hardware.audio.core;
/**
* Audio patch specifies a connection between multiple audio port
* configurations.
*/
@JavaDerive(equals=true, toString=true)
@VintfStability
parcelable AudioPatch {
/** The ID of the patch, unique within the HAL module. */
int id;
/**
* The list of IDs of source audio port configs ('AudioPortConfig.id').
* There must be at least one source in a valid patch and all IDs must be
* unique.
*/
int[] sourcePortConfigIds;
/**
* The list of IDs of sink audio port configs ('AudioPortConfig.id').
* There must be at least one sink in a valid patch and all IDs must be
* unique.
*/
int[] sinkPortConfigIds;
}

View file

@ -0,0 +1,39 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.hardware.audio.core;
/**
* Audio route specifies a path from multiple audio source ports to one audio
* sink port. As an example, when emitting audio output, source ports typically
* are mix ports (audio data from the framework), the sink is a device
* port. When acquiring audio, source ports are device ports, the sink is a mix
* port.
*/
@JavaDerive(equals=true, toString=true)
@VintfStability
parcelable AudioRoute {
/**
* The list of IDs of source audio ports ('AudioPort.id').
* There must be at least one source in a valid route and all IDs must be
* unique.
*/
int[] sourcePortIds;
/** The ID of the sink audio port ('AudioPort.id'). */
int sinkPortId;
/** If set, only one source can be active, mixing is not supported. */
boolean isExclusive;
}

View file

@ -0,0 +1,24 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.hardware.audio.core;
/**
* This interface provides system-wide configuration parameters for audio I/O
* (by "system" here we mean the device running Android).
*/
@VintfStability
interface IConfig {}

View file

@ -0,0 +1,281 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.hardware.audio.core;
import android.hardware.audio.common.SinkMetadata;
import android.hardware.audio.common.SourceMetadata;
import android.hardware.audio.core.AudioPatch;
import android.hardware.audio.core.AudioRoute;
import android.hardware.audio.core.IStreamIn;
import android.hardware.audio.core.IStreamOut;
import android.media.audio.common.AudioOffloadInfo;
import android.media.audio.common.AudioPort;
import android.media.audio.common.AudioPortConfig;
/**
* Each instance of IModule corresponds to a separate audio module. The system
* (the term "system" as used here applies to the entire device running Android)
* may have multiple modules due to the physical architecture, for example, it
* can have multiple DSPs or other audio I/O units which are not interconnected
* in hardware directly. Usually there is at least one audio module which is
* responsible for the "main" (or "built-in") audio functionality of the
* system. Even if the system lacks any physical audio I/O capabilities, there
* will be a "null" audio module.
*
* On a typical mobile phone there is usually a main DSP module which handles
* most of the phone's audio I/O via the built-in speakers and microphones. USB
* audio can exist as a separate module. Some audio modules can be implemented
* purely in software, for example, the remote submix module.
*/
@VintfStability
interface IModule {
/**
* Return all audio patches of this module.
*
* Returns a list of audio patches, that is, established connections between
* audio port configurations.
*
* @return The list of audio patches.
*/
AudioPatch[] getAudioPatches();
/**
* Return the current state of the audio port.
*
* Using the port ID provided on input, returns the current state of the
* audio port. For device port representing a connection to some external
* device, e.g. over HDMI or USB, currently supported audio profiles and
* extra audio descriptors may change.
*
* For all other audio ports it must be the same configuration as returned
* for this port ID by 'getAudioPorts'.
*
* @return The current state of an audio port.
* @param portId The ID of the audio port.
* @throws EX_ILLEGAL_ARGUMENT If the port can not be found by the ID.
*/
AudioPort getAudioPort(int portId);
/**
* Return all active audio port configurations of this module.
*
* Returns a list of active configurations that are currently set for mix
* ports and device ports. Each returned configuration must have an unique
* ID within this module ('AudioPortConfig.id' field), which can coincide
* with an ID of an audio port, if the port only supports a single active
* configuration. Each returned configuration must also have a reference to
* an existing port ('AudioPortConfig.portId' field). All optional
* (nullable) fields of the configurations must be initialized by the HAL
* module.
*
* @return The list of active audio port configurations.
*/
AudioPortConfig[] getAudioPortConfigs();
/**
* Return all audio ports provided by this module.
*
* Returns a list of all mix ports and device ports provided by this
* module. Each returned port must have a unique ID within this module
* ('AudioPort.id' field). The returned list must not change during
* the lifetime of the IModule instance. For audio ports with dynamic
* profiles (changing depending on external devices being connected
* to the system) an empty list of profiles must be returned. The list
* of currently supported audio profiles is obtained from 'getAudioPort'
* method.
*
* @return The list of audio ports.
*/
AudioPort[] getAudioPorts();
/**
* Return all audio routes of this module.
*
* Returns a list of audio routes, that is, allowed connections between
* audio ports. The returned list must not change during the lifetime of the
* IModule instance.
*
* @return The list of audio routes.
*/
AudioRoute[] getAudioRoutes();
/**
* Open an input stream using an existing audio mix port configuration.
*
* The audio port configuration ID must be obtained by calling
* 'setAudioPortConfig' method. Existence of an audio patch involving this
* port configuration is not required for successful opening of a stream.
*
* Only one stream is allowed per audio port configuration. HAL module can
* also set a limit on how many output streams can be opened for a particular
* mix port by using its 'AudioPortMixExt.maxOpenStreamCount' field.
*
* @return An opened input stream.
* @param portConfigId The ID of the audio mix port config.
* @param sinkMetadata Description of the audio that will be recorded.
* @throws EX_ILLEGAL_ARGUMENT In the following cases:
* - If the port config can not be found by the ID.
* - If the port config is not of an input mix port.
* @throws EX_ILLEGAL_STATE In the following cases:
* - If the port config already has a stream opened on it.
* - If the limit on the open stream count for the port has
* been reached.
*/
IStreamIn openInputStream(int portConfigId, in SinkMetadata sinkMetadata);
/**
* Open an output stream using an existing audio mix port configuration.
*
* The audio port configuration ID must be obtained by calling
* 'setAudioPortConfig' method. Existence of an audio patch involving this
* port configuration is not required for successful opening of a stream.
*
* If the port configuration has 'COMPRESS_OFFLOAD' output flag set,
* the framework must provide additional information about the encoded
* audio stream in 'offloadInfo' argument.
*
* Only one stream is allowed per audio port configuration. HAL module can
* also set a limit on how many output streams can be opened for a particular
* mix port by using its 'AudioPortMixExt.maxOpenStreamCount' field.
* Only one stream can be opened on the audio port with 'PRIMARY' output
* flag. This rule can not be overridden with 'maxOpenStreamCount' field.
*
* @return An opened output stream.
* @param portConfigId The ID of the audio mix port config.
* @param sourceMetadata Description of the audio that will be played.
* @param offloadInfo Additional information for offloaded playback.
* @throws EX_ILLEGAL_ARGUMENT In the following cases:
* - If the port config can not be found by the ID.
* - If the port config is not of an output mix port.
* @throws EX_ILLEGAL_STATE In the following cases:
* - If the port config already has a stream opened on it.
* - If the limit on the open stream count for the port has
* been reached.
* - If another opened stream already exists for the 'PRIMARY'
* output port.
*/
IStreamOut openOutputStream(int portConfigId, in SourceMetadata sourceMetadata,
in @nullable AudioOffloadInfo offloadInfo);
/**
* Set an audio patch.
*
* This method creates new or updates an existing audio patch. If the
* requested audio patch does not have a specified id, then a new patch is
* created and an ID is allocated for it by the HAL module. Otherwise an
* attempt to update an existing patch is made. It is recommended that
* updating of an existing audio patch should be performed by the HAL module
* in a way that does not interrupt active audio streams involving audio
* port configurations of the patch. If the HAL module is unable to avoid
* interruption when updating a certain patch, it is permitted to allocate a
* new patch ID for the result. The returned audio patch contains all the
* information about the new or updated audio patch.
*
* Audio port configurations specified in the patch must be obtained by
* calling 'setAudioPortConfig' method. There must be an audio route which
* allows connection between the audio ports whose configurations are used.
* An audio patch may be created before or after an audio steam is created
* for this configuration.
*
* @return Resulting audio patch.
* @param requested Requested audio patch.
* @throws EX_ILLEGAL_ARGUMENT In the following cases:
* - If the patch is invalid (see AudioPatch).
* - If a port config can not be found from the specified IDs.
* - If there are no routes satisfying the patch.
* - If an existing patch can not be found by the ID.
* @throws EX_ILLEGAL_STATE In the following cases:
* - If application of the patch can only use a route with an
* exclusive use the sink port, and it is already patched.
* @throws EX_UNSUPPORTED_OPERATION If the patch can not be established because
* the HAL module does not support this otherwise valid
* patch configuration. For example, if it's a patch
* between multiple sources and sinks, and the HAL module
* does not support this.
*/
AudioPatch setAudioPatch(in AudioPatch requested);
/**
* Set the active configuration of an audio port.
*
* This method is used to create or update an active configuration for a mix
* port or a device port. The port is specified using the
* 'AudioPortConfig.portId' field. If the requested audio port
* configuration does not have a specified id in the 'AudioPortConfig.id'
* field, then a new configuration is created and an ID is allocated for it
* by the HAL module. Otherwise an attempt to update an existing port
* configuration is made. The HAL module returns the resulting audio port
* configuration. Depending on the port and on the capabilities of the HAL
* module, it can either update an existing port configuration (same port
* configuration ID remains), or create a new one. The resulting port
* configuration ID is returned in the 'id' field of the 'suggested'
* argument.
*
* If the specified port configuration can not be set, this method must
* return 'false' and provide its own suggestion in the output
* parameter. The framework can then set the suggested configuration on a
* subsequent retry call to this method.
*
* @return Whether the requested configuration has been applied.
* @param requested Requested audio port configuration.
* @param suggested Same as requested configuration, if it was applied.
* Suggested audio port configuration if the requested
* configuration can't be applied.
* @throws EX_ILLEGAL_ARGUMENT In the following cases:
* - If neither port config ID, nor port ID are specified.
* - If an existing port config can not be found by the ID.
* - If the port can not be found by the port ID.
* - If it is not possible to generate a suggested port
* configuration, for example, if the port only has dynamic
* profiles and they are currently empty.
*/
boolean setAudioPortConfig(in AudioPortConfig requested, out AudioPortConfig suggested);
/**
* Reset the audio patch.
*
* Resets previously created audio patch using its ID ('AudioPatch.id'). It
* is allowed to reset a patch which uses audio port configurations having
* associated streams. In this case the mix port becomes disconnected from
* the hardware, but the stream does not close.
*
* @param patchId The ID of the audio patch.
* @throws EX_ILLEGAL_ARGUMENT If an existing patch can not be found by the ID.
*/
void resetAudioPatch(int patchId);
/**
* Reset the audio port configuration.
*
* Resets the specified audio port configuration, discarding all changes
* previously done by the framework. That means, if a call to this method is
* a success, the effect of all previous calls to 'setAudioPortConfig' which
* used or initially have generated the provided 'portConfigId', since the
* module start, or since the last call to this method, has been canceled.
*
* Audio port configurations of mix ports with streams opened on them can
* not be reset. Also can not be reset port configurations currently used by
* any patches.
*
* @param portConfigId The ID of the audio port config.
* @throws EX_ILLEGAL_ARGUMENT If the port config can not be found by the ID.
* @throws EX_ILLEGAL_STATE In the following cases:
* - If the port config has a stream opened on it;
* - If the port config is used by a patch.
*/
void resetAudioPortConfig(int portConfigId);
}

View file

@ -0,0 +1,46 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.hardware.audio.core;
import android.hardware.audio.common.SinkMetadata;
/**
* This interface provides means for receiving audio data from input devices.
*/
@VintfStability
interface IStreamIn {
/**
* Close the stream.
*
* Releases any resources allocated for this stream on the HAL module side.
* The stream can not be operated after it has been closed. Methods of this
* interface throw EX_ILLEGAL_STATE in for a closed stream.
*
* @throws EX_ILLEGAL_STATE If the stream has already been closed.
*/
void close();
/**
* Update stream metadata.
*
* Updates the metadata initially provided at the stream creation.
*
* @param sinkMetadata Updated metadata.
* @throws EX_ILLEGAL_STATE If the stream is closed.
*/
void updateMetadata(in SinkMetadata sinkMetadata);
}

View file

@ -0,0 +1,46 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package android.hardware.audio.core;
import android.hardware.audio.common.SourceMetadata;
/**
* This interface provides means for sending audio data to output devices.
*/
@VintfStability
interface IStreamOut {
/**
* Close the stream.
*
* Releases any resources allocated for this stream on the HAL module side.
* The stream can not be operated after it has been closed. Methods of this
* interface throw EX_ILLEGAL_STATE in for a closed stream.
*
* @throws EX_ILLEGAL_STATE If the stream has already been closed.
*/
void close();
/**
* Update stream metadata.
*
* Updates the metadata initially provided at the stream creation.
*
* @param sourceMetadata Updated metadata.
* @throws EX_ILLEGAL_STATE If the stream is closed.
*/
void updateMetadata(in SourceMetadata sourceMetadata);
}

View file

@ -0,0 +1,45 @@
package {
// See: http://go/android-license-faq
// A large-scale-change added 'default_applicable_licenses' to import
// all of the 'license_kinds' from "hardware_interfaces_license"
// to get the below license kinds:
// SPDX-license-identifier-Apache-2.0
default_applicable_licenses: ["hardware_interfaces_license"],
}
cc_library_static {
name: "libaudioserviceexampleimpl",
vendor: true,
shared_libs: [
"libbase",
"libbinder_ndk",
"android.hardware.audio.core-V1-ndk",
],
export_include_dirs: ["include"],
srcs: [
"Config.cpp",
"Configuration.cpp",
"Module.cpp",
"Stream.cpp",
],
visibility: [
":__subpackages__",
],
}
cc_binary {
name: "android.hardware.audio.service-aidl.example",
relative_install_path: "hw",
init_rc: ["android.hardware.audio.service-aidl.example.rc"],
vintf_fragments: ["android.hardware.audio.service-aidl.xml"],
vendor: true,
shared_libs: [
"libbase",
"libbinder_ndk",
"android.hardware.audio.core-V1-ndk",
],
static_libs: [
"libaudioserviceexampleimpl",
],
srcs: ["main.cpp"],
}

View file

@ -0,0 +1,19 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "core-impl/Config.h"
namespace aidl::android::hardware::audio::core {} // namespace aidl::android::hardware::audio::core

View file

@ -0,0 +1,196 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <aidl/android/media/audio/common/AudioChannelLayout.h>
#include <aidl/android/media/audio/common/AudioDeviceType.h>
#include <aidl/android/media/audio/common/AudioFormatType.h>
#include <aidl/android/media/audio/common/AudioIoFlags.h>
#include <aidl/android/media/audio/common/AudioOutputFlags.h>
#include "aidl/android/media/audio/common/AudioFormatDescription.h"
#include "core-impl/Configuration.h"
using aidl::android::media::audio::common::AudioChannelLayout;
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::AudioIoFlags;
using aidl::android::media::audio::common::AudioOutputFlags;
using aidl::android::media::audio::common::AudioPort;
using aidl::android::media::audio::common::AudioPortConfig;
using aidl::android::media::audio::common::AudioPortDeviceExt;
using aidl::android::media::audio::common::AudioPortExt;
using aidl::android::media::audio::common::AudioPortMixExt;
using aidl::android::media::audio::common::AudioProfile;
using aidl::android::media::audio::common::Int;
using aidl::android::media::audio::common::PcmType;
namespace aidl::android::hardware::audio::core::internal {
static AudioProfile createProfile(PcmType pcmType, const std::vector<int32_t>& channelLayouts,
const std::vector<int32_t>& sampleRates) {
AudioProfile profile;
profile.format.type = AudioFormatType::PCM;
profile.format.pcm = pcmType;
for (auto layout : channelLayouts) {
profile.channelMasks.push_back(
AudioChannelLayout::make<AudioChannelLayout::layoutMask>(layout));
}
profile.sampleRates.insert(profile.sampleRates.end(), sampleRates.begin(), sampleRates.end());
return profile;
}
static AudioPortExt createDeviceExt(AudioDeviceType devType, int32_t flags) {
AudioPortDeviceExt deviceExt;
deviceExt.device.type.type = devType;
deviceExt.flags = flags;
return AudioPortExt::make<AudioPortExt::Tag::device>(deviceExt);
}
static AudioPortExt createPortMixExt(int32_t maxOpenStreamCount, int32_t maxActiveStreamCount) {
AudioPortMixExt mixExt;
mixExt.maxOpenStreamCount = maxOpenStreamCount;
mixExt.maxActiveStreamCount = maxActiveStreamCount;
return AudioPortExt::make<AudioPortExt::Tag::mix>(mixExt);
}
static AudioPort createPort(int32_t id, const std::string& name, int32_t flags, bool isInput,
const AudioPortExt& ext) {
AudioPort port;
port.id = id;
port.name = name;
port.flags = isInput ? AudioIoFlags::make<AudioIoFlags::Tag::input>(flags)
: AudioIoFlags::make<AudioIoFlags::Tag::output>(flags);
port.ext = ext;
return port;
}
static AudioPortConfig createPortConfig(int32_t id, int32_t portId, PcmType pcmType, int32_t layout,
int32_t sampleRate, int32_t flags, bool isInput,
const AudioPortExt& ext) {
AudioPortConfig config;
config.id = id;
config.portId = portId;
config.sampleRate = Int{.value = sampleRate};
config.channelMask = AudioChannelLayout::make<AudioChannelLayout::layoutMask>(layout);
config.format = AudioFormatDescription{.type = AudioFormatType::PCM, .pcm = pcmType};
config.gain = AudioGainConfig();
config.flags = isInput ? AudioIoFlags::make<AudioIoFlags::Tag::input>(flags)
: AudioIoFlags::make<AudioIoFlags::Tag::output>(flags);
config.ext = ext;
return config;
}
static AudioRoute createRoute(const std::vector<int32_t>& sources, int32_t sink) {
AudioRoute route;
route.sinkPortId = sink;
route.sourcePortIds.insert(route.sourcePortIds.end(), sources.begin(), sources.end());
return route;
}
Configuration& getNullPrimaryConfiguration() {
static Configuration configuration = []() {
Configuration c;
AudioPort nullOutDevice =
createPort(c.nextPortId++, "Null", 0, false,
createDeviceExt(AudioDeviceType::OUT_SPEAKER,
1 << AudioPortDeviceExt::FLAG_INDEX_DEFAULT_DEVICE));
c.ports.push_back(nullOutDevice);
AudioPort primaryOutMix = createPort(c.nextPortId++, "primary output",
1 << static_cast<int32_t>(AudioOutputFlags::PRIMARY),
false, createPortMixExt(1, 1));
primaryOutMix.profiles.push_back(
createProfile(PcmType::INT_16_BIT,
{AudioChannelLayout::LAYOUT_MONO, AudioChannelLayout::LAYOUT_STEREO},
{44100, 48000}));
primaryOutMix.profiles.push_back(
createProfile(PcmType::INT_24_BIT,
{AudioChannelLayout::LAYOUT_MONO, AudioChannelLayout::LAYOUT_STEREO},
{44100, 48000}));
c.ports.push_back(primaryOutMix);
c.routes.push_back(createRoute({primaryOutMix.id}, nullOutDevice.id));
c.initialConfigs.push_back(
createPortConfig(nullOutDevice.id, nullOutDevice.id, PcmType::INT_24_BIT,
AudioChannelLayout::LAYOUT_STEREO, 48000, 0, false,
createDeviceExt(AudioDeviceType::OUT_SPEAKER, 0)));
AudioPort loopOutDevice = createPort(c.nextPortId++, "Loopback Out", 0, false,
createDeviceExt(AudioDeviceType::OUT_SUBMIX, 0));
loopOutDevice.profiles.push_back(
createProfile(PcmType::INT_24_BIT, {AudioChannelLayout::LAYOUT_STEREO}, {48000}));
c.ports.push_back(loopOutDevice);
AudioPort loopOutMix =
createPort(c.nextPortId++, "loopback output", 0, false, createPortMixExt(0, 0));
loopOutMix.profiles.push_back(
createProfile(PcmType::INT_24_BIT, {AudioChannelLayout::LAYOUT_STEREO}, {48000}));
c.ports.push_back(loopOutMix);
c.routes.push_back(createRoute({loopOutMix.id}, loopOutDevice.id));
AudioPort zeroInDevice =
createPort(c.nextPortId++, "Zero", 0, true,
createDeviceExt(AudioDeviceType::IN_MICROPHONE,
1 << AudioPortDeviceExt::FLAG_INDEX_DEFAULT_DEVICE));
c.ports.push_back(zeroInDevice);
AudioPort primaryInMix =
createPort(c.nextPortId++, "primary input", 0, true, createPortMixExt(2, 2));
primaryInMix.profiles.push_back(
createProfile(PcmType::INT_16_BIT,
{AudioChannelLayout::LAYOUT_MONO, AudioChannelLayout::LAYOUT_STEREO,
AudioChannelLayout::LAYOUT_FRONT_BACK},
{8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000}));
primaryInMix.profiles.push_back(
createProfile(PcmType::INT_24_BIT,
{AudioChannelLayout::LAYOUT_MONO, AudioChannelLayout::LAYOUT_STEREO,
AudioChannelLayout::LAYOUT_FRONT_BACK},
{8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000}));
c.ports.push_back(primaryInMix);
c.routes.push_back(createRoute({zeroInDevice.id}, primaryInMix.id));
c.initialConfigs.push_back(
createPortConfig(zeroInDevice.id, zeroInDevice.id, PcmType::INT_24_BIT,
AudioChannelLayout::LAYOUT_MONO, 48000, 0, true,
createDeviceExt(AudioDeviceType::IN_MICROPHONE, 0)));
AudioPort loopInDevice = createPort(c.nextPortId++, "Loopback In", 0, true,
createDeviceExt(AudioDeviceType::IN_SUBMIX, 0));
loopInDevice.profiles.push_back(
createProfile(PcmType::INT_24_BIT, {AudioChannelLayout::LAYOUT_STEREO}, {48000}));
c.ports.push_back(loopInDevice);
AudioPort loopInMix =
createPort(c.nextPortId++, "loopback input", 0, true, createPortMixExt(0, 0));
loopInMix.profiles.push_back(
createProfile(PcmType::INT_24_BIT, {AudioChannelLayout::LAYOUT_STEREO}, {48000}));
c.ports.push_back(loopInMix);
c.routes.push_back(createRoute({loopInDevice.id}, loopInMix.id));
c.portConfigs.insert(c.portConfigs.end(), c.initialConfigs.begin(), c.initialConfigs.end());
return c;
}();
return configuration;
}
} // namespace aidl::android::hardware::audio::core::internal

View file

@ -0,0 +1,522 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <algorithm>
#include <set>
#define LOG_TAG "AHAL_Module"
#define LOG_NDEBUG 0
#include <android-base/logging.h>
#include <aidl/android/media/audio/common/AudioOutputFlags.h>
#include "core-impl/Module.h"
#include "core-impl/utils.h"
using aidl::android::hardware::audio::common::SinkMetadata;
using aidl::android::hardware::audio::common::SourceMetadata;
using aidl::android::media::audio::common::AudioFormatDescription;
using aidl::android::media::audio::common::AudioIoFlags;
using aidl::android::media::audio::common::AudioOffloadInfo;
using aidl::android::media::audio::common::AudioOutputFlags;
using aidl::android::media::audio::common::AudioPort;
using aidl::android::media::audio::common::AudioPortConfig;
using aidl::android::media::audio::common::AudioPortExt;
using aidl::android::media::audio::common::AudioProfile;
using aidl::android::media::audio::common::Int;
namespace aidl::android::hardware::audio::core {
namespace {
bool generateDefaultPortConfig(const AudioPort& port, AudioPortConfig* config) {
*config = {};
config->portId = port.id;
if (port.profiles.empty()) {
LOG(ERROR) << __func__ << ": port " << port.id << " has no profiles";
return false;
}
const auto& profile = port.profiles.begin();
config->format = profile->format;
if (profile->channelMasks.empty()) {
LOG(ERROR) << __func__ << ": the first profile in port " << port.id
<< " has no channel masks";
return false;
}
config->channelMask = *profile->channelMasks.begin();
if (profile->sampleRates.empty()) {
LOG(ERROR) << __func__ << ": the first profile in port " << port.id
<< " has no sample rates";
return false;
}
Int sampleRate;
sampleRate.value = *profile->sampleRates.begin();
config->sampleRate = sampleRate;
config->flags = port.flags;
config->ext = port.ext;
return true;
}
bool findAudioProfile(const AudioPort& port, const AudioFormatDescription& format,
AudioProfile* profile) {
if (auto profilesIt =
find_if(port.profiles.begin(), port.profiles.end(),
[&format](const auto& profile) { return profile.format == format; });
profilesIt != port.profiles.end()) {
*profile = *profilesIt;
return true;
}
return false;
}
} // namespace
void Module::cleanUpPatch(int32_t patchId) {
erase_all_values(mPatches, std::set<int32_t>{patchId});
}
void Module::cleanUpPatches(int32_t portConfigId) {
auto& patches = getConfig().patches;
if (patches.size() == 0) return;
auto range = mPatches.equal_range(portConfigId);
for (auto it = range.first; it != range.second; ++it) {
auto patchIt = findById<AudioPatch>(patches, it->second);
if (patchIt != patches.end()) {
erase_if(patchIt->sourcePortConfigIds,
[portConfigId](auto e) { return e == portConfigId; });
erase_if(patchIt->sinkPortConfigIds,
[portConfigId](auto e) { return e == portConfigId; });
}
}
std::set<int32_t> erasedPatches;
for (size_t i = patches.size() - 1; i != 0; --i) {
const auto& patch = patches[i];
if (patch.sourcePortConfigIds.empty() || patch.sinkPortConfigIds.empty()) {
erasedPatches.insert(patch.id);
patches.erase(patches.begin() + i);
}
}
erase_all_values(mPatches, erasedPatches);
}
internal::Configuration& Module::getConfig() {
if (!mConfig) {
mConfig.reset(new internal::Configuration(internal::getNullPrimaryConfiguration()));
}
return *mConfig;
}
void Module::registerPatch(const AudioPatch& patch) {
auto& configs = getConfig().portConfigs;
auto do_insert = [&](const std::vector<int32_t>& portConfigIds) {
for (auto portConfigId : portConfigIds) {
auto configIt = findById<AudioPortConfig>(configs, portConfigId);
if (configIt != configs.end()) {
mPatches.insert(std::pair{portConfigId, patch.id});
if (configIt->portId != portConfigId) {
mPatches.insert(std::pair{configIt->portId, patch.id});
}
}
};
};
do_insert(patch.sourcePortConfigIds);
do_insert(patch.sinkPortConfigIds);
}
ndk::ScopedAStatus Module::getAudioPatches(std::vector<AudioPatch>* _aidl_return) {
*_aidl_return = getConfig().patches;
LOG(DEBUG) << __func__ << ": returning " << _aidl_return->size() << " patches";
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus Module::getAudioPort(int32_t in_portId, AudioPort* _aidl_return) {
auto& ports = getConfig().ports;
auto portIt = findById<AudioPort>(ports, in_portId);
if (portIt != ports.end()) {
*_aidl_return = *portIt;
LOG(DEBUG) << __func__ << ": returning port by id " << in_portId;
return ndk::ScopedAStatus::ok();
}
LOG(ERROR) << __func__ << ": port id " << in_portId << " not found";
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
ndk::ScopedAStatus Module::getAudioPortConfigs(std::vector<AudioPortConfig>* _aidl_return) {
*_aidl_return = getConfig().portConfigs;
LOG(DEBUG) << __func__ << ": returning " << _aidl_return->size() << " port configs";
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus Module::getAudioPorts(std::vector<AudioPort>* _aidl_return) {
*_aidl_return = getConfig().ports;
LOG(DEBUG) << __func__ << ": returning " << _aidl_return->size() << " ports";
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus Module::getAudioRoutes(std::vector<AudioRoute>* _aidl_return) {
*_aidl_return = getConfig().routes;
LOG(DEBUG) << __func__ << ": returning " << _aidl_return->size() << " routes";
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus Module::openInputStream(int32_t in_portConfigId,
const SinkMetadata& in_sinkMetadata,
std::shared_ptr<IStreamIn>* _aidl_return) {
auto& configs = getConfig().portConfigs;
auto portConfigIt = findById<AudioPortConfig>(configs, in_portConfigId);
if (portConfigIt == configs.end()) {
LOG(ERROR) << __func__ << ": existing port config id " << in_portConfigId << " not found";
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
const int32_t portId = portConfigIt->portId;
// In our implementation, configs of mix ports always have unique IDs.
CHECK(portId != in_portConfigId);
auto& ports = getConfig().ports;
auto portIt = findById<AudioPort>(ports, portId);
if (portIt == ports.end()) {
LOG(ERROR) << __func__ << ": port id " << portId << " used by port config id "
<< in_portConfigId << " not found";
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
if (portIt->flags.getTag() != AudioIoFlags::Tag::input ||
portIt->ext.getTag() != AudioPortExt::Tag::mix) {
LOG(ERROR) << __func__ << ": port config id " << in_portConfigId
<< " does not correspond to an input mix port";
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
if (mStreams.count(in_portConfigId) != 0) {
LOG(ERROR) << __func__ << ": port config id " << in_portConfigId
<< " already has a stream opened on it";
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
}
const int32_t maxOpenStreamCount = portIt->ext.get<AudioPortExt::Tag::mix>().maxOpenStreamCount;
if (maxOpenStreamCount != 0 && mStreams.count(portId) >= maxOpenStreamCount) {
LOG(ERROR) << __func__ << ": port id " << portId
<< " has already reached maximum allowed opened stream count: "
<< maxOpenStreamCount;
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
}
auto stream = ndk::SharedRefBase::make<StreamIn>(in_sinkMetadata);
mStreams.insert(portId, in_portConfigId, StreamWrapper(stream));
*_aidl_return = std::move(stream);
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus Module::openOutputStream(int32_t in_portConfigId,
const SourceMetadata& in_sourceMetadata,
const std::optional<AudioOffloadInfo>& in_offloadInfo,
std::shared_ptr<IStreamOut>* _aidl_return) {
auto& configs = getConfig().portConfigs;
auto portConfigIt = findById<AudioPortConfig>(configs, in_portConfigId);
if (portConfigIt == configs.end()) {
LOG(ERROR) << __func__ << ": existing port config id " << in_portConfigId << " not found";
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
const int32_t portId = portConfigIt->portId;
// In our implementation, configs of mix ports always have unique IDs.
CHECK(portId != in_portConfigId);
auto& ports = getConfig().ports;
auto portIt = findById<AudioPort>(ports, portId);
if (portIt == ports.end()) {
LOG(ERROR) << __func__ << ": port id " << portId << " used by port config id "
<< in_portConfigId << " not found";
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
if (portIt->flags.getTag() != AudioIoFlags::Tag::output ||
portIt->ext.getTag() != AudioPortExt::Tag::mix) {
LOG(ERROR) << __func__ << ": port config id " << in_portConfigId
<< " does not correspond to an output mix port";
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
if (mStreams.count(in_portConfigId) != 0) {
LOG(ERROR) << __func__ << ": port config id " << in_portConfigId
<< " already has a stream opened on it";
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
}
const int32_t maxOpenStreamCount = portIt->ext.get<AudioPortExt::Tag::mix>().maxOpenStreamCount;
if (maxOpenStreamCount != 0 && mStreams.count(portId) >= maxOpenStreamCount) {
LOG(ERROR) << __func__ << ": port id " << portId
<< " has already reached maximum allowed opened stream count: "
<< maxOpenStreamCount;
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
}
auto stream = ndk::SharedRefBase::make<StreamOut>(in_sourceMetadata, in_offloadInfo);
mStreams.insert(portId, in_portConfigId, StreamWrapper(stream));
*_aidl_return = std::move(stream);
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus Module::setAudioPatch(const AudioPatch& in_requested, AudioPatch* _aidl_return) {
if (in_requested.sourcePortConfigIds.empty()) {
LOG(ERROR) << __func__ << ": requested patch has empty sources list";
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
if (!all_unique<int32_t>(in_requested.sourcePortConfigIds)) {
LOG(ERROR) << __func__ << ": requested patch has duplicate ids in the sources list";
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
if (in_requested.sinkPortConfigIds.empty()) {
LOG(ERROR) << __func__ << ": requested patch has empty sinks list";
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
if (!all_unique<int32_t>(in_requested.sinkPortConfigIds)) {
LOG(ERROR) << __func__ << ": requested patch has duplicate ids in the sinks list";
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
auto& configs = getConfig().portConfigs;
std::vector<int32_t> missingIds;
auto sources =
selectByIds<AudioPortConfig>(configs, in_requested.sourcePortConfigIds, &missingIds);
if (!missingIds.empty()) {
LOG(ERROR) << __func__ << ": following source port config ids not found: "
<< ::android::internal::ToString(missingIds);
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
auto sinks = selectByIds<AudioPortConfig>(configs, in_requested.sinkPortConfigIds, &missingIds);
if (!missingIds.empty()) {
LOG(ERROR) << __func__ << ": following sink port config ids not found: "
<< ::android::internal::ToString(missingIds);
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
// bool indicates whether a non-exclusive route is available.
// If only an exclusive route is available, that means the patch can not be
// established if there is any other patch which currently uses the sink port.
std::map<int32_t, bool> allowedSinkPorts;
auto& routes = getConfig().routes;
for (auto src : sources) {
for (const auto& r : routes) {
const auto& srcs = r.sourcePortIds;
if (std::find(srcs.begin(), srcs.end(), src->portId) != srcs.end()) {
if (!allowedSinkPorts[r.sinkPortId]) { // prefer non-exclusive
allowedSinkPorts[r.sinkPortId] = !r.isExclusive;
}
}
}
}
for (auto sink : sinks) {
if (allowedSinkPorts.count(sink->portId) == 0) {
LOG(ERROR) << __func__ << ": there is no route to the sink port id " << sink->portId;
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
}
auto& patches = getConfig().patches;
auto existing = patches.end();
std::optional<decltype(mPatches)> patchesBackup;
if (in_requested.id != 0) {
existing = findById<AudioPatch>(patches, in_requested.id);
if (existing != patches.end()) {
patchesBackup = mPatches;
cleanUpPatch(existing->id);
} else {
LOG(ERROR) << __func__ << ": not found existing patch id " << in_requested.id;
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
}
// Validate the requested patch.
for (const auto& [sinkPortId, nonExclusive] : allowedSinkPorts) {
if (!nonExclusive && mPatches.count(sinkPortId) != 0) {
LOG(ERROR) << __func__ << ": sink port id " << sinkPortId
<< "is exclusive and is already used by some other patch";
if (patchesBackup.has_value()) {
mPatches = std::move(*patchesBackup);
}
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
}
}
*_aidl_return = in_requested;
if (existing == patches.end()) {
_aidl_return->id = getConfig().nextPatchId++;
patches.push_back(*_aidl_return);
existing = patches.begin() + (patches.size() - 1);
} else {
*existing = *_aidl_return;
}
registerPatch(*existing);
LOG(DEBUG) << __func__ << ": created or updated patch id " << _aidl_return->id;
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus Module::setAudioPortConfig(const AudioPortConfig& in_requested,
AudioPortConfig* out_suggested, bool* _aidl_return) {
LOG(DEBUG) << __func__ << ": requested " << in_requested.toString();
auto& configs = getConfig().portConfigs;
auto existing = configs.end();
if (in_requested.id != 0) {
if (existing = findById<AudioPortConfig>(configs, in_requested.id);
existing == configs.end()) {
LOG(ERROR) << __func__ << ": existing port config id " << in_requested.id
<< " not found";
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
}
const int portId = existing != configs.end() ? existing->portId : in_requested.portId;
if (portId == 0) {
LOG(ERROR) << __func__ << ": input port config does not specify portId";
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
auto& ports = getConfig().ports;
auto portIt = findById<AudioPort>(ports, portId);
if (portIt == ports.end()) {
LOG(ERROR) << __func__ << ": input port config points to non-existent portId " << portId;
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
if (existing != configs.end()) {
*out_suggested = *existing;
} else {
AudioPortConfig newConfig;
if (generateDefaultPortConfig(*portIt, &newConfig)) {
*out_suggested = newConfig;
} else {
LOG(ERROR) << __func__ << ": unable generate a default config for port " << portId;
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
}
// From this moment, 'out_suggested' is either an existing port config,
// or a new generated config. Now attempt to update it according to the specified
// fields of 'in_requested'.
bool requestedIsValid = true, requestedIsFullySpecified = true;
AudioIoFlags portFlags = portIt->flags;
if (in_requested.flags.has_value()) {
if (in_requested.flags.value() != portFlags) {
LOG(WARNING) << __func__ << ": requested flags "
<< in_requested.flags.value().toString() << " do not match port's "
<< portId << " flags " << portFlags.toString();
requestedIsValid = false;
}
} else {
requestedIsFullySpecified = false;
}
AudioProfile portProfile;
if (in_requested.format.has_value()) {
const auto& format = in_requested.format.value();
if (findAudioProfile(*portIt, format, &portProfile)) {
out_suggested->format = format;
} else {
LOG(WARNING) << __func__ << ": requested format " << format.toString()
<< " is not found in port's " << portId << " profiles";
requestedIsValid = false;
}
} else {
requestedIsFullySpecified = false;
}
if (!findAudioProfile(*portIt, out_suggested->format.value(), &portProfile)) {
LOG(ERROR) << __func__ << ": port " << portId << " does not support format "
<< out_suggested->format.value().toString() << " anymore";
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
if (in_requested.channelMask.has_value()) {
const auto& channelMask = in_requested.channelMask.value();
if (find(portProfile.channelMasks.begin(), portProfile.channelMasks.end(), channelMask) !=
portProfile.channelMasks.end()) {
out_suggested->channelMask = channelMask;
} else {
LOG(WARNING) << __func__ << ": requested channel mask " << channelMask.toString()
<< " is not supported for the format " << portProfile.format.toString()
<< " by the port " << portId;
requestedIsValid = false;
}
} else {
requestedIsFullySpecified = false;
}
if (in_requested.sampleRate.has_value()) {
const auto& sampleRate = in_requested.sampleRate.value();
if (find(portProfile.sampleRates.begin(), portProfile.sampleRates.end(),
sampleRate.value) != portProfile.sampleRates.end()) {
out_suggested->sampleRate = sampleRate;
} else {
LOG(WARNING) << __func__ << ": requested sample rate " << sampleRate.value
<< " is not supported for the format " << portProfile.format.toString()
<< " by the port " << portId;
requestedIsValid = false;
}
} else {
requestedIsFullySpecified = false;
}
if (in_requested.gain.has_value()) {
// Let's pretend that gain can always be applied.
out_suggested->gain = in_requested.gain.value();
}
if (existing == configs.end() && requestedIsValid && requestedIsFullySpecified) {
out_suggested->id = getConfig().nextPortId++;
configs.push_back(*out_suggested);
*_aidl_return = true;
LOG(DEBUG) << __func__ << ": created new port config " << out_suggested->toString();
} else if (existing != configs.end() && requestedIsValid) {
*existing = *out_suggested;
*_aidl_return = true;
LOG(DEBUG) << __func__ << ": updated port config " << out_suggested->toString();
} else {
LOG(DEBUG) << __func__ << ": not applied; existing config ? " << (existing != configs.end())
<< "; requested is valid? " << requestedIsValid << ", fully specified? "
<< requestedIsFullySpecified;
*_aidl_return = false;
}
return ndk::ScopedAStatus::ok();
}
ndk::ScopedAStatus Module::resetAudioPatch(int32_t in_patchId) {
auto& patches = getConfig().patches;
auto patchIt = findById<AudioPatch>(patches, in_patchId);
if (patchIt != patches.end()) {
cleanUpPatch(patchIt->id);
patches.erase(patchIt);
LOG(DEBUG) << __func__ << ": erased patch " << in_patchId;
return ndk::ScopedAStatus::ok();
}
LOG(ERROR) << __func__ << ": patch id " << in_patchId << " not found";
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
ndk::ScopedAStatus Module::resetAudioPortConfig(int32_t in_portConfigId) {
auto& configs = getConfig().portConfigs;
auto configIt = findById<AudioPortConfig>(configs, in_portConfigId);
if (configIt != configs.end()) {
if (mStreams.count(in_portConfigId) != 0) {
LOG(ERROR) << __func__ << ": port config id " << in_portConfigId
<< " has a stream opened on it";
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
}
auto patchIt = mPatches.find(in_portConfigId);
if (patchIt != mPatches.end()) {
LOG(ERROR) << __func__ << ": port config id " << in_portConfigId
<< " is used by the patch with id " << patchIt->second;
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
}
auto& initials = getConfig().initialConfigs;
auto initialIt = findById<AudioPortConfig>(initials, in_portConfigId);
if (initialIt == initials.end()) {
configs.erase(configIt);
LOG(DEBUG) << __func__ << ": erased port config " << in_portConfigId;
} else if (*configIt != *initialIt) {
*configIt = *initialIt;
LOG(DEBUG) << __func__ << ": reset port config " << in_portConfigId;
}
return ndk::ScopedAStatus::ok();
}
LOG(ERROR) << __func__ << ": port config id " << in_portConfigId << " not found";
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
}
} // namespace aidl::android::hardware::audio::core

View file

@ -0,0 +1,76 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define LOG_TAG "AHAL_Stream"
#define LOG_NDEBUG 0
#include <android-base/logging.h>
#include "core-impl/Stream.h"
using aidl::android::hardware::audio::common::SinkMetadata;
using aidl::android::hardware::audio::common::SourceMetadata;
using aidl::android::media::audio::common::AudioOffloadInfo;
namespace aidl::android::hardware::audio::core {
StreamIn::StreamIn(const SinkMetadata& sinkMetadata) : mMetadata(sinkMetadata) {}
ndk::ScopedAStatus StreamIn::close() {
LOG(DEBUG) << __func__;
if (!mIsClosed) {
mIsClosed = true;
return ndk::ScopedAStatus::ok();
} else {
LOG(ERROR) << __func__ << ": stream was already closed";
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
}
}
ndk::ScopedAStatus StreamIn::updateMetadata(const SinkMetadata& in_sinkMetadata) {
LOG(DEBUG) << __func__;
if (!mIsClosed) {
mMetadata = in_sinkMetadata;
return ndk::ScopedAStatus::ok();
}
LOG(ERROR) << __func__ << ": stream was closed";
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
}
StreamOut::StreamOut(const SourceMetadata& sourceMetadata,
const std::optional<AudioOffloadInfo>& offloadInfo)
: mMetadata(sourceMetadata), mOffloadInfo(offloadInfo) {}
ndk::ScopedAStatus StreamOut::close() {
LOG(DEBUG) << __func__;
if (!mIsClosed) {
mIsClosed = true;
return ndk::ScopedAStatus::ok();
}
LOG(ERROR) << __func__ << ": stream was already closed";
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
}
ndk::ScopedAStatus StreamOut::updateMetadata(const SourceMetadata& in_sourceMetadata) {
LOG(DEBUG) << __func__;
if (!mIsClosed) {
mMetadata = in_sourceMetadata;
return ndk::ScopedAStatus::ok();
}
LOG(ERROR) << __func__ << ": stream was closed";
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
}
} // namespace aidl::android::hardware::audio::core

View file

@ -0,0 +1,9 @@
service vendor.audio-hal-aidl /vendor/bin/hw/android.hardware.audio.service-aidl.example
class hal
user audioserver
# media gid needed for /dev/fm (radio) and for /data/misc/media (tee)
group audio camera drmrpc inet media mediadrm net_bt net_bt_admin net_bw_acct wakelock context_hub
capabilities BLOCK_SUSPEND
ioprio rt 4
task_profiles ProcessCapacityHigh HighPerformance
onrestart restart audioserver

View file

@ -0,0 +1,12 @@
<manifest version="1.0" type="device">
<hal format="aidl">
<name>android.hardware.audio.core</name>
<version>1</version>
<fqname>IModule/default</fqname>
</hal>
<hal format="aidl">
<name>android.hardware.audio.core</name>
<version>1</version>
<fqname>IConfig/default</fqname>
</hal>
</manifest>

View file

@ -0,0 +1,25 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <aidl/android/hardware/audio/core/BnConfig.h>
namespace aidl::android::hardware::audio::core {
class Config : public BnConfig {};
} // namespace aidl::android::hardware::audio::core

View file

@ -0,0 +1,40 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <vector>
#include <aidl/android/hardware/audio/core/AudioPatch.h>
#include <aidl/android/hardware/audio/core/AudioRoute.h>
#include <aidl/android/media/audio/common/AudioPort.h>
#include <aidl/android/media/audio/common/AudioPortConfig.h>
namespace aidl::android::hardware::audio::core::internal {
struct Configuration {
std::vector<::aidl::android::media::audio::common::AudioPort> ports;
std::vector<::aidl::android::media::audio::common::AudioPortConfig> portConfigs;
std::vector<::aidl::android::media::audio::common::AudioPortConfig> initialConfigs;
std::vector<AudioRoute> routes;
std::vector<AudioPatch> patches;
int32_t nextPortId = 1;
int32_t nextPatchId = 1;
};
Configuration& getNullPrimaryConfiguration();
} // namespace aidl::android::hardware::audio::core::internal

View file

@ -0,0 +1,72 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <map>
#include <memory>
#include <aidl/android/hardware/audio/core/BnModule.h>
#include "core-impl/Configuration.h"
#include "core-impl/Stream.h"
namespace aidl::android::hardware::audio::core {
class Module : public BnModule {
ndk::ScopedAStatus getAudioPatches(std::vector<AudioPatch>* _aidl_return) override;
ndk::ScopedAStatus getAudioPort(
int32_t in_portId,
::aidl::android::media::audio::common::AudioPort* _aidl_return) override;
ndk::ScopedAStatus getAudioPortConfigs(
std::vector<::aidl::android::media::audio::common::AudioPortConfig>* _aidl_return)
override;
ndk::ScopedAStatus getAudioPorts(
std::vector<::aidl::android::media::audio::common::AudioPort>* _aidl_return) override;
ndk::ScopedAStatus getAudioRoutes(std::vector<AudioRoute>* _aidl_return) override;
ndk::ScopedAStatus openInputStream(
int32_t in_portConfigId,
const ::aidl::android::hardware::audio::common::SinkMetadata& in_sinkMetadata,
std::shared_ptr<IStreamIn>* _aidl_return) override;
ndk::ScopedAStatus openOutputStream(
int32_t in_portConfigId,
const ::aidl::android::hardware::audio::common::SourceMetadata& in_sourceMetadata,
const std::optional<::aidl::android::media::audio::common::AudioOffloadInfo>&
in_offloadInfo,
std::shared_ptr<IStreamOut>* _aidl_return) override;
ndk::ScopedAStatus setAudioPatch(const AudioPatch& in_requested,
AudioPatch* _aidl_return) override;
ndk::ScopedAStatus setAudioPortConfig(
const ::aidl::android::media::audio::common::AudioPortConfig& in_requested,
::aidl::android::media::audio::common::AudioPortConfig* out_suggested,
bool* _aidl_return) override;
ndk::ScopedAStatus resetAudioPatch(int32_t in_patchId) override;
ndk::ScopedAStatus resetAudioPortConfig(int32_t in_portConfigId) override;
private:
void cleanUpPatch(int32_t patchId);
void cleanUpPatches(int32_t portConfigId);
internal::Configuration& getConfig();
void registerPatch(const AudioPatch& patch);
std::unique_ptr<internal::Configuration> mConfig;
Streams mStreams;
// Maps port ids and port config ids to patch ids.
// Multimap because both ports and configs can be used by multiple patches.
std::multimap<int32_t, int32_t> mPatches;
};
} // namespace aidl::android::hardware::audio::core

View file

@ -0,0 +1,103 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <map>
#include <optional>
#include <variant>
#include <aidl/android/hardware/audio/common/SinkMetadata.h>
#include <aidl/android/hardware/audio/common/SourceMetadata.h>
#include <aidl/android/hardware/audio/core/BnStreamIn.h>
#include <aidl/android/hardware/audio/core/BnStreamOut.h>
#include <aidl/android/media/audio/common/AudioOffloadInfo.h>
#include "core-impl/utils.h"
namespace aidl::android::hardware::audio::core {
class StreamIn : public BnStreamIn {
ndk::ScopedAStatus close() override;
ndk::ScopedAStatus updateMetadata(
const ::aidl::android::hardware::audio::common::SinkMetadata& in_sinkMetadata) override;
public:
explicit StreamIn(const ::aidl::android::hardware::audio::common::SinkMetadata& sinkMetadata);
bool isClosed() const { return mIsClosed; }
private:
::aidl::android::hardware::audio::common::SinkMetadata mMetadata;
bool mIsClosed = false;
};
class StreamOut : public BnStreamOut {
ndk::ScopedAStatus close() override;
ndk::ScopedAStatus updateMetadata(
const ::aidl::android::hardware::audio::common::SourceMetadata& in_sourceMetadata)
override;
public:
StreamOut(const ::aidl::android::hardware::audio::common::SourceMetadata& sourceMetadata,
const std::optional<::aidl::android::media::audio::common::AudioOffloadInfo>&
offloadInfo);
bool isClosed() const { return mIsClosed; }
private:
::aidl::android::hardware::audio::common::SourceMetadata mMetadata;
std::optional<::aidl::android::media::audio::common::AudioOffloadInfo> mOffloadInfo;
bool mIsClosed = false;
};
class StreamWrapper {
public:
explicit StreamWrapper(std::shared_ptr<StreamIn> streamIn) : mStream(streamIn) {}
explicit StreamWrapper(std::shared_ptr<StreamOut> streamOut) : mStream(streamOut) {}
bool isStreamOpen() const {
return std::visit(
[](auto&& ws) -> bool {
auto s = ws.lock();
return s && !s->isClosed();
},
mStream);
}
private:
std::variant<std::weak_ptr<StreamIn>, std::weak_ptr<StreamOut>> mStream;
};
class Streams {
public:
Streams() = default;
Streams(const Streams&) = delete;
Streams& operator=(const Streams&) = delete;
size_t count(int32_t id) {
// Streams do not remove themselves from the collection on close.
erase_if(mStreams, [](const auto& pair) { return !pair.second.isStreamOpen(); });
return mStreams.count(id);
}
void insert(int32_t portId, int32_t portConfigId, StreamWrapper sw) {
mStreams.insert(std::pair{portConfigId, sw});
mStreams.insert(std::pair{portId, sw});
}
private:
// Maps port ids and port config ids to streams. Multimap because a port
// (not port config) can have multiple streams opened on it.
std::multimap<int32_t, StreamWrapper> mStreams;
};
} // namespace aidl::android::hardware::audio::core

View file

@ -0,0 +1,104 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <algorithm>
#include <set>
#include <vector>
namespace aidl::android::hardware::audio::core {
// Return whether all the elements in the vector are unique.
template <typename T>
bool all_unique(const std::vector<T>& v) {
return std::set<T>(v.begin(), v.end()).size() == v.size();
}
// Erase all the specified elements from a map.
template <typename C, typename V>
auto erase_all(C& c, const V& keys) {
auto oldSize = c.size();
for (auto& k : keys) {
c.erase(k);
}
return oldSize - c.size();
}
// Erase all the elements in the map that satisfy the provided predicate.
template <typename C, typename P>
auto erase_if(C& c, P pred) {
auto oldSize = c.size();
for (auto it = c.begin(), last = c.end(); it != last;) {
if (pred(*it)) {
it = c.erase(it);
} else {
++it;
}
}
return oldSize - c.size();
}
// Erase all the elements in the map that have specified values.
template <typename C, typename V>
auto erase_all_values(C& c, const V& values) {
return erase_if(c, [values](const auto& pair) { return values.count(pair.second) != 0; });
}
// Return non-zero count of elements for any of the provided keys.
template <typename M, typename V>
size_t count_any(const M& m, const V& keys) {
for (auto& k : keys) {
if (size_t c = m.count(k); c != 0) return c;
}
return 0;
}
// Assuming that M is a map whose values have an 'id' field,
// find an element with the specified id.
template <typename M>
auto findById(M& m, int32_t id) {
return std::find_if(m.begin(), m.end(), [&](const auto& p) { return p.second.id == id; });
}
// Assuming that the vector contains elements with an 'id' field,
// find an element with the specified id.
template <typename T>
auto findById(std::vector<T>& v, int32_t id) {
return std::find_if(v.begin(), v.end(), [&](const auto& e) { return e.id == id; });
}
// Return elements from the vector that have specified ids, also
// optionally return which ids were not found.
template <typename T>
std::vector<T*> selectByIds(std::vector<T>& v, const std::vector<int32_t>& ids,
std::vector<int32_t>* missingIds = nullptr) {
std::vector<T*> result;
std::set<int32_t> idsSet(ids.begin(), ids.end());
for (size_t i = 0; i < v.size(); ++i) {
T& e = v[i];
if (idsSet.count(e.id) != 0) {
result.push_back(&v[i]);
idsSet.erase(e.id);
}
}
if (missingIds) {
*missingIds = std::vector(idsSet.begin(), idsSet.end());
}
return result;
}
} // namespace aidl::android::hardware::audio::core

View file

@ -0,0 +1,45 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "core-impl/Config.h"
#include "core-impl/Module.h"
#include <android-base/logging.h>
#include <android/binder_manager.h>
#include <android/binder_process.h>
using aidl::android::hardware::audio::core::Config;
using aidl::android::hardware::audio::core::Module;
int main() {
ABinderProcess_setThreadPoolMaxThreadCount(16);
// make the default config service
auto config = ndk::SharedRefBase::make<Config>();
const std::string configName = std::string() + Config::descriptor + "/default";
binder_status_t status =
AServiceManager_addService(config->asBinder().get(), configName.c_str());
CHECK(status == STATUS_OK);
// make the default module
auto moduleDefault = ndk::SharedRefBase::make<Module>();
const std::string moduleDefaultName = std::string() + Module::descriptor + "/default";
status = AServiceManager_addService(moduleDefault->asBinder().get(), moduleDefaultName.c_str());
CHECK(status == STATUS_OK);
ABinderProcess_joinThreadPool();
return EXIT_FAILURE; // should not reach
}

32
audio/aidl/vts/Android.bp Normal file
View file

@ -0,0 +1,32 @@
package {
// See: http://go/android-license-faq
// A large-scale-change added 'default_applicable_licenses' to import
// all of the 'license_kinds' from "hardware_interfaces_license"
// to get the below license kinds:
// SPDX-license-identifier-Apache-2.0
default_applicable_licenses: ["hardware_interfaces_license"],
}
cc_test {
name: "VtsHalAudioCoreTargetTest",
defaults: [
"VtsHalTargetTestDefaults",
"use_libaidlvintf_gtest_helper_static",
],
srcs: [
"ModuleConfig.cpp",
"VtsHalAudioCoreTargetTest.cpp",
],
shared_libs: [
"libbinder",
],
static_libs: [
"android.hardware.audio.common-V1-cpp",
"android.hardware.audio.core-V1-cpp",
"android.media.audio.common.types-V1-cpp",
],
test_suites: [
"general-tests",
"vts",
],
}

View file

@ -0,0 +1,330 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <algorithm>
#include <android/media/audio/common/AudioIoFlags.h>
#include <android/media/audio/common/AudioOutputFlags.h>
#include "ModuleConfig.h"
using namespace android;
using android::hardware::audio::core::IModule;
using android::media::audio::common::AudioChannelLayout;
using android::media::audio::common::AudioFormatDescription;
using android::media::audio::common::AudioFormatType;
using android::media::audio::common::AudioIoFlags;
using android::media::audio::common::AudioOutputFlags;
using android::media::audio::common::AudioPort;
using android::media::audio::common::AudioPortConfig;
using android::media::audio::common::AudioPortExt;
using android::media::audio::common::AudioProfile;
using android::media::audio::common::Int;
template <typename T>
auto findById(const std::vector<T>& v, int32_t id) {
return std::find_if(v.begin(), v.end(), [&](const auto& p) { return p.id == id; });
}
ModuleConfig::ModuleConfig(IModule* module) {
mStatus = module->getAudioPorts(&mPorts);
if (!mStatus.isOk()) return;
for (const auto& port : mPorts) {
if (port.ext.getTag() != AudioPortExt::Tag::device) continue;
const auto& devicePort = port.ext.get<AudioPortExt::Tag::device>();
const bool isInput = port.flags.getTag() == AudioIoFlags::Tag::input;
if (devicePort.device.type.connection.empty()) {
// Permanently attached device.
if (isInput) {
mAttachedSourceDevicePorts.insert(port.id);
} else {
mAttachedSinkDevicePorts.insert(port.id);
}
}
}
if (!mStatus.isOk()) return;
mStatus = module->getAudioRoutes(&mRoutes);
if (!mStatus.isOk()) return;
mStatus = module->getAudioPortConfigs(&mInitialConfigs);
}
std::vector<AudioPort> ModuleConfig::getInputMixPorts() const {
std::vector<AudioPort> result;
std::copy_if(mPorts.begin(), mPorts.end(), std::back_inserter(result), [](const auto& port) {
return port.ext.getTag() == AudioPortExt::Tag::mix &&
port.flags.getTag() == AudioIoFlags::Tag::input;
});
return result;
}
std::vector<AudioPort> ModuleConfig::getOutputMixPorts() const {
std::vector<AudioPort> result;
std::copy_if(mPorts.begin(), mPorts.end(), std::back_inserter(result), [](const auto& port) {
return port.ext.getTag() == AudioPortExt::Tag::mix &&
port.flags.getTag() == AudioIoFlags::Tag::output;
});
return result;
}
std::vector<AudioPort> ModuleConfig::getAttachedSinkDevicesPortsForMixPort(
const AudioPort& mixPort) const {
std::vector<AudioPort> result;
for (const auto& route : mRoutes) {
if (mAttachedSinkDevicePorts.count(route.sinkPortId) != 0 &&
std::find(route.sourcePortIds.begin(), route.sourcePortIds.end(), mixPort.id) !=
route.sourcePortIds.end()) {
const auto devicePortIt = findById<AudioPort>(mPorts, route.sinkPortId);
if (devicePortIt != mPorts.end()) result.push_back(*devicePortIt);
}
}
return result;
}
std::vector<AudioPort> ModuleConfig::getAttachedSourceDevicesPortsForMixPort(
const AudioPort& mixPort) const {
std::vector<AudioPort> result;
for (const auto& route : mRoutes) {
if (route.sinkPortId == mixPort.id) {
for (const auto srcId : route.sourcePortIds) {
if (mAttachedSourceDevicePorts.count(srcId) != 0) {
const auto devicePortIt = findById<AudioPort>(mPorts, srcId);
if (devicePortIt != mPorts.end()) result.push_back(*devicePortIt);
}
}
}
}
return result;
}
std::optional<AudioPort> ModuleConfig::getSourceMixPortForAttachedDevice() const {
for (const auto& route : mRoutes) {
if (mAttachedSinkDevicePorts.count(route.sinkPortId) != 0) {
const auto mixPortIt = findById<AudioPort>(mPorts, route.sourcePortIds[0]);
if (mixPortIt != mPorts.end()) return *mixPortIt;
}
}
return {};
}
std::optional<ModuleConfig::SrcSinkPair> ModuleConfig::getNonRoutableSrcSinkPair(
bool isInput) const {
const auto mixPorts = getMixPorts(isInput);
std::set<std::pair<int32_t, int32_t>> allowedRoutes;
for (const auto& route : mRoutes) {
for (const auto srcPortId : route.sourcePortIds) {
allowedRoutes.emplace(std::make_pair(srcPortId, route.sinkPortId));
}
}
auto make_pair = [isInput](auto& device, auto& mix) {
return isInput ? std::make_pair(device, mix) : std::make_pair(mix, device);
};
for (const auto portId : isInput ? mAttachedSourceDevicePorts : mAttachedSinkDevicePorts) {
const auto devicePortIt = findById<AudioPort>(mPorts, portId);
if (devicePortIt == mPorts.end()) continue;
auto devicePortConfig = getSingleConfigForDevicePort(*devicePortIt);
for (const auto& mixPort : mixPorts) {
if (std::find(allowedRoutes.begin(), allowedRoutes.end(),
make_pair(portId, mixPort.id)) == allowedRoutes.end()) {
auto mixPortConfig = getSingleConfigForMixPort(isInput, mixPort);
if (mixPortConfig.has_value()) {
return make_pair(devicePortConfig, mixPortConfig.value());
}
}
}
}
return {};
}
std::optional<ModuleConfig::SrcSinkPair> ModuleConfig::getRoutableSrcSinkPair(bool isInput) const {
if (isInput) {
for (const auto& route : mRoutes) {
auto srcPortIdIt = std::find_if(
route.sourcePortIds.begin(), route.sourcePortIds.end(),
[&](const auto& portId) { return mAttachedSourceDevicePorts.count(portId); });
if (srcPortIdIt == route.sourcePortIds.end()) continue;
const auto devicePortIt = findById<AudioPort>(mPorts, *srcPortIdIt);
const auto mixPortIt = findById<AudioPort>(mPorts, route.sinkPortId);
if (devicePortIt == mPorts.end() || mixPortIt == mPorts.end()) continue;
auto devicePortConfig = getSingleConfigForDevicePort(*devicePortIt);
auto mixPortConfig = getSingleConfigForMixPort(isInput, *mixPortIt);
if (!mixPortConfig.has_value()) continue;
return std::make_pair(devicePortConfig, mixPortConfig.value());
}
} else {
for (const auto& route : mRoutes) {
if (mAttachedSinkDevicePorts.count(route.sinkPortId) == 0) continue;
const auto mixPortIt = findById<AudioPort>(mPorts, route.sourcePortIds[0]);
const auto devicePortIt = findById<AudioPort>(mPorts, route.sinkPortId);
if (devicePortIt == mPorts.end() || mixPortIt == mPorts.end()) continue;
auto mixPortConfig = getSingleConfigForMixPort(isInput, *mixPortIt);
auto devicePortConfig = getSingleConfigForDevicePort(*devicePortIt);
if (!mixPortConfig.has_value()) continue;
return std::make_pair(mixPortConfig.value(), devicePortConfig);
}
}
return {};
}
std::vector<ModuleConfig::SrcSinkGroup> ModuleConfig::getRoutableSrcSinkGroups(bool isInput) const {
std::vector<SrcSinkGroup> result;
if (isInput) {
for (const auto& route : mRoutes) {
std::vector<int32_t> srcPortIds;
std::copy_if(route.sourcePortIds.begin(), route.sourcePortIds.end(),
std::back_inserter(srcPortIds), [&](const auto& portId) {
return mAttachedSourceDevicePorts.count(portId);
});
if (srcPortIds.empty()) continue;
const auto mixPortIt = findById<AudioPort>(mPorts, route.sinkPortId);
if (mixPortIt == mPorts.end()) continue;
auto mixPortConfig = getSingleConfigForMixPort(isInput, *mixPortIt);
if (!mixPortConfig.has_value()) continue;
std::vector<SrcSinkPair> pairs;
for (const auto srcPortId : srcPortIds) {
const auto devicePortIt = findById<AudioPort>(mPorts, srcPortId);
if (devicePortIt == mPorts.end()) continue;
// Using all configs for every source would be too much.
auto devicePortConfig = getSingleConfigForDevicePort(*devicePortIt);
pairs.emplace_back(devicePortConfig, mixPortConfig.value());
}
if (!pairs.empty()) {
result.emplace_back(route, std::move(pairs));
}
}
} else {
for (const auto& route : mRoutes) {
if (mAttachedSinkDevicePorts.count(route.sinkPortId) == 0) continue;
const auto devicePortIt = findById<AudioPort>(mPorts, route.sinkPortId);
if (devicePortIt == mPorts.end()) continue;
auto devicePortConfig = getSingleConfigForDevicePort(*devicePortIt);
std::vector<SrcSinkPair> pairs;
for (const auto srcPortId : route.sourcePortIds) {
const auto mixPortIt = findById<AudioPort>(mPorts, srcPortId);
if (mixPortIt == mPorts.end()) continue;
// Using all configs for every source would be too much.
auto mixPortConfig = getSingleConfigForMixPort(isInput, *mixPortIt);
if (mixPortConfig.has_value()) {
pairs.emplace_back(mixPortConfig.value(), devicePortConfig);
}
}
if (!pairs.empty()) {
result.emplace_back(route, std::move(pairs));
}
}
}
return result;
}
static std::vector<AudioPortConfig> combineAudioConfigs(const AudioPort& port,
const AudioProfile& profile) {
std::vector<AudioPortConfig> configs;
configs.reserve(profile.channelMasks.size() * profile.sampleRates.size());
for (auto channelMask : profile.channelMasks) {
for (auto sampleRate : profile.sampleRates) {
AudioPortConfig config{};
config.portId = port.id;
Int sr;
sr.value = sampleRate;
config.sampleRate = sr;
config.channelMask = channelMask;
config.format = profile.format;
config.ext = port.ext;
configs.push_back(config);
}
}
return configs;
}
std::vector<AudioPortConfig> ModuleConfig::generateInputAudioMixPortConfigs(
const std::vector<AudioPort>& ports, bool singleProfile) const {
std::vector<AudioPortConfig> result;
for (const auto& mixPort : ports) {
if (getAttachedSourceDevicesPortsForMixPort(mixPort).empty()) {
continue; // no attached devices
}
for (const auto& profile : mixPort.profiles) {
if (profile.format.type == AudioFormatType::DEFAULT || profile.sampleRates.empty() ||
profile.channelMasks.empty()) {
continue; // dynamic profile
}
auto configs = combineAudioConfigs(mixPort, profile);
for (auto& config : configs) {
config.flags = mixPort.flags;
result.push_back(config);
if (singleProfile) return result;
}
}
}
return result;
}
static std::tuple<AudioIoFlags, bool> generateOutFlags(const AudioPort& mixPort) {
static const AudioIoFlags offloadFlags = AudioIoFlags::make<AudioIoFlags::Tag::output>(
(1 << static_cast<int>(AudioOutputFlags::COMPRESS_OFFLOAD)) |
(1 << static_cast<int>(AudioOutputFlags::DIRECT)));
const bool isOffload = (mixPort.flags.get<AudioIoFlags::Tag::output>() &
(1 << static_cast<int>(AudioOutputFlags::COMPRESS_OFFLOAD))) != 0;
return {isOffload ? offloadFlags : mixPort.flags, isOffload};
}
std::vector<AudioPortConfig> ModuleConfig::generateOutputAudioMixPortConfigs(
const std::vector<AudioPort>& ports, bool singleProfile) const {
std::vector<AudioPortConfig> result;
for (const auto& mixPort : ports) {
if (getAttachedSinkDevicesPortsForMixPort(mixPort).empty()) {
continue; // no attached devices
}
auto [flags, isOffload] = generateOutFlags(mixPort);
(void)isOffload;
for (const auto& profile : mixPort.profiles) {
if (profile.format.type == AudioFormatType::DEFAULT) continue;
auto configs = combineAudioConfigs(mixPort, profile);
for (auto& config : configs) {
// Some combinations of flags declared in the config file require special
// treatment.
// if (isOffload) {
// config.offloadInfo.info(generateOffloadInfo(config.base));
// }
config.flags = flags;
result.push_back(config);
if (singleProfile) return result;
}
}
}
return result;
}
std::vector<AudioPortConfig> ModuleConfig::generateAudioDevicePortConfigs(
const std::vector<AudioPort>& ports, bool singleProfile) const {
std::vector<AudioPortConfig> result;
for (const auto& devicePort : ports) {
const size_t resultSizeBefore = result.size();
for (const auto& profile : devicePort.profiles) {
auto configs = combineAudioConfigs(devicePort, profile);
result.insert(result.end(), configs.begin(), configs.end());
if (singleProfile && !result.empty()) return result;
}
if (resultSizeBefore == result.size()) {
AudioPortConfig empty;
empty.portId = devicePort.id;
empty.ext = devicePort.ext;
result.push_back(empty);
}
if (singleProfile) return result;
}
return result;
}

View file

@ -0,0 +1,131 @@
/*
* Copyright (C) 2022 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <optional>
#include <set>
#include <utility>
#include <vector>
#include <android/hardware/audio/core/AudioRoute.h>
#include <android/hardware/audio/core/IModule.h>
#include <android/media/audio/common/AudioPort.h>
#include <binder/Status.h>
class ModuleConfig {
public:
using SrcSinkPair = std::pair<android::media::audio::common::AudioPortConfig,
android::media::audio::common::AudioPortConfig>;
using SrcSinkGroup =
std::pair<android::hardware::audio::core::AudioRoute, std::vector<SrcSinkPair>>;
explicit ModuleConfig(android::hardware::audio::core::IModule* module);
android::binder::Status getStatus() const { return mStatus; }
std::string getError() const { return mStatus.toString8().c_str(); }
std::vector<android::media::audio::common::AudioPort> getInputMixPorts() const;
std::vector<android::media::audio::common::AudioPort> getOutputMixPorts() const;
std::vector<android::media::audio::common::AudioPort> getMixPorts(bool isInput) const {
return isInput ? getInputMixPorts() : getOutputMixPorts();
}
std::vector<android::media::audio::common::AudioPort> getAttachedDevicesPortsForMixPort(
bool isInput, const android::media::audio::common::AudioPort& mixPort) const {
return isInput ? getAttachedSourceDevicesPortsForMixPort(mixPort)
: getAttachedSinkDevicesPortsForMixPort(mixPort);
}
std::vector<android::media::audio::common::AudioPort> getAttachedSinkDevicesPortsForMixPort(
const android::media::audio::common::AudioPort& mixPort) const;
std::vector<android::media::audio::common::AudioPort> getAttachedSourceDevicesPortsForMixPort(
const android::media::audio::common::AudioPort& mixPort) const;
std::optional<android::media::audio::common::AudioPort> getSourceMixPortForAttachedDevice()
const;
std::optional<SrcSinkPair> getNonRoutableSrcSinkPair(bool isInput) const;
std::optional<SrcSinkPair> getRoutableSrcSinkPair(bool isInput) const;
std::vector<SrcSinkGroup> getRoutableSrcSinkGroups(bool isInput) const;
std::vector<android::media::audio::common::AudioPortConfig> getPortConfigsForMixPorts() const {
auto inputs = generateInputAudioMixPortConfigs(getInputMixPorts(), false);
auto outputs = generateOutputAudioMixPortConfigs(getOutputMixPorts(), false);
inputs.insert(inputs.end(), outputs.begin(), outputs.end());
return inputs;
}
std::vector<android::media::audio::common::AudioPortConfig> getPortConfigsForMixPorts(
bool isInput) const {
return isInput ? generateInputAudioMixPortConfigs(getInputMixPorts(), false)
: generateOutputAudioMixPortConfigs(getOutputMixPorts(), false);
}
std::vector<android::media::audio::common::AudioPortConfig> getPortConfigsForMixPorts(
bool isInput, const android::media::audio::common::AudioPort& port) const {
return isInput ? generateInputAudioMixPortConfigs({port}, false)
: generateOutputAudioMixPortConfigs({port}, false);
}
std::optional<android::media::audio::common::AudioPortConfig> getSingleConfigForMixPort(
bool isInput) const {
const auto config = isInput ? generateInputAudioMixPortConfigs(getInputMixPorts(), true)
: generateOutputAudioMixPortConfigs(getOutputMixPorts(), true);
// TODO: Avoid returning configs for offload since they require an extra
// argument to openOutputStream.
if (!config.empty()) {
return *config.begin();
} else {
return {};
}
}
std::optional<android::media::audio::common::AudioPortConfig> getSingleConfigForMixPort(
bool isInput, const android::media::audio::common::AudioPort& port) const {
const auto config = isInput ? generateInputAudioMixPortConfigs({port}, true)
: generateOutputAudioMixPortConfigs({port}, true);
if (!config.empty()) {
return *config.begin();
} else {
return {};
}
}
android::media::audio::common::AudioPortConfig getSingleConfigForDevicePort(
const android::media::audio::common::AudioPort& port) const {
for (const auto& config : mInitialConfigs) {
if (config.portId == port.id) return config;
}
const auto config = generateAudioDevicePortConfigs({port}, true);
return *config.begin();
}
private:
std::vector<android::media::audio::common::AudioPortConfig> generateInputAudioMixPortConfigs(
const std::vector<android::media::audio::common::AudioPort>& ports,
bool singleProfile) const;
std::vector<android::media::audio::common::AudioPortConfig> generateOutputAudioMixPortConfigs(
const std::vector<android::media::audio::common::AudioPort>& ports,
bool singleProfile) const;
// Unlike MixPorts, the generator for DevicePorts always returns a non-empty
// vector for a non-empty input port list. If there are no profiles in the
// port, a vector with an empty config is returned.
std::vector<android::media::audio::common::AudioPortConfig> generateAudioDevicePortConfigs(
const std::vector<android::media::audio::common::AudioPort>& ports,
bool singleProfile) const;
android::binder::Status mStatus = android::binder::Status::ok();
std::vector<android::media::audio::common::AudioPort> mPorts;
std::vector<android::media::audio::common::AudioPortConfig> mInitialConfigs;
std::set<int32_t> mAttachedSinkDevicePorts;
std::set<int32_t> mAttachedSourceDevicePorts;
std::vector<android::hardware::audio::core::AudioRoute> mRoutes;
};

File diff suppressed because it is too large Load diff

View file

@ -25,6 +25,18 @@
<instance>default</instance>
</interface>
</hal>
<hal format="aidl" optional="true">
<name>android.hardware.audio.core</name>
<version>1</version>
<interface>
<name>IModule</name>
<instance>default</instance>
</interface>
<interface>
<name>IConfig</name>
<instance>default</instance>
</interface>
</hal>
<hal format="aidl" optional="true">
<name>android.hardware.authsecret</name>
<version>1</version>