diff options
Diffstat (limited to 'audio')
232 files changed, 7766 insertions, 7165 deletions
diff --git a/audio/5.0/Android.bp b/audio/5.0/Android.bp new file mode 100644 index 0000000000..27c1ef5f5e --- /dev/null +++ b/audio/5.0/Android.bp @@ -0,0 +1,48 @@ +// This file is autogenerated by hidl-gen -Landroidbp. + +hidl_interface { + name: "android.hardware.audio@5.0", + root: "android.hardware", + vndk: { + enabled: true, + }, + srcs: [ + "types.hal", + "IDevice.hal", + "IDevicesFactory.hal", + "IPrimaryDevice.hal", + "IStream.hal", + "IStreamIn.hal", + "IStreamOut.hal", + "IStreamOutCallback.hal", + ], + interfaces: [ + "android.hardware.audio.common@5.0", + "android.hardware.audio.effect@5.0", + "android.hidl.base@1.0", + ], + types: [ + "AudioDrain", + "AudioFrequencyResponsePoint", + "AudioMicrophoneChannelMapping", + "AudioMicrophoneCoordinate", + "AudioMicrophoneDirectionality", + "AudioMicrophoneLocation", + "DeviceAddress", + "MessageQueueFlagBits", + "MicrophoneInfo", + "MmapBufferFlag", + "MmapBufferInfo", + "MmapPosition", + "ParameterValue", + "PlaybackTrackMetadata", + "RecordTrackMetadata", + "Result", + "SinkMetadata", + "SourceMetadata", + "TimeSpec", + ], + gen_java: false, + gen_java_constants: true, +} + diff --git a/audio/5.0/IDevice.hal b/audio/5.0/IDevice.hal new file mode 100644 index 0000000000..afb4fad211 --- /dev/null +++ b/audio/5.0/IDevice.hal @@ -0,0 +1,282 @@ +/* + * Copyright (C) 2018 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@5.0; + +import android.hardware.audio.common@5.0; +import IStreamIn; +import IStreamOut; + +interface IDevice { + /** + * Returns whether the audio hardware interface has been initialized. + * + * @return retval OK on success, NOT_INITIALIZED on failure. + */ + initCheck() generates (Result retval); + + /** + * Sets the audio volume for all audio activities other than voice call. If + * NOT_SUPPORTED is returned, the software mixer will emulate this + * capability. + * + * @param volume 1.0f means unity, 0.0f is zero. + * @return retval operation completion status. + */ + setMasterVolume(float volume) generates (Result retval); + + /** + * Get the current master volume value for the HAL, if the HAL supports + * master volume control. For example, AudioFlinger will query this value + * from the primary audio HAL when the service starts and use the value for + * setting the initial master volume across all HALs. HALs which do not + * support this method must return NOT_SUPPORTED in 'retval'. + * + * @return retval operation completion status. + * @return volume 1.0f means unity, 0.0f is zero. + */ + getMasterVolume() generates (Result retval, float volume); + + /** + * Sets microphone muting state. + * + * @param mute whether microphone is muted. + * @return retval operation completion status. + */ + setMicMute(bool mute) generates (Result retval); + + /** + * Gets whether microphone is muted. + * + * @return retval operation completion status. + * @return mute whether microphone is muted. + */ + getMicMute() generates (Result retval, bool mute); + + /** + * Set the audio mute status for all audio activities. If the return value + * is NOT_SUPPORTED, the software mixer will emulate this capability. + * + * @param mute whether audio is muted. + * @return retval operation completion status. + */ + setMasterMute(bool mute) generates (Result retval); + + /** + * Get the current master mute status for the HAL, if the HAL supports + * master mute control. AudioFlinger will query this value from the primary + * audio HAL when the service starts and use the value for setting the + * initial master mute across all HALs. HAL must indicate that the feature + * is not supported by returning NOT_SUPPORTED status. + * + * @return retval operation completion status. + * @return mute whether audio is muted. + */ + getMasterMute() generates (Result retval, bool mute); + + /** + * Returns audio input buffer size according to parameters passed or + * INVALID_ARGUMENTS if one of the parameters is not supported. + * + * @param config audio configuration. + * @return retval operation completion status. + * @return bufferSize input buffer size in bytes. + */ + getInputBufferSize(AudioConfig config) + generates (Result retval, uint64_t bufferSize); + + /** + * This method creates and opens the audio hardware output stream. + * If the stream can not be opened with the proposed audio config, + * HAL must provide suggested values for the audio config. + * + * @param ioHandle handle assigned by AudioFlinger. + * @param device device type and (if needed) address. + * @param config stream configuration. + * @param flags additional flags. + * @param sourceMetadata Description of the audio that will be played. + May be used by implementations to configure hardware effects. + * @return retval operation completion status. + * @return outStream created output stream. + * @return suggestedConfig in case of invalid parameters, suggested config. + */ + openOutputStream( + AudioIoHandle ioHandle, + DeviceAddress device, + AudioConfig config, + bitfield<AudioOutputFlag> flags, + SourceMetadata sourceMetadata) generates ( + Result retval, + IStreamOut outStream, + AudioConfig suggestedConfig); + + /** + * This method creates and opens the audio hardware input stream. + * If the stream can not be opened with the proposed audio config, + * HAL must provide suggested values for the audio config. + * + * @param ioHandle handle assigned by AudioFlinger. + * @param device device type and (if needed) address. + * @param config stream configuration. + * @param flags additional flags. + * @param sinkMetadata Description of the audio that is suggested by the client. + * May be used by implementations to configure hardware effects. + * @return retval operation completion status. + * @return inStream in case of success, created input stream. + * @return suggestedConfig in case of invalid parameters, suggested config. + */ + openInputStream( + AudioIoHandle ioHandle, + DeviceAddress device, + AudioConfig config, + bitfield<AudioInputFlag> flags, + SinkMetadata sinkMetadata) generates ( + Result retval, + IStreamIn inStream, + AudioConfig suggestedConfig); + + /** + * Returns whether HAL supports audio patches. + * + * @return supports true if audio patches are supported. + */ + supportsAudioPatches() generates (bool supports); + + /** + * Creates an audio patch between several source and sink ports. The handle + * is allocated by the HAL and must be unique for this audio HAL module. + * + * @param sources patch sources. + * @param sinks patch sinks. + * @return retval operation completion status. + * @return patch created patch handle. + */ + createAudioPatch(vec<AudioPortConfig> sources, vec<AudioPortConfig> sinks) + generates (Result retval, AudioPatchHandle patch); + + /** + * Release an audio patch. + * + * @param patch patch handle. + * @return retval operation completion status. + */ + releaseAudioPatch(AudioPatchHandle patch) generates (Result retval); + + /** + * Returns the list of supported attributes for a given audio port. + * + * As input, 'port' contains the information (type, role, address etc...) + * needed by the HAL to identify the port. + * + * As output, 'resultPort' contains possible attributes (sampling rates, + * formats, channel masks, gain controllers...) for this port. + * + * @param port port identifier. + * @return retval operation completion status. + * @return resultPort port descriptor with all parameters filled up. + */ + getAudioPort(AudioPort port) + generates (Result retval, AudioPort resultPort); + + /** + * Set audio port configuration. + * + * @param config audio port configuration. + * @return retval operation completion status. + */ + setAudioPortConfig(AudioPortConfig config) generates (Result retval); + + /** + * Gets the HW synchronization source of the device. Calling this method is + * equivalent to getting AUDIO_PARAMETER_HW_AV_SYNC on the legacy HAL. + * Optional method + * + * @return retval operation completion status: OK or NOT_SUPPORTED. + * @return hwAvSync HW synchronization source + */ + getHwAvSync() generates (Result retval, AudioHwSync hwAvSync); + + /** + * Sets whether the screen is on. Calling this method is equivalent to + * setting AUDIO_PARAMETER_KEY_SCREEN_STATE on the legacy HAL. + * Optional method + * + * @param turnedOn whether the screen is turned on. + * @return retval operation completion status. + */ + setScreenState(bool turnedOn) generates (Result retval); + + /** + * Generic method for retrieving vendor-specific parameter values. + * The framework does not interpret the parameters, they are passed + * in an opaque manner between a vendor application and HAL. + * + * Multiple parameters can be retrieved at the same time. + * The implementation should return as many requested parameters + * as possible, even if one or more is not supported + * + * @param context provides more information about the request + * @param keys keys of the requested parameters + * @return retval operation completion status. + * OK must be returned if keys is empty. + * NOT_SUPPORTED must be returned if at least one key is unknown. + * @return parameters parameter key value pairs. + * Must contain the value of all requested keys if retval == OK + */ + getParameters(vec<ParameterValue> context, vec<string> keys) + generates (Result retval, vec<ParameterValue> parameters); + + /** + * Generic method for setting vendor-specific parameter values. + * The framework does not interpret the parameters, they are passed + * in an opaque manner between a vendor application and HAL. + * + * Multiple parameters can be set at the same time though this is + * discouraged as it make failure analysis harder. + * + * If possible, a failed setParameters should not impact the platform state. + * + * @param context provides more information about the request + * @param parameters parameter key value pairs. + * @return retval operation completion status. + * All parameters must be successfully set for OK to be returned + */ + setParameters(vec<ParameterValue> context, vec<ParameterValue> parameters) + generates (Result retval); + + /** + * Returns an array with available microphones in device. + * + * @return retval INVALID_STATE if the call is not successful, + * OK otherwise. + * + * @return microphones array with microphones info + */ + getMicrophones() + generates(Result retval, vec<MicrophoneInfo> microphones); + + /** + * Notifies the device module about the connection state of an input/output + * device attached to it. Calling this method is equivalent to setting + * AUDIO_PARAMETER_DEVICE_[DIS]CONNECT on the legacy HAL. + * + * @param address audio device specification. + * @param connected whether the device is connected. + * @return retval operation completion status. + */ + setConnectedState(DeviceAddress address, bool connected) + generates (Result retval); +}; diff --git a/audio/5.0/IDevicesFactory.hal b/audio/5.0/IDevicesFactory.hal new file mode 100644 index 0000000000..92060e7be1 --- /dev/null +++ b/audio/5.0/IDevicesFactory.hal @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2018 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@5.0; + +import android.hardware.audio.common@5.0; +import IDevice; +import IPrimaryDevice; + +/** This factory allows a HAL implementation to be split in multiple independent + * devices (called module in the pre-treble API). + * Note that this division is arbitrary and implementation are free + * to only have a Primary. + * The framework will query the devices according to audio_policy_configuration.xml + * + * Each device name is arbitrary, provided by the vendor's audio_policy_configuration.xml + * and only used to identify a device in this factory. + * The framework must not interpret the name, treating it as a vendor opaque data + * with the following exception: + * - the "r_submix" device that must be present to support policyMixes (Eg: Android projected). + * Note that this Device is included by default in a build derived from AOSP. + * + * Note that on AOSP Oreo (including MR1) the "a2dp" module is not using this API + * but is loaded directly from the system partition using the legacy API + * due to limitations with the Bluetooth framework. + */ +interface IDevicesFactory { + + /** + * Opens an audio device. To close the device, it is necessary to release + * references to the returned device object. + * + * @param device device name. + * @return retval operation completion status. Returns INVALID_ARGUMENTS + * if there is no corresponding hardware module found, + * NOT_INITIALIZED if an error occured while opening the hardware + * module. + * @return result the interface for the created device. + */ + openDevice(string device) generates (Result retval, IDevice result); + + /** + * Opens the Primary audio device that must be present. + * This function is not optional and must return successfully the primary device. + * + * This device must have the name "primary". + * + * The telephony stack uses this device to control the audio during a voice call. + * + * @return retval operation completion status. Must be SUCCESS. + * For debuging, return INVALID_ARGUMENTS if there is no corresponding + * hardware module found, NOT_INITIALIZED if an error occurred + * while opening the hardware module. + * @return result the interface for the created device. + */ + openPrimaryDevice() generates (Result retval, IPrimaryDevice result); +}; diff --git a/audio/5.0/IPrimaryDevice.hal b/audio/5.0/IPrimaryDevice.hal new file mode 100644 index 0000000000..60add5a164 --- /dev/null +++ b/audio/5.0/IPrimaryDevice.hal @@ -0,0 +1,195 @@ +/* + * Copyright (C) 2018 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@5.0; + +import android.hardware.audio.common@5.0; +import IDevice; + +interface IPrimaryDevice extends IDevice { + /** + * Sets the audio volume of a voice call. + * + * @param volume 1.0f means unity, 0.0f is zero. + * @return retval operation completion status. + */ + setVoiceVolume(float volume) generates (Result retval); + + /** + * This method is used to notify the HAL about audio mode changes. + * + * @param mode new mode. + * @return retval operation completion status. + */ + setMode(AudioMode mode) generates (Result retval); + + /** + * Sets the name of the current BT SCO headset. Calling this method + * is equivalent to setting legacy "bt_headset_name" parameter. + * The BT SCO headset name must only be used for debugging purposes. + * Optional method + * + * @param name the name of the current BT SCO headset (can be empty). + * @return retval operation completion status. + */ + setBtScoHeadsetDebugName(string name) generates (Result retval); + + /** + * Gets whether BT SCO Noise Reduction and Echo Cancellation are enabled. + * Calling this method is equivalent to getting AUDIO_PARAMETER_KEY_BT_NREC + * on the legacy HAL. + * + * @return retval operation completion status. + * @return enabled whether BT SCO NR + EC are enabled. + */ + getBtScoNrecEnabled() generates (Result retval, bool enabled); + + /** + * Sets whether BT SCO Noise Reduction and Echo Cancellation are enabled. + * Calling this method is equivalent to setting AUDIO_PARAMETER_KEY_BT_NREC + * on the legacy HAL. + * Optional method + * + * @param enabled whether BT SCO NR + EC are enabled. + * @return retval operation completion status. + */ + setBtScoNrecEnabled(bool enabled) generates (Result retval); + + /** + * Gets whether BT SCO Wideband mode is enabled. Calling this method is + * equivalent to getting AUDIO_PARAMETER_KEY_BT_SCO_WB on the legacy HAL. + * + * @return retval operation completion status. + * @return enabled whether BT Wideband is enabled. + */ + getBtScoWidebandEnabled() generates (Result retval, bool enabled); + + /** + * Sets whether BT SCO Wideband mode is enabled. Calling this method is + * equivalent to setting AUDIO_PARAMETER_KEY_BT_SCO_WB on the legacy HAL. + * Optional method + * + * @param enabled whether BT Wideband is enabled. + * @return retval operation completion status. + */ + setBtScoWidebandEnabled(bool enabled) generates (Result retval); + + /** + * Gets whether BT HFP (Hands-Free Profile) is enabled. Calling this method + * is equivalent to getting "hfp_enable" parameter value on the legacy HAL. + * + * @return retval operation completion status. + * @return enabled whether BT HFP is enabled. + */ + getBtHfpEnabled() generates (Result retval, bool enabled); + + /** + * Sets whether BT HFP (Hands-Free Profile) is enabled. Calling this method + * is equivalent to setting "hfp_enable" parameter on the legacy HAL. + * Optional method + * + * @param enabled whether BT HFP is enabled. + * @return retval operation completion status. + */ + setBtHfpEnabled(bool enabled) generates (Result retval); + + /** + * Sets the sampling rate of BT HFP (Hands-Free Profile). Calling this + * method is equivalent to setting "hfp_set_sampling_rate" parameter + * on the legacy HAL. + * Optional method + * + * @param sampleRateHz sample rate in Hz. + * @return retval operation completion status. + */ + setBtHfpSampleRate(uint32_t sampleRateHz) generates (Result retval); + + /** + * Sets the current output volume Hz for BT HFP (Hands-Free Profile). + * Calling this method is equivalent to setting "hfp_volume" parameter value + * on the legacy HAL (except that legacy HAL implementations expect + * an integer value in the range from 0 to 15.) + * Optional method + * + * @param volume 1.0f means unity, 0.0f is zero. + * @return retval operation completion status. + */ + setBtHfpVolume(float volume) generates (Result retval); + + enum TtyMode : int32_t { + OFF, + VCO, + HCO, + FULL + }; + + /** + * Gets current TTY mode selection. Calling this method is equivalent to + * getting AUDIO_PARAMETER_KEY_TTY_MODE on the legacy HAL. + * + * @return retval operation completion status. + * @return mode TTY mode. + */ + getTtyMode() generates (Result retval, TtyMode mode); + + /** + * Sets current TTY mode. Calling this method is equivalent to setting + * AUDIO_PARAMETER_KEY_TTY_MODE on the legacy HAL. + * + * @param mode TTY mode. + * @return retval operation completion status. + */ + setTtyMode(TtyMode mode) generates (Result retval); + + /** + * Gets whether Hearing Aid Compatibility - Telecoil (HAC-T) mode is + * enabled. Calling this method is equivalent to getting + * AUDIO_PARAMETER_KEY_HAC on the legacy HAL. + * + * @return retval operation completion status. + * @return enabled whether HAC mode is enabled. + */ + getHacEnabled() generates (Result retval, bool enabled); + + /** + * Sets whether Hearing Aid Compatibility - Telecoil (HAC-T) mode is + * enabled. Calling this method is equivalent to setting + * AUDIO_PARAMETER_KEY_HAC on the legacy HAL. + * Optional method + * + * @param enabled whether HAC mode is enabled. + * @return retval operation completion status. + */ + setHacEnabled(bool enabled) generates (Result retval); + + enum Rotation : int32_t { + DEG_0, + DEG_90, + DEG_180, + DEG_270 + }; + + /** + * Updates HAL on the current rotation of the device relative to natural + * orientation. Calling this method is equivalent to setting legacy + * parameter "rotation". + * + * @param rotation rotation in degrees relative to natural device + * orientation. + * @return retval operation completion status. + */ + updateRotation(Rotation rotation) generates (Result retval); +}; diff --git a/audio/5.0/IStream.hal b/audio/5.0/IStream.hal new file mode 100644 index 0000000000..0f975b6971 --- /dev/null +++ b/audio/5.0/IStream.hal @@ -0,0 +1,310 @@ +/* + * Copyright (C) 2018 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@5.0; + +import android.hardware.audio.common@5.0; +import android.hardware.audio.effect@5.0::IEffect; + +interface IStream { + /** + * Return the frame size (number of bytes per sample). + * + * @return frameSize frame size in bytes. + */ + getFrameSize() generates (uint64_t frameSize); + + /** + * Return the frame count of the buffer. Calling this method is equivalent + * to getting AUDIO_PARAMETER_STREAM_FRAME_COUNT on the legacy HAL. + * + * @return count frame count. + */ + getFrameCount() generates (uint64_t count); + + /** + * Return the size of input/output buffer in bytes for this stream. + * It must be a multiple of the frame size. + * + * @return buffer buffer size in bytes. + */ + getBufferSize() generates (uint64_t bufferSize); + + /** + * Return the sampling rate in Hz. + * + * @return sampleRateHz sample rate in Hz. + */ + getSampleRate() generates (uint32_t sampleRateHz); + + /** + * Return supported native sampling rates of the stream for a given format. + * A supported native sample rate is a sample rate that can be efficiently + * played by the hardware (typically without sample-rate conversions). + * + * This function is only called for dynamic profile. If called for + * non-dynamic profile is should return NOT_SUPPORTED or the same list + * as in audio_policy_configuration.xml. + * + * Calling this method is equivalent to getting + * AUDIO_PARAMETER_STREAM_SUP_SAMPLING_RATES on the legacy HAL. + * + * + * @param format audio format for which the sample rates are supported. + * @return retval operation completion status. + * Must be OK if the format is supported. + * @return sampleRateHz supported sample rates. + */ + getSupportedSampleRates(AudioFormat format) + generates (Result retval, vec<uint32_t> sampleRates); + + /** + * Sets the sampling rate of the stream. Calling this method is equivalent + * to setting AUDIO_PARAMETER_STREAM_SAMPLING_RATE on the legacy HAL. + * Optional method. If implemented, only called on a stopped stream. + * + * @param sampleRateHz sample rate in Hz. + * @return retval operation completion status. + */ + setSampleRate(uint32_t sampleRateHz) generates (Result retval); + + /** + * Return the channel mask of the stream. + * + * @return mask channel mask. + */ + getChannelMask() generates (bitfield<AudioChannelMask> mask); + + /** + * Return supported channel masks of the stream. Calling this method is + * equivalent to getting AUDIO_PARAMETER_STREAM_SUP_CHANNELS on the legacy + * HAL. + * + * @param format audio format for which the channel masks are supported. + * @return retval operation completion status. + * Must be OK if the format is supported. + * @return masks supported audio masks. + */ + getSupportedChannelMasks(AudioFormat format) + generates (Result retval, vec<bitfield<AudioChannelMask>> masks); + + /** + * Sets the channel mask of the stream. Calling this method is equivalent to + * setting AUDIO_PARAMETER_STREAM_CHANNELS on the legacy HAL. + * Optional method + * + * @param format audio format. + * @return retval operation completion status. + */ + setChannelMask(bitfield<AudioChannelMask> mask) generates (Result retval); + + /** + * Return the audio format of the stream. + * + * @return format audio format. + */ + getFormat() generates (AudioFormat format); + + /** + * Return supported audio formats of the stream. Calling this method is + * equivalent to getting AUDIO_PARAMETER_STREAM_SUP_FORMATS on the legacy + * HAL. + * + * @return formats supported audio formats. + */ + getSupportedFormats() generates (vec<AudioFormat> formats); + + /** + * Sets the audio format of the stream. Calling this method is equivalent to + * setting AUDIO_PARAMETER_STREAM_FORMAT on the legacy HAL. + * Optional method + * + * @param format audio format. + * @return retval operation completion status. + */ + setFormat(AudioFormat format) generates (Result retval); + + /** + * Convenience method for retrieving several stream parameters in + * one transaction. + * + * @return sampleRateHz sample rate in Hz. + * @return mask channel mask. + * @return format audio format. + */ + getAudioProperties() generates ( + uint32_t sampleRateHz, bitfield<AudioChannelMask> mask, AudioFormat format); + + /** + * Applies audio effect to the stream. + * + * @param effectId effect ID (obtained from IEffectsFactory.createEffect) of + * the effect to apply. + * @return retval operation completion status. + */ + addEffect(uint64_t effectId) generates (Result retval); + + /** + * Stops application of the effect to the stream. + * + * @param effectId effect ID (obtained from IEffectsFactory.createEffect) of + * the effect to remove. + * @return retval operation completion status. + */ + removeEffect(uint64_t effectId) generates (Result retval); + + /** + * Put the audio hardware input/output into standby mode. + * Driver must exit from standby mode at the next I/O operation. + * + * @return retval operation completion status. + */ + standby() generates (Result retval); + + /** + * Return the set of devices which this stream is connected to. + * Optional method + * + * @return retval operation completion status: OK or NOT_SUPPORTED. + * @return device set of devices which this stream is connected to. + */ + getDevices() generates (Result retval, vec<DeviceAddress> devices); + + /** + * Connects the stream to one or multiple devices. + * + * This method must only be used for HALs that do not support + * 'IDevice.createAudioPatch' method. Calling this method is + * equivalent to setting AUDIO_PARAMETER_STREAM_ROUTING preceeded + * with a device address in the legacy HAL interface. + * + * @param address device to connect the stream to. + * @return retval operation completion status. + */ + setDevices(vec<DeviceAddress> devices) generates (Result retval); + + /** + * Sets the HW synchronization source. Calling this method is equivalent to + * setting AUDIO_PARAMETER_STREAM_HW_AV_SYNC on the legacy HAL. + * Optional method + * + * @param hwAvSync HW synchronization source + * @return retval operation completion status. + */ + setHwAvSync(AudioHwSync hwAvSync) generates (Result retval); + + /** + * Generic method for retrieving vendor-specific parameter values. + * The framework does not interpret the parameters, they are passed + * in an opaque manner between a vendor application and HAL. + * + * Multiple parameters can be retrieved at the same time. + * The implementation should return as many requested parameters + * as possible, even if one or more is not supported + * + * @param context provides more information about the request + * @param keys keys of the requested parameters + * @return retval operation completion status. + * OK must be returned if keys is empty. + * NOT_SUPPORTED must be returned if at least one key is unknown. + * @return parameters parameter key value pairs. + * Must contain the value of all requested keys if retval == OK + */ + getParameters(vec<ParameterValue> context, vec<string> keys) + generates (Result retval, vec<ParameterValue> parameters); + + /** + * Generic method for setting vendor-specific parameter values. + * The framework does not interpret the parameters, they are passed + * in an opaque manner between a vendor application and HAL. + * + * Multiple parameters can be set at the same time though this is + * discouraged as it make failure analysis harder. + * + * If possible, a failed setParameters should not impact the platform state. + * + * @param context provides more information about the request + * @param parameters parameter key value pairs. + * @return retval operation completion status. + * All parameters must be successfully set for OK to be returned + */ + setParameters(vec<ParameterValue> context, vec<ParameterValue> parameters) + generates (Result retval); + + /** + * Called by the framework to start a stream operating in mmap mode. + * createMmapBuffer() must be called before calling start(). + * Function only implemented by streams operating in mmap mode. + * + * @return retval OK in case the success. + * NOT_SUPPORTED on non mmap mode streams + * INVALID_STATE if called out of sequence + */ + start() generates (Result retval); + + /** + * Called by the framework to stop a stream operating in mmap mode. + * Function only implemented by streams operating in mmap mode. + * + * @return retval OK in case the succes. + * NOT_SUPPORTED on non mmap mode streams + * INVALID_STATE if called out of sequence + */ + stop() generates (Result retval) ; + + /** + * Called by the framework to retrieve information on the mmap buffer used for audio + * samples transfer. + * Function only implemented by streams operating in mmap mode. + * + * @param minSizeFrames minimum buffer size requested. The actual buffer + * size returned in struct MmapBufferInfo can be larger. + * @return retval OK in case the success. + * NOT_SUPPORTED on non mmap mode streams + * NOT_INITIALIZED in case of memory allocation error + * INVALID_ARGUMENTS if the requested buffer size is too large + * INVALID_STATE if called out of sequence + * @return info a MmapBufferInfo struct containing information on the MMMAP buffer created. + */ + createMmapBuffer(int32_t minSizeFrames) + generates (Result retval, MmapBufferInfo info); + + /** + * Called by the framework to read current read/write position in the mmap buffer + * with associated time stamp. + * Function only implemented by streams operating in mmap mode. + * + * @return retval OK in case the success. + * NOT_SUPPORTED on non mmap mode streams + * INVALID_STATE if called out of sequence + * @return position a MmapPosition struct containing current HW read/write position in frames + * with associated time stamp. + */ + getMmapPosition() + generates (Result retval, MmapPosition position); + + /** + * Called by the framework to deinitialize the stream and free up + * all the currently allocated resources. It is recommended to close + * the stream on the client side as soon as it is becomes unused. + * + * @return retval OK in case the success. + * NOT_SUPPORTED if called on IStream instead of input or + * output stream interface. + * INVALID_STATE if the stream was already closed. + */ + close() generates (Result retval); +}; diff --git a/audio/5.0/IStreamIn.hal b/audio/5.0/IStreamIn.hal new file mode 100644 index 0000000000..d33cfdc773 --- /dev/null +++ b/audio/5.0/IStreamIn.hal @@ -0,0 +1,168 @@ +/* + * Copyright (C) 2018 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@5.0; + +import android.hardware.audio.common@5.0; +import IStream; + +interface IStreamIn extends IStream { + /** + * Returns the source descriptor of the input stream. Calling this method is + * equivalent to getting AUDIO_PARAMETER_STREAM_INPUT_SOURCE on the legacy + * HAL. + * Optional method + * + * @return retval operation completion status. + * @return source audio source. + */ + getAudioSource() generates (Result retval, AudioSource source); + + /** + * Set the input gain for the audio driver. + * Optional method + * + * @param gain 1.0f is unity, 0.0f is zero. + * @result retval operation completion status. + */ + setGain(float gain) generates (Result retval); + + /** + * Commands that can be executed on the driver reader thread. + */ + enum ReadCommand : int32_t { + READ, + GET_CAPTURE_POSITION + }; + + /** + * Data structure passed to the driver for executing commands + * on the driver reader thread. + */ + struct ReadParameters { + ReadCommand command; // discriminator + union Params { + uint64_t read; // READ command, amount of bytes to read, >= 0. + // No parameters for GET_CAPTURE_POSITION. + } params; + }; + + /** + * Data structure passed back to the client via status message queue + * of 'read' operation. + * + * Possible values of 'retval' field: + * - OK, read operation was successful; + * - INVALID_ARGUMENTS, stream was not configured properly; + * - INVALID_STATE, stream is in a state that doesn't allow reads. + */ + struct ReadStatus { + Result retval; + ReadCommand replyTo; // discriminator + union Reply { + uint64_t read; // READ command, amount of bytes read, >= 0. + struct CapturePosition { // same as generated by getCapturePosition. + uint64_t frames; + uint64_t time; + } capturePosition; + } reply; + }; + + /** + * Called when the metadata of the stream's sink has been changed. + * @param sinkMetadata Description of the audio that is suggested by the clients. + */ + updateSinkMetadata(SinkMetadata sinkMetadata); + + /** + * Set up required transports for receiving audio buffers from the driver. + * + * The transport consists of three message queues: + * -- command queue is used to instruct the reader thread what operation + * to perform; + * -- data queue is used for passing audio data from the driver + * to the client; + * -- status queue is used for reporting operation status + * (e.g. amount of bytes actually read or error code). + * + * The driver operates on a dedicated thread. The client must ensure that + * the thread is given an appropriate priority and assigned to correct + * scheduler and cgroup. For this purpose, the method returns identifiers + * of the driver thread. + * + * @param frameSize the size of a single frame, in bytes. + * @param framesCount the number of frames in a buffer. + * @param threadPriority priority of the driver thread. + * @return retval OK if both message queues were created successfully. + * INVALID_STATE if the method was already called. + * INVALID_ARGUMENTS if there was a problem setting up + * the queues. + * @return commandMQ a message queue used for passing commands. + * @return dataMQ a message queue used for passing audio data in the format + * specified at the stream opening. + * @return statusMQ a message queue used for passing status from the driver + * using ReadStatus structures. + * @return threadInfo identifiers of the driver's dedicated thread. + */ + prepareForReading(uint32_t frameSize, uint32_t framesCount) + generates ( + Result retval, + fmq_sync<ReadParameters> commandMQ, + fmq_sync<uint8_t> dataMQ, + fmq_sync<ReadStatus> statusMQ, + ThreadInfo threadInfo); + + /** + * Return the amount of input frames lost in the audio driver since the last + * call of this function. + * + * Audio driver is expected to reset the value to 0 and restart counting + * upon returning the current value by this function call. Such loss + * typically occurs when the user space process is blocked longer than the + * capacity of audio driver buffers. + * + * @return framesLost the number of input audio frames lost. + */ + getInputFramesLost() generates (uint32_t framesLost); + + /** + * Return a recent count of the number of audio frames received and the + * clock time associated with that frame count. + * + * @return retval INVALID_STATE if the device is not ready/available, + * NOT_SUPPORTED if the command is not supported, + * OK otherwise. + * @return frames the total frame count received. This must be as early in + * the capture pipeline as possible. In general, frames + * must be non-negative and must not go "backwards". + * @return time is the clock monotonic time when frames was measured. In + * general, time must be a positive quantity and must not + * go "backwards". + */ + getCapturePosition() + generates (Result retval, uint64_t frames, uint64_t time); + + /** + * Returns an array with active microphones in the stream. + * + * @return retval INVALID_STATE if the call is not successful, + * OK otherwise. + * + * @return microphones array with microphones info + */ + getActiveMicrophones() + generates(Result retval, vec<MicrophoneInfo> microphones); +}; diff --git a/audio/5.0/IStreamOut.hal b/audio/5.0/IStreamOut.hal new file mode 100644 index 0000000000..119a642185 --- /dev/null +++ b/audio/5.0/IStreamOut.hal @@ -0,0 +1,279 @@ +/* + * Copyright (C) 2018 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@5.0; + +import android.hardware.audio.common@5.0; +import IStream; +import IStreamOutCallback; + +interface IStreamOut extends IStream { + /** + * Return the audio hardware driver estimated latency in milliseconds. + * + * @return latencyMs latency in milliseconds. + */ + getLatency() generates (uint32_t latencyMs); + + /** + * This method is used in situations where audio mixing is done in the + * hardware. This method serves as a direct interface with hardware, + * allowing to directly set the volume as apposed to via the framework. + * This method might produce multiple PCM outputs or hardware accelerated + * codecs, such as MP3 or AAC. + * Optional method + * + * @param left left channel attenuation, 1.0f is unity, 0.0f is zero. + * @param right right channel attenuation, 1.0f is unity, 0.0f is zero. + * @return retval operation completion status. + * If a volume is outside [0,1], return INVALID_ARGUMENTS + */ + setVolume(float left, float right) generates (Result retval); + + /** + * Commands that can be executed on the driver writer thread. + */ + enum WriteCommand : int32_t { + WRITE, + GET_PRESENTATION_POSITION, + GET_LATENCY + }; + + /** + * Data structure passed back to the client via status message queue + * of 'write' operation. + * + * Possible values of 'retval' field: + * - OK, write operation was successful; + * - INVALID_ARGUMENTS, stream was not configured properly; + * - INVALID_STATE, stream is in a state that doesn't allow writes; + * - INVALID_OPERATION, retrieving presentation position isn't supported. + */ + struct WriteStatus { + Result retval; + WriteCommand replyTo; // discriminator + union Reply { + uint64_t written; // WRITE command, amount of bytes written, >= 0. + struct PresentationPosition { // same as generated by + uint64_t frames; // getPresentationPosition. + TimeSpec timeStamp; + } presentationPosition; + uint32_t latencyMs; // Same as generated by getLatency. + } reply; + }; + + /** + * Called when the metadata of the stream's source has been changed. + * @param sourceMetadata Description of the audio that is played by the clients. + */ + updateSourceMetadata(SourceMetadata sourceMetadata); + + /** + * Set up required transports for passing audio buffers to the driver. + * + * The transport consists of three message queues: + * -- command queue is used to instruct the writer thread what operation + * to perform; + * -- data queue is used for passing audio data from the client + * to the driver; + * -- status queue is used for reporting operation status + * (e.g. amount of bytes actually written or error code). + * + * The driver operates on a dedicated thread. The client must ensure that + * the thread is given an appropriate priority and assigned to correct + * scheduler and cgroup. For this purpose, the method returns identifiers + * of the driver thread. + * + * @param frameSize the size of a single frame, in bytes. + * @param framesCount the number of frames in a buffer. + * @return retval OK if both message queues were created successfully. + * INVALID_STATE if the method was already called. + * INVALID_ARGUMENTS if there was a problem setting up + * the queues. + * @return commandMQ a message queue used for passing commands. + * @return dataMQ a message queue used for passing audio data in the format + * specified at the stream opening. + * @return statusMQ a message queue used for passing status from the driver + * using WriteStatus structures. + * @return threadInfo identifiers of the driver's dedicated thread. + */ + prepareForWriting(uint32_t frameSize, uint32_t framesCount) + generates ( + Result retval, + fmq_sync<WriteCommand> commandMQ, + fmq_sync<uint8_t> dataMQ, + fmq_sync<WriteStatus> statusMQ, + ThreadInfo threadInfo); + + /** + * Return the number of audio frames written by the audio DSP to DAC since + * the output has exited standby. + * Optional method + * + * @return retval operation completion status. + * @return dspFrames number of audio frames written. + */ + getRenderPosition() generates (Result retval, uint32_t dspFrames); + + /** + * Get the local time at which the next write to the audio driver will be + * presented. The units are microseconds, where the epoch is decided by the + * local audio HAL. + * Optional method + * + * @return retval operation completion status. + * @return timestampUs time of the next write. + */ + getNextWriteTimestamp() generates (Result retval, int64_t timestampUs); + + /** + * Set the callback interface for notifying completion of non-blocking + * write and drain. + * + * Calling this function implies that all future 'write' and 'drain' + * must be non-blocking and use the callback to signal completion. + * + * 'clearCallback' method needs to be called in order to release the local + * callback proxy on the server side and thus dereference the callback + * implementation on the client side. + * + * @return retval operation completion status. + */ + setCallback(IStreamOutCallback callback) generates (Result retval); + + /** + * Clears the callback previously set via 'setCallback' method. + * + * Warning: failure to call this method results in callback implementation + * on the client side being held until the HAL server termination. + * + * If no callback was previously set, the method should be a no-op + * and return OK. + * + * @return retval operation completion status: OK or NOT_SUPPORTED. + */ + clearCallback() generates (Result retval); + + /** + * Returns whether HAL supports pausing and resuming of streams. + * + * @return supportsPause true if pausing is supported. + * @return supportsResume true if resume is supported. + */ + supportsPauseAndResume() + generates (bool supportsPause, bool supportsResume); + + /** + * Notifies to the audio driver to stop playback however the queued buffers + * are retained by the hardware. Useful for implementing pause/resume. Empty + * implementation if not supported however must be implemented for hardware + * with non-trivial latency. In the pause state, some audio hardware may + * still be using power. Client code may consider calling 'suspend' after a + * timeout to prevent that excess power usage. + * + * Implementation of this function is mandatory for offloaded playback. + * + * @return retval operation completion status. + */ + pause() generates (Result retval); + + /** + * Notifies to the audio driver to resume playback following a pause. + * Returns error INVALID_STATE if called without matching pause. + * + * Implementation of this function is mandatory for offloaded playback. + * + * @return retval operation completion status. + */ + resume() generates (Result retval); + + /** + * Returns whether HAL supports draining of streams. + * + * @return supports true if draining is supported. + */ + supportsDrain() generates (bool supports); + + /** + * Requests notification when data buffered by the driver/hardware has been + * played. If 'setCallback' has previously been called to enable + * non-blocking mode, then 'drain' must not block, instead it must return + * quickly and completion of the drain is notified through the callback. If + * 'setCallback' has not been called, then 'drain' must block until + * completion. + * + * If 'type' is 'ALL', the drain completes when all previously written data + * has been played. + * + * If 'type' is 'EARLY_NOTIFY', the drain completes shortly before all data + * for the current track has played to allow time for the framework to + * perform a gapless track switch. + * + * Drain must return immediately on 'stop' and 'flush' calls. + * + * Implementation of this function is mandatory for offloaded playback. + * + * @param type type of drain. + * @return retval operation completion status. + */ + drain(AudioDrain type) generates (Result retval); + + /** + * Notifies to the audio driver to flush the queued data. Stream must + * already be paused before calling 'flush'. + * Optional method + * + * Implementation of this function is mandatory for offloaded playback. + * + * @return retval operation completion status. + */ + flush() generates (Result retval); + + /** + * Return a recent count of the number of audio frames presented to an + * external observer. This excludes frames which have been written but are + * still in the pipeline. The count is not reset to zero when output enters + * standby. Also returns the value of CLOCK_MONOTONIC as of this + * presentation count. The returned count is expected to be 'recent', but + * does not need to be the most recent possible value. However, the + * associated time must correspond to whatever count is returned. + * + * Example: assume that N+M frames have been presented, where M is a 'small' + * number. Then it is permissible to return N instead of N+M, and the + * timestamp must correspond to N rather than N+M. The terms 'recent' and + * 'small' are not defined. They reflect the quality of the implementation. + * + * Optional method + * + * @return retval operation completion status. + * @return frames count of presented audio frames. + * @return timeStamp associated clock time. + */ + getPresentationPosition() + generates (Result retval, uint64_t frames, TimeSpec timeStamp); + + /** + * Selects a presentation for decoding from a next generation media stream + * (as defined per ETSI TS 103 190-2) and a program within the presentation. + * Optional method + * + * @param presentationId selected audio presentation. + * @param programId refinement for the presentation. + * @return retval operation completion status. + */ + selectPresentation(int32_t presentationId, int32_t programId) + generates (Result retval); +}; diff --git a/audio/effect/4.0/default/Effect.cpp b/audio/5.0/IStreamOutCallback.hal index 707044bff0..c52a0402f5 100644 --- a/audio/effect/4.0/default/Effect.cpp +++ b/audio/5.0/IStreamOutCallback.hal @@ -14,15 +14,24 @@ * limitations under the License. */ -#include <memory.h> +package android.hardware.audio@5.0; -#define LOG_TAG "EffectHAL" -#define ATRACE_TAG ATRACE_TAG_AUDIO +/** + * Asynchronous write callback interface. + */ +interface IStreamOutCallback { + /** + * Non blocking write completed. + */ + oneway onWriteReady(); -#include "Conversions.h" -#include "Effect.h" -#include "common/all-versions/default/EffectMap.h" + /** + * Drain completed. + */ + oneway onDrainReady(); -#define AUDIO_HAL_VERSION V4_0 -#include <effect/all-versions/default/Effect.impl.h> -#undef AUDIO_HAL_VERSION + /** + * Stream hit an error. + */ + oneway onError(); +}; diff --git a/audio/5.0/config/audio_policy_configuration.xsd b/audio/5.0/config/audio_policy_configuration.xsd new file mode 100644 index 0000000000..311b9c1a83 --- /dev/null +++ b/audio/5.0/config/audio_policy_configuration.xsd @@ -0,0 +1,595 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Copyright (C) 2017 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. +--> +<!-- TODO: define a targetNamespace. Note that it will break retrocompatibility --> +<xs:schema version="2.0" + elementFormDefault="qualified" + attributeFormDefault="unqualified" + xmlns:xs="http://www.w3.org/2001/XMLSchema"> + <!-- List the config versions supported by audio policy. --> + <xs:simpleType name="version"> + <xs:restriction base="xs:decimal"> + <xs:enumeration value="1.0"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="halVersion"> + <xs:annotation> + <xs:documentation xml:lang="en"> + Version of the interface the hal implements. + </xs:documentation> + </xs:annotation> + <xs:restriction base="xs:decimal"> + <!-- List of HAL versions supported by the framework. --> + <xs:enumeration value="2.0"/> + <xs:enumeration value="3.0"/> + </xs:restriction> + </xs:simpleType> + <xs:element name="audioPolicyConfiguration"> + <xs:complexType> + <xs:sequence> + <xs:element name="globalConfiguration" type="globalConfiguration"/> + <xs:element name="modules" type="modules" maxOccurs="unbounded"/> + <xs:element name="volumes" type="volumes" maxOccurs="unbounded"/> + <xs:element name="surroundSound" type="surroundSound" /> + </xs:sequence> + <xs:attribute name="version" type="version"/> + </xs:complexType> + <xs:key name="moduleNameKey"> + <xs:selector xpath="modules/module"/> + <xs:field xpath="@name"/> + </xs:key> + <xs:unique name="volumeTargetUniqueness"> + <xs:selector xpath="volumes/volume"/> + <xs:field xpath="@stream"/> + <xs:field xpath="@deviceCategory"/> + </xs:unique> + <xs:key name="volumeCurveNameKey"> + <xs:selector xpath="volumes/reference"/> + <xs:field xpath="@name"/> + </xs:key> + <xs:keyref name="volumeCurveRef" refer="volumeCurveNameKey"> + <xs:selector xpath="volumes/volume"/> + <xs:field xpath="@ref"/> + </xs:keyref> + </xs:element> + <xs:complexType name="globalConfiguration"> + <xs:attribute name="speaker_drc_enabled" type="xs:boolean" use="required"/> + </xs:complexType> + <xs:complexType name="modules"> + <xs:annotation> + <xs:documentation xml:lang="en"> + There should be one section per audio HW module present on the platform. + Each <module/> contains two mandatory tags: “halVersion” and “name”. + The module "name" is the same as in previous .conf file. + Each module must contain the following sections: + - <devicePorts/>: a list of device descriptors for all + input and output devices accessible via this module. + This contains both permanently attached devices and removable devices. + - <mixPorts/>: listing all output and input streams exposed by the audio HAL + - <routes/>: list of possible connections between input + and output devices or between stream and devices. + A <route/> is defined by a set of 3 attributes: + -"type": mux|mix means all sources are mutual exclusive (mux) or can be mixed (mix) + -"sink": the sink involved in this route + -"sources": all the sources than can be connected to the sink via this route + - <attachedDevices/>: permanently attached devices. + The attachedDevices section is a list of devices names. + Their names correspond to device names defined in "devicePorts" section. + - <defaultOutputDevice/> is the device to be used when no policy rule applies + </xs:documentation> + </xs:annotation> + <xs:sequence> + <xs:element name="module" maxOccurs="unbounded"> + <xs:complexType> + <xs:sequence> + <xs:element name="attachedDevices" type="attachedDevices" minOccurs="0"> + <xs:unique name="attachedDevicesUniqueness"> + <xs:selector xpath="item"/> + <xs:field xpath="."/> + </xs:unique> + </xs:element> + <xs:element name="defaultOutputDevice" type="xs:token" minOccurs="0"/> + <xs:element name="mixPorts" type="mixPorts" minOccurs="0"/> + <xs:element name="devicePorts" type="devicePorts" minOccurs="0"/> + <xs:element name="routes" type="routes" minOccurs="0"/> + </xs:sequence> + <xs:attribute name="name" type="xs:string" use="required"/> + <xs:attribute name="halVersion" type="halVersion" use="required"/> + </xs:complexType> + <xs:unique name="mixPortNameUniqueness"> + <xs:selector xpath="mixPorts/mixPort"/> + <xs:field xpath="@name"/> + </xs:unique> + <xs:key name="devicePortNameKey"> + <xs:selector xpath="devicePorts/devicePort"/> + <xs:field xpath="@tagName"/> + </xs:key> + <xs:unique name="devicePortUniqueness"> + <xs:selector xpath="devicePorts/devicePort"/> + <xs:field xpath="@type"/> + <xs:field xpath="@address"/> + </xs:unique> + <xs:keyref name="defaultOutputDeviceRef" refer="devicePortNameKey"> + <xs:selector xpath="defaultOutputDevice"/> + <xs:field xpath="."/> + </xs:keyref> + <xs:keyref name="attachedDeviceRef" refer="devicePortNameKey"> + <xs:selector xpath="attachedDevices/item"/> + <xs:field xpath="."/> + </xs:keyref> + <!-- The following 3 constraints try to make sure each sink port + is reference in one an only one route. --> + <xs:key name="routeSinkKey"> + <!-- predicate [@type='sink'] does not work in xsd 1.0 --> + <xs:selector xpath="devicePorts/devicePort|mixPorts/mixPort"/> + <xs:field xpath="@tagName|@name"/> + </xs:key> + <xs:keyref name="routeSinkRef" refer="routeSinkKey"> + <xs:selector xpath="routes/route"/> + <xs:field xpath="@sink"/> + </xs:keyref> + <xs:unique name="routeUniqueness"> + <xs:selector xpath="routes/route"/> + <xs:field xpath="@sink"/> + </xs:unique> + </xs:element> + </xs:sequence> + </xs:complexType> + <xs:complexType name="attachedDevices"> + <xs:sequence> + <xs:element name="item" type="xs:token" minOccurs="0" maxOccurs="unbounded"/> + </xs:sequence> + </xs:complexType> + <!-- TODO: separate values by space for better xsd validations. --> + <xs:simpleType name="audioInOutFlags"> + <xs:annotation> + <xs:documentation xml:lang="en"> + "|" separated list of audio_output_flags_t or audio_input_flags_t. + </xs:documentation> + </xs:annotation> + <xs:restriction base="xs:string"> + <xs:pattern value="|[_A-Z]+(\|[_A-Z]+)*"/> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="role"> + <xs:restriction base="xs:string"> + <xs:enumeration value="sink"/> + <xs:enumeration value="source"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="mixPorts"> + <xs:sequence> + <xs:element name="mixPort" minOccurs="0" maxOccurs="unbounded"> + <xs:complexType> + <xs:sequence> + <xs:element name="profile" type="profile" minOccurs="0" maxOccurs="unbounded"/> + <xs:element name="gains" type="gains" minOccurs="0"/> + </xs:sequence> + <xs:attribute name="name" type="xs:token" use="required"/> + <xs:attribute name="role" type="role" use="required"/> + <xs:attribute name="flags" type="audioInOutFlags"/> + <xs:attribute name="maxOpenCount" type="xs:unsignedInt"/> + <xs:attribute name="maxActiveCount" type="xs:unsignedInt"/> + <xs:attribute name="preferredUsage" type="audioUsageList"> + <xs:annotation> + <xs:documentation xml:lang="en"> + When choosing the mixPort of an audio track, the audioPolicy + first considers the mixPorts with a preferredUsage including + the track AudioUsage preferred . + If non support the track format, the other mixPorts are considered. + Eg: a <mixPort preferredUsage="AUDIO_USAGE_MEDIA" /> will receive + the audio of all apps playing with a MEDIA usage. + It may receive audio from ALARM if there are no audio compatible + <mixPort preferredUsage="AUDIO_USAGE_ALARM" />. + </xs:documentation> + </xs:annotation> + </xs:attribute> + </xs:complexType> + <xs:unique name="mixPortProfileUniqueness"> + <xs:selector xpath="profile"/> + <xs:field xpath="format"/> + <xs:field xpath="samplingRate"/> + <xs:field xpath="channelMasks"/> + </xs:unique> + <xs:unique name="mixPortGainUniqueness"> + <xs:selector xpath="gains/gain"/> + <xs:field xpath="@name"/> + </xs:unique> + </xs:element> + </xs:sequence> + </xs:complexType> + <!-- Enum values of audio_device_t in audio.h + TODO: generate from hidl to avoid manual sync. + TODO: separate source and sink in the xml for better xsd validations. --> + <xs:simpleType name="audioDevice"> + <xs:restriction base="xs:string"> + <xs:enumeration value="AUDIO_DEVICE_NONE"/> + + <xs:enumeration value="AUDIO_DEVICE_OUT_EARPIECE"/> + <xs:enumeration value="AUDIO_DEVICE_OUT_SPEAKER"/> + <xs:enumeration value="AUDIO_DEVICE_OUT_WIRED_HEADSET"/> + <xs:enumeration value="AUDIO_DEVICE_OUT_WIRED_HEADPHONE"/> + <xs:enumeration value="AUDIO_DEVICE_OUT_BLUETOOTH_SCO"/> + <xs:enumeration value="AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET"/> + <xs:enumeration value="AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT"/> + <xs:enumeration value="AUDIO_DEVICE_OUT_BLUETOOTH_A2DP"/> + <xs:enumeration value="AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES"/> + <xs:enumeration value="AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER"/> + <xs:enumeration value="AUDIO_DEVICE_OUT_AUX_DIGITAL"/> + <xs:enumeration value="AUDIO_DEVICE_OUT_HDMI"/> + <xs:enumeration value="AUDIO_DEVICE_OUT_ANLG_DOCK_HEADSET"/> + <xs:enumeration value="AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET"/> + <xs:enumeration value="AUDIO_DEVICE_OUT_USB_ACCESSORY"/> + <xs:enumeration value="AUDIO_DEVICE_OUT_USB_DEVICE"/> + <xs:enumeration value="AUDIO_DEVICE_OUT_REMOTE_SUBMIX"/> + <xs:enumeration value="AUDIO_DEVICE_OUT_TELEPHONY_TX"/> + <xs:enumeration value="AUDIO_DEVICE_OUT_LINE"/> + <xs:enumeration value="AUDIO_DEVICE_OUT_HDMI_ARC"/> + <xs:enumeration value="AUDIO_DEVICE_OUT_SPDIF"/> + <xs:enumeration value="AUDIO_DEVICE_OUT_FM"/> + <xs:enumeration value="AUDIO_DEVICE_OUT_AUX_LINE"/> + <xs:enumeration value="AUDIO_DEVICE_OUT_SPEAKER_SAFE"/> + <xs:enumeration value="AUDIO_DEVICE_OUT_IP"/> + <xs:enumeration value="AUDIO_DEVICE_OUT_BUS"/> + <xs:enumeration value="AUDIO_DEVICE_OUT_PROXY"/> + <xs:enumeration value="AUDIO_DEVICE_OUT_USB_HEADSET"/> + <xs:enumeration value="AUDIO_DEVICE_OUT_HEARING_AID"/> + <xs:enumeration value="AUDIO_DEVICE_OUT_ECHO_CANCELLER"/> + <xs:enumeration value="AUDIO_DEVICE_OUT_DEFAULT"/> + <xs:enumeration value="AUDIO_DEVICE_OUT_STUB"/> + + <!-- Due to the xml format, IN types can not be a separated from OUT types --> + <xs:enumeration value="AUDIO_DEVICE_IN_COMMUNICATION"/> + <xs:enumeration value="AUDIO_DEVICE_IN_AMBIENT"/> + <xs:enumeration value="AUDIO_DEVICE_IN_BUILTIN_MIC"/> + <xs:enumeration value="AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET"/> + <xs:enumeration value="AUDIO_DEVICE_IN_WIRED_HEADSET"/> + <xs:enumeration value="AUDIO_DEVICE_IN_AUX_DIGITAL"/> + <xs:enumeration value="AUDIO_DEVICE_IN_HDMI"/> + <xs:enumeration value="AUDIO_DEVICE_IN_VOICE_CALL"/> + <xs:enumeration value="AUDIO_DEVICE_IN_TELEPHONY_RX"/> + <xs:enumeration value="AUDIO_DEVICE_IN_BACK_MIC"/> + <xs:enumeration value="AUDIO_DEVICE_IN_REMOTE_SUBMIX"/> + <xs:enumeration value="AUDIO_DEVICE_IN_ANLG_DOCK_HEADSET"/> + <xs:enumeration value="AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET"/> + <xs:enumeration value="AUDIO_DEVICE_IN_USB_ACCESSORY"/> + <xs:enumeration value="AUDIO_DEVICE_IN_USB_DEVICE"/> + <xs:enumeration value="AUDIO_DEVICE_IN_FM_TUNER"/> + <xs:enumeration value="AUDIO_DEVICE_IN_TV_TUNER"/> + <xs:enumeration value="AUDIO_DEVICE_IN_LINE"/> + <xs:enumeration value="AUDIO_DEVICE_IN_SPDIF"/> + <xs:enumeration value="AUDIO_DEVICE_IN_BLUETOOTH_A2DP"/> + <xs:enumeration value="AUDIO_DEVICE_IN_LOOPBACK"/> + <xs:enumeration value="AUDIO_DEVICE_IN_IP"/> + <xs:enumeration value="AUDIO_DEVICE_IN_BUS"/> + <xs:enumeration value="AUDIO_DEVICE_IN_PROXY"/> + <xs:enumeration value="AUDIO_DEVICE_IN_USB_HEADSET"/> + <xs:enumeration value="AUDIO_DEVICE_IN_BLUETOOTH_BLE"/> + <xs:enumeration value="AUDIO_DEVICE_IN_DEFAULT"/> + <xs:enumeration value="AUDIO_DEVICE_IN_STUB"/> + </xs:restriction> + </xs:simpleType> + <!-- Enum values of audio_format_t in audio.h + TODO: generate from hidl to avoid manual sync. --> + <xs:simpleType name="audioFormat"> + <xs:restriction base="xs:string"> + <xs:enumeration value="AUDIO_FORMAT_PCM_16_BIT" /> + <xs:enumeration value="AUDIO_FORMAT_PCM_8_BIT"/> + <xs:enumeration value="AUDIO_FORMAT_PCM_32_BIT"/> + <xs:enumeration value="AUDIO_FORMAT_PCM_8_24_BIT"/> + <xs:enumeration value="AUDIO_FORMAT_PCM_FLOAT"/> + <xs:enumeration value="AUDIO_FORMAT_PCM_24_BIT_PACKED"/> + <xs:enumeration value="AUDIO_FORMAT_MP3"/> + <xs:enumeration value="AUDIO_FORMAT_AMR_NB"/> + <xs:enumeration value="AUDIO_FORMAT_AMR_WB"/> + <xs:enumeration value="AUDIO_FORMAT_AAC"/> + <xs:enumeration value="AUDIO_FORMAT_AAC_MAIN"/> + <xs:enumeration value="AUDIO_FORMAT_AAC_LC"/> + <xs:enumeration value="AUDIO_FORMAT_AAC_SSR"/> + <xs:enumeration value="AUDIO_FORMAT_AAC_LTP"/> + <xs:enumeration value="AUDIO_FORMAT_AAC_HE_V1"/> + <xs:enumeration value="AUDIO_FORMAT_AAC_SCALABLE"/> + <xs:enumeration value="AUDIO_FORMAT_AAC_ERLC"/> + <xs:enumeration value="AUDIO_FORMAT_AAC_LD"/> + <xs:enumeration value="AUDIO_FORMAT_AAC_HE_V2"/> + <xs:enumeration value="AUDIO_FORMAT_AAC_ELD"/> + <xs:enumeration value="AUDIO_FORMAT_AAC_ADTS_MAIN"/> + <xs:enumeration value="AUDIO_FORMAT_AAC_ADTS_LC"/> + <xs:enumeration value="AUDIO_FORMAT_AAC_ADTS_SSR"/> + <xs:enumeration value="AUDIO_FORMAT_AAC_ADTS_LTP"/> + <xs:enumeration value="AUDIO_FORMAT_AAC_ADTS_HE_V1"/> + <xs:enumeration value="AUDIO_FORMAT_AAC_ADTS_SCALABLE"/> + <xs:enumeration value="AUDIO_FORMAT_AAC_ADTS_ERLC"/> + <xs:enumeration value="AUDIO_FORMAT_AAC_ADTS_LD"/> + <xs:enumeration value="AUDIO_FORMAT_AAC_ADTS_HE_V2"/> + <xs:enumeration value="AUDIO_FORMAT_AAC_ADTS_ELD"/> + <xs:enumeration value="AUDIO_FORMAT_VORBIS"/> + <xs:enumeration value="AUDIO_FORMAT_HE_AAC_V1"/> + <xs:enumeration value="AUDIO_FORMAT_HE_AAC_V2"/> + <xs:enumeration value="AUDIO_FORMAT_OPUS"/> + <xs:enumeration value="AUDIO_FORMAT_AC3"/> + <xs:enumeration value="AUDIO_FORMAT_E_AC3"/> + <xs:enumeration value="AUDIO_FORMAT_DTS"/> + <xs:enumeration value="AUDIO_FORMAT_DTS_HD"/> + <xs:enumeration value="AUDIO_FORMAT_IEC61937"/> + <xs:enumeration value="AUDIO_FORMAT_DOLBY_TRUEHD"/> + <xs:enumeration value="AUDIO_FORMAT_EVRC"/> + <xs:enumeration value="AUDIO_FORMAT_EVRCB"/> + <xs:enumeration value="AUDIO_FORMAT_EVRCWB"/> + <xs:enumeration value="AUDIO_FORMAT_EVRCNW"/> + <xs:enumeration value="AUDIO_FORMAT_AAC_ADIF"/> + <xs:enumeration value="AUDIO_FORMAT_WMA"/> + <xs:enumeration value="AUDIO_FORMAT_WMA_PRO"/> + <xs:enumeration value="AUDIO_FORMAT_AMR_WB_PLUS"/> + <xs:enumeration value="AUDIO_FORMAT_MP2"/> + <xs:enumeration value="AUDIO_FORMAT_QCELP"/> + <xs:enumeration value="AUDIO_FORMAT_DSD"/> + <xs:enumeration value="AUDIO_FORMAT_FLAC"/> + <xs:enumeration value="AUDIO_FORMAT_ALAC"/> + <xs:enumeration value="AUDIO_FORMAT_APE"/> + <xs:enumeration value="AUDIO_FORMAT_AAC_ADTS"/> + <xs:enumeration value="AUDIO_FORMAT_SBC"/> + <xs:enumeration value="AUDIO_FORMAT_APTX"/> + <xs:enumeration value="AUDIO_FORMAT_APTX_HD"/> + <xs:enumeration value="AUDIO_FORMAT_AC4"/> + <xs:enumeration value="AUDIO_FORMAT_LDAC"/> + <xs:enumeration value="AUDIO_FORMAT_E_AC3_JOC"/> + <xs:enumeration value="AUDIO_FORMAT_MAT_1_0"/> + <xs:enumeration value="AUDIO_FORMAT_MAT_2_0"/> + <xs:enumeration value="AUDIO_FORMAT_MAT_2_1"/> + <xs:enumeration value="AUDIO_FORMAT_AAC_XHE"/> + <xs:enumeration value="AUDIO_FORMAT_AAC_ADTS_XHE"/> + </xs:restriction> + </xs:simpleType> + <!-- Enum values of audio::common::4_0::AudioUsage + TODO: generate from HIDL to avoid manual sync. --> + <xs:simpleType name="audioUsage"> + <xs:restriction base="xs:string"> + <xs:enumeration value="AUDIO_USAGE_UNKNOWN" /> + <xs:enumeration value="AUDIO_USAGE_MEDIA" /> + <xs:enumeration value="AUDIO_USAGE_VOICE_COMMUNICATION" /> + <xs:enumeration value="AUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING" /> + <xs:enumeration value="AUDIO_USAGE_ALARM" /> + <xs:enumeration value="AUDIO_USAGE_NOTIFICATION" /> + <xs:enumeration value="AUDIO_USAGE_NOTIFICATION_TELEPHONY_RINGTONE" /> + <xs:enumeration value="AUDIO_USAGE_ASSISTANCE_ACCESSIBILITY" /> + <xs:enumeration value="AUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE" /> + <xs:enumeration value="AUDIO_USAGE_ASSISTANCE_SONIFICATION" /> + <xs:enumeration value="AUDIO_USAGE_GAME" /> + <xs:enumeration value="AUDIO_USAGE_VIRTUAL_SOURCE" /> + <xs:enumeration value="AUDIO_USAGE_ASSISTANT" /> + </xs:restriction> + </xs:simpleType> + <xs:simpleType name="audioUsageList"> + <xs:list itemType="audioUsage"/> + </xs:simpleType> + <!-- TODO: Change to a space separated list to xsd enforce correctness. --> + <xs:simpleType name="samplingRates"> + <xs:restriction base="xs:string"> + <xs:pattern value="[0-9]+(,[0-9]+)*"/> + </xs:restriction> + </xs:simpleType> + <!-- TODO: Change to a space separated list to xsd enforce correctness. --> + <xs:simpleType name="channelMask"> + <xs:annotation> + <xs:documentation xml:lang="en"> + Comma (",") separated list of channel flags + from audio_channel_mask_t. + </xs:documentation> + </xs:annotation> + <xs:restriction base="xs:string"> + <xs:pattern value="[_A-Z][_A-Z0-9]*(,[_A-Z][_A-Z0-9]*)*"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="profile"> + <xs:attribute name="name" type="xs:token" use="optional"/> + <xs:attribute name="format" type="audioFormat" use="optional"/> + <xs:attribute name="samplingRates" type="samplingRates" use="optional"/> + <xs:attribute name="channelMasks" type="channelMask" use="optional"/> + </xs:complexType> + <xs:simpleType name="gainMode"> + <xs:restriction base="xs:string"> + <xs:enumeration value="AUDIO_GAIN_MODE_JOINT"/> + <xs:enumeration value="AUDIO_GAIN_MODE_CHANNELS"/> + <xs:enumeration value="AUDIO_GAIN_MODE_RAMP"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="gains"> + <xs:sequence> + <xs:element name="gain" minOccurs="0" maxOccurs="unbounded"> + <xs:complexType> + <xs:attribute name="name" type="xs:token" use="required"/> + <xs:attribute name="mode" type="gainMode" use="required"/> + <xs:attribute name="channel_mask" type="channelMask" use="optional"/> + <xs:attribute name="minValueMB" type="xs:int" use="optional"/> + <xs:attribute name="maxValueMB" type="xs:int" use="optional"/> + <xs:attribute name="defaultValueMB" type="xs:int" use="optional"/> + <xs:attribute name="stepValueMB" type="xs:int" use="optional"/> + <xs:attribute name="minRampMs" type="xs:int" use="optional"/> + <xs:attribute name="maxRampMs" type="xs:int" use="optional"/> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + <xs:complexType name="devicePorts"> + <xs:sequence> + <xs:element name="devicePort" minOccurs="0" maxOccurs="unbounded"> + <xs:complexType> + <xs:sequence> + <xs:element name="profile" type="profile" minOccurs="0" maxOccurs="unbounded"/> + <xs:element name="gains" type="gains" minOccurs="0"/> + </xs:sequence> + <xs:attribute name="tagName" type="xs:token" use="required"/> + <xs:attribute name="type" type="audioDevice" use="required"/> + <xs:attribute name="role" type="role" use="required"/> + <xs:attribute name="address" type="xs:string" use="optional" default=""/> + <!-- Note that XSD 1.0 can not check that a type only has one default. --> + <xs:attribute name="default" type="xs:boolean" use="optional"> + <xs:annotation> + <xs:documentation xml:lang="en"> + The default device will be used if multiple have the same type + and no explicit route request exists for a specific device of + that type. + </xs:documentation> + </xs:annotation> + </xs:attribute> + </xs:complexType> + <xs:unique name="devicePortProfileUniqueness"> + <xs:selector xpath="profile"/> + <xs:field xpath="format"/> + <xs:field xpath="samplingRate"/> + <xs:field xpath="channelMasks"/> + </xs:unique> + <xs:unique name="devicePortGainUniqueness"> + <xs:selector xpath="gains/gain"/> + <xs:field xpath="@name"/> + </xs:unique> + </xs:element> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="mixType"> + <xs:restriction base="xs:string"> + <xs:enumeration value="mix"/> + <xs:enumeration value="mux"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="routes"> + <xs:sequence> + <xs:element name="route" minOccurs="0" maxOccurs="unbounded"> + <xs:annotation> + <xs:documentation xml:lang="en"> + List all available sources for a given sink. + </xs:documentation> + </xs:annotation> + <xs:complexType> + <xs:attribute name="type" type="mixType" use="required"/> + <xs:attribute name="sink" type="xs:string" use="required"/> + <xs:attribute name="sources" type="xs:string" use="required"/> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> + <xs:complexType name="volumes"> + <xs:sequence> + <xs:element name="volume" type="volume" minOccurs="0" maxOccurs="unbounded"/> + <xs:element name="reference" type="reference" minOccurs="0" maxOccurs="unbounded"> + </xs:element> + </xs:sequence> + </xs:complexType> + <!-- TODO: Always require a ref for better xsd validations. + Currently a volume could have no points nor ref + as it can not be forbidden by xsd 1.0.--> + <xs:simpleType name="volumePoint"> + <xs:annotation> + <xs:documentation xml:lang="en"> + Comma separated pair of number. + The fist one is the framework level (between 0 and 100). + The second one is the volume to send to the HAL. + The framework will interpolate volumes not specified. + Their MUST be at least 2 points specified. + </xs:documentation> + </xs:annotation> + <xs:restriction base="xs:string"> + <xs:pattern value="([0-9]{1,2}|100),-?[0-9]+"/> + </xs:restriction> + </xs:simpleType> + <!-- Enum values of audio_stream_type_t in audio-base.h + TODO: generate from hidl to avoid manual sync. --> + <xs:simpleType name="stream"> + <xs:restriction base="xs:string"> + <xs:enumeration value="AUDIO_STREAM_VOICE_CALL"/> + <xs:enumeration value="AUDIO_STREAM_SYSTEM"/> + <xs:enumeration value="AUDIO_STREAM_RING"/> + <xs:enumeration value="AUDIO_STREAM_MUSIC"/> + <xs:enumeration value="AUDIO_STREAM_ALARM"/> + <xs:enumeration value="AUDIO_STREAM_NOTIFICATION"/> + <xs:enumeration value="AUDIO_STREAM_BLUETOOTH_SCO"/> + <xs:enumeration value="AUDIO_STREAM_ENFORCED_AUDIBLE"/> + <xs:enumeration value="AUDIO_STREAM_DTMF"/> + <xs:enumeration value="AUDIO_STREAM_TTS"/> + <xs:enumeration value="AUDIO_STREAM_ACCESSIBILITY"/> + <xs:enumeration value="AUDIO_STREAM_REROUTING"/> + <xs:enumeration value="AUDIO_STREAM_PATCH"/> + </xs:restriction> + </xs:simpleType> + <!-- Enum values of device_category from Volume.h. + TODO: generate from hidl to avoid manual sync. --> + <xs:simpleType name="deviceCategory"> + <xs:restriction base="xs:string"> + <xs:enumeration value="DEVICE_CATEGORY_HEADSET"/> + <xs:enumeration value="DEVICE_CATEGORY_SPEAKER"/> + <xs:enumeration value="DEVICE_CATEGORY_EARPIECE"/> + <xs:enumeration value="DEVICE_CATEGORY_EXT_MEDIA"/> + <xs:enumeration value="DEVICE_CATEGORY_HEARING_AID"/> + </xs:restriction> + </xs:simpleType> + <xs:complexType name="volume"> + <xs:annotation> + <xs:documentation xml:lang="en"> + Volume section defines a volume curve for a given use case and device category. + It contains a list of points of this curve expressing the attenuation in Millibels + for a given volume index from 0 to 100. + <volume stream="AUDIO_STREAM_MUSIC" deviceCategory="DEVICE_CATEGORY_SPEAKER"> + <point>0,-9600</point> + <point>100,0</point> + </volume> + + It may also reference a reference/@name to avoid duplicating curves. + <volume stream="AUDIO_STREAM_MUSIC" deviceCategory="DEVICE_CATEGORY_SPEAKER" + ref="DEFAULT_MEDIA_VOLUME_CURVE"/> + <reference name="DEFAULT_MEDIA_VOLUME_CURVE"> + <point>0,-9600</point> + <point>100,0</point> + </reference> + </xs:documentation> + </xs:annotation> + <xs:sequence> + <xs:element name="point" type="volumePoint" minOccurs="0" maxOccurs="unbounded"/> + </xs:sequence> + <xs:attribute name="stream" type="stream"/> + <xs:attribute name="deviceCategory" type="deviceCategory"/> + <xs:attribute name="ref" type="xs:token" use="optional"/> + </xs:complexType> + <xs:complexType name="reference"> + <xs:sequence> + <xs:element name="point" type="volumePoint" minOccurs="2" maxOccurs="unbounded"/> + </xs:sequence> + <xs:attribute name="name" type="xs:token" use="required"/> + </xs:complexType> + <xs:complexType name="surroundSound"> + <xs:annotation> + <xs:documentation xml:lang="en"> + Surround Sound section provides configuration related to handling of + multi-channel formats. + </xs:documentation> + </xs:annotation> + <xs:sequence> + <xs:element name="formats" type="surroundFormats"/> + </xs:sequence> + </xs:complexType> + <xs:simpleType name="surroundFormatsList"> + <xs:list itemType="audioFormat" /> + </xs:simpleType> + <xs:complexType name="surroundFormats"> + <xs:sequence> + <xs:element name="format" minOccurs="0" maxOccurs="unbounded"> + <xs:complexType> + <xs:attribute name="name" type="audioFormat" use="required"/> + <xs:attribute name="subformats" type="surroundFormatsList" /> + </xs:complexType> + </xs:element> + </xs:sequence> + </xs:complexType> +</xs:schema> diff --git a/audio/5.0/types.hal b/audio/5.0/types.hal new file mode 100644 index 0000000000..988f584b62 --- /dev/null +++ b/audio/5.0/types.hal @@ -0,0 +1,246 @@ +/* + * Copyright (C) 2018 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@5.0; + +import android.hardware.audio.common@5.0; + +enum Result : int32_t { + OK, + NOT_INITIALIZED, + INVALID_ARGUMENTS, + INVALID_STATE, + /** + * Methods marked as "Optional method" must return this result value + * if the operation is not supported by HAL. + */ + NOT_SUPPORTED +}; + +@export(name="audio_drain_type_t", value_prefix="AUDIO_DRAIN_") +enum AudioDrain : int32_t { + /** drain() returns when all data has been played. */ + ALL, + /** + * drain() returns a short time before all data from the current track has + * been played to give time for gapless track switch. + */ + EARLY_NOTIFY +}; + +/** + * A substitute for POSIX timespec. + */ +struct TimeSpec { + uint64_t tvSec; // seconds + uint64_t tvNSec; // nanoseconds +}; + +/** + * IEEE 802 MAC address. + */ +typedef uint8_t[6] MacAddress; + +struct ParameterValue { + string key; + string value; +}; + +/** + * Specifies a device in case when several devices of the same type + * can be connected (e.g. BT A2DP, USB). + */ +struct DeviceAddress { + AudioDevice device; // discriminator + union Address { + MacAddress mac; // used for BLUETOOTH_A2DP_* + uint8_t[4] ipv4; // used for IP + struct Alsa { + int32_t card; + int32_t device; + } alsa; // used for USB_* + } address; + string busAddress; // used for BUS + string rSubmixAddress; // used for REMOTE_SUBMIX +}; + +enum MmapBufferFlag : uint32_t { + NONE = 0x0, + /** + * If the buffer can be securely shared to untrusted applications + * through the AAudio exclusive mode. + * Only set this flag if applications are restricted from accessing the + * memory surrounding the audio data buffer by a kernel mechanism. + * See Linux kernel's dma_buf. + */ + APPLICATION_SHAREABLE = 0x1, +}; + +/** + * Mmap buffer descriptor returned by IStream.createMmapBuffer(). + * Used by streams opened in mmap mode. + */ +struct MmapBufferInfo { + /** Mmap memory buffer */ + memory sharedMemory; + /** Total buffer size in frames */ + uint32_t bufferSizeFrames; + /** Transfer size granularity in frames */ + uint32_t burstSizeFrames; + /** Attributes describing the buffer. */ + bitfield<MmapBufferFlag> flags; +}; + +/** + * Mmap buffer read/write position returned by IStream.getMmapPosition(). + * Used by streams opened in mmap mode. + */ +struct MmapPosition { + int64_t timeNanoseconds; // time stamp in ns, CLOCK_MONOTONIC + int32_t positionFrames; // increasing 32 bit frame count reset when IStream.stop() is called +}; + +/** + * The message queue flags used to synchronize reads and writes from + * message queues used by StreamIn and StreamOut. + */ +enum MessageQueueFlagBits : uint32_t { + NOT_EMPTY = 1 << 0, + NOT_FULL = 1 << 1 +}; + +/* + * Microphone information + * + */ + +/** + * A 3D point used to represent position or orientation of a microphone. + * + * Position: Coordinates of the microphone's capsule, in meters, from the + * bottom-left-back corner of the bounding box of android device in natural + * orientation (PORTRAIT for phones, LANDSCAPE for tablets, tvs, etc). + * The orientation musth match the reported by the api Display.getRotation(). + * + * Orientation: Normalized vector to signal the main orientation of the + * microphone's capsule. Magnitude = sqrt(x^2 + y^2 + z^2) = 1 + */ +struct AudioMicrophoneCoordinate { + float x; + float y; + float z; +}; + +/** + * Enum to identify the type of channel mapping for active microphones. + * Used channels further identify if the microphone has any significative + * process (e.g. High Pass Filtering, dynamic compression) + * Simple processing as constant gain adjustment must be DIRECT. + */ +enum AudioMicrophoneChannelMapping : uint32_t { + UNUSED = 0, /* Channel not used */ + DIRECT = 1, /* Channel used and signal not processed */ + PROCESSED = 2, /* Channel used and signal has some process */ +}; + +/** + * Enum to identify locations of microphones in regards to the body of the + * android device. + */ +enum AudioMicrophoneLocation : uint32_t { + UNKNOWN = 0, + MAINBODY = 1, + MAINBODY_MOVABLE = 2, + PERIPHERAL = 3, +}; + +/** + * Identifier to help group related microphones together + * e.g. microphone arrays should belong to the same group + */ +typedef int32_t AudioMicrophoneGroup; + +/** + * Enum with standard polar patterns of microphones + */ +enum AudioMicrophoneDirectionality : uint32_t { + UNKNOWN = 0, + OMNI = 1, + BI_DIRECTIONAL = 2, + CARDIOID = 3, + HYPER_CARDIOID = 4, + SUPER_CARDIOID = 5, +}; + +/** + * A (frequency, level) pair. Used to represent frequency response. + */ +struct AudioFrequencyResponsePoint { + /** In Hz */ + float frequency; + /** In dB */ + float level; +}; + +/** + * Structure used by the HAL to describe microphone's characteristics + * Used by StreamIn and Device + */ +struct MicrophoneInfo { + /** Unique alphanumeric id for microphone. Guaranteed to be the same + * even after rebooting. + */ + string deviceId; + /** + * Device specific information + */ + DeviceAddress deviceAddress; + /** Each element of the vector must describe the channel with the same + * index. + */ + vec<AudioMicrophoneChannelMapping> channelMapping; + /** Location of the microphone in regard to the body of the device */ + AudioMicrophoneLocation location; + /** Identifier to help group related microphones together + * e.g. microphone arrays should belong to the same group + */ + AudioMicrophoneGroup group; + /** Index of this microphone within the group. + * (group, index) must be unique within the same device. + */ + uint32_t indexInTheGroup; + /** Level in dBFS produced by a 1000 Hz tone at 94 dB SPL */ + float sensitivity; + /** Level in dB of the max SPL supported at 1000 Hz */ + float maxSpl; + /** Level in dB of the min SPL supported at 1000 Hz */ + float minSpl; + /** Standard polar pattern of the microphone */ + AudioMicrophoneDirectionality directionality; + /** Vector with ordered frequency responses (from low to high frequencies) + * with the frequency response of the microphone. + * Levels are in dB, relative to level at 1000 Hz + */ + vec<AudioFrequencyResponsePoint> frequencyResponse; + /** Position of the microphone's capsule in meters, from the + * bottom-left-back corner of the bounding box of device. + */ + AudioMicrophoneCoordinate position; + /** Normalized point to signal the main orientation of the microphone's + * capsule. sqrt(x^2 + y^2 + z^2) = 1 + */ + AudioMicrophoneCoordinate orientation; +}; diff --git a/audio/README b/audio/README index 1f1e8e3ad8..abe979c0fa 100644 --- a/audio/README +++ b/audio/README @@ -1,48 +1,33 @@ Directory structure of the audio HIDL related code. audio -|-- 2.0 <== HIDL (.hal) can not be moved to fit the directory structure -| because that would create a separate HAL +|-- 2.0 <== core 2.0 HIDL API. .hal can not be moved into the core directory +| because that would change its namespace and include path |-- 4.0 <== Version 4.0 of the core API | +|-- ... +| |-- common <== code common to audio core and effect API -| |-- 2.0 -| | |-- default <== code that wraps the legacy API -| | `-- vts <== vts of 2.0 core and effect API common code +| |-- 2.0 <== HIDL API of V2 | |-- 4.0 -| | |-- default -| | `-- vts -| |-- ... <== The future versions should continue this structure -| | |-- default -| | `-- vts +| |-- ... | `-- all_versions <== code common to all version of both core and effect API -| |-- default -| `-- vts <== vts of core and effect API common version independent code +| |-- default <== implementation shared code between core and effect impl +| |-- test <== utilities used by tests +| `-- util <== utilities used by both implementation and tests | -|-- core <== code relative to the core API -| |-- 2.0 <== 2.0 core API code (except .hal, see audio/2.0) -| | |-- default -| | `-- vts -| |-- 4.0 -| | |-- default <== default implementation of the core 4.0 api -| | `-- vts <== vts code of the 4.0 API -| |-- ... -| | |-- default -| | `-- vts -| `-- all_versions -| |-- default -| `-- vts <== vts of core API common version independent code +|-- core <== VTS and default implementation of the core API (not HIDL, see /audio/2.0)) +| `-- all_versions <== Code is version independent through #if and separate files +| |-- default <== code that wraps the legacy API +| `-- vts <== vts of core API +| |-- 2.0 <== 2.0 specific tests and helpers +| |-- 4.0 +| |-- ... | `-- effect <== idem for the effect API |-- 2.0 - | |-- default - | `-- vts |-- 4.0 - | |-- default - | `-- vts |-- ... - | |-- default - | `-- vts `-- all_versions |-- default `-- vts diff --git a/audio/common/2.0/default/Android.bp b/audio/common/2.0/default/Android.bp deleted file mode 100644 index ac66479c93..0000000000 --- a/audio/common/2.0/default/Android.bp +++ /dev/null @@ -1,47 +0,0 @@ -// -// Copyright (C) 2016 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. - -cc_library_shared { - name: "android.hardware.audio.common@2.0-util", - defaults: ["hidl_defaults"], - vendor_available: true, - vndk: { - enabled: true, - }, - srcs: [ - "HidlUtils.cpp", - ], - - export_include_dirs: ["."], - - static_libs: [ - ], - - shared_libs: [ - "liblog", - "libutils", - "libhidlbase", - "android.hardware.audio.common-util", - "android.hardware.audio.common@2.0", - ], - export_shared_lib_headers: [ - "android.hardware.audio.common-util" - ], - - header_libs: [ - "libaudio_system_headers", - "libhardware_headers", - ], -} diff --git a/audio/common/2.0/default/HidlUtils.cpp b/audio/common/2.0/default/HidlUtils.cpp deleted file mode 100644 index 9771b7bda2..0000000000 --- a/audio/common/2.0/default/HidlUtils.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2016 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 "HidlUtils.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <common/all-versions/default/HidlUtils.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/common/2.0/default/HidlUtils.h b/audio/common/2.0/default/HidlUtils.h deleted file mode 100644 index 24543b1617..0000000000 --- a/audio/common/2.0/default/HidlUtils.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2016 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. - */ - -#ifndef android_hardware_audio_V2_0_Hidl_Utils_H_ -#define android_hardware_audio_V2_0_Hidl_Utils_H_ - -#include <android/hardware/audio/common/2.0/types.h> - -#define AUDIO_HAL_VERSION V2_0 -#include <common/all-versions/default/HidlUtils.h> -#undef AUDIO_HAL_VERSION - -#endif // android_hardware_audio_V2_0_Hidl_Utils_H_ diff --git a/audio/common/2.0/default/VersionUtils.h b/audio/common/2.0/default/VersionUtils.h deleted file mode 100644 index 60d1f9cb6d..0000000000 --- a/audio/common/2.0/default/VersionUtils.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (C) 2018 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_VERSION_UTILS_H -#define ANDROID_HARDWARE_AUDIO_EFFECT_VERSION_UTILS_H - -#include <android/hardware/audio/common/2.0/types.h> - -namespace android { -namespace hardware { -namespace audio { -namespace common { -namespace V2_0 { -namespace implementation { - -typedef common::V2_0::AudioDevice AudioDeviceBitfield; -typedef common::V2_0::AudioChannelMask AudioChannelBitfield; -typedef common::V2_0::AudioOutputFlag AudioOutputFlagBitfield; -typedef common::V2_0::AudioInputFlag AudioInputFlagBitfield; - -} // namespace implementation -} // namespace V2_0 -} // namespace common -} // namespace audio -} // namespace hardware -} // namespace android - -#endif // ANDROID_HARDWARE_AUDIO_EFFECT_VERSION_UTILS_H diff --git a/audio/common/4.0/default/Android.bp b/audio/common/4.0/default/Android.bp deleted file mode 100644 index 57b2e01f3d..0000000000 --- a/audio/common/4.0/default/Android.bp +++ /dev/null @@ -1,47 +0,0 @@ -// -// Copyright (C) 2018 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. - -cc_library_shared { - name: "android.hardware.audio.common@4.0-util", - defaults: ["hidl_defaults"], - vendor_available: true, - vndk: { - enabled: true, - }, - srcs: [ - "HidlUtils.cpp", - ], - - export_include_dirs: ["."], - - static_libs: [ - ], - - shared_libs: [ - "liblog", - "libutils", - "libhidlbase", - "android.hardware.audio.common-util", - "android.hardware.audio.common@4.0", - ], - export_shared_lib_headers: [ - "android.hardware.audio.common-util" - ], - - header_libs: [ - "libaudio_system_headers", - "libhardware_headers", - ], -} diff --git a/audio/common/4.0/default/HidlUtils.cpp b/audio/common/4.0/default/HidlUtils.cpp deleted file mode 100644 index b66eff975a..0000000000 --- a/audio/common/4.0/default/HidlUtils.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2018 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 "HidlUtils.h" - -#define AUDIO_HAL_VERSION V4_0 -#include <common/all-versions/default/HidlUtils.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/common/4.0/default/HidlUtils.h b/audio/common/4.0/default/HidlUtils.h deleted file mode 100644 index 91e6a9e121..0000000000 --- a/audio/common/4.0/default/HidlUtils.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2018 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. - */ - -#ifndef android_hardware_audio_V4_0_Hidl_Utils_H_ -#define android_hardware_audio_V4_0_Hidl_Utils_H_ - -#include <android/hardware/audio/common/4.0/types.h> - -#define AUDIO_HAL_VERSION V4_0 -#include <common/all-versions/default/HidlUtils.h> -#undef AUDIO_HAL_VERSION - -#endif // android_hardware_audio_V4_0_Hidl_Utils_H_ diff --git a/audio/common/5.0/Android.bp b/audio/common/5.0/Android.bp new file mode 100644 index 0000000000..663f8470f9 --- /dev/null +++ b/audio/common/5.0/Android.bp @@ -0,0 +1,48 @@ +// This file is autogenerated by hidl-gen -Landroidbp. + +hidl_interface { + name: "android.hardware.audio.common@5.0", + root: "android.hardware", + vndk: { + enabled: true, + }, + srcs: [ + "types.hal", + ], + types: [ + "AudioChannelMask", + "AudioConfig", + "AudioContentType", + "AudioDevice", + "AudioFormat", + "AudioGain", + "AudioGainConfig", + "AudioGainMode", + "AudioHandleConsts", + "AudioInputFlag", + "AudioMixLatencyClass", + "AudioMode", + "AudioOffloadInfo", + "AudioOutputFlag", + "AudioPort", + "AudioPortConfig", + "AudioPortConfigDeviceExt", + "AudioPortConfigMask", + "AudioPortConfigSessionExt", + "AudioPortDeviceExt", + "AudioPortMixExt", + "AudioPortRole", + "AudioPortSessionExt", + "AudioPortType", + "AudioSessionConsts", + "AudioSource", + "AudioStreamType", + "AudioUsage", + "FixedChannelCount", + "ThreadInfo", + "Uuid", + ], + gen_java: false, + gen_java_constants: true, +} + diff --git a/audio/common/5.0/types.hal b/audio/common/5.0/types.hal new file mode 100644 index 0000000000..2ce2929dce --- /dev/null +++ b/audio/common/5.0/types.hal @@ -0,0 +1,936 @@ +/* + * Copyright (C) 2018 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.common@5.0; + +/* + * + * IDs and Handles + * + */ + +/** + * Handle type for identifying audio sources and sinks. + */ +typedef int32_t AudioIoHandle; + +/** + * Audio hw module handle functions or structures referencing a module. + */ +typedef int32_t AudioModuleHandle; + +/** + * Each port has a unique ID or handle allocated by policy manager. + */ +typedef int32_t AudioPortHandle; + +/** + * Each patch is identified by a handle at the interface used to create that + * patch. For instance, when a patch is created by the audio HAL, the HAL + * allocates and returns a handle. This handle is unique to a given audio HAL + * hardware module. But the same patch receives another system wide unique + * handle allocated by the framework. This unique handle is used for all + * transactions inside the framework. + */ +typedef int32_t AudioPatchHandle; + +/** + * A HW synchronization source returned by the audio HAL. + */ +typedef uint32_t AudioHwSync; + +/** + * Each port has a unique ID or handle allocated by policy manager. + */ +@export(name="") +enum AudioHandleConsts : int32_t { + AUDIO_IO_HANDLE_NONE = 0, + AUDIO_MODULE_HANDLE_NONE = 0, + AUDIO_PORT_HANDLE_NONE = 0, + AUDIO_PATCH_HANDLE_NONE = 0, +}; + +/** + * Commonly used structure for passing unique identifieds (UUID). + * For the definition of UUID, refer to ITU-T X.667 spec. + */ +struct Uuid { + uint32_t timeLow; + uint16_t timeMid; + uint16_t versionAndTimeHigh; + uint16_t variantAndClockSeqHigh; + uint8_t[6] node; +}; + + +/* + * + * Audio streams + * + */ + +/** + * Audio stream type describing the intended use case of a stream. + */ +@export(name="audio_stream_type_t", value_prefix="AUDIO_STREAM_") +enum AudioStreamType : int32_t { + // These values must kept in sync with + // frameworks/base/media/java/android/media/AudioSystem.java + DEFAULT = -1, + MIN = 0, + VOICE_CALL = 0, + SYSTEM = 1, + RING = 2, + MUSIC = 3, + ALARM = 4, + NOTIFICATION = 5, + BLUETOOTH_SCO = 6, + ENFORCED_AUDIBLE = 7, // Sounds that cannot be muted by user and must be + // routed to speaker + DTMF = 8, + TTS = 9, // Transmitted Through Speaker. Plays over speaker + // only, silent on other devices + ACCESSIBILITY = 10, // For accessibility talk back prompts +}; + +@export(name="audio_source_t", value_prefix="AUDIO_SOURCE_") +enum AudioSource : int32_t { + // These values must kept in sync with + // frameworks/base/media/java/android/media/MediaRecorder.java, + // frameworks/av/services/audiopolicy/AudioPolicyService.cpp, + // system/media/audio_effects/include/audio_effects/audio_effects_conf.h + DEFAULT = 0, + MIC = 1, + VOICE_UPLINK = 2, + VOICE_DOWNLINK = 3, + VOICE_CALL = 4, + CAMCORDER = 5, + VOICE_RECOGNITION = 6, + VOICE_COMMUNICATION = 7, + /** + * Source for the mix to be presented remotely. An example of remote + * presentation is Wifi Display where a dongle attached to a TV can be used + * to play the mix captured by this audio source. + */ + REMOTE_SUBMIX = 8, + /** + * Source for unprocessed sound. Usage examples include level measurement + * and raw signal analysis. + */ + UNPROCESSED = 9, + + FM_TUNER = 1998, +}; + +typedef int32_t AudioSession; +/** + * Special audio session values. + */ +@export(name="audio_session_t", value_prefix="AUDIO_SESSION_") +enum AudioSessionConsts : int32_t { + /** + * Session for effects attached to a particular output stream + * (value must be less than 0) + */ + OUTPUT_STAGE = -1, + /** + * Session for effects applied to output mix. These effects can + * be moved by audio policy manager to another output stream + * (value must be 0) + */ + OUTPUT_MIX = 0, + /** + * Application does not specify an explicit session ID to be used, and + * requests a new session ID to be allocated. Corresponds to + * AudioManager.AUDIO_SESSION_ID_GENERATE and + * AudioSystem.AUDIO_SESSION_ALLOCATE. + */ + ALLOCATE = 0, + /** + * For use with AudioRecord::start(), this indicates no trigger session. + * It is also used with output tracks and patch tracks, which never have a + * session. + */ + NONE = 0 +}; + +/** + * Audio format is a 32-bit word that consists of: + * main format field (upper 8 bits) + * sub format field (lower 24 bits). + * + * The main format indicates the main codec type. The sub format field indicates + * options and parameters for each format. The sub format is mainly used for + * record to indicate for instance the requested bitrate or profile. It can + * also be used for certain formats to give informations not present in the + * encoded audio stream (e.g. octet alignement for AMR). + */ +@export(name="audio_format_t", value_prefix="AUDIO_FORMAT_") +enum AudioFormat : uint32_t { + INVALID = 0xFFFFFFFFUL, + DEFAULT = 0, + PCM = 0x00000000UL, + MP3 = 0x01000000UL, + AMR_NB = 0x02000000UL, + AMR_WB = 0x03000000UL, + AAC = 0x04000000UL, + /** Deprecated, Use AAC_HE_V1 */ + HE_AAC_V1 = 0x05000000UL, + /** Deprecated, Use AAC_HE_V2 */ + HE_AAC_V2 = 0x06000000UL, + VORBIS = 0x07000000UL, + OPUS = 0x08000000UL, + AC3 = 0x09000000UL, + E_AC3 = 0x0A000000UL, + DTS = 0x0B000000UL, + DTS_HD = 0x0C000000UL, + /** IEC61937 is encoded audio wrapped in 16-bit PCM. */ + IEC61937 = 0x0D000000UL, + DOLBY_TRUEHD = 0x0E000000UL, + EVRC = 0x10000000UL, + EVRCB = 0x11000000UL, + EVRCWB = 0x12000000UL, + EVRCNW = 0x13000000UL, + AAC_ADIF = 0x14000000UL, + WMA = 0x15000000UL, + WMA_PRO = 0x16000000UL, + AMR_WB_PLUS = 0x17000000UL, + MP2 = 0x18000000UL, + QCELP = 0x19000000UL, + DSD = 0x1A000000UL, + FLAC = 0x1B000000UL, + ALAC = 0x1C000000UL, + APE = 0x1D000000UL, + AAC_ADTS = 0x1E000000UL, + SBC = 0x1F000000UL, + APTX = 0x20000000UL, + APTX_HD = 0x21000000UL, + AC4 = 0x22000000UL, + LDAC = 0x23000000UL, + /** Dolby Metadata-enhanced Audio Transmission */ + MAT = 0x24000000UL, + /** Deprecated */ + MAIN_MASK = 0xFF000000UL, + SUB_MASK = 0x00FFFFFFUL, + + /* Subformats */ + PCM_SUB_16_BIT = 0x1, // PCM signed 16 bits + PCM_SUB_8_BIT = 0x2, // PCM unsigned 8 bits + PCM_SUB_32_BIT = 0x3, // PCM signed .31 fixed point + PCM_SUB_8_24_BIT = 0x4, // PCM signed 8.23 fixed point + PCM_SUB_FLOAT = 0x5, // PCM single-precision float pt + PCM_SUB_24_BIT_PACKED = 0x6, // PCM signed .23 fix pt (3 bytes) + + MP3_SUB_NONE = 0x0, + + AMR_SUB_NONE = 0x0, + + AAC_SUB_MAIN = 0x1, + AAC_SUB_LC = 0x2, + AAC_SUB_SSR = 0x4, + AAC_SUB_LTP = 0x8, + AAC_SUB_HE_V1 = 0x10, + AAC_SUB_SCALABLE = 0x20, + AAC_SUB_ERLC = 0x40, + AAC_SUB_LD = 0x80, + AAC_SUB_HE_V2 = 0x100, + AAC_SUB_ELD = 0x200, + AAC_SUB_XHE = 0x300, + + VORBIS_SUB_NONE = 0x0, + + E_AC3_SUB_JOC = 0x1, + + MAT_SUB_1_0 = 0x1, + MAT_SUB_2_0 = 0x2, + MAT_SUB_2_1 = 0x3, + + /* Aliases */ + /** note != AudioFormat.ENCODING_PCM_16BIT */ + PCM_16_BIT = (PCM | PCM_SUB_16_BIT), + /** note != AudioFormat.ENCODING_PCM_8BIT */ + PCM_8_BIT = (PCM | PCM_SUB_8_BIT), + PCM_32_BIT = (PCM | PCM_SUB_32_BIT), + PCM_8_24_BIT = (PCM | PCM_SUB_8_24_BIT), + PCM_FLOAT = (PCM | PCM_SUB_FLOAT), + PCM_24_BIT_PACKED = (PCM | PCM_SUB_24_BIT_PACKED), + AAC_MAIN = (AAC | AAC_SUB_MAIN), + AAC_LC = (AAC | AAC_SUB_LC), + AAC_SSR = (AAC | AAC_SUB_SSR), + AAC_LTP = (AAC | AAC_SUB_LTP), + AAC_HE_V1 = (AAC | AAC_SUB_HE_V1), + AAC_SCALABLE = (AAC | AAC_SUB_SCALABLE), + AAC_ERLC = (AAC | AAC_SUB_ERLC), + AAC_LD = (AAC | AAC_SUB_LD), + AAC_HE_V2 = (AAC | AAC_SUB_HE_V2), + AAC_ELD = (AAC | AAC_SUB_ELD), + AAC_XHE = (AAC | AAC_SUB_XHE), + AAC_ADTS_MAIN = (AAC_ADTS | AAC_SUB_MAIN), + AAC_ADTS_LC = (AAC_ADTS | AAC_SUB_LC), + AAC_ADTS_SSR = (AAC_ADTS | AAC_SUB_SSR), + AAC_ADTS_LTP = (AAC_ADTS | AAC_SUB_LTP), + AAC_ADTS_HE_V1 = (AAC_ADTS | AAC_SUB_HE_V1), + AAC_ADTS_SCALABLE = (AAC_ADTS | AAC_SUB_SCALABLE), + AAC_ADTS_ERLC = (AAC_ADTS | AAC_SUB_ERLC), + AAC_ADTS_LD = (AAC_ADTS | AAC_SUB_LD), + AAC_ADTS_HE_V2 = (AAC_ADTS | AAC_SUB_HE_V2), + AAC_ADTS_ELD = (AAC_ADTS | AAC_SUB_ELD), + AAC_ADTS_XHE = (AAC_ADTS | AAC_SUB_XHE), + E_AC3_JOC = (E_AC3 | E_AC3_SUB_JOC), + MAT_1_0 = (MAT | MAT_SUB_1_0), + MAT_2_0 = (MAT | MAT_SUB_2_0), + MAT_2_1 = (MAT | MAT_SUB_2_1), +}; + +/** + * Usage of these values highlights places in the code that use 2- or 8- channel + * assumptions. + */ +@export(name="") +enum FixedChannelCount : int32_t { + FCC_2 = 2, // This is typically due to legacy implementation of stereo I/O + FCC_8 = 8 // This is typically due to audio mixer and resampler limitations +}; + +/** + * A channel mask per se only defines the presence or absence of a channel, not + * the order. See AUDIO_INTERLEAVE_* for the platform convention of order. + * + * AudioChannelMask is an opaque type and its internal layout should not be + * assumed as it may change in the future. Instead, always use functions + * to examine it. + * + * These are the current representations: + * + * REPRESENTATION_POSITION + * is a channel mask representation for position assignment. Each low-order + * bit corresponds to the spatial position of a transducer (output), or + * interpretation of channel (input). The user of a channel mask needs to + * know the context of whether it is for output or input. The constants + * OUT_* or IN_* apply to the bits portion. It is not permitted for no bits + * to be set. + * + * REPRESENTATION_INDEX + * is a channel mask representation for index assignment. Each low-order + * bit corresponds to a selected channel. There is no platform + * interpretation of the various bits. There is no concept of output or + * input. It is not permitted for no bits to be set. + * + * All other representations are reserved for future use. + * + * Warning: current representation distinguishes between input and output, but + * this will not the be case in future revisions of the platform. Wherever there + * is an ambiguity between input and output that is currently resolved by + * checking the channel mask, the implementer should look for ways to fix it + * with additional information outside of the mask. + */ +@export(name="", value_prefix="AUDIO_CHANNEL_") +enum AudioChannelMask : uint32_t { + /** must be 0 for compatibility */ + REPRESENTATION_POSITION = 0, + /** 1 is reserved for future use */ + REPRESENTATION_INDEX = 2, + /* 3 is reserved for future use */ + + /** These can be a complete value of AudioChannelMask */ + NONE = 0x0, + INVALID = 0xC0000000, + + /* + * These can be the bits portion of an AudioChannelMask + * with representation REPRESENTATION_POSITION. + */ + + /** output channels */ + OUT_FRONT_LEFT = 0x1, + OUT_FRONT_RIGHT = 0x2, + OUT_FRONT_CENTER = 0x4, + OUT_LOW_FREQUENCY = 0x8, + OUT_BACK_LEFT = 0x10, + OUT_BACK_RIGHT = 0x20, + OUT_FRONT_LEFT_OF_CENTER = 0x40, + OUT_FRONT_RIGHT_OF_CENTER = 0x80, + OUT_BACK_CENTER = 0x100, + OUT_SIDE_LEFT = 0x200, + OUT_SIDE_RIGHT = 0x400, + OUT_TOP_CENTER = 0x800, + OUT_TOP_FRONT_LEFT = 0x1000, + OUT_TOP_FRONT_CENTER = 0x2000, + OUT_TOP_FRONT_RIGHT = 0x4000, + OUT_TOP_BACK_LEFT = 0x8000, + OUT_TOP_BACK_CENTER = 0x10000, + OUT_TOP_BACK_RIGHT = 0x20000, + OUT_TOP_SIDE_LEFT = 0x40000, + OUT_TOP_SIDE_RIGHT = 0x80000, + + OUT_MONO = OUT_FRONT_LEFT, + OUT_STEREO = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT), + OUT_2POINT1 = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT | OUT_LOW_FREQUENCY), + OUT_2POINT0POINT2 = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT | + OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT), + OUT_2POINT1POINT2 = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT | + OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT | + OUT_LOW_FREQUENCY), + OUT_3POINT0POINT2 = (OUT_FRONT_LEFT | OUT_FRONT_CENTER | OUT_FRONT_RIGHT | + OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT), + OUT_3POINT1POINT2 = (OUT_FRONT_LEFT | OUT_FRONT_CENTER | OUT_FRONT_RIGHT | + OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT | + OUT_LOW_FREQUENCY), + OUT_QUAD = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT | + OUT_BACK_LEFT | OUT_BACK_RIGHT), + OUT_QUAD_BACK = OUT_QUAD, + /** like OUT_QUAD_BACK with *_SIDE_* instead of *_BACK_* */ + OUT_QUAD_SIDE = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT | + OUT_SIDE_LEFT | OUT_SIDE_RIGHT), + OUT_SURROUND = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT | + OUT_FRONT_CENTER | OUT_BACK_CENTER), + OUT_PENTA = (OUT_QUAD | OUT_FRONT_CENTER), + OUT_5POINT1 = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT | + OUT_FRONT_CENTER | OUT_LOW_FREQUENCY | + OUT_BACK_LEFT | OUT_BACK_RIGHT), + OUT_5POINT1_BACK = OUT_5POINT1, + /** like OUT_5POINT1_BACK with *_SIDE_* instead of *_BACK_* */ + OUT_5POINT1_SIDE = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT | + OUT_FRONT_CENTER | OUT_LOW_FREQUENCY | + OUT_SIDE_LEFT | OUT_SIDE_RIGHT), + OUT_5POINT1POINT2 = (OUT_5POINT1 | OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT), + OUT_5POINT1POINT4 = (OUT_5POINT1 | + OUT_TOP_FRONT_LEFT | OUT_TOP_FRONT_RIGHT | + OUT_TOP_BACK_LEFT | OUT_TOP_BACK_RIGHT), + OUT_6POINT1 = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT | + OUT_FRONT_CENTER | OUT_LOW_FREQUENCY | + OUT_BACK_LEFT | OUT_BACK_RIGHT | + OUT_BACK_CENTER), + /** matches the correct AudioFormat.CHANNEL_OUT_7POINT1_SURROUND */ + OUT_7POINT1 = (OUT_FRONT_LEFT | OUT_FRONT_RIGHT | + OUT_FRONT_CENTER | OUT_LOW_FREQUENCY | + OUT_BACK_LEFT | OUT_BACK_RIGHT | + OUT_SIDE_LEFT | OUT_SIDE_RIGHT), + OUT_7POINT1POINT2 = (OUT_7POINT1 | OUT_TOP_SIDE_LEFT | OUT_TOP_SIDE_RIGHT), + OUT_7POINT1POINT4 = (OUT_7POINT1 | + OUT_TOP_FRONT_LEFT | OUT_TOP_FRONT_RIGHT | + OUT_TOP_BACK_LEFT | OUT_TOP_BACK_RIGHT), + // Note that the 2.0 OUT_ALL* have been moved to helper functions + + /* These are bits only, not complete values */ + + /** input channels */ + IN_LEFT = 0x4, + IN_RIGHT = 0x8, + IN_FRONT = 0x10, + IN_BACK = 0x20, + IN_LEFT_PROCESSED = 0x40, + IN_RIGHT_PROCESSED = 0x80, + IN_FRONT_PROCESSED = 0x100, + IN_BACK_PROCESSED = 0x200, + IN_PRESSURE = 0x400, + IN_X_AXIS = 0x800, + IN_Y_AXIS = 0x1000, + IN_Z_AXIS = 0x2000, + IN_BACK_LEFT = 0x10000, + IN_BACK_RIGHT = 0x20000, + IN_CENTER = 0x40000, + IN_LOW_FREQUENCY = 0x100000, + IN_TOP_LEFT = 0x200000, + IN_TOP_RIGHT = 0x400000, + + IN_VOICE_UPLINK = 0x4000, + IN_VOICE_DNLINK = 0x8000, + + IN_MONO = IN_FRONT, + IN_STEREO = (IN_LEFT | IN_RIGHT), + IN_FRONT_BACK = (IN_FRONT | IN_BACK), + IN_6 = (IN_LEFT | IN_RIGHT | + IN_FRONT | IN_BACK | + IN_LEFT_PROCESSED | IN_RIGHT_PROCESSED), + IN_2POINT0POINT2 = (IN_LEFT | IN_RIGHT | IN_TOP_LEFT | IN_TOP_RIGHT), + IN_2POINT1POINT2 = (IN_LEFT | IN_RIGHT | IN_TOP_LEFT | IN_TOP_RIGHT | + IN_LOW_FREQUENCY), + IN_3POINT0POINT2 = (IN_LEFT | IN_CENTER | IN_RIGHT | IN_TOP_LEFT | IN_TOP_RIGHT), + IN_3POINT1POINT2 = (IN_LEFT | IN_CENTER | IN_RIGHT | + IN_TOP_LEFT | IN_TOP_RIGHT | IN_LOW_FREQUENCY), + IN_5POINT1 = (IN_LEFT | IN_CENTER | IN_RIGHT | + IN_BACK_LEFT | IN_BACK_RIGHT | IN_LOW_FREQUENCY), + IN_VOICE_UPLINK_MONO = (IN_VOICE_UPLINK | IN_MONO), + IN_VOICE_DNLINK_MONO = (IN_VOICE_DNLINK | IN_MONO), + IN_VOICE_CALL_MONO = (IN_VOICE_UPLINK_MONO | + IN_VOICE_DNLINK_MONO), + // Note that the 2.0 IN_ALL* have been moved to helper functions + + COUNT_MAX = 30, + INDEX_HDR = REPRESENTATION_INDEX << COUNT_MAX, + INDEX_MASK_1 = INDEX_HDR | ((1 << 1) - 1), + INDEX_MASK_2 = INDEX_HDR | ((1 << 2) - 1), + INDEX_MASK_3 = INDEX_HDR | ((1 << 3) - 1), + INDEX_MASK_4 = INDEX_HDR | ((1 << 4) - 1), + INDEX_MASK_5 = INDEX_HDR | ((1 << 5) - 1), + INDEX_MASK_6 = INDEX_HDR | ((1 << 6) - 1), + INDEX_MASK_7 = INDEX_HDR | ((1 << 7) - 1), + INDEX_MASK_8 = INDEX_HDR | ((1 << 8) - 1) +}; + +/** + * Major modes for a mobile device. The current mode setting affects audio + * routing. + */ +@export(name="audio_mode_t", value_prefix="AUDIO_MODE_") +enum AudioMode : int32_t { + NORMAL = 0, + RINGTONE = 1, + /** Calls handled by the telephony stack (Eg: PSTN). */ + IN_CALL = 2, + /** Calls handled by apps (Eg: Hangout). */ + IN_COMMUNICATION = 3, +}; + +@export(name="", value_prefix="AUDIO_DEVICE_") +enum AudioDevice : uint32_t { + NONE = 0x0, + /** reserved bits */ + BIT_IN = 0x80000000, + BIT_DEFAULT = 0x40000000, + /** output devices */ + OUT_EARPIECE = 0x1, + OUT_SPEAKER = 0x2, + OUT_WIRED_HEADSET = 0x4, + OUT_WIRED_HEADPHONE = 0x8, + OUT_BLUETOOTH_SCO = 0x10, + OUT_BLUETOOTH_SCO_HEADSET = 0x20, + OUT_BLUETOOTH_SCO_CARKIT = 0x40, + OUT_BLUETOOTH_A2DP = 0x80, + OUT_BLUETOOTH_A2DP_HEADPHONES = 0x100, + OUT_BLUETOOTH_A2DP_SPEAKER = 0x200, + OUT_AUX_DIGITAL = 0x400, + OUT_HDMI = OUT_AUX_DIGITAL, + /** uses an analog connection (multiplexed over the USB pins for instance) */ + OUT_ANLG_DOCK_HEADSET = 0x800, + OUT_DGTL_DOCK_HEADSET = 0x1000, + /** USB accessory mode: Android device is USB device and dock is USB host */ + OUT_USB_ACCESSORY = 0x2000, + /** USB host mode: Android device is USB host and dock is USB device */ + OUT_USB_DEVICE = 0x4000, + OUT_REMOTE_SUBMIX = 0x8000, + /** Telephony voice TX path */ + OUT_TELEPHONY_TX = 0x10000, + /** Analog jack with line impedance detected */ + OUT_LINE = 0x20000, + /** HDMI Audio Return Channel */ + OUT_HDMI_ARC = 0x40000, + /** S/PDIF out */ + OUT_SPDIF = 0x80000, + /** FM transmitter out */ + OUT_FM = 0x100000, + /** Line out for av devices */ + OUT_AUX_LINE = 0x200000, + /** limited-output speaker device for acoustic safety */ + OUT_SPEAKER_SAFE = 0x400000, + OUT_IP = 0x800000, + /** audio bus implemented by the audio system (e.g an MOST stereo channel) */ + OUT_BUS = 0x1000000, + OUT_PROXY = 0x2000000, + OUT_USB_HEADSET = 0x4000000, + OUT_HEARING_AID = 0x8000000, + OUT_ECHO_CANCELLER = 0x10000000, + OUT_DEFAULT = BIT_DEFAULT, + // Note that the 2.0 OUT_ALL* have been moved to helper functions + + /** input devices */ + IN_COMMUNICATION = BIT_IN | 0x1, + IN_AMBIENT = BIT_IN | 0x2, + IN_BUILTIN_MIC = BIT_IN | 0x4, + IN_BLUETOOTH_SCO_HEADSET = BIT_IN | 0x8, + IN_WIRED_HEADSET = BIT_IN | 0x10, + IN_AUX_DIGITAL = BIT_IN | 0x20, + IN_HDMI = IN_AUX_DIGITAL, + /** Telephony voice RX path */ + IN_VOICE_CALL = BIT_IN | 0x40, + IN_TELEPHONY_RX = IN_VOICE_CALL, + IN_BACK_MIC = BIT_IN | 0x80, + IN_REMOTE_SUBMIX = BIT_IN | 0x100, + IN_ANLG_DOCK_HEADSET = BIT_IN | 0x200, + IN_DGTL_DOCK_HEADSET = BIT_IN | 0x400, + IN_USB_ACCESSORY = BIT_IN | 0x800, + IN_USB_DEVICE = BIT_IN | 0x1000, + /** FM tuner input */ + IN_FM_TUNER = BIT_IN | 0x2000, + /** TV tuner input */ + IN_TV_TUNER = BIT_IN | 0x4000, + /** Analog jack with line impedance detected */ + IN_LINE = BIT_IN | 0x8000, + /** S/PDIF in */ + IN_SPDIF = BIT_IN | 0x10000, + IN_BLUETOOTH_A2DP = BIT_IN | 0x20000, + IN_LOOPBACK = BIT_IN | 0x40000, + IN_IP = BIT_IN | 0x80000, + /** audio bus implemented by the audio system (e.g an MOST stereo channel) */ + IN_BUS = BIT_IN | 0x100000, + IN_PROXY = BIT_IN | 0x1000000, + IN_USB_HEADSET = BIT_IN | 0x2000000, + IN_BLUETOOTH_BLE = BIT_IN | 0x4000000, + IN_DEFAULT = BIT_IN | BIT_DEFAULT, + + // Note that the 2.0 IN_ALL* have been moved to helper functions +}; + +/** + * The audio output flags serve two purposes: + * + * - when an AudioTrack is created they indicate a "wish" to be connected to an + * output stream with attributes corresponding to the specified flags; + * + * - when present in an output profile descriptor listed for a particular audio + * hardware module, they indicate that an output stream can be opened that + * supports the attributes indicated by the flags. + * + * The audio policy manager will try to match the flags in the request + * (when getOuput() is called) to an available output stream. + */ +@export(name="audio_output_flags_t", value_prefix="AUDIO_OUTPUT_FLAG_") +enum AudioOutputFlag : int32_t { + NONE = 0x0, // no attributes + DIRECT = 0x1, // this output directly connects a track + // to one output stream: no software mixer + PRIMARY = 0x2, // this output is the primary output of the device. It is + // unique and must be present. It is opened by default and + // receives routing, audio mode and volume controls related + // to voice calls. + FAST = 0x4, // output supports "fast tracks", defined elsewhere + DEEP_BUFFER = 0x8, // use deep audio buffers + COMPRESS_OFFLOAD = 0x10, // offload playback of compressed streams to + // hardware codec + NON_BLOCKING = 0x20, // use non-blocking write + HW_AV_SYNC = 0x40, // output uses a hardware A/V sync + TTS = 0x80, // output for streams transmitted through speaker at a + // sample rate high enough to accommodate lower-range + // ultrasonic p/b + RAW = 0x100, // minimize signal processing + SYNC = 0x200, // synchronize I/O streams + IEC958_NONAUDIO = 0x400, // Audio stream contains compressed audio in SPDIF + // data bursts, not PCM. + DIRECT_PCM = 0x2000, // Audio stream containing PCM data that needs + // to pass through compress path for DSP post proc. + MMAP_NOIRQ = 0x4000, // output operates in MMAP no IRQ mode. + VOIP_RX = 0x8000, // preferred output for VoIP calls. + /** preferred output for call music */ + INCALL_MUSIC = 0x10000, +}; + +/** + * The audio input flags are analogous to audio output flags. + * Currently they are used only when an AudioRecord is created, + * to indicate a preference to be connected to an input stream with + * attributes corresponding to the specified flags. + */ +@export(name="audio_input_flags_t", value_prefix="AUDIO_INPUT_FLAG_") +enum AudioInputFlag : int32_t { + NONE = 0x0, // no attributes + FAST = 0x1, // prefer an input that supports "fast tracks" + HW_HOTWORD = 0x2, // prefer an input that captures from hw hotword source + RAW = 0x4, // minimize signal processing + SYNC = 0x8, // synchronize I/O streams + MMAP_NOIRQ = 0x10, // input operates in MMAP no IRQ mode. + VOIP_TX = 0x20, // preferred input for VoIP calls. + HW_AV_SYNC = 0x40, // input connected to an output that uses a hardware A/V sync +}; + +@export(name="audio_usage_t", value_prefix="AUDIO_USAGE_") +enum AudioUsage : int32_t { + // These values must kept in sync with + // frameworks/base/media/java/android/media/AudioAttributes.java + // Note that not all framework values are exposed + UNKNOWN = 0, + MEDIA = 1, + VOICE_COMMUNICATION = 2, + VOICE_COMMUNICATION_SIGNALLING = 3, + ALARM = 4, + NOTIFICATION = 5, + NOTIFICATION_TELEPHONY_RINGTONE = 6, + ASSISTANCE_ACCESSIBILITY = 11, + ASSISTANCE_NAVIGATION_GUIDANCE = 12, + ASSISTANCE_SONIFICATION = 13, + GAME = 14, + VIRTUAL_SOURCE = 15, + ASSISTANT = 16, +}; + +/** Type of audio generated by an application. */ +@export(name="audio_content_type_t", value_prefix="AUDIO_CONTENT_TYPE_") +enum AudioContentType : uint32_t { + // Do not change these values without updating their counterparts + // in frameworks/base/media/java/android/media/AudioAttributes.java + UNKNOWN = 0, + SPEECH = 1, + MUSIC = 2, + MOVIE = 3, + SONIFICATION = 4, +}; + +/** + * Additional information about the stream passed to hardware decoders. + */ +struct AudioOffloadInfo { + uint32_t sampleRateHz; + bitfield<AudioChannelMask> channelMask; + AudioFormat format; + AudioStreamType streamType; + uint32_t bitRatePerSecond; + int64_t durationMicroseconds; // -1 if unknown + bool hasVideo; + bool isStreaming; + uint32_t bitWidth; + uint32_t bufferSize; + AudioUsage usage; +}; + +/** + * Commonly used audio stream configuration parameters. + */ +struct AudioConfig { + uint32_t sampleRateHz; + bitfield<AudioChannelMask> channelMask; + AudioFormat format; + AudioOffloadInfo offloadInfo; + uint64_t frameCount; +}; + +/** Metadata of a playback track for a StreamOut. */ +struct PlaybackTrackMetadata { + AudioUsage usage; + AudioContentType contentType; + /** + * Positive linear gain applied to the track samples. 0 being muted and 1 is no attenuation, + * 2 means double amplification... + * Must not be negative. + */ + float gain; +}; + +/** Metadatas of the source of a StreamOut. */ +struct SourceMetadata { + vec<PlaybackTrackMetadata> tracks; +}; + +/** Metadata of a record track for a StreamIn. */ +struct RecordTrackMetadata { + AudioSource source; + /** + * Positive linear gain applied to the track samples. 0 being muted and 1 is no attenuation, + * 2 means double amplification... + * Must not be negative. + */ + float gain; +}; + +/** Metadatas of the source of a StreamIn. */ +struct SinkMetadata { + vec<RecordTrackMetadata> tracks; +}; + + +/* + * + * Volume control + * + */ + +/** + * Type of gain control exposed by an audio port. + */ +@export(name="", value_prefix="AUDIO_GAIN_MODE_") +enum AudioGainMode : uint32_t { + JOINT = 0x1, // supports joint channel gain control + CHANNELS = 0x2, // supports separate channel gain control + RAMP = 0x4 // supports gain ramps +}; + +/** + * An audio_gain struct is a representation of a gain stage. + * A gain stage is always attached to an audio port. + */ +struct AudioGain { + bitfield<AudioGainMode> mode; + bitfield<AudioChannelMask> channelMask; // channels which gain an be controlled + int32_t minValue; // minimum gain value in millibels + int32_t maxValue; // maximum gain value in millibels + int32_t defaultValue; // default gain value in millibels + uint32_t stepValue; // gain step in millibels + uint32_t minRampMs; // minimum ramp duration in ms + uint32_t maxRampMs; // maximum ramp duration in ms +}; + +/** + * The gain configuration structure is used to get or set the gain values of a + * given port. + */ +struct AudioGainConfig { + int32_t index; // index of the corresponding AudioGain in AudioPort.gains + AudioGainMode mode; + AudioChannelMask channelMask; // channels which gain value follows + /** + * 4 = sizeof(AudioChannelMask), + * 8 is not "FCC_8", so it won't need to be changed for > 8 channels. + * Gain values in millibels for each channel ordered from LSb to MSb in + * channel mask. The number of values is 1 in joint mode or + * popcount(channel_mask). + */ + int32_t[4 * 8] values; + uint32_t rampDurationMs; // ramp duration in ms +}; + + +/* + * + * Routing control + * + */ + +/* + * Types defined here are used to describe an audio source or sink at internal + * framework interfaces (audio policy, patch panel) or at the audio HAL. + * Sink and sources are grouped in a concept of “audio port” representing an + * audio end point at the edge of the system managed by the module exposing + * the interface. + */ + +/** Audio port role: either source or sink */ +@export(name="audio_port_role_t", value_prefix="AUDIO_PORT_ROLE_") +enum AudioPortRole : int32_t { + NONE, + SOURCE, + SINK, +}; + +/** + * Audio port type indicates if it is a session (e.g AudioTrack), a mix (e.g + * PlaybackThread output) or a physical device (e.g OUT_SPEAKER) + */ +@export(name="audio_port_type_t", value_prefix="AUDIO_PORT_TYPE_") +enum AudioPortType : int32_t { + NONE, + DEVICE, + MIX, + SESSION, +}; + +/** + * Extension for audio port configuration structure when the audio port is a + * hardware device. + */ +struct AudioPortConfigDeviceExt { + AudioModuleHandle hwModule; // module the device is attached to + AudioDevice type; // device type (e.g OUT_SPEAKER) + uint8_t[32] address; // device address. "" if N/A +}; + +/** + * Extension for audio port configuration structure when the audio port is an + * audio session. + */ +struct AudioPortConfigSessionExt { + AudioSession session; +}; + +/** + * Flags indicating which fields are to be considered in AudioPortConfig. + */ +@export(name="", value_prefix="AUDIO_PORT_CONFIG_") +enum AudioPortConfigMask : uint32_t { + SAMPLE_RATE = 0x1, + CHANNEL_MASK = 0x2, + FORMAT = 0x4, + GAIN = 0x8, +}; + +/** + * Audio port configuration structure used to specify a particular configuration + * of an audio port. + */ +struct AudioPortConfig { + AudioPortHandle id; + bitfield<AudioPortConfigMask> configMask; + uint32_t sampleRateHz; + bitfield<AudioChannelMask> channelMask; + AudioFormat format; + AudioGainConfig gain; + AudioPortType type; // type is used as a discriminator for Ext union + AudioPortRole role; // role is used as a discriminator for UseCase union + union Ext { + AudioPortConfigDeviceExt device; + struct AudioPortConfigMixExt { + AudioModuleHandle hwModule; // module the stream is attached to + AudioIoHandle ioHandle; // I/O handle of the input/output stream + union UseCase { + AudioStreamType stream; + AudioSource source; + } useCase; + } mix; + AudioPortConfigSessionExt session; + } ext; +}; + +/** + * Extension for audio port structure when the audio port is a hardware device. + */ +struct AudioPortDeviceExt { + AudioModuleHandle hwModule; // module the device is attached to + AudioDevice type; + /** 32 byte string identifying the port. */ + uint8_t[32] address; +}; + +/** + * Latency class of the audio mix. + */ +@export(name="audio_mix_latency_class_t", value_prefix="AUDIO_LATENCY_") +enum AudioMixLatencyClass : int32_t { + LOW, + NORMAL +}; + +struct AudioPortMixExt { + AudioModuleHandle hwModule; // module the stream is attached to + AudioIoHandle ioHandle; // I/O handle of the stream + AudioMixLatencyClass latencyClass; +}; + +/** + * Extension for audio port structure when the audio port is an audio session. + */ +struct AudioPortSessionExt { + AudioSession session; +}; + +struct AudioPort { + AudioPortHandle id; + AudioPortRole role; + string name; + vec<uint32_t> sampleRates; + vec<bitfield<AudioChannelMask>> channelMasks; + vec<AudioFormat> formats; + vec<AudioGain> gains; + AudioPortConfig activeConfig; // current audio port configuration + AudioPortType type; // type is used as a discriminator + union Ext { + AudioPortDeviceExt device; + AudioPortMixExt mix; + AudioPortSessionExt session; + } ext; +}; + +struct ThreadInfo { + int64_t pid; + int64_t tid; +}; diff --git a/audio/common/all-versions/default/Android.bp b/audio/common/all-versions/default/Android.bp index 4a27bb76cb..c0bd34c45f 100644 --- a/audio/common/all-versions/default/Android.bp +++ b/audio/common/all-versions/default/Android.bp @@ -17,9 +17,6 @@ cc_library_shared { name: "android.hardware.audio.common-util", defaults: ["hidl_defaults"], vendor_available: true, - vndk: { - enabled: true, - }, srcs: [ "EffectMap.cpp", ], @@ -41,3 +38,72 @@ cc_library_shared { "android.hardware.audio.common.util@all-versions", ] } + +cc_defaults { + name: "android.hardware.audio.common-util_default", + defaults: ["hidl_defaults"], + + vendor_available: true, + srcs: [ + "HidlUtils.cpp", + ], + + export_include_dirs: ["."], + + shared_libs: [ + "liblog", + "libutils", + "libhidlbase", + "android.hardware.audio.common-util", + ], + export_shared_lib_headers: [ + "android.hardware.audio.common-util" + ], + + header_libs: [ + "libaudio_system_headers", + "libhardware_headers", + ], +} + +cc_library_shared { + name: "android.hardware.audio.common@2.0-util", + defaults: ["android.hardware.audio.common-util_default"], + + shared_libs: [ + "android.hardware.audio.common@2.0", + ], + cflags: [ + "-DMAJOR_VERSION=2", + "-DMINOR_VERSION=0", + "-include common/all-versions/VersionMacro.h", + ] +} + +cc_library_shared { + name: "android.hardware.audio.common@4.0-util", + defaults: ["android.hardware.audio.common-util_default"], + + shared_libs: [ + "android.hardware.audio.common@4.0", + ], + cflags: [ + "-DMAJOR_VERSION=4", + "-DMINOR_VERSION=0", + "-include common/all-versions/VersionMacro.h", + ] +} + +cc_library_shared { + name: "android.hardware.audio.common@5.0-util", + defaults: ["android.hardware.audio.common-util_default"], + + shared_libs: [ + "android.hardware.audio.common@5.0", + ], + cflags: [ + "-DMAJOR_VERSION=5", + "-DMINOR_VERSION=0", + "-include common/all-versions/VersionMacro.h", + ] +} diff --git a/audio/common/all-versions/default/EffectMap.cpp b/audio/common/all-versions/default/EffectMap.cpp index 7f8da1e2ab..cb3e3d59d7 100644 --- a/audio/common/all-versions/default/EffectMap.cpp +++ b/audio/common/all-versions/default/EffectMap.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. diff --git a/audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.impl.h b/audio/common/all-versions/default/HidlUtils.cpp index 8ab73501bc..5ed059c5a7 100644 --- a/audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.impl.h +++ b/audio/common/all-versions/default/HidlUtils.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,36 +14,34 @@ * limitations under the License. */ -#ifndef AUDIO_HAL_VERSION -#error "AUDIO_HAL_VERSION must be set before including this file." -#endif +#include "HidlUtils.h" #include <common/all-versions/VersionUtils.h> #include <string.h> -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioChannelMask; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioDevice; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioFormat; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioGainMode; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioMixLatencyClass; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioPortConfigMask; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioPortRole; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioPortType; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioSource; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioStreamType; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioUsage; +using ::android::hardware::audio::common::CPP_VERSION::AudioChannelMask; +using ::android::hardware::audio::common::CPP_VERSION::AudioDevice; +using ::android::hardware::audio::common::CPP_VERSION::AudioFormat; +using ::android::hardware::audio::common::CPP_VERSION::AudioGainMode; +using ::android::hardware::audio::common::CPP_VERSION::AudioMixLatencyClass; +using ::android::hardware::audio::common::CPP_VERSION::AudioPortConfigMask; +using ::android::hardware::audio::common::CPP_VERSION::AudioPortRole; +using ::android::hardware::audio::common::CPP_VERSION::AudioPortType; +using ::android::hardware::audio::common::CPP_VERSION::AudioSource; +using ::android::hardware::audio::common::CPP_VERSION::AudioStreamType; +using ::android::hardware::audio::common::CPP_VERSION::AudioUsage; -using ::android::hardware::audio::common::utils::mkEnumConverter; +using ::android::hardware::audio::common::utils::EnumBitfield; namespace android { namespace hardware { namespace audio { namespace common { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { void HidlUtils::audioConfigFromHal(const audio_config_t& halConfig, AudioConfig* config) { config->sampleRateHz = halConfig.sample_rate; - config->channelMask = mkEnumConverter<AudioChannelMask>(halConfig.channel_mask); + config->channelMask = EnumBitfield<AudioChannelMask>(halConfig.channel_mask); config->format = AudioFormat(halConfig.format); audioOffloadInfoFromHal(halConfig.offload_info, &config->offloadInfo); config->frameCount = halConfig.frame_count; @@ -61,8 +59,8 @@ void HidlUtils::audioConfigToHal(const AudioConfig& config, audio_config_t* halC void HidlUtils::audioGainConfigFromHal(const struct audio_gain_config& halConfig, AudioGainConfig* config) { config->index = halConfig.index; - config->mode = mkEnumConverter<AudioGainMode>(halConfig.mode); - config->channelMask = mkEnumConverter<AudioChannelMask>(halConfig.channel_mask); + config->mode = EnumBitfield<AudioGainMode>(halConfig.mode); + config->channelMask = EnumBitfield<AudioChannelMask>(halConfig.channel_mask); for (size_t i = 0; i < sizeof(audio_channel_mask_t) * 8; ++i) { config->values[i] = halConfig.values[i]; } @@ -82,8 +80,8 @@ void HidlUtils::audioGainConfigToHal(const AudioGainConfig& config, } void HidlUtils::audioGainFromHal(const struct audio_gain& halGain, AudioGain* gain) { - gain->mode = mkEnumConverter<AudioGainMode>(halGain.mode); - gain->channelMask = mkEnumConverter<AudioChannelMask>(halGain.channel_mask); + gain->mode = EnumBitfield<AudioGainMode>(halGain.mode); + gain->channelMask = EnumBitfield<AudioChannelMask>(halGain.channel_mask); gain->minValue = halGain.min_value; gain->maxValue = halGain.max_value; gain->defaultValue = halGain.default_value; @@ -122,7 +120,7 @@ audio_usage_t HidlUtils::audioUsageToHal(const AudioUsage usage) { void HidlUtils::audioOffloadInfoFromHal(const audio_offload_info_t& halOffload, AudioOffloadInfo* offload) { offload->sampleRateHz = halOffload.sample_rate; - offload->channelMask = mkEnumConverter<AudioChannelMask>(halOffload.channel_mask); + offload->channelMask = EnumBitfield<AudioChannelMask>(halOffload.channel_mask); offload->format = AudioFormat(halOffload.format); offload->streamType = AudioStreamType(halOffload.stream_type); offload->bitRatePerSecond = halOffload.bit_rate; @@ -155,9 +153,9 @@ void HidlUtils::audioPortConfigFromHal(const struct audio_port_config& halConfig config->id = halConfig.id; config->role = AudioPortRole(halConfig.role); config->type = AudioPortType(halConfig.type); - config->configMask = mkEnumConverter<AudioPortConfigMask>(halConfig.config_mask); + config->configMask = EnumBitfield<AudioPortConfigMask>(halConfig.config_mask); config->sampleRateHz = halConfig.sample_rate; - config->channelMask = mkEnumConverter<AudioChannelMask>(halConfig.channel_mask); + config->channelMask = EnumBitfield<AudioChannelMask>(halConfig.channel_mask); config->format = AudioFormat(halConfig.format); audioGainConfigFromHal(halConfig.gain, &config->gain); switch (halConfig.type) { @@ -174,9 +172,9 @@ void HidlUtils::audioPortConfigFromHal(const struct audio_port_config& halConfig config->ext.mix.hwModule = halConfig.ext.mix.hw_module; config->ext.mix.ioHandle = halConfig.ext.mix.handle; if (halConfig.role == AUDIO_PORT_ROLE_SOURCE) { - config->ext.mix.useCase.source = AudioSource(halConfig.ext.mix.usecase.source); - } else if (halConfig.role == AUDIO_PORT_ROLE_SINK) { config->ext.mix.useCase.stream = AudioStreamType(halConfig.ext.mix.usecase.stream); + } else if (halConfig.role == AUDIO_PORT_ROLE_SINK) { + config->ext.mix.useCase.source = AudioSource(halConfig.ext.mix.usecase.source); } break; } @@ -212,11 +210,11 @@ void HidlUtils::audioPortConfigToHal(const AudioPortConfig& config, halConfig->ext.mix.hw_module = config.ext.mix.hwModule; halConfig->ext.mix.handle = config.ext.mix.ioHandle; if (config.role == AudioPortRole::SOURCE) { - halConfig->ext.mix.usecase.source = - static_cast<audio_source_t>(config.ext.mix.useCase.source); - } else if (config.role == AudioPortRole::SINK) { halConfig->ext.mix.usecase.stream = static_cast<audio_stream_type_t>(config.ext.mix.useCase.stream); + } else if (config.role == AudioPortRole::SINK) { + halConfig->ext.mix.usecase.source = + static_cast<audio_source_t>(config.ext.mix.useCase.source); } break; } @@ -257,7 +255,7 @@ void HidlUtils::audioPortFromHal(const struct audio_port& halPort, AudioPort* po } port->channelMasks.resize(halPort.num_channel_masks); for (size_t i = 0; i < halPort.num_channel_masks; ++i) { - port->channelMasks[i] = mkEnumConverter<AudioChannelMask>(halPort.channel_masks[i]); + port->channelMasks[i] = EnumBitfield<AudioChannelMask>(halPort.channel_masks[i]); } port->formats.resize(halPort.num_formats); for (size_t i = 0; i < halPort.num_formats; ++i) { @@ -358,7 +356,7 @@ void HidlUtils::uuidToHal(const Uuid& uuid, audio_uuid_t* halUuid) { memcpy(halUuid->node, uuid.node.data(), uuid.node.size()); } -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace common } // namespace audio } // namespace hardware diff --git a/audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.h b/audio/common/all-versions/default/HidlUtils.h index f9a5697418..77c8b89e1a 100644 --- a/audio/common/all-versions/default/include/common/all-versions/default/HidlUtils.h +++ b/audio/common/all-versions/default/HidlUtils.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,28 +14,29 @@ * limitations under the License. */ -#ifndef AUDIO_HAL_VERSION -#error "AUDIO_HAL_VERSION must be set before including this file." -#endif +#ifndef android_hardware_audio_Hidl_Utils_H_ +#define android_hardware_audio_Hidl_Utils_H_ + +#include PATH(android/hardware/audio/common/FILE_VERSION/types.h) #include <memory> #include <system/audio.h> -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioConfig; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioGain; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioGainConfig; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioOffloadInfo; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioPort; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioPortConfig; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::Uuid; using ::android::hardware::hidl_vec; +using ::android::hardware::audio::common::CPP_VERSION::AudioConfig; +using ::android::hardware::audio::common::CPP_VERSION::AudioGain; +using ::android::hardware::audio::common::CPP_VERSION::AudioGainConfig; +using ::android::hardware::audio::common::CPP_VERSION::AudioOffloadInfo; +using ::android::hardware::audio::common::CPP_VERSION::AudioPort; +using ::android::hardware::audio::common::CPP_VERSION::AudioPortConfig; +using ::android::hardware::audio::common::CPP_VERSION::Uuid; namespace android { namespace hardware { namespace audio { namespace common { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { class HidlUtils { public: @@ -68,8 +69,10 @@ class HidlUtils { static void uuidToHal(const Uuid& uuid, audio_uuid_t* halUuid); }; -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace common } // namespace audio } // namespace hardware } // namespace android + +#endif // android_hardware_audio_Hidl_Utils_H_ diff --git a/audio/common/2.0/default/OWNERS b/audio/common/all-versions/default/OWNERS index 6fdc97ca29..6fdc97ca29 100644 --- a/audio/common/2.0/default/OWNERS +++ b/audio/common/all-versions/default/OWNERS diff --git a/audio/common/4.0/default/VersionUtils.h b/audio/common/all-versions/default/VersionUtils.h index b7f2aec8f9..e7755b1a7a 100644 --- a/audio/common/4.0/default/VersionUtils.h +++ b/audio/common/all-versions/default/VersionUtils.h @@ -17,22 +17,29 @@ #ifndef ANDROID_HARDWARE_AUDIO_EFFECT_VERSION_UTILS_H #define ANDROID_HARDWARE_AUDIO_EFFECT_VERSION_UTILS_H -#include <android/hardware/audio/common/4.0/types.h> +#include PATH(android/hardware/audio/common/FILE_VERSION/types.h) namespace android { namespace hardware { namespace audio { namespace common { -namespace V4_0 { +namespace CPP_VERSION { namespace implementation { -typedef hidl_bitfield<common::V4_0::AudioDevice> AudioDeviceBitfield; -typedef hidl_bitfield<common::V4_0::AudioChannelMask> AudioChannelBitfield; -typedef hidl_bitfield<common::V4_0::AudioOutputFlag> AudioOutputFlagBitfield; -typedef hidl_bitfield<common::V4_0::AudioInputFlag> AudioInputFlagBitfield; +#if MAJOR_VERSION == 2 +typedef common::CPP_VERSION::AudioDevice AudioDeviceBitfield; +typedef common::CPP_VERSION::AudioChannelMask AudioChannelBitfield; +typedef common::CPP_VERSION::AudioOutputFlag AudioOutputFlagBitfield; +typedef common::CPP_VERSION::AudioInputFlag AudioInputFlagBitfield; +#elif MAJOR_VERSION >= 4 +typedef hidl_bitfield<common::CPP_VERSION::AudioDevice> AudioDeviceBitfield; +typedef hidl_bitfield<common::CPP_VERSION::AudioChannelMask> AudioChannelBitfield; +typedef hidl_bitfield<common::CPP_VERSION::AudioOutputFlag> AudioOutputFlagBitfield; +typedef hidl_bitfield<common::CPP_VERSION::AudioInputFlag> AudioInputFlagBitfield; +#endif } // namespace implementation -} // namespace V4_0 +} // namespace CPP_VERSION } // namespace common } // namespace audio } // namespace hardware diff --git a/audio/common/all-versions/default/include/common/all-versions/default/EffectMap.h b/audio/common/all-versions/default/include/common/all-versions/default/EffectMap.h index 547c6d5a9f..7f630bf09e 100644 --- a/audio/common/all-versions/default/include/common/all-versions/default/EffectMap.h +++ b/audio/common/all-versions/default/include/common/all-versions/default/EffectMap.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. diff --git a/audio/common/all-versions/default/service/Android.mk b/audio/common/all-versions/default/service/Android.mk index 43d7fe19c5..32110eec60 100644 --- a/audio/common/all-versions/default/service/Android.mk +++ b/audio/common/all-versions/default/service/Android.mk @@ -31,18 +31,23 @@ LOCAL_SRC_FILES := \ LOCAL_CFLAGS := -Wall -Werror LOCAL_SHARED_LIBRARIES := \ + libcutils \ libbinder \ libhidlbase \ libhidltransport \ liblog \ libutils \ libhardware \ + libhwbinder \ android.hardware.audio@2.0 \ android.hardware.audio@4.0 \ + android.hardware.audio@5.0 \ android.hardware.audio.common@2.0 \ android.hardware.audio.common@4.0 \ + android.hardware.audio.common@5.0 \ android.hardware.audio.effect@2.0 \ android.hardware.audio.effect@4.0 \ + android.hardware.audio.effect@5.0 \ android.hardware.bluetooth.a2dp@1.0 \ android.hardware.soundtrigger@2.0 \ android.hardware.soundtrigger@2.1 diff --git a/audio/common/all-versions/default/service/service.cpp b/audio/common/all-versions/default/service/service.cpp index c7ce638e7f..7b5da814be 100644 --- a/audio/common/all-versions/default/service/service.cpp +++ b/audio/common/all-versions/default/service/service.cpp @@ -18,31 +18,45 @@ #include <android/hardware/audio/2.0/IDevicesFactory.h> #include <android/hardware/audio/4.0/IDevicesFactory.h> +#include <android/hardware/audio/5.0/IDevicesFactory.h> #include <android/hardware/audio/effect/2.0/IEffectsFactory.h> #include <android/hardware/audio/effect/4.0/IEffectsFactory.h> +#include <android/hardware/audio/effect/5.0/IEffectsFactory.h> #include <android/hardware/bluetooth/a2dp/1.0/IBluetoothAudioOffload.h> #include <android/hardware/soundtrigger/2.0/ISoundTriggerHw.h> #include <android/hardware/soundtrigger/2.1/ISoundTriggerHw.h> #include <binder/ProcessState.h> +#include <cutils/properties.h> #include <hidl/HidlTransportSupport.h> #include <hidl/LegacySupport.h> +#include <hwbinder/ProcessState.h> using namespace android::hardware; using android::OK; int main(int /* argc */, char* /* argv */ []) { - android::ProcessState::initWithDriver("/dev/vndbinder"); + ::android::ProcessState::initWithDriver("/dev/vndbinder"); // start a threadpool for vndbinder interactions - android::ProcessState::self()->startThreadPool(); + ::android::ProcessState::self()->startThreadPool(); + + const int32_t defaultValue = -1; + int32_t value = + property_get_int32("persist.vendor.audio.service.hwbinder.size_kbyte", defaultValue); + if (value != defaultValue) { + ALOGD("Configuring hwbinder with mmap size %d KBytes", value); + ProcessState::initWithMmapSize(static_cast<size_t>(value) * 1024); + } configureRpcThreadpool(16, true /*callerWillJoin*/); - bool fail = registerPassthroughServiceImplementation<audio::V4_0::IDevicesFactory>() != OK && + bool fail = registerPassthroughServiceImplementation<audio::V5_0::IDevicesFactory>() != OK && + registerPassthroughServiceImplementation<audio::V4_0::IDevicesFactory>() != OK && registerPassthroughServiceImplementation<audio::V2_0::IDevicesFactory>() != OK; - LOG_ALWAYS_FATAL_IF(fail, "Could not register audio core API 2.0 nor 4.0"); + LOG_ALWAYS_FATAL_IF(fail, "Could not register audio core API 2, 4 nor 5"); - fail = registerPassthroughServiceImplementation<audio::effect::V4_0::IEffectsFactory>() != OK && + fail = registerPassthroughServiceImplementation<audio::effect::V5_0::IEffectsFactory>() != OK && + registerPassthroughServiceImplementation<audio::effect::V4_0::IEffectsFactory>() != OK && registerPassthroughServiceImplementation<audio::effect::V2_0::IEffectsFactory>() != OK, - LOG_ALWAYS_FATAL_IF(fail, "Could not register audio effect API 2.0 nor 4.0"); + LOG_ALWAYS_FATAL_IF(fail, "Could not register audio effect API 2, 4 nor 5"); fail = registerPassthroughServiceImplementation<soundtrigger::V2_1::ISoundTriggerHw>() != OK && registerPassthroughServiceImplementation<soundtrigger::V2_0::ISoundTriggerHw>() != OK, diff --git a/audio/common/all-versions/test/utility/include/utility/AssertOk.h b/audio/common/all-versions/test/utility/include/utility/AssertOk.h index 11e1c24783..5ac2fdc936 100644 --- a/audio/common/all-versions/test/utility/include/utility/AssertOk.h +++ b/audio/common/all-versions/test/utility/include/utility/AssertOk.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 The Android Open Source Project + * Copyright (C) 2018 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. diff --git a/audio/common/all-versions/test/utility/include/utility/Documentation.h b/audio/common/all-versions/test/utility/include/utility/Documentation.h index e10cf79ecc..1b555b996a 100644 --- a/audio/common/all-versions/test/utility/include/utility/Documentation.h +++ b/audio/common/all-versions/test/utility/include/utility/Documentation.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 The Android Open Source Project + * Copyright (C) 2018 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. diff --git a/audio/common/all-versions/test/utility/include/utility/EnvironmentTearDown.h b/audio/common/all-versions/test/utility/include/utility/EnvironmentTearDown.h index 7a08a54fc8..0e416f3c64 100644 --- a/audio/common/all-versions/test/utility/include/utility/EnvironmentTearDown.h +++ b/audio/common/all-versions/test/utility/include/utility/EnvironmentTearDown.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 The Android Open Source Project + * Copyright (C) 2018 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. diff --git a/audio/common/all-versions/test/utility/include/utility/PrettyPrintAudioTypes.h b/audio/common/all-versions/test/utility/include/utility/PrettyPrintAudioTypes.h index abc2ff5f82..3833fd072e 100644 --- a/audio/common/all-versions/test/utility/include/utility/PrettyPrintAudioTypes.h +++ b/audio/common/all-versions/test/utility/include/utility/PrettyPrintAudioTypes.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,10 +14,6 @@ * limitations under the License. */ -#ifndef AUDIO_HAL_VERSION -#error "AUDIO_HAL_VERSION must be set before including this file." -#endif - #ifndef ANDROID_HARDWARE_AUDIO_COMMON_TEST_UTILITY_PRETTY_PRINT_AUDIO_TYPES_H #define ANDROID_HARDWARE_AUDIO_COMMON_TEST_UTILITY_PRETTY_PRINT_AUDIO_TYPES_H @@ -40,19 +36,19 @@ namespace audio { #define DEFINE_GTEST_PRINT_TO(T) \ inline void PrintTo(const T& val, ::std::ostream* os) { *os << toString(val); } -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { DEFINE_GTEST_PRINT_TO(IPrimaryDevice::TtyMode) DEFINE_GTEST_PRINT_TO(Result) -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION namespace common { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { DEFINE_GTEST_PRINT_TO(AudioConfig) DEFINE_GTEST_PRINT_TO(AudioMode) DEFINE_GTEST_PRINT_TO(AudioDevice) DEFINE_GTEST_PRINT_TO(AudioFormat) DEFINE_GTEST_PRINT_TO(AudioChannelMask) -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace common #undef DEFINE_GTEST_PRINT_TO diff --git a/audio/common/all-versions/test/utility/include/utility/ReturnIn.h b/audio/common/all-versions/test/utility/include/utility/ReturnIn.h index 7fd0d4a437..de16809380 100644 --- a/audio/common/all-versions/test/utility/include/utility/ReturnIn.h +++ b/audio/common/all-versions/test/utility/include/utility/ReturnIn.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 The Android Open Source Project + * Copyright (C) 2018 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. diff --git a/audio/common/all-versions/test/utility/include/utility/ValidateXml.h b/audio/common/all-versions/test/utility/include/utility/ValidateXml.h index 91adfc12c8..ee206f7458 100644 --- a/audio/common/all-versions/test/utility/include/utility/ValidateXml.h +++ b/audio/common/all-versions/test/utility/include/utility/ValidateXml.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 The Android Open Source Project + * Copyright (C) 2018 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. diff --git a/audio/common/all-versions/test/utility/src/ValidateXml.cpp b/audio/common/all-versions/test/utility/src/ValidateXml.cpp index 1a906d668b..bdafa82d6b 100644 --- a/audio/common/all-versions/test/utility/src/ValidateXml.cpp +++ b/audio/common/all-versions/test/utility/src/ValidateXml.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 The Android Open Source Project + * Copyright (C) 2018 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. @@ -162,8 +162,8 @@ template <bool atLeastOneRequired> << "\n Which is: " << xmlFileName << "\n In the following folders: " << xmlFileLocationsExpr << "\n Which is: " << ::testing::PrintToString(xmlFileLocations) - << (atLeastOneRequired ? "Where at least one file must be found." - : "Where no file might exist."); + << (atLeastOneRequired ? "\nWhere at least one file must be found." + : "\nWhere no file might exist."); } template ::testing::AssertionResult validateXmlMultipleLocations<true>(const char*, const char*, diff --git a/audio/common/all-versions/util/Android.bp b/audio/common/all-versions/util/Android.bp index 5d33a3a189..3c7e62e4e4 100644 --- a/audio/common/all-versions/util/Android.bp +++ b/audio/common/all-versions/util/Android.bp @@ -2,9 +2,6 @@ cc_library_headers { name: "android.hardware.audio.common.util@all-versions", defaults: ["hidl_defaults"], vendor_available: true, - vndk: { - enabled: true, - }, export_include_dirs: ["include"], } diff --git a/audio/common/all-versions/util/include/common/all-versions/IncludeGuard.h b/audio/common/all-versions/util/include/common/all-versions/IncludeGuard.h deleted file mode 100644 index 2d5481625c..0000000000 --- a/audio/common/all-versions/util/include/common/all-versions/IncludeGuard.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -#ifndef AUDIO_HAL_VERSION -#error "AUDIO_HAL_VERSION must be set before including this file." -#endif diff --git a/audio/common/all-versions/util/include/common/all-versions/VersionMacro.h b/audio/common/all-versions/util/include/common/all-versions/VersionMacro.h new file mode 100644 index 0000000000..dc54cee206 --- /dev/null +++ b/audio/common/all-versions/util/include/common/all-versions/VersionMacro.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2018 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. + */ + +#ifndef ANDROID_HARDWARE_VERSION_MACRO_H +#define ANDROID_HARDWARE_VERSION_MACRO_H + +#if !defined(MAJOR_VERSION) || !defined(MINOR_VERSION) +#error "MAJOR_VERSION and MINOR_VERSION must be defined" +#endif + +/** Allows macro expansion for x and add surrounding `<>`. + * Is intended to be used for version dependant includes as + * `#include` do not macro expand if starting with < or " + * Example usage: + * #include PATH(path/to/FILE_VERSION/file) + * @note: uses the implementation-define "Computed Includes" feature. + */ +#define PATH(x) <x> + +#define CONCAT_3(a, b, c) a##b##c +#define EXPAND_CONCAT_3(a, b, c) CONCAT_3(a, b, c) +/** The directory name of the version: <major>.<minor> */ +#define FILE_VERSION EXPAND_CONCAT_3(MAJOR_VERSION, ., MINOR_VERSION) + +#define CONCAT_4(a, b, c, d) a##b##c##d +#define EXPAND_CONCAT_4(a, b, c, d) CONCAT_4(a, b, c, d) +/** The c++ namespace of the version: V<major>_<minor> */ +#define CPP_VERSION EXPAND_CONCAT_4(V, MAJOR_VERSION, _, MINOR_VERSION) + +#endif // ANDROID_HARDWARE_VERSION_MACRO_H diff --git a/audio/common/all-versions/util/include/common/all-versions/VersionUtils.h b/audio/common/all-versions/util/include/common/all-versions/VersionUtils.h index 70c3d56a42..3b5c0fbc4f 100644 --- a/audio/common/all-versions/util/include/common/all-versions/VersionUtils.h +++ b/audio/common/all-versions/util/include/common/all-versions/VersionUtils.h @@ -26,36 +26,31 @@ namespace audio { namespace common { namespace utils { -/** Similar to static_cast but also casts to hidl_bitfield depending on - * return type inference (emulated through user-define conversion). - */ -template <class Source, class Destination = Source> -class EnumConverter { +/** Converting between a bitfield or itself. */ +template <class Enum> +class EnumBitfield { public: - static_assert(std::is_enum<Source>::value || std::is_enum<Destination>::value, - "Source or destination should be an enum"); + using Bitfield = ::android::hardware::hidl_bitfield<Enum>; - explicit EnumConverter(Source source) : mSource(source) {} + EnumBitfield(const EnumBitfield&) = default; + explicit EnumBitfield(Enum value) : mValue(value) {} + explicit EnumBitfield(Bitfield value) : EnumBitfield(static_cast<Enum>(value)) {} - operator Destination() const { return static_cast<Destination>(mSource); } + EnumBitfield& operator=(const EnumBitfield&) = default; + EnumBitfield& operator=(Enum value) { return *this = EnumBitfield{value}; } + EnumBitfield& operator=(Bitfield value) { return *this = EnumBitfield{value}; } - template <class = std::enable_if_t<std::is_enum<Destination>::value>> - operator ::android::hardware::hidl_bitfield<Destination>() { - return static_cast<std::underlying_type_t<Destination>>(mSource); - } + operator Enum() const { return mValue; } + operator Bitfield() const { return static_cast<Bitfield>(mValue); } private: - const Source mSource; + Enum mValue; }; -template <class Destination, class Source> -auto mkEnumConverter(Source source) { - return EnumConverter<Source, Destination>{source}; -} -/** Allows converting an enum to its bitfield or itself. */ +/** ATD way to create a EnumBitfield. */ template <class Enum> -EnumConverter<Enum> mkBitfield(Enum value) { - return EnumConverter<Enum>{value}; +EnumBitfield<Enum> mkEnumBitfield(Enum value) { + return EnumBitfield<Enum>{value}; } } // namespace utils diff --git a/audio/core/2.0/default/Android.bp b/audio/core/2.0/default/Android.bp deleted file mode 100644 index 625df74a88..0000000000 --- a/audio/core/2.0/default/Android.bp +++ /dev/null @@ -1,53 +0,0 @@ -cc_library_shared { - name: "android.hardware.audio@2.0-impl", - relative_install_path: "hw", - proprietary: true, - vendor: true, - srcs: [ - "Conversions.cpp", - "Device.cpp", - "DevicesFactory.cpp", - "ParametersUtil.cpp", - "PrimaryDevice.cpp", - "Stream.cpp", - "StreamIn.cpp", - "StreamOut.cpp", - ], - - cflags: [ - "-DAUDIO_HAL_VERSION_2_0", - ], - - defaults: ["hidl_defaults"], - - export_include_dirs: ["include"], - - shared_libs: [ - "libbase", - "libcutils", - "libfmq", - "libhardware", - "libhidlbase", - "libhidltransport", - "liblog", - "libutils", - "android.hardware.audio@2.0", - "android.hardware.audio.common@2.0", - "android.hardware.audio.common@2.0-util", - "android.hardware.audio.common-util", - ], - - header_libs: [ - "android.hardware.audio.common.util@all-versions", - "android.hardware.audio.core@all-versions-impl", - "libaudioclient_headers", - "libaudio_system_headers", - "libhardware_headers", - "libmedia_headers", - ], - - whole_static_libs: [ - "libmedia_helper", - ], - -} diff --git a/audio/core/2.0/default/Conversions.cpp b/audio/core/2.0/default/Conversions.cpp deleted file mode 100644 index 6c32090626..0000000000 --- a/audio/core/2.0/default/Conversions.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2017 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/2.0/default/Conversions.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <core/all-versions/default/Conversions.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/core/2.0/default/Device.cpp b/audio/core/2.0/default/Device.cpp deleted file mode 100644 index b67203d50e..0000000000 --- a/audio/core/2.0/default/Device.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2017 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 "DeviceHAL" - -#include "core/2.0/default/Device.h" -#include <HidlUtils.h> -#include "core/2.0/default/Conversions.h" -#include "core/2.0/default/StreamIn.h" -#include "core/2.0/default/StreamOut.h" -#include "core/2.0/default/Util.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <core/all-versions/default/Device.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/core/2.0/default/DevicesFactory.cpp b/audio/core/2.0/default/DevicesFactory.cpp deleted file mode 100644 index 65a9ccdc4e..0000000000 --- a/audio/core/2.0/default/DevicesFactory.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2017 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 "DevicesFactoryHAL" - -#include "core/2.0/default/DevicesFactory.h" -#include "core/2.0/default/Device.h" -#include "core/2.0/default/PrimaryDevice.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <core/all-versions/default/DevicesFactory.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/core/2.0/default/ParametersUtil.cpp b/audio/core/2.0/default/ParametersUtil.cpp deleted file mode 100644 index 963e291de0..0000000000 --- a/audio/core/2.0/default/ParametersUtil.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 2017 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/2.0/default/ParametersUtil.h" -#include "core/2.0/default/Util.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <core/all-versions/default/ParametersUtil.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/core/2.0/default/PrimaryDevice.cpp b/audio/core/2.0/default/PrimaryDevice.cpp deleted file mode 100644 index decaa14658..0000000000 --- a/audio/core/2.0/default/PrimaryDevice.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2017 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 "PrimaryDeviceHAL" - -#include "core/2.0/default/PrimaryDevice.h" -#include "core/2.0/default/Util.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <core/all-versions/default/PrimaryDevice.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/core/2.0/default/Stream.cpp b/audio/core/2.0/default/Stream.cpp deleted file mode 100644 index 0863a7c399..0000000000 --- a/audio/core/2.0/default/Stream.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2017 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 "StreamHAL" - -#include "core/2.0/default/Stream.h" -#include "common/all-versions/default/EffectMap.h" -#include "core/2.0/default/Conversions.h" -#include "core/2.0/default/Util.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <core/all-versions/default/Stream.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/core/2.0/default/StreamIn.cpp b/audio/core/2.0/default/StreamIn.cpp deleted file mode 100644 index 2021df1c49..0000000000 --- a/audio/core/2.0/default/StreamIn.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2017 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 "StreamInHAL" - -#include "core/2.0/default/StreamIn.h" -#include "core/2.0/default/Util.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <core/all-versions/default/StreamIn.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/core/2.0/default/StreamOut.cpp b/audio/core/2.0/default/StreamOut.cpp deleted file mode 100644 index 940a251272..0000000000 --- a/audio/core/2.0/default/StreamOut.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2017 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 "StreamOutHAL" - -#include "core/2.0/default/StreamOut.h" -#include "core/2.0/default/Util.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <core/all-versions/default/StreamOut.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/core/2.0/default/include/core/2.0/default/Conversions.h b/audio/core/2.0/default/include/core/2.0/default/Conversions.h deleted file mode 100644 index b3a6ea886e..0000000000 --- a/audio/core/2.0/default/include/core/2.0/default/Conversions.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_V2_0_CONVERSIONS_H_ -#define ANDROID_HARDWARE_AUDIO_V2_0_CONVERSIONS_H_ - -#include <android/hardware/audio/2.0/types.h> - -#define AUDIO_HAL_VERSION V2_0 -#include <core/all-versions/default/Conversions.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_V2_0_CONVERSIONS_H_ diff --git a/audio/core/2.0/default/include/core/2.0/default/Device.h b/audio/core/2.0/default/include/core/2.0/default/Device.h deleted file mode 100644 index 3ec74649ec..0000000000 --- a/audio/core/2.0/default/include/core/2.0/default/Device.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_V2_0_DEVICE_H -#define ANDROID_HARDWARE_AUDIO_V2_0_DEVICE_H - -#include <android/hardware/audio/2.0/IDevice.h> - -#include "ParametersUtil.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <core/all-versions/default/Device.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_V2_0_DEVICE_H diff --git a/audio/core/2.0/default/include/core/2.0/default/DevicesFactory.h b/audio/core/2.0/default/include/core/2.0/default/DevicesFactory.h deleted file mode 100644 index 8e8ee88ffa..0000000000 --- a/audio/core/2.0/default/include/core/2.0/default/DevicesFactory.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_V2_0_DEVICESFACTORY_H -#define ANDROID_HARDWARE_AUDIO_V2_0_DEVICESFACTORY_H - -#include <android/hardware/audio/2.0/IDevicesFactory.h> - -#define AUDIO_HAL_VERSION V2_0 -#include <core/all-versions/default/DevicesFactory.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_V2_0_DEVICESFACTORY_H diff --git a/audio/core/2.0/default/include/core/2.0/default/ParametersUtil.h b/audio/core/2.0/default/include/core/2.0/default/ParametersUtil.h deleted file mode 100644 index a5c1c78f94..0000000000 --- a/audio/core/2.0/default/include/core/2.0/default/ParametersUtil.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_V2_0_PARAMETERS_UTIL_H_ -#define ANDROID_HARDWARE_AUDIO_V2_0_PARAMETERS_UTIL_H_ - -#include <android/hardware/audio/2.0/types.h> - -#define AUDIO_HAL_VERSION V2_0 -#include <core/all-versions/default/ParametersUtil.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_V2_0_PARAMETERS_UTIL_H_ diff --git a/audio/core/2.0/default/include/core/2.0/default/PrimaryDevice.h b/audio/core/2.0/default/include/core/2.0/default/PrimaryDevice.h deleted file mode 100644 index f89859700a..0000000000 --- a/audio/core/2.0/default/include/core/2.0/default/PrimaryDevice.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_V2_0_PRIMARYDEVICE_H -#define ANDROID_HARDWARE_AUDIO_V2_0_PRIMARYDEVICE_H - -#include <android/hardware/audio/2.0/IPrimaryDevice.h> - -#include "Device.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <core/all-versions/default/PrimaryDevice.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_V2_0_PRIMARYDEVICE_H diff --git a/audio/core/2.0/default/include/core/2.0/default/Stream.h b/audio/core/2.0/default/include/core/2.0/default/Stream.h deleted file mode 100644 index a2d845609c..0000000000 --- a/audio/core/2.0/default/include/core/2.0/default/Stream.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_V2_0_STREAM_H -#define ANDROID_HARDWARE_AUDIO_V2_0_STREAM_H - -#include <android/hardware/audio/2.0/IStream.h> - -#include "ParametersUtil.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <core/all-versions/default/Stream.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_V2_0_STREAM_H diff --git a/audio/core/2.0/default/include/core/2.0/default/StreamIn.h b/audio/core/2.0/default/include/core/2.0/default/StreamIn.h deleted file mode 100644 index c36abbd68e..0000000000 --- a/audio/core/2.0/default/include/core/2.0/default/StreamIn.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_V2_0_STREAMIN_H -#define ANDROID_HARDWARE_AUDIO_V2_0_STREAMIN_H - -#include <android/hardware/audio/2.0/IStreamIn.h> - -#include "Device.h" -#include "Stream.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <core/all-versions/default/StreamIn.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_V2_0_STREAMIN_H diff --git a/audio/core/2.0/default/include/core/2.0/default/StreamOut.h b/audio/core/2.0/default/include/core/2.0/default/StreamOut.h deleted file mode 100644 index ab35687414..0000000000 --- a/audio/core/2.0/default/include/core/2.0/default/StreamOut.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_V2_0_STREAMOUT_H -#define ANDROID_HARDWARE_AUDIO_V2_0_STREAMOUT_H - -#include <android/hardware/audio/2.0/IStreamOut.h> - -#include "Device.h" -#include "Stream.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <core/all-versions/default/StreamOut.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_V2_0_STREAMOUT_H diff --git a/audio/core/2.0/vts/OWNERS b/audio/core/2.0/vts/OWNERS deleted file mode 100644 index 8711a9ff6a..0000000000 --- a/audio/core/2.0/vts/OWNERS +++ /dev/null @@ -1,5 +0,0 @@ -elaurent@google.com -krocard@google.com -mnaganov@google.com -yim@google.com -zhuoyao@google.com
\ No newline at end of file diff --git a/audio/core/2.0/vts/functional/Android.bp b/audio/core/2.0/vts/functional/Android.bp deleted file mode 100644 index d1ddaff948..0000000000 --- a/audio/core/2.0/vts/functional/Android.bp +++ /dev/null @@ -1,32 +0,0 @@ -// -// Copyright (C) 2017 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. -// - -cc_test { - name: "VtsHalAudioV2_0TargetTest", - defaults: ["VtsHalTargetTestDefaults"], - srcs: [ - "AudioPrimaryHidlHalTest.cpp", - "ValidateAudioConfiguration.cpp" - ], - static_libs: [ - "android.hardware.audio.common.test.utility", - "android.hardware.audio@2.0", - "android.hardware.audio.common@2.0", - "libicuuc", - "libicuuc_stubdata", - "libxml2", - ], -} diff --git a/audio/core/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp b/audio/core/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp deleted file mode 100644 index a08a2d62bb..0000000000 --- a/audio/core/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp +++ /dev/null @@ -1,1280 +0,0 @@ -/* - * Copyright (C) 2017 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 "VtsHalAudioV2_0TargetTest" - -#include <algorithm> -#include <cmath> -#include <cstddef> -#include <cstdio> -#include <initializer_list> -#include <limits> -#include <string> -#include <vector> - -#include <fcntl.h> -#include <unistd.h> - -#include <VtsHalHidlTargetTestBase.h> - -#include <android-base/logging.h> - -#include <android/hardware/audio/2.0/IDevice.h> -#include <android/hardware/audio/2.0/IDevicesFactory.h> -#include <android/hardware/audio/2.0/IPrimaryDevice.h> -#include <android/hardware/audio/2.0/types.h> -#include <android/hardware/audio/common/2.0/types.h> - -#include "utility/AssertOk.h" -#include "utility/Documentation.h" -#include "utility/EnvironmentTearDown.h" -#define AUDIO_HAL_VERSION V2_0 -#include "utility/PrettyPrintAudioTypes.h" -#include "utility/ReturnIn.h" - -using std::initializer_list; -using std::string; -using std::to_string; -using std::vector; - -using ::android::sp; -using ::android::hardware::Return; -using ::android::hardware::hidl_handle; -using ::android::hardware::hidl_string; -using ::android::hardware::hidl_vec; -using ::android::hardware::MQDescriptorSync; -using ::android::hardware::audio::V2_0::AudioDrain; -using ::android::hardware::audio::V2_0::DeviceAddress; -using ::android::hardware::audio::V2_0::IDevice; -using ::android::hardware::audio::V2_0::IPrimaryDevice; -using TtyMode = ::android::hardware::audio::V2_0::IPrimaryDevice::TtyMode; -using ::android::hardware::audio::V2_0::IDevicesFactory; -using ::android::hardware::audio::V2_0::IStream; -using ::android::hardware::audio::V2_0::IStreamIn; -using ::android::hardware::audio::V2_0::TimeSpec; -using ReadParameters = ::android::hardware::audio::V2_0::IStreamIn::ReadParameters; -using ReadStatus = ::android::hardware::audio::V2_0::IStreamIn::ReadStatus; -using ::android::hardware::audio::V2_0::IStreamOut; -using ::android::hardware::audio::V2_0::IStreamOutCallback; -using ::android::hardware::audio::V2_0::MmapBufferInfo; -using ::android::hardware::audio::V2_0::MmapPosition; -using ::android::hardware::audio::V2_0::ParameterValue; -using ::android::hardware::audio::V2_0::Result; -using ::android::hardware::audio::common::V2_0::AudioChannelMask; -using ::android::hardware::audio::common::V2_0::AudioConfig; -using ::android::hardware::audio::common::V2_0::AudioDevice; -using ::android::hardware::audio::common::V2_0::AudioFormat; -using ::android::hardware::audio::common::V2_0::AudioHandleConsts; -using ::android::hardware::audio::common::V2_0::AudioInputFlag; -using ::android::hardware::audio::common::V2_0::AudioIoHandle; -using ::android::hardware::audio::common::V2_0::AudioMode; -using ::android::hardware::audio::common::V2_0::AudioOffloadInfo; -using ::android::hardware::audio::common::V2_0::AudioOutputFlag; -using ::android::hardware::audio::common::V2_0::AudioSource; -using ::android::hardware::audio::common::V2_0::ThreadInfo; - -using namespace ::android::hardware::audio::common::test::utility; - -class AudioHidlTestEnvironment : public ::Environment { - public: - virtual void registerTestServices() override { registerTestService<IDevicesFactory>(); } -}; - -// Instance to register global tearDown -static AudioHidlTestEnvironment* environment; - -class HidlTest : public ::testing::VtsHalHidlTargetTestBase { - protected: - // Convenient member to store results - Result res; -}; - -////////////////////////////////////////////////////////////////////////////// -////////////////////// getService audio_devices_factory ////////////////////// -////////////////////////////////////////////////////////////////////////////// - -// Test all audio devices -class AudioHidlTest : public HidlTest { - public: - void SetUp() override { - ASSERT_NO_FATAL_FAILURE(HidlTest::SetUp()); // setup base - - if (devicesFactory == nullptr) { - environment->registerTearDown([] { devicesFactory.clear(); }); - devicesFactory = ::testing::VtsHalHidlTargetTestBase::getService<IDevicesFactory>( - environment->getServiceName<IDevicesFactory>("default")); - } - ASSERT_TRUE(devicesFactory != nullptr); - } - - protected: - // Cache the devicesFactory retrieval to speed up each test by ~0.5s - static sp<IDevicesFactory> devicesFactory; -}; -sp<IDevicesFactory> AudioHidlTest::devicesFactory; - -TEST_F(AudioHidlTest, GetAudioDevicesFactoryService) { - doc::test("test the getService (called in SetUp)"); -} - -TEST_F(AudioHidlTest, OpenDeviceInvalidParameter) { - doc::test("test passing an invalid parameter to openDevice"); - IDevicesFactory::Result result; - sp<IDevice> device; - ASSERT_OK(devicesFactory->openDevice(IDevicesFactory::Device(-1), returnIn(result, device))); - ASSERT_EQ(IDevicesFactory::Result::INVALID_ARGUMENTS, result); - ASSERT_TRUE(device == nullptr); -} - -////////////////////////////////////////////////////////////////////////////// -/////////////////////////////// openDevice primary /////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -// Test the primary device -class AudioPrimaryHidlTest : public AudioHidlTest { - public: - /** Primary HAL test are NOT thread safe. */ - void SetUp() override { - ASSERT_NO_FATAL_FAILURE(AudioHidlTest::SetUp()); // setup base - - if (device == nullptr) { - IDevicesFactory::Result result; - sp<IDevice> baseDevice; - ASSERT_OK(devicesFactory->openDevice(IDevicesFactory::Device::PRIMARY, - returnIn(result, baseDevice))); - ASSERT_OK(result); - ASSERT_TRUE(baseDevice != nullptr); - - environment->registerTearDown([] { device.clear(); }); - device = IPrimaryDevice::castFrom(baseDevice); - ASSERT_TRUE(device != nullptr); - } - } - - protected: - // Cache the device opening to speed up each test by ~0.5s - static sp<IPrimaryDevice> device; -}; -sp<IPrimaryDevice> AudioPrimaryHidlTest::device; - -TEST_F(AudioPrimaryHidlTest, OpenPrimaryDevice) { - doc::test("Test the openDevice (called in SetUp)"); -} - -TEST_F(AudioPrimaryHidlTest, Init) { - doc::test("Test that the audio primary hal initialized correctly"); - ASSERT_OK(device->initCheck()); -} - -////////////////////////////////////////////////////////////////////////////// -///////////////////// {set,get}{Master,Mic}{Mute,Volume} ///////////////////// -////////////////////////////////////////////////////////////////////////////// - -template <class Property> -class AccessorPrimaryHidlTest : public AudioPrimaryHidlTest { - protected: - /** Test a property getter and setter. */ - template <class Getter, class Setter> - void testAccessors(const string& propertyName, const vector<Property>& valuesToTest, - Setter setter, Getter getter, const vector<Property>& invalidValues = {}) { - Property initialValue; // Save initial value to restore it at the end - // of the test - ASSERT_OK((device.get()->*getter)(returnIn(res, initialValue))); - ASSERT_OK(res); - - for (Property setValue : valuesToTest) { - SCOPED_TRACE("Test " + propertyName + " getter and setter for " + - testing::PrintToString(setValue)); - ASSERT_OK((device.get()->*setter)(setValue)); - Property getValue; - // Make sure the getter returns the same value just set - ASSERT_OK((device.get()->*getter)(returnIn(res, getValue))); - ASSERT_OK(res); - EXPECT_EQ(setValue, getValue); - } - - for (Property invalidValue : invalidValues) { - SCOPED_TRACE("Try to set " + propertyName + " with the invalid value " + - testing::PrintToString(invalidValue)); - EXPECT_RESULT(Result::INVALID_ARGUMENTS, (device.get()->*setter)(invalidValue)); - } - - ASSERT_OK((device.get()->*setter)(initialValue)); // restore initial value - } - - /** Test the getter and setter of an optional feature. */ - template <class Getter, class Setter> - void testOptionalAccessors(const string& propertyName, const vector<Property>& valuesToTest, - Setter setter, Getter getter, - const vector<Property>& invalidValues = {}) { - doc::test("Test the optional " + propertyName + " getters and setter"); - { - SCOPED_TRACE("Test feature support by calling the getter"); - Property initialValue; - ASSERT_OK((device.get()->*getter)(returnIn(res, initialValue))); - if (res == Result::NOT_SUPPORTED) { - doc::partialTest(propertyName + " getter is not supported"); - return; - } - ASSERT_OK(res); // If it is supported it must succeed - } - // The feature is supported, test it - testAccessors(propertyName, valuesToTest, setter, getter, invalidValues); - } -}; - -using BoolAccessorPrimaryHidlTest = AccessorPrimaryHidlTest<bool>; - -TEST_F(BoolAccessorPrimaryHidlTest, MicMuteTest) { - doc::test("Check that the mic can be muted and unmuted"); - testAccessors("mic mute", {true, false, true}, &IDevice::setMicMute, &IDevice::getMicMute); - // TODO: check that the mic is really muted (all sample are 0) -} - -TEST_F(BoolAccessorPrimaryHidlTest, MasterMuteTest) { - doc::test( - "If master mute is supported, try to mute and unmute the master " - "output"); - testOptionalAccessors("master mute", {true, false, true}, &IDevice::setMasterMute, - &IDevice::getMasterMute); - // TODO: check that the master volume is really muted -} - -using FloatAccessorPrimaryHidlTest = AccessorPrimaryHidlTest<float>; -TEST_F(FloatAccessorPrimaryHidlTest, MasterVolumeTest) { - doc::test("Test the master volume if supported"); - testOptionalAccessors( - "master volume", {0, 0.5, 1}, &IDevice::setMasterVolume, &IDevice::getMasterVolume, - {-0.1, 1.1, NAN, INFINITY, -INFINITY, 1 + std::numeric_limits<float>::epsilon()}); - // TODO: check that the master volume is really changed -} - -////////////////////////////////////////////////////////////////////////////// -//////////////////////////////// AudioPatches //////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -class AudioPatchPrimaryHidlTest : public AudioPrimaryHidlTest { - protected: - bool areAudioPatchesSupported() { - auto result = device->supportsAudioPatches(); - EXPECT_IS_OK(result); - return result; - } -}; - -TEST_F(AudioPatchPrimaryHidlTest, AudioPatches) { - doc::test("Test if audio patches are supported"); - if (!areAudioPatchesSupported()) { - doc::partialTest("Audio patches are not supported"); - return; - } - // TODO: test audio patches -} - -////////////////////////////////////////////////////////////////////////////// -//////////////// Required and recommended audio format support /////////////// -// From: -// https://source.android.com/compatibility/android-cdd.html#5_4_audio_recording -// From: -// https://source.android.com/compatibility/android-cdd.html#5_5_audio_playback -/////////// TODO: move to the beginning of the file for easier update //////// -////////////////////////////////////////////////////////////////////////////// - -class AudioConfigPrimaryTest : public AudioPatchPrimaryHidlTest { - public: - // Cache result ? - static const vector<AudioConfig> getRequiredSupportPlaybackAudioConfig() { - return combineAudioConfig({AudioChannelMask::OUT_STEREO, AudioChannelMask::OUT_MONO}, - {8000, 11025, 16000, 22050, 32000, 44100}, - {AudioFormat::PCM_16_BIT}); - } - - static const vector<AudioConfig> getRecommendedSupportPlaybackAudioConfig() { - return combineAudioConfig({AudioChannelMask::OUT_STEREO, AudioChannelMask::OUT_MONO}, - {24000, 48000}, {AudioFormat::PCM_16_BIT}); - } - - static const vector<AudioConfig> getSupportedPlaybackAudioConfig() { - // TODO: retrieve audio config supported by the platform - // as declared in the policy configuration - return {}; - } - - static const vector<AudioConfig> getRequiredSupportCaptureAudioConfig() { - return combineAudioConfig({AudioChannelMask::IN_MONO}, {8000, 11025, 16000, 44100}, - {AudioFormat::PCM_16_BIT}); - } - static const vector<AudioConfig> getRecommendedSupportCaptureAudioConfig() { - return combineAudioConfig({AudioChannelMask::IN_STEREO}, {22050, 48000}, - {AudioFormat::PCM_16_BIT}); - } - static const vector<AudioConfig> getSupportedCaptureAudioConfig() { - // TODO: retrieve audio config supported by the platform - // as declared in the policy configuration - return {}; - } - - private: - static const vector<AudioConfig> combineAudioConfig(vector<AudioChannelMask> channelMasks, - vector<uint32_t> sampleRates, - vector<AudioFormat> formats) { - vector<AudioConfig> configs; - for (auto channelMask : channelMasks) { - for (auto sampleRate : sampleRates) { - for (auto format : formats) { - AudioConfig config{}; - // leave offloadInfo to 0 - config.channelMask = channelMask; - config.sampleRateHz = sampleRate; - config.format = format; - // FIXME: leave frameCount to 0 ? - configs.push_back(config); - } - } - } - return configs; - } -}; - -/** Generate a test name based on an audio config. - * - * As the only parameter changing are channel mask and sample rate, - * only print those ones in the test name. - */ -static string generateTestName(const testing::TestParamInfo<AudioConfig>& info) { - const AudioConfig& config = info.param; - return to_string(info.index) + "__" + to_string(config.sampleRateHz) + "_" + - // "MONO" is more clear than "FRONT_LEFT" - ((config.channelMask == AudioChannelMask::OUT_MONO || - config.channelMask == AudioChannelMask::IN_MONO) - ? "MONO" - : toString(config.channelMask)); -} - -////////////////////////////////////////////////////////////////////////////// -///////////////////////////// getInputBufferSize ///////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -// FIXME: execute input test only if platform declares -// android.hardware.microphone -// how to get this value ? is it a property ??? - -class AudioCaptureConfigPrimaryTest : public AudioConfigPrimaryTest, - public ::testing::WithParamInterface<AudioConfig> { - protected: - void inputBufferSizeTest(const AudioConfig& audioConfig, bool supportRequired) { - uint64_t bufferSize; - ASSERT_OK(device->getInputBufferSize(audioConfig, returnIn(res, bufferSize))); - - switch (res) { - case Result::INVALID_ARGUMENTS: - EXPECT_FALSE(supportRequired); - break; - case Result::OK: - // Check that the buffer is of a sane size - // For now only that it is > 0 - EXPECT_GT(bufferSize, uint64_t(0)); - break; - default: - FAIL() << "Invalid return status: " << ::testing::PrintToString(res); - } - } -}; - -// Test that the required capture config and those declared in the policy are -// indeed supported -class RequiredInputBufferSizeTest : public AudioCaptureConfigPrimaryTest {}; -TEST_P(RequiredInputBufferSizeTest, RequiredInputBufferSizeTest) { - doc::test( - "Input buffer size must be retrievable for a format with required " - "support."); - inputBufferSizeTest(GetParam(), true); -} -INSTANTIATE_TEST_CASE_P( - RequiredInputBufferSize, RequiredInputBufferSizeTest, - ::testing::ValuesIn(AudioConfigPrimaryTest::getRequiredSupportCaptureAudioConfig()), - &generateTestName); -INSTANTIATE_TEST_CASE_P( - SupportedInputBufferSize, RequiredInputBufferSizeTest, - ::testing::ValuesIn(AudioConfigPrimaryTest::getSupportedCaptureAudioConfig()), - &generateTestName); - -// Test that the recommended capture config are supported or lead to a -// INVALID_ARGUMENTS return -class OptionalInputBufferSizeTest : public AudioCaptureConfigPrimaryTest {}; -TEST_P(OptionalInputBufferSizeTest, OptionalInputBufferSizeTest) { - doc::test( - "Input buffer size should be retrievable for a format with recommended " - "support."); - inputBufferSizeTest(GetParam(), false); -} -INSTANTIATE_TEST_CASE_P( - RecommendedCaptureAudioConfigSupport, OptionalInputBufferSizeTest, - ::testing::ValuesIn(AudioConfigPrimaryTest::getRecommendedSupportCaptureAudioConfig()), - &generateTestName); - -////////////////////////////////////////////////////////////////////////////// -/////////////////////////////// setScreenState /////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -TEST_F(AudioPrimaryHidlTest, setScreenState) { - doc::test("Check that the hal can receive the screen state"); - for (bool turnedOn : {false, true, true, false, false}) { - auto ret = device->setScreenState(turnedOn); - ASSERT_IS_OK(ret); - Result result = ret; - auto okOrNotSupported = {Result::OK, Result::NOT_SUPPORTED}; - ASSERT_RESULT(okOrNotSupported, result); - } -} - -////////////////////////////////////////////////////////////////////////////// -//////////////////////////// {get,set}Parameters ///////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -TEST_F(AudioPrimaryHidlTest, getParameters) { - doc::test("Check that the hal can set and get parameters"); - hidl_vec<hidl_string> keys; - hidl_vec<ParameterValue> values; - ASSERT_OK(device->getParameters(keys, returnIn(res, values))); - ASSERT_OK(device->setParameters(values)); - values.resize(0); - ASSERT_OK(device->setParameters(values)); -} - -////////////////////////////////////////////////////////////////////////////// -//////////////////////////////// debugDebug ////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -template <class DebugDump> -static void testDebugDump(DebugDump debugDump) { - // File descriptors to our pipe. fds[0] corresponds to the read end and - // fds[1] to the write end. - int fds[2]; - ASSERT_EQ(0, pipe2(fds, O_NONBLOCK)) << errno; - - // Make sure that the pipe is at least 1 MB in size. The test process runs - // in su domain, so it should be safe to make this call. - fcntl(fds[0], F_SETPIPE_SZ, 1 << 20); - - // Wrap the temporary file file descriptor in a native handle - auto* nativeHandle = native_handle_create(1, 0); - ASSERT_NE(nullptr, nativeHandle); - nativeHandle->data[0] = fds[1]; - - // Wrap this native handle in a hidl handle - hidl_handle handle; - handle.setTo(nativeHandle, false /*take ownership*/); - - ASSERT_OK(debugDump(handle)); - - // Check that at least one bit was written by the hal - // TODO: debugDump does not return a Result. - // This mean that the hal can not report that it not implementing the - // function. - char buff; - if (read(fds[0], &buff, 1) != 1) { - doc::note("debugDump does not seem implemented"); - } - EXPECT_EQ(0, close(fds[0])) << errno; - EXPECT_EQ(0, close(fds[1])) << errno; -} - -TEST_F(AudioPrimaryHidlTest, DebugDump) { - doc::test("Check that the hal can dump its state without error"); - testDebugDump([](const auto& handle) { return device->debugDump(handle); }); -} - -TEST_F(AudioPrimaryHidlTest, DebugDumpInvalidArguments) { - doc::test("Check that the hal dump doesn't crash on invalid arguments"); - ASSERT_OK(device->debugDump(hidl_handle())); -} - -////////////////////////////////////////////////////////////////////////////// -////////////////////////// open{Output,Input}Stream ////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -template <class Stream> -class OpenStreamTest : public AudioConfigPrimaryTest, - public ::testing::WithParamInterface<AudioConfig> { - protected: - template <class Open> - void testOpen(Open openStream, const AudioConfig& config) { - // FIXME: Open a stream without an IOHandle - // This is not required to be accepted by hal implementations - AudioIoHandle ioHandle = (AudioIoHandle)AudioHandleConsts::AUDIO_IO_HANDLE_NONE; - AudioConfig suggestedConfig{}; - ASSERT_OK(openStream(ioHandle, config, returnIn(res, stream, suggestedConfig))); - - // TODO: only allow failure for RecommendedPlaybackAudioConfig - switch (res) { - case Result::OK: - ASSERT_TRUE(stream != nullptr); - audioConfig = config; - break; - case Result::INVALID_ARGUMENTS: - ASSERT_TRUE(stream == nullptr); - AudioConfig suggestedConfigRetry; - // Could not open stream with config, try again with the - // suggested one - ASSERT_OK(openStream(ioHandle, suggestedConfig, - returnIn(res, stream, suggestedConfigRetry))); - // This time it must succeed - ASSERT_OK(res); - ASSERT_TRUE(stream != nullptr); - audioConfig = suggestedConfig; - break; - default: - FAIL() << "Invalid return status: " << ::testing::PrintToString(res); - } - open = true; - } - - Return<Result> closeStream() { - open = false; - return stream->close(); - } - - private: - void TearDown() override { - if (open) { - ASSERT_OK(stream->close()); - } - } - - protected: - AudioConfig audioConfig; - DeviceAddress address = {}; - sp<Stream> stream; - bool open = false; -}; - -////////////////////////////// openOutputStream ////////////////////////////// - -class OutputStreamTest : public OpenStreamTest<IStreamOut> { - virtual void SetUp() override { - ASSERT_NO_FATAL_FAILURE(OpenStreamTest::SetUp()); // setup base - address.device = AudioDevice::OUT_DEFAULT; - const AudioConfig& config = GetParam(); - AudioOutputFlag flags = AudioOutputFlag::NONE; // TODO: test all flag combination - testOpen( - [&](AudioIoHandle handle, AudioConfig config, auto cb) { - return device->openOutputStream(handle, address, config, flags, cb); - }, - config); - } -}; -TEST_P(OutputStreamTest, OpenOutputStreamTest) { - doc::test( - "Check that output streams can be open with the required and " - "recommended config"); - // Open done in SetUp -} -INSTANTIATE_TEST_CASE_P( - RequiredOutputStreamConfigSupport, OutputStreamTest, - ::testing::ValuesIn(AudioConfigPrimaryTest::getRequiredSupportPlaybackAudioConfig()), - &generateTestName); -INSTANTIATE_TEST_CASE_P( - SupportedOutputStreamConfig, OutputStreamTest, - ::testing::ValuesIn(AudioConfigPrimaryTest::getSupportedPlaybackAudioConfig()), - &generateTestName); - -INSTANTIATE_TEST_CASE_P( - RecommendedOutputStreamConfigSupport, OutputStreamTest, - ::testing::ValuesIn(AudioConfigPrimaryTest::getRecommendedSupportPlaybackAudioConfig()), - &generateTestName); - -////////////////////////////// openInputStream ////////////////////////////// - -class InputStreamTest : public OpenStreamTest<IStreamIn> { - virtual void SetUp() override { - ASSERT_NO_FATAL_FAILURE(OpenStreamTest::SetUp()); // setup base - address.device = AudioDevice::IN_DEFAULT; - const AudioConfig& config = GetParam(); - AudioInputFlag flags = AudioInputFlag::NONE; // TODO: test all flag combination - AudioSource source = AudioSource::DEFAULT; // TODO: test all flag combination - testOpen( - [&](AudioIoHandle handle, AudioConfig config, auto cb) { - return device->openInputStream(handle, address, config, flags, source, cb); - }, - config); - } -}; - -TEST_P(InputStreamTest, OpenInputStreamTest) { - doc::test( - "Check that input streams can be open with the required and " - "recommended config"); - // Open done in setup -} -INSTANTIATE_TEST_CASE_P( - RequiredInputStreamConfigSupport, InputStreamTest, - ::testing::ValuesIn(AudioConfigPrimaryTest::getRequiredSupportCaptureAudioConfig()), - &generateTestName); -INSTANTIATE_TEST_CASE_P( - SupportedInputStreamConfig, InputStreamTest, - ::testing::ValuesIn(AudioConfigPrimaryTest::getSupportedCaptureAudioConfig()), - &generateTestName); - -INSTANTIATE_TEST_CASE_P( - RecommendedInputStreamConfigSupport, InputStreamTest, - ::testing::ValuesIn(AudioConfigPrimaryTest::getRecommendedSupportCaptureAudioConfig()), - &generateTestName); - -////////////////////////////////////////////////////////////////////////////// -////////////////////////////// IStream getters /////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -/** Unpack the provided result. - * If the result is not OK, register a failure and return an undefined value. */ -template <class R> -static R extract(Return<R> ret) { - if (!ret.isOk()) { - EXPECT_IS_OK(ret); - return R{}; - } - return ret; -} - -/* Could not find a way to write a test for two parametrized class fixure - * thus use this macro do duplicate tests for Input and Output stream */ -#define TEST_IO_STREAM(test_name, documentation, code) \ - TEST_P(InputStreamTest, test_name) { \ - doc::test(documentation); \ - code; \ - } \ - TEST_P(OutputStreamTest, test_name) { \ - doc::test(documentation); \ - code; \ - } - -TEST_IO_STREAM(GetFrameCount, "Check that getting stream frame count does not crash the HAL.", - ASSERT_TRUE(stream->getFrameCount().isOk())) - -TEST_IO_STREAM(GetSampleRate, "Check that the stream sample rate == the one it was opened with", - ASSERT_EQ(audioConfig.sampleRateHz, extract(stream->getSampleRate()))) - -TEST_IO_STREAM(GetChannelMask, "Check that the stream channel mask == the one it was opened with", - ASSERT_EQ(audioConfig.channelMask, extract(stream->getChannelMask()))) - -TEST_IO_STREAM(GetFormat, "Check that the stream format == the one it was opened with", - ASSERT_EQ(audioConfig.format, extract(stream->getFormat()))) - -// TODO: for now only check that the framesize is not incoherent -TEST_IO_STREAM(GetFrameSize, "Check that the stream frame size == the one it was opened with", - ASSERT_GT(extract(stream->getFrameSize()), 0U)) - -TEST_IO_STREAM(GetBufferSize, "Check that the stream buffer size== the one it was opened with", - ASSERT_GE(extract(stream->getBufferSize()), extract(stream->getFrameSize()))); - -template <class Property, class CapabilityGetter> -static void testCapabilityGetter(const string& name, IStream* stream, - CapabilityGetter capablityGetter, - Return<Property> (IStream::*getter)(), - Return<Result> (IStream::*setter)(Property), - bool currentMustBeSupported = true) { - hidl_vec<Property> capabilities; - ASSERT_OK((stream->*capablityGetter)(returnIn(capabilities))); - if (capabilities.size() == 0) { - // The default hal should probably return a NOT_SUPPORTED if the hal - // does not expose - // capability retrieval. For now it returns an empty list if not - // implemented - doc::partialTest(name + " is not supported"); - return; - }; - - if (currentMustBeSupported) { - Property currentValue = extract((stream->*getter)()); - EXPECT_NE(std::find(capabilities.begin(), capabilities.end(), currentValue), - capabilities.end()) - << "current " << name << " is not in the list of the supported ones " - << toString(capabilities); - } - - // Check that all declared supported values are indeed supported - for (auto capability : capabilities) { - auto ret = (stream->*setter)(capability); - ASSERT_TRUE(ret.isOk()); - if (ret == Result::NOT_SUPPORTED) { - doc::partialTest("Setter is not supported"); - return; - } - ASSERT_OK(ret); - ASSERT_EQ(capability, extract((stream->*getter)())); - } -} - -TEST_IO_STREAM(SupportedSampleRate, "Check that the stream sample rate is declared as supported", - testCapabilityGetter("getSupportedSampleRate", stream.get(), - &IStream::getSupportedSampleRates, &IStream::getSampleRate, - &IStream::setSampleRate, - // getSupportedSampleRate returns the native sampling rates, - // (the sampling rates that can be played without resampling) - // but other sampling rates can be supported by the HAL. - false)) - -TEST_IO_STREAM(SupportedChannelMask, "Check that the stream channel mask is declared as supported", - testCapabilityGetter("getSupportedChannelMask", stream.get(), - &IStream::getSupportedChannelMasks, &IStream::getChannelMask, - &IStream::setChannelMask)) - -TEST_IO_STREAM(SupportedFormat, "Check that the stream format is declared as supported", - testCapabilityGetter("getSupportedFormat", stream.get(), - &IStream::getSupportedFormats, &IStream::getFormat, - &IStream::setFormat)) - -static void testGetDevice(IStream* stream, AudioDevice expectedDevice) { - // Unfortunately the interface does not allow the implementation to return - // NOT_SUPPORTED - // Thus allow NONE as signaling that the call is not supported. - auto ret = stream->getDevice(); - ASSERT_IS_OK(ret); - AudioDevice device = ret; - ASSERT_TRUE(device == expectedDevice || device == AudioDevice::NONE) - << "Expected: " << ::testing::PrintToString(expectedDevice) - << "\n Actual: " << ::testing::PrintToString(device); -} - -TEST_IO_STREAM(GetDevice, "Check that the stream device == the one it was opened with", - areAudioPatchesSupported() ? doc::partialTest("Audio patches are supported") - : testGetDevice(stream.get(), address.device)) - -static void testSetDevice(IStream* stream, const DeviceAddress& address) { - DeviceAddress otherAddress = address; - otherAddress.device = (address.device & AudioDevice::BIT_IN) == 0 ? AudioDevice::OUT_SPEAKER - : AudioDevice::IN_BUILTIN_MIC; - EXPECT_OK(stream->setDevice(otherAddress)); - - ASSERT_OK(stream->setDevice(address)); // Go back to the original value -} - -TEST_IO_STREAM(SetDevice, "Check that the stream can be rerouted to SPEAKER or BUILTIN_MIC", - areAudioPatchesSupported() ? doc::partialTest("Audio patches are supported") - : testSetDevice(stream.get(), address)) - -static void testGetAudioProperties(IStream* stream, AudioConfig expectedConfig) { - uint32_t sampleRateHz; - AudioChannelMask mask; - AudioFormat format; - - stream->getAudioProperties(returnIn(sampleRateHz, mask, format)); - - // FIXME: the qcom hal it does not currently negotiate the sampleRate & - // channel mask - EXPECT_EQ(expectedConfig.sampleRateHz, sampleRateHz); - EXPECT_EQ(expectedConfig.channelMask, mask); - EXPECT_EQ(expectedConfig.format, format); -} - -TEST_IO_STREAM(GetAudioProperties, - "Check that the stream audio properties == the ones it was opened with", - testGetAudioProperties(stream.get(), audioConfig)) - -static void testConnectedState(IStream* stream) { - DeviceAddress address = {}; - using AD = AudioDevice; - for (auto device : {AD::OUT_HDMI, AD::OUT_WIRED_HEADPHONE, AD::IN_USB_HEADSET}) { - address.device = device; - - ASSERT_OK(stream->setConnectedState(address, true)); - ASSERT_OK(stream->setConnectedState(address, false)); - } -} -TEST_IO_STREAM(SetConnectedState, - "Check that the stream can be notified of device connection and " - "deconnection", - testConnectedState(stream.get())) - -static auto invalidArgsOrNotSupportedOrOK = {Result::INVALID_ARGUMENTS, Result::NOT_SUPPORTED, - Result::OK}; -TEST_IO_STREAM(SetHwAvSync, "Try to set hardware sync to an invalid value", - ASSERT_RESULT(invalidArgsOrNotSupportedOrOK, stream->setHwAvSync(666))) - -TEST_IO_STREAM(GetHwAvSync, "Get hardware sync can not fail", ASSERT_IS_OK(device->getHwAvSync())); - -static void checkGetNoParameter(IStream* stream, hidl_vec<hidl_string> keys, - initializer_list<Result> expectedResults) { - hidl_vec<ParameterValue> parameters; - Result res; - ASSERT_OK(stream->getParameters(keys, returnIn(res, parameters))); - ASSERT_RESULT(expectedResults, res); - if (res == Result::OK) { - for (auto& parameter : parameters) { - ASSERT_EQ(0U, parameter.value.size()) << toString(parameter); - } - } -} - -/* Get/Set parameter is intended to be an opaque channel between vendors app and - * their HALs. - * Thus can not be meaningfully tested. - */ -TEST_IO_STREAM(getEmptySetParameter, "Retrieve the values of an empty set", - checkGetNoParameter(stream.get(), {} /* keys */, {Result::OK})) - -TEST_IO_STREAM(getNonExistingParameter, "Retrieve the values of an non existing parameter", - checkGetNoParameter(stream.get(), {"Non existing key"} /* keys */, - {Result::NOT_SUPPORTED})) - -TEST_IO_STREAM(setEmptySetParameter, "Set the values of an empty set of parameters", - ASSERT_RESULT(Result::OK, stream->setParameters({}))) - -TEST_IO_STREAM(setNonExistingParameter, "Set the values of an non existing parameter", - // Unfortunately, the set_parameter legacy interface did not return any - // error code when a key is not supported. - // To allow implementation to just wrapped the legacy one, consider OK as a - // valid result for setting a non existing parameter. - ASSERT_RESULT(invalidArgsOrNotSupportedOrOK, - stream->setParameters({{"non existing key", "0"}}))) - -TEST_IO_STREAM(DebugDump, "Check that a stream can dump its state without error", - testDebugDump([this](const auto& handle) { return stream->debugDump(handle); })) - -TEST_IO_STREAM(DebugDumpInvalidArguments, - "Check that the stream dump doesn't crash on invalid arguments", - ASSERT_OK(stream->debugDump(hidl_handle()))) - -////////////////////////////////////////////////////////////////////////////// -////////////////////////////// addRemoveEffect /////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -TEST_IO_STREAM(AddNonExistingEffect, "Adding a non existing effect should fail", - ASSERT_RESULT(Result::INVALID_ARGUMENTS, stream->addEffect(666))) -TEST_IO_STREAM(RemoveNonExistingEffect, "Removing a non existing effect should fail", - ASSERT_RESULT(Result::INVALID_ARGUMENTS, stream->removeEffect(666))) - -// TODO: positive tests - -////////////////////////////////////////////////////////////////////////////// -/////////////////////////////// Control //////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -TEST_IO_STREAM(standby, "Make sure the stream can be put in stanby", - ASSERT_OK(stream->standby())) // can not fail - -static constexpr auto invalidStateOrNotSupported = {Result::INVALID_STATE, Result::NOT_SUPPORTED}; - -TEST_IO_STREAM(startNoMmap, "Starting a mmaped stream before mapping it should fail", - ASSERT_RESULT(invalidStateOrNotSupported, stream->start())) - -TEST_IO_STREAM(stopNoMmap, "Stopping a mmaped stream before mapping it should fail", - ASSERT_RESULT(invalidStateOrNotSupported, stream->stop())) - -TEST_IO_STREAM(getMmapPositionNoMmap, "Get a stream Mmap position before mapping it should fail", - ASSERT_RESULT(invalidStateOrNotSupported, stream->stop())) - -TEST_IO_STREAM(close, "Make sure a stream can be closed", ASSERT_OK(closeStream())) -TEST_IO_STREAM(closeTwice, "Make sure a stream can not be closed twice", ASSERT_OK(closeStream()); - ASSERT_RESULT(Result::INVALID_STATE, closeStream())) - -static auto invalidArgsOrNotSupported = {Result::INVALID_ARGUMENTS, Result::NOT_SUPPORTED}; -static void testCreateTooBigMmapBuffer(IStream* stream) { - MmapBufferInfo info; - Result res; - // Assume that int max is a value too big to be allocated - // This is true currently with a 32bit media server, but might not when it - // will run in 64 bit - auto minSizeFrames = std::numeric_limits<int32_t>::max(); - ASSERT_OK(stream->createMmapBuffer(minSizeFrames, returnIn(res, info))); - ASSERT_RESULT(invalidArgsOrNotSupported, res); -} - -TEST_IO_STREAM(CreateTooBigMmapBuffer, "Create mmap buffer too big should fail", - testCreateTooBigMmapBuffer(stream.get())) - -static void testGetMmapPositionOfNonMmapedStream(IStream* stream) { - Result res; - MmapPosition position; - ASSERT_OK(stream->getMmapPosition(returnIn(res, position))); - ASSERT_RESULT(invalidArgsOrNotSupported, res); -} - -TEST_IO_STREAM(GetMmapPositionOfNonMmapedStream, - "Retrieving the mmap position of a non mmaped stream should fail", - testGetMmapPositionOfNonMmapedStream(stream.get())) - -////////////////////////////////////////////////////////////////////////////// -///////////////////////////////// StreamIn /////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -TEST_P(InputStreamTest, GetAudioSource) { - doc::test("Retrieving the audio source of an input stream should always succeed"); - AudioSource source; - ASSERT_OK(stream->getAudioSource(returnIn(res, source))); - if (res == Result::NOT_SUPPORTED) { - doc::partialTest("getAudioSource is not supported"); - return; - } - ASSERT_OK(res); - ASSERT_EQ(AudioSource::DEFAULT, source); -} - -static void testUnitaryGain(std::function<Return<Result>(float)> setGain) { - for (float value : (float[]){-INFINITY, -1.0, 1.0 + std::numeric_limits<float>::epsilon(), 2.0, - INFINITY, NAN}) { - EXPECT_RESULT(Result::INVALID_ARGUMENTS, setGain(value)) << "value=" << value; - } - // Do not consider -0.0 as an invalid value as it is == with 0.0 - for (float value : {-0.0, 0.0, 0.01, 0.5, 0.09, 1.0 /* Restore volume*/}) { - EXPECT_OK(setGain(value)) << "value=" << value; - } -} - -static void testOptionalUnitaryGain(std::function<Return<Result>(float)> setGain, - string debugName) { - auto result = setGain(1); - ASSERT_IS_OK(result); - if (result == Result::NOT_SUPPORTED) { - doc::partialTest(debugName + " is not supported"); - return; - } - testUnitaryGain(setGain); -} - -TEST_P(InputStreamTest, SetGain) { - doc::test("The gain of an input stream should only be set between [0,1]"); - testOptionalUnitaryGain([this](float volume) { return stream->setGain(volume); }, - "InputStream::setGain"); -} - -static void testPrepareForReading(IStreamIn* stream, uint32_t frameSize, uint32_t framesCount) { - Result res; - // Ignore output parameters as the call should fail - ASSERT_OK(stream->prepareForReading(frameSize, framesCount, - [&res](auto r, auto&, auto&, auto&, auto&) { res = r; })); - EXPECT_RESULT(Result::INVALID_ARGUMENTS, res); -} - -TEST_P(InputStreamTest, PrepareForReadingWithZeroBuffer) { - doc::test("Preparing a stream for reading with a 0 sized buffer should fail"); - testPrepareForReading(stream.get(), 0, 0); -} - -TEST_P(InputStreamTest, PrepareForReadingWithHugeBuffer) { - doc::test("Preparing a stream for reading with a 2^32 sized buffer should fail"); - testPrepareForReading(stream.get(), 1, std::numeric_limits<uint32_t>::max()); -} - -TEST_P(InputStreamTest, PrepareForReadingCheckOverflow) { - doc::test( - "Preparing a stream for reading with a overflowing sized buffer should " - "fail"); - auto uintMax = std::numeric_limits<uint32_t>::max(); - testPrepareForReading(stream.get(), uintMax, uintMax); -} - -TEST_P(InputStreamTest, GetInputFramesLost) { - doc::test("The number of frames lost on a never started stream should be 0"); - auto ret = stream->getInputFramesLost(); - ASSERT_IS_OK(ret); - uint32_t framesLost{ret}; - ASSERT_EQ(0U, framesLost); -} - -TEST_P(InputStreamTest, getCapturePosition) { - doc::test( - "The capture position of a non prepared stream should not be " - "retrievable"); - uint64_t frames; - uint64_t time; - ASSERT_OK(stream->getCapturePosition(returnIn(res, frames, time))); - ASSERT_RESULT(invalidStateOrNotSupported, res); -} - -////////////////////////////////////////////////////////////////////////////// -///////////////////////////////// StreamIn /////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -TEST_P(OutputStreamTest, getLatency) { - doc::test("Make sure latency is over 0"); - auto result = stream->getLatency(); - ASSERT_IS_OK(result); - ASSERT_GT(result, 0U); -} - -TEST_P(OutputStreamTest, setVolume) { - doc::test("Try to set the output volume"); - testOptionalUnitaryGain([this](float volume) { return stream->setVolume(volume, volume); }, - "setVolume"); -} - -static void testPrepareForWriting(IStreamOut* stream, uint32_t frameSize, uint32_t framesCount) { - Result res; - // Ignore output parameters as the call should fail - ASSERT_OK(stream->prepareForWriting(frameSize, framesCount, - [&res](auto r, auto&, auto&, auto&, auto&) { res = r; })); - EXPECT_RESULT(Result::INVALID_ARGUMENTS, res); -} - -TEST_P(OutputStreamTest, PrepareForWriteWithZeroBuffer) { - doc::test("Preparing a stream for writing with a 0 sized buffer should fail"); - testPrepareForWriting(stream.get(), 0, 0); -} - -TEST_P(OutputStreamTest, PrepareForWriteWithHugeBuffer) { - doc::test("Preparing a stream for writing with a 2^32 sized buffer should fail"); - testPrepareForWriting(stream.get(), 1, std::numeric_limits<uint32_t>::max()); -} - -TEST_P(OutputStreamTest, PrepareForWritingCheckOverflow) { - doc::test( - "Preparing a stream for writing with a overflowing sized buffer should " - "fail"); - auto uintMax = std::numeric_limits<uint32_t>::max(); - testPrepareForWriting(stream.get(), uintMax, uintMax); -} - -struct Capability { - Capability(IStreamOut* stream) { - EXPECT_OK(stream->supportsPauseAndResume(returnIn(pause, resume))); - auto ret = stream->supportsDrain(); - EXPECT_IS_OK(ret); - if (ret.isOk()) { - drain = ret; - } - } - bool pause = false; - bool resume = false; - bool drain = false; -}; - -TEST_P(OutputStreamTest, SupportsPauseAndResumeAndDrain) { - doc::test("Implementation must expose pause, resume and drain capabilities"); - Capability(stream.get()); -} - -template <class Value> -static void checkInvalidStateOr0(Result res, Value value) { - switch (res) { - case Result::INVALID_STATE: - break; - case Result::OK: - ASSERT_EQ(0U, value); - break; - default: - FAIL() << "Unexpected result " << toString(res); - } -} - -TEST_P(OutputStreamTest, GetRenderPosition) { - doc::test("A new stream render position should be 0 or INVALID_STATE"); - uint32_t dspFrames; - ASSERT_OK(stream->getRenderPosition(returnIn(res, dspFrames))); - if (res == Result::NOT_SUPPORTED) { - doc::partialTest("getRenderPosition is not supported"); - return; - } - checkInvalidStateOr0(res, dspFrames); -} - -TEST_P(OutputStreamTest, GetNextWriteTimestamp) { - doc::test("A new stream next write timestamp should be 0 or INVALID_STATE"); - uint64_t timestampUs; - ASSERT_OK(stream->getNextWriteTimestamp(returnIn(res, timestampUs))); - if (res == Result::NOT_SUPPORTED) { - doc::partialTest("getNextWriteTimestamp is not supported"); - return; - } - checkInvalidStateOr0(res, timestampUs); -} - -/** Stub implementation of out stream callback. */ -class MockOutCallbacks : public IStreamOutCallback { - Return<void> onWriteReady() override { return {}; } - Return<void> onDrainReady() override { return {}; } - Return<void> onError() override { return {}; } -}; - -static bool isAsyncModeSupported(IStreamOut* stream) { - auto res = stream->setCallback(new MockOutCallbacks); - stream->clearCallback(); // try to restore the no callback state, ignore - // any error - auto okOrNotSupported = {Result::OK, Result::NOT_SUPPORTED}; - EXPECT_RESULT(okOrNotSupported, res); - return res.isOk() ? res == Result::OK : false; -} - -TEST_P(OutputStreamTest, SetCallback) { - doc::test( - "If supported, registering callback for async operation should never " - "fail"); - if (!isAsyncModeSupported(stream.get())) { - doc::partialTest("The stream does not support async operations"); - return; - } - ASSERT_OK(stream->setCallback(new MockOutCallbacks)); - ASSERT_OK(stream->setCallback(new MockOutCallbacks)); -} - -TEST_P(OutputStreamTest, clearCallback) { - doc::test( - "If supported, clearing a callback to go back to sync operation should " - "not fail"); - if (!isAsyncModeSupported(stream.get())) { - doc::partialTest("The stream does not support async operations"); - return; - } - // TODO: Clarify if clearing a non existing callback should fail - ASSERT_OK(stream->setCallback(new MockOutCallbacks)); - ASSERT_OK(stream->clearCallback()); -} - -TEST_P(OutputStreamTest, Resume) { - doc::test( - "If supported, a stream should fail to resume if not previously " - "paused"); - if (!Capability(stream.get()).resume) { - doc::partialTest("The output stream does not support resume"); - return; - } - ASSERT_RESULT(Result::INVALID_STATE, stream->resume()); -} - -TEST_P(OutputStreamTest, Pause) { - doc::test( - "If supported, a stream should fail to pause if not previously " - "started"); - if (!Capability(stream.get()).pause) { - doc::partialTest("The output stream does not support pause"); - return; - } - ASSERT_RESULT(Result::INVALID_STATE, stream->resume()); -} - -static void testDrain(IStreamOut* stream, AudioDrain type) { - if (!Capability(stream).drain) { - doc::partialTest("The output stream does not support drain"); - return; - } - ASSERT_RESULT(Result::OK, stream->drain(type)); -} - -TEST_P(OutputStreamTest, DrainAll) { - doc::test("If supported, a stream should always succeed to drain"); - testDrain(stream.get(), AudioDrain::ALL); -} - -TEST_P(OutputStreamTest, DrainEarlyNotify) { - doc::test("If supported, a stream should always succeed to drain"); - testDrain(stream.get(), AudioDrain::EARLY_NOTIFY); -} - -TEST_P(OutputStreamTest, FlushStop) { - doc::test("If supported, a stream should always succeed to flush"); - auto ret = stream->flush(); - ASSERT_IS_OK(ret); - if (ret == Result::NOT_SUPPORTED) { - doc::partialTest("Flush is not supported"); - return; - } - ASSERT_OK(ret); -} - -TEST_P(OutputStreamTest, GetPresentationPositionStop) { - doc::test( - "If supported, a stream should always succeed to retrieve the " - "presentation position"); - uint64_t frames; - TimeSpec mesureTS; - ASSERT_OK(stream->getPresentationPosition(returnIn(res, frames, mesureTS))); - if (res == Result::NOT_SUPPORTED) { - doc::partialTest("getpresentationPosition is not supported"); - return; - } - ASSERT_EQ(0U, frames); - - if (mesureTS.tvNSec == 0 && mesureTS.tvSec == 0) { - // As the stream has never written a frame yet, - // the timestamp does not really have a meaning, allow to return 0 - return; - } - - // Make sure the return measure is not more than 1s old. - struct timespec currentTS; - ASSERT_EQ(0, clock_gettime(CLOCK_MONOTONIC, ¤tTS)) << errno; - - auto toMicroSec = [](uint64_t sec, auto nsec) { return sec * 1e+6 + nsec / 1e+3; }; - auto currentTime = toMicroSec(currentTS.tv_sec, currentTS.tv_nsec); - auto mesureTime = toMicroSec(mesureTS.tvSec, mesureTS.tvNSec); - ASSERT_PRED2([](auto c, auto m) { return c - m < 1e+6; }, currentTime, mesureTime); -} - -////////////////////////////////////////////////////////////////////////////// -/////////////////////////////// PrimaryDevice //////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -TEST_F(AudioPrimaryHidlTest, setVoiceVolume) { - doc::test("Make sure setVoiceVolume only succeed if volume is in [0,1]"); - testUnitaryGain([](float volume) { return device->setVoiceVolume(volume); }); -} - -TEST_F(AudioPrimaryHidlTest, setMode) { - doc::test( - "Make sure setMode always succeeds if mode is valid " - "and fails otherwise"); - // Test Invalid values - for (AudioMode mode : {AudioMode::INVALID, AudioMode::CURRENT, AudioMode::CNT}) { - SCOPED_TRACE("mode=" + toString(mode)); - ASSERT_RESULT(Result::INVALID_ARGUMENTS, device->setMode(mode)); - } - // Test valid values - for (AudioMode mode : {AudioMode::IN_CALL, AudioMode::IN_COMMUNICATION, AudioMode::RINGTONE, - AudioMode::NORMAL /* Make sure to leave the test in normal mode */}) { - SCOPED_TRACE("mode=" + toString(mode)); - ASSERT_OK(device->setMode(mode)); - } -} - -TEST_F(BoolAccessorPrimaryHidlTest, BtScoNrecEnabled) { - doc::test("Query and set the BT SCO NR&EC state"); - testOptionalAccessors("BtScoNrecEnabled", {true, false, true}, - &IPrimaryDevice::setBtScoNrecEnabled, - &IPrimaryDevice::getBtScoNrecEnabled); -} - -TEST_F(BoolAccessorPrimaryHidlTest, setGetBtScoWidebandEnabled) { - doc::test("Query and set the SCO whideband state"); - testOptionalAccessors("BtScoWideband", {true, false, true}, - &IPrimaryDevice::setBtScoWidebandEnabled, - &IPrimaryDevice::getBtScoWidebandEnabled); -} - -using TtyModeAccessorPrimaryHidlTest = AccessorPrimaryHidlTest<TtyMode>; -TEST_F(TtyModeAccessorPrimaryHidlTest, setGetTtyMode) { - doc::test("Query and set the TTY mode state"); - testOptionalAccessors("TTY mode", {TtyMode::OFF, TtyMode::HCO, TtyMode::VCO, TtyMode::FULL}, - &IPrimaryDevice::setTtyMode, &IPrimaryDevice::getTtyMode); -} - -TEST_F(BoolAccessorPrimaryHidlTest, setGetHac) { - doc::test("Query and set the HAC state"); - testOptionalAccessors("HAC", {true, false, true}, &IPrimaryDevice::setHacEnabled, - &IPrimaryDevice::getHacEnabled); -} - -////////////////////////////////////////////////////////////////////////////// -//////////////////// Clean caches on global tear down //////////////////////// -////////////////////////////////////////////////////////////////////////////// - -int main(int argc, char** argv) { - environment = new AudioHidlTestEnvironment; - ::testing::AddGlobalTestEnvironment(environment); - ::testing::InitGoogleTest(&argc, argv); - environment->init(&argc, argv); - int status = RUN_ALL_TESTS(); - return status; -} diff --git a/audio/core/2.0/vts/functional/ValidateAudioConfiguration.cpp b/audio/core/2.0/vts/functional/ValidateAudioConfiguration.cpp deleted file mode 100644 index bef0e8276c..0000000000 --- a/audio/core/2.0/vts/functional/ValidateAudioConfiguration.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2017 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 <unistd.h> -#include <string> - -#include "utility/ValidateXml.h" - -TEST(CheckConfig, audioPolicyConfigurationValidation) { - RecordProperty("description", - "Verify that the audio policy configuration file " - "is valid according to the schema"); - - std::vector<const char*> locations = {"/odm/etc", "/vendor/etc", "/system/etc"}; - EXPECT_ONE_VALID_XML_MULTIPLE_LOCATIONS("audio_policy_configuration.xml", locations, - "/data/local/tmp/audio_policy_configuration.xsd"); -} diff --git a/audio/core/4.0/default/Android.bp b/audio/core/4.0/default/Android.bp deleted file mode 100644 index 8e415459be..0000000000 --- a/audio/core/4.0/default/Android.bp +++ /dev/null @@ -1,53 +0,0 @@ -cc_library_shared { - name: "android.hardware.audio@4.0-impl", - relative_install_path: "hw", - proprietary: true, - vendor: true, - srcs: [ - "Conversions.cpp", - "Device.cpp", - "DevicesFactory.cpp", - "ParametersUtil.cpp", - "PrimaryDevice.cpp", - "Stream.cpp", - "StreamIn.cpp", - "StreamOut.cpp", - ], - - cflags: [ - "-DAUDIO_HAL_VERSION_4_0", - ], - - defaults: ["hidl_defaults"], - - export_include_dirs: ["include"], - - shared_libs: [ - "libbase", - "libcutils", - "libfmq", - "libhardware", - "libhidlbase", - "libhidltransport", - "liblog", - "libutils", - "android.hardware.audio@4.0", - "android.hardware.audio.common@4.0", - "android.hardware.audio.common@4.0-util", - "android.hardware.audio.common-util", - ], - - header_libs: [ - "android.hardware.audio.common.util@all-versions", - "android.hardware.audio.core@all-versions-impl", - "libaudioclient_headers", - "libaudio_system_headers", - "libhardware_headers", - "libmedia_headers", - ], - - whole_static_libs: [ - "libmedia_helper", - ], - -} diff --git a/audio/core/4.0/default/Conversions.cpp b/audio/core/4.0/default/Conversions.cpp deleted file mode 100644 index 4f1874412c..0000000000 --- a/audio/core/4.0/default/Conversions.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2017 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/4.0/default/Conversions.h" - -#define AUDIO_HAL_VERSION V4_0 -#include <core/all-versions/default/Conversions.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/core/4.0/default/Device.cpp b/audio/core/4.0/default/Device.cpp deleted file mode 100644 index b33434ecfb..0000000000 --- a/audio/core/4.0/default/Device.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2017 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 "DeviceHAL" - -#include "core/4.0/default/Device.h" -#include <HidlUtils.h> -#include "core/4.0/default/Conversions.h" -#include "core/4.0/default/StreamIn.h" -#include "core/4.0/default/StreamOut.h" -#include "core/4.0/default/Util.h" - -#define AUDIO_HAL_VERSION V4_0 -#include <core/all-versions/default/Device.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/core/4.0/default/DevicesFactory.cpp b/audio/core/4.0/default/DevicesFactory.cpp deleted file mode 100644 index cb8a3c3e97..0000000000 --- a/audio/core/4.0/default/DevicesFactory.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2017 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 "DevicesFactoryHAL" - -#include "core/4.0/default/DevicesFactory.h" -#include "core/4.0/default/Device.h" -#include "core/4.0/default/PrimaryDevice.h" - -#define AUDIO_HAL_VERSION V4_0 -#include <core/all-versions/default/DevicesFactory.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/core/4.0/default/OWNERS b/audio/core/4.0/default/OWNERS deleted file mode 100644 index 6fdc97ca29..0000000000 --- a/audio/core/4.0/default/OWNERS +++ /dev/null @@ -1,3 +0,0 @@ -elaurent@google.com -krocard@google.com -mnaganov@google.com diff --git a/audio/core/4.0/default/ParametersUtil.cpp b/audio/core/4.0/default/ParametersUtil.cpp deleted file mode 100644 index 2cc9fb56a3..0000000000 --- a/audio/core/4.0/default/ParametersUtil.cpp +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (C) 2017 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/4.0/default/ParametersUtil.h" -#include "core/4.0/default/Util.h" - -#define AUDIO_HAL_VERSION V4_0 -#include <core/all-versions/default/ParametersUtil.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/core/4.0/default/PrimaryDevice.cpp b/audio/core/4.0/default/PrimaryDevice.cpp deleted file mode 100644 index e3e49768d5..0000000000 --- a/audio/core/4.0/default/PrimaryDevice.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2017 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 "PrimaryDeviceHAL" - -#include "core/4.0/default/PrimaryDevice.h" -#include "core/4.0/default/Util.h" - -#define AUDIO_HAL_VERSION V4_0 -#include <core/all-versions/default/PrimaryDevice.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/core/4.0/default/Stream.cpp b/audio/core/4.0/default/Stream.cpp deleted file mode 100644 index b8c71de7b7..0000000000 --- a/audio/core/4.0/default/Stream.cpp +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2017 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 "StreamHAL" - -#include "core/4.0/default/Stream.h" -#include "common/all-versions/default/EffectMap.h" -#include "core/4.0/default/Conversions.h" -#include "core/4.0/default/Util.h" - -#define AUDIO_HAL_VERSION V4_0 -#include <core/all-versions/default/Stream.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/core/4.0/default/StreamIn.cpp b/audio/core/4.0/default/StreamIn.cpp deleted file mode 100644 index 718bd25a63..0000000000 --- a/audio/core/4.0/default/StreamIn.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2017 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 "StreamInHAL" - -#include "core/4.0/default/StreamIn.h" -#include "core/4.0/default/Util.h" - -#define AUDIO_HAL_VERSION V4_0 -#include <core/all-versions/default/StreamIn.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/core/4.0/default/StreamOut.cpp b/audio/core/4.0/default/StreamOut.cpp deleted file mode 100644 index db88e401d2..0000000000 --- a/audio/core/4.0/default/StreamOut.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2017 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 "StreamOutHAL" - -#include "core/4.0/default/StreamOut.h" -#include "core/4.0/default/Util.h" - -#define AUDIO_HAL_VERSION V4_0 -#include <core/all-versions/default/StreamOut.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/core/4.0/default/include/core/4.0/default/Conversions.h b/audio/core/4.0/default/include/core/4.0/default/Conversions.h deleted file mode 100644 index 32c2f887ee..0000000000 --- a/audio/core/4.0/default/include/core/4.0/default/Conversions.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_V4_0_CONVERSIONS_H_ -#define ANDROID_HARDWARE_AUDIO_V4_0_CONVERSIONS_H_ - -#include <android/hardware/audio/4.0/types.h> - -#define AUDIO_HAL_VERSION V4_0 -#include <core/all-versions/default/Conversions.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_V4_0_CONVERSIONS_H_ diff --git a/audio/core/4.0/default/include/core/4.0/default/Device.h b/audio/core/4.0/default/include/core/4.0/default/Device.h deleted file mode 100644 index 770d606720..0000000000 --- a/audio/core/4.0/default/include/core/4.0/default/Device.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_V4_0_DEVICE_H -#define ANDROID_HARDWARE_AUDIO_V4_0_DEVICE_H - -#include <android/hardware/audio/4.0/IDevice.h> - -#include "ParametersUtil.h" - -#define AUDIO_HAL_VERSION V4_0 -#include <core/all-versions/default/Device.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_V4_0_DEVICE_H diff --git a/audio/core/4.0/default/include/core/4.0/default/DevicesFactory.h b/audio/core/4.0/default/include/core/4.0/default/DevicesFactory.h deleted file mode 100644 index 200e59d96f..0000000000 --- a/audio/core/4.0/default/include/core/4.0/default/DevicesFactory.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_V4_0_DEVICESFACTORY_H -#define ANDROID_HARDWARE_AUDIO_V4_0_DEVICESFACTORY_H - -#include <android/hardware/audio/4.0/IDevicesFactory.h> - -#define AUDIO_HAL_VERSION V4_0 -#include <core/all-versions/default/DevicesFactory.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_V4_0_DEVICESFACTORY_H diff --git a/audio/core/4.0/default/include/core/4.0/default/ParametersUtil.h b/audio/core/4.0/default/include/core/4.0/default/ParametersUtil.h deleted file mode 100644 index fa31ee9dd3..0000000000 --- a/audio/core/4.0/default/include/core/4.0/default/ParametersUtil.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_V4_0_PARAMETERS_UTIL_H_ -#define ANDROID_HARDWARE_AUDIO_V4_0_PARAMETERS_UTIL_H_ - -#include <android/hardware/audio/4.0/types.h> - -#define AUDIO_HAL_VERSION V4_0 -#include <core/all-versions/default/ParametersUtil.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_V4_0_PARAMETERS_UTIL_H_ diff --git a/audio/core/4.0/default/include/core/4.0/default/PrimaryDevice.h b/audio/core/4.0/default/include/core/4.0/default/PrimaryDevice.h deleted file mode 100644 index e7f846b622..0000000000 --- a/audio/core/4.0/default/include/core/4.0/default/PrimaryDevice.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_V4_0_PRIMARYDEVICE_H -#define ANDROID_HARDWARE_AUDIO_V4_0_PRIMARYDEVICE_H - -#include <android/hardware/audio/4.0/IPrimaryDevice.h> - -#include "Device.h" - -#define AUDIO_HAL_VERSION V4_0 -#include <core/all-versions/default/PrimaryDevice.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_V4_0_PRIMARYDEVICE_H diff --git a/audio/core/4.0/default/include/core/4.0/default/Stream.h b/audio/core/4.0/default/include/core/4.0/default/Stream.h deleted file mode 100644 index afad80fe53..0000000000 --- a/audio/core/4.0/default/include/core/4.0/default/Stream.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_V4_0_STREAM_H -#define ANDROID_HARDWARE_AUDIO_V4_0_STREAM_H - -#include <android/hardware/audio/4.0/IStream.h> - -#include "ParametersUtil.h" - -#define AUDIO_HAL_VERSION V4_0 -#include <core/all-versions/default/Stream.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_V4_0_STREAM_H diff --git a/audio/core/4.0/default/include/core/4.0/default/StreamIn.h b/audio/core/4.0/default/include/core/4.0/default/StreamIn.h deleted file mode 100644 index 151f03fc2b..0000000000 --- a/audio/core/4.0/default/include/core/4.0/default/StreamIn.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_V4_0_STREAMIN_H -#define ANDROID_HARDWARE_AUDIO_V4_0_STREAMIN_H - -#include <android/hardware/audio/4.0/IStreamIn.h> - -#include "Device.h" -#include "Stream.h" - -#define AUDIO_HAL_VERSION V4_0 -#include <core/all-versions/default/StreamIn.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_V4_0_STREAMIN_H diff --git a/audio/core/4.0/default/include/core/4.0/default/StreamOut.h b/audio/core/4.0/default/include/core/4.0/default/StreamOut.h deleted file mode 100644 index dbf3bd16ce..0000000000 --- a/audio/core/4.0/default/include/core/4.0/default/StreamOut.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_V4_0_STREAMOUT_H -#define ANDROID_HARDWARE_AUDIO_V4_0_STREAMOUT_H - -#include <android/hardware/audio/4.0/IStreamOut.h> - -#include "Device.h" -#include "Stream.h" - -#define AUDIO_HAL_VERSION V4_0 -#include <core/all-versions/default/StreamOut.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_V4_0_STREAMOUT_H diff --git a/audio/core/4.0/default/include/core/4.0/default/Util.h b/audio/core/4.0/default/include/core/4.0/default/Util.h deleted file mode 100644 index ce31e6f7f2..0000000000 --- a/audio/core/4.0/default/include/core/4.0/default/Util.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2018 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_V4_0_UTIL_H -#define ANDROID_HARDWARE_AUDIO_V4_0_UTIL_H - -#include <android/hardware/audio/4.0/types.h> - -#define AUDIO_HAL_VERSION V4_0 -#include <core/all-versions/default/Util.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_V4_0_UTIL_H diff --git a/audio/core/4.0/vts/functional/Android.bp b/audio/core/4.0/vts/functional/Android.bp deleted file mode 100644 index e3b376ca88..0000000000 --- a/audio/core/4.0/vts/functional/Android.bp +++ /dev/null @@ -1,38 +0,0 @@ -// -// Copyright (C) 2017 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. -// - -cc_test { - name: "VtsHalAudioV4_0TargetTest", - defaults: ["VtsHalTargetTestDefaults"], - srcs: [ - "AudioPrimaryHidlHalTest.cpp", - "ValidateAudioConfiguration.cpp" - ], - static_libs: [ - "android.hardware.audio.common.test.utility", - "android.hardware.audio@4.0", - "android.hardware.audio.common@4.0", - "libicuuc", - "libicuuc_stubdata", - "libxml2", - ], - shared_libs: [ - "libfmq", - ], - header_libs: [ - "android.hardware.audio.common.util@all-versions", - ], -} diff --git a/audio/core/4.0/vts/functional/ValidateAudioConfiguration.cpp b/audio/core/4.0/vts/functional/ValidateAudioConfiguration.cpp deleted file mode 100644 index a64513fc81..0000000000 --- a/audio/core/4.0/vts/functional/ValidateAudioConfiguration.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2017 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 <unistd.h> -#include <string> - -#include "utility/ValidateXml.h" - -TEST(CheckConfig, audioPolicyConfigurationValidation) { - RecordProperty("description", - "Verify that the audio policy configuration file " - "is valid according to the schema"); - - std::vector<const char*> locations = {"/odm/etc", "/vendor/etc", "/system/etc"}; - EXPECT_ONE_VALID_XML_MULTIPLE_LOCATIONS("audio_policy_configuration.xml", locations, - "/data/local/tmp/audio_policy_configuration_V4_0.xsd"); -} diff --git a/audio/core/all-versions/OWNERS b/audio/core/all-versions/OWNERS deleted file mode 100644 index 6fdc97ca29..0000000000 --- a/audio/core/all-versions/OWNERS +++ /dev/null @@ -1,3 +0,0 @@ -elaurent@google.com -krocard@google.com -mnaganov@google.com diff --git a/audio/core/all-versions/default/Android.bp b/audio/core/all-versions/default/Android.bp index bb02863ba6..a1af3c4db5 100644 --- a/audio/core/all-versions/default/Android.bp +++ b/audio/core/all-versions/default/Android.bp @@ -1,7 +1,18 @@ -cc_library_headers { - name: "android.hardware.audio.core@all-versions-impl", +cc_defaults { + name: "android.hardware.audio-impl_default", relative_install_path: "hw", + proprietary: true, vendor: true, + srcs: [ + "Conversions.cpp", + "Device.cpp", + "DevicesFactory.cpp", + "ParametersUtil.cpp", + "PrimaryDevice.cpp", + "Stream.cpp", + "StreamIn.cpp", + "StreamOut.cpp", + ], defaults: ["hidl_defaults"], @@ -20,10 +31,65 @@ cc_library_headers { ], header_libs: [ + "android.hardware.audio.common.util@all-versions", "libaudioclient_headers", "libaudio_system_headers", "libhardware_headers", "libmedia_headers", - "android.hardware.audio.common.util@all-versions", ], + + whole_static_libs: [ + "libmedia_helper", + ], +} + +cc_library_shared { + name: "android.hardware.audio@2.0-impl", + defaults: ["android.hardware.audio-impl_default"], + + shared_libs: [ + "android.hardware.audio@2.0", + "android.hardware.audio.common@2.0", + "android.hardware.audio.common@2.0-util", + ], + + cflags: [ + "-DMAJOR_VERSION=2", + "-DMINOR_VERSION=0", + "-include common/all-versions/VersionMacro.h", + ] +} + +cc_library_shared { + name: "android.hardware.audio@4.0-impl", + defaults: ["android.hardware.audio-impl_default"], + + shared_libs: [ + "android.hardware.audio@4.0", + "android.hardware.audio.common@4.0", + "android.hardware.audio.common@4.0-util", + ], + + cflags: [ + "-DMAJOR_VERSION=4", + "-DMINOR_VERSION=0", + "-include common/all-versions/VersionMacro.h", + ] +} + +cc_library_shared { + name: "android.hardware.audio@5.0-impl", + defaults: ["android.hardware.audio-impl_default"], + + shared_libs: [ + "android.hardware.audio@5.0", + "android.hardware.audio.common@5.0", + "android.hardware.audio.common@5.0-util", + ], + + cflags: [ + "-DMAJOR_VERSION=5", + "-DMINOR_VERSION=0", + "-include common/all-versions/VersionMacro.h", + ] } diff --git a/audio/core/all-versions/default/include/core/all-versions/default/Conversions.impl.h b/audio/core/all-versions/default/Conversions.cpp index 5828c3f373..b1e6c603b3 100644 --- a/audio/core/all-versions/default/include/core/all-versions/default/Conversions.impl.h +++ b/audio/core/all-versions/default/Conversions.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#include "core/default/Conversions.h" #include <stdio.h> @@ -23,10 +23,10 @@ namespace android { namespace hardware { namespace audio { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioDevice; +using ::android::hardware::audio::common::CPP_VERSION::AudioDevice; std::string deviceAddressToHal(const DeviceAddress& address) { // HAL assumes that the address is NUL-terminated. @@ -58,7 +58,7 @@ std::string deviceAddressToHal(const DeviceAddress& address) { return halAddress; } -#ifdef AUDIO_HAL_VERSION_4_0 +#if MAJOR_VERSION >= 4 status_t deviceAddressFromHal(audio_devices_t device, const char* halAddress, DeviceAddress* address) { if (address == nullptr) { @@ -188,7 +188,7 @@ bool halToMicrophoneCharacteristics(MicrophoneInfo* pDst, #endif } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace audio } // namespace hardware } // namespace android diff --git a/audio/core/all-versions/default/include/core/all-versions/default/Device.impl.h b/audio/core/all-versions/default/Device.cpp index 230b8de243..6a04903a16 100644 --- a/audio/core/all-versions/default/include/core/all-versions/default/Device.impl.h +++ b/audio/core/all-versions/default/Device.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,14 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#define LOG_TAG "DeviceHAL" + +#include "core/default/Device.h" +#include <HidlUtils.h> +#include "core/default/Conversions.h" +#include "core/default/StreamIn.h" +#include "core/default/StreamOut.h" +#include "core/default/Util.h" //#define LOG_NDEBUG 0 @@ -24,12 +31,12 @@ #include <android/log.h> -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::HidlUtils; +using ::android::hardware::audio::common::CPP_VERSION::HidlUtils; namespace android { namespace hardware { namespace audio { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { Device::Device(audio_hw_device_t* device) : mDevice(device) {} @@ -40,8 +47,9 @@ Device::~Device() { mDevice = nullptr; } -Result Device::analyzeStatus(const char* funcName, int status) { - return util::analyzeStatus("Device", funcName, status); +Result Device::analyzeStatus(const char* funcName, int status, + const std::vector<int>& ignoreErrors) { + return util::analyzeStatus("Device", funcName, status, ignoreErrors); } void Device::closeInputStream(audio_stream_in_t* stream) { @@ -60,7 +68,7 @@ int Device::halSetParameters(const char* keysAndValues) { return mDevice->set_parameters(mDevice, keysAndValues); } -// Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IDevice follow. +// Methods from ::android::hardware::audio::CPP_VERSION::IDevice follow. Return<Result> Device::initCheck() { return analyzeStatus("init_check", mDevice->init_check(mDevice)); } @@ -131,7 +139,7 @@ Return<void> Device::getInputBufferSize(const AudioConfig& config, getInputBuffe Return<void> Device::openOutputStream(int32_t ioHandle, const DeviceAddress& device, const AudioConfig& config, AudioOutputFlagBitfield flags, -#ifdef AUDIO_HAL_VERSION_4_0 +#if MAJOR_VERSION >= 4 const SourceMetadata& /* sourceMetadata */, #endif openOutputStream_cb _hidl_cb) { @@ -155,7 +163,8 @@ Return<void> Device::openOutputStream(int32_t ioHandle, const DeviceAddress& dev } AudioConfig suggestedConfig; HidlUtils::audioConfigFromHal(halConfig, &suggestedConfig); - _hidl_cb(analyzeStatus("open_output_stream", status), streamOut, suggestedConfig); + _hidl_cb(analyzeStatus("open_output_stream", status, {EINVAL} /* ignore */), streamOut, + suggestedConfig); return Void(); } @@ -183,11 +192,12 @@ Return<void> Device::openInputStream(int32_t ioHandle, const DeviceAddress& devi } AudioConfig suggestedConfig; HidlUtils::audioConfigFromHal(halConfig, &suggestedConfig); - _hidl_cb(analyzeStatus("open_input_stream", status), streamIn, suggestedConfig); + _hidl_cb(analyzeStatus("open_input_stream", status, {EINVAL} /* ignore */), streamIn, + suggestedConfig); return Void(); } -#ifdef AUDIO_HAL_VERSION_4_0 +#if MAJOR_VERSION >= 4 Return<void> Device::openInputStream(int32_t ioHandle, const DeviceAddress& device, const AudioConfig& config, AudioInputFlagBitfield flags, const SinkMetadata& sinkMetadata, @@ -260,13 +270,13 @@ Return<Result> Device::setAudioPortConfig(const AudioPortConfig& config) { return Result::NOT_SUPPORTED; } -#ifdef AUDIO_HAL_VERSION_2_0 +#if MAJOR_VERSION == 2 Return<AudioHwSync> Device::getHwAvSync() { int halHwAvSync; Result retval = getParam(AudioParameter::keyHwAvSync, &halHwAvSync); return retval == Result::OK ? halHwAvSync : AUDIO_HW_SYNC_INVALID; } -#elif defined(AUDIO_HAL_VERSION_4_0) +#elif MAJOR_VERSION >= 4 Return<void> Device::getHwAvSync(getHwAvSync_cb _hidl_cb) { int halHwAvSync; Result retval = getParam(AudioParameter::keyHwAvSync, &halHwAvSync); @@ -279,7 +289,7 @@ Return<Result> Device::setScreenState(bool turnedOn) { return setParam(AudioParameter::keyScreenState, turnedOn); } -#ifdef AUDIO_HAL_VERSION_2_0 +#if MAJOR_VERSION == 2 Return<void> Device::getParameters(const hidl_vec<hidl_string>& keys, getParameters_cb _hidl_cb) { getParametersImpl({}, keys, _hidl_cb); return Void(); @@ -288,7 +298,7 @@ Return<void> Device::getParameters(const hidl_vec<hidl_string>& keys, getParamet Return<Result> Device::setParameters(const hidl_vec<ParameterValue>& parameters) { return setParametersImpl({} /* context */, parameters); } -#elif defined(AUDIO_HAL_VERSION_4_0) +#elif MAJOR_VERSION >= 4 Return<void> Device::getParameters(const hidl_vec<ParameterValue>& context, const hidl_vec<hidl_string>& keys, getParameters_cb _hidl_cb) { getParametersImpl(context, keys, _hidl_cb); @@ -300,7 +310,7 @@ Return<Result> Device::setParameters(const hidl_vec<ParameterValue>& context, } #endif -#ifdef AUDIO_HAL_VERSION_2_0 +#if MAJOR_VERSION == 2 Return<void> Device::debugDump(const hidl_handle& fd) { return debug(fd, {}); } @@ -313,7 +323,7 @@ Return<void> Device::debug(const hidl_handle& fd, const hidl_vec<hidl_string>& / return Void(); } -#ifdef AUDIO_HAL_VERSION_4_0 +#if MAJOR_VERSION >= 4 Return<void> Device::getMicrophones(getMicrophones_cb _hidl_cb) { Result retval = Result::NOT_SUPPORTED; size_t actual_mics = AUDIO_MICROPHONE_MAX_COUNT; @@ -339,7 +349,7 @@ Return<Result> Device::setConnectedState(const DeviceAddress& address, bool conn #endif } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace audio } // namespace hardware } // namespace android diff --git a/audio/core/all-versions/default/include/core/all-versions/default/DevicesFactory.impl.h b/audio/core/all-versions/default/DevicesFactory.cpp index 43e5d6eaed..729f18cf91 100644 --- a/audio/core/all-versions/default/include/core/all-versions/default/DevicesFactory.impl.h +++ b/audio/core/all-versions/default/DevicesFactory.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,11 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#define LOG_TAG "DevicesFactoryHAL" + +#include "core/default/DevicesFactory.h" +#include "core/default/Device.h" +#include "core/default/PrimaryDevice.h" #include <string.h> @@ -23,10 +27,10 @@ namespace android { namespace hardware { namespace audio { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { -#ifdef AUDIO_HAL_VERSION_2_0 +#if MAJOR_VERSION == 2 Return<void> DevicesFactory::openDevice(IDevicesFactory::Device device, openDevice_cb _hidl_cb) { switch (device) { case IDevicesFactory::Device::PRIMARY: @@ -43,8 +47,7 @@ Return<void> DevicesFactory::openDevice(IDevicesFactory::Device device, openDevi _hidl_cb(Result::INVALID_ARGUMENTS, nullptr); return Void(); } -#endif -#ifdef AUDIO_HAL_VERSION_4_0 +#elif MAJOR_VERSION >= 4 Return<void> DevicesFactory::openDevice(const hidl_string& moduleName, openDevice_cb _hidl_cb) { if (moduleName == AUDIO_HARDWARE_MODULE_ID_PRIMARY) { return openDevice<PrimaryDevice>(moduleName.c_str(), _hidl_cb); @@ -106,12 +109,12 @@ out: return rc; } -IDevicesFactory* HIDL_FETCH_IDevicesFactory(const char* /* name */) { - return new DevicesFactory(); +IDevicesFactory* HIDL_FETCH_IDevicesFactory(const char* name) { + return strcmp(name, "default") == 0 ? new DevicesFactory() : nullptr; } } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace audio } // namespace hardware } // namespace android diff --git a/audio/common/4.0/default/OWNERS b/audio/core/all-versions/default/OWNERS index 6fdc97ca29..6fdc97ca29 100644 --- a/audio/common/4.0/default/OWNERS +++ b/audio/core/all-versions/default/OWNERS diff --git a/audio/core/all-versions/default/include/core/all-versions/default/ParametersUtil.impl.h b/audio/core/all-versions/default/ParametersUtil.cpp index 34bc53c7a7..0c8e28af8b 100644 --- a/audio/core/all-versions/default/include/core/all-versions/default/ParametersUtil.impl.h +++ b/audio/core/all-versions/default/ParametersUtil.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,14 +14,16 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> -#include <core/all-versions/default/Conversions.h> +#include "core/default/ParametersUtil.h" +#include "core/default/Conversions.h" +#include "core/default/Util.h" + #include <system/audio.h> namespace android { namespace hardware { namespace audio { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { /** Converts a status_t in Result according to the rules of AudioParameter::get* @@ -159,7 +161,7 @@ Result ParametersUtil::setParams(const AudioParameter& param) { } } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace audio } // namespace hardware } // namespace android diff --git a/audio/core/all-versions/default/include/core/all-versions/default/PrimaryDevice.impl.h b/audio/core/all-versions/default/PrimaryDevice.cpp index f269dd4f91..99590b0bdc 100644 --- a/audio/core/all-versions/default/include/core/all-versions/default/PrimaryDevice.impl.h +++ b/audio/core/all-versions/default/PrimaryDevice.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,23 +14,26 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#define LOG_TAG "PrimaryDeviceHAL" -#ifdef AUDIO_HAL_VERSION_4_0 +#include "core/default/PrimaryDevice.h" +#include "core/default/Util.h" + +#if MAJOR_VERSION >= 4 #include <cmath> #endif namespace android { namespace hardware { namespace audio { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { PrimaryDevice::PrimaryDevice(audio_hw_device_t* device) : mDevice(new Device(device)) {} PrimaryDevice::~PrimaryDevice() {} -// Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IDevice follow. +// Methods from ::android::hardware::audio::CPP_VERSION::IDevice follow. Return<Result> PrimaryDevice::initCheck() { return mDevice->initCheck(); } @@ -64,7 +67,7 @@ Return<void> PrimaryDevice::getInputBufferSize(const AudioConfig& config, return mDevice->getInputBufferSize(config, _hidl_cb); } -#ifdef AUDIO_HAL_VERSION_2_0 +#if MAJOR_VERSION == 2 Return<void> PrimaryDevice::openOutputStream(int32_t ioHandle, const DeviceAddress& device, const AudioConfig& config, AudioOutputFlagBitfield flags, @@ -77,7 +80,7 @@ Return<void> PrimaryDevice::openInputStream(int32_t ioHandle, const DeviceAddres AudioSource source, openInputStream_cb _hidl_cb) { return mDevice->openInputStream(ioHandle, device, config, flags, source, _hidl_cb); } -#elif defined(AUDIO_HAL_VERSION_4_0) +#elif MAJOR_VERSION >= 4 Return<void> PrimaryDevice::openOutputStream(int32_t ioHandle, const DeviceAddress& device, const AudioConfig& config, AudioOutputFlagBitfield flags, @@ -120,7 +123,7 @@ Return<Result> PrimaryDevice::setScreenState(bool turnedOn) { return mDevice->setScreenState(turnedOn); } -#ifdef AUDIO_HAL_VERSION_2_0 +#if MAJOR_VERSION == 2 Return<AudioHwSync> PrimaryDevice::getHwAvSync() { return mDevice->getHwAvSync(); } @@ -137,7 +140,7 @@ Return<Result> PrimaryDevice::setParameters(const hidl_vec<ParameterValue>& para Return<void> PrimaryDevice::debugDump(const hidl_handle& fd) { return mDevice->debugDump(fd); } -#elif defined(AUDIO_HAL_VERSION_4_0) +#elif MAJOR_VERSION >= 4 Return<void> PrimaryDevice::getHwAvSync(getHwAvSync_cb _hidl_cb) { return mDevice->getHwAvSync(_hidl_cb); } @@ -158,7 +161,7 @@ Return<Result> PrimaryDevice::setConnectedState(const DeviceAddress& address, bo } #endif -// Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IPrimaryDevice follow. +// Methods from ::android::hardware::audio::CPP_VERSION::IPrimaryDevice follow. Return<Result> PrimaryDevice::setVoiceVolume(float volume) { if (!isGainNormalized(volume)) { ALOGW("Can not set a voice volume (%f) outside [0,1]", volume); @@ -271,7 +274,7 @@ Return<Result> PrimaryDevice::setHacEnabled(bool enabled) { return mDevice->setParam(AUDIO_PARAMETER_KEY_HAC, enabled); } -#ifdef AUDIO_HAL_VERSION_4_0 +#if MAJOR_VERSION >= 4 Return<Result> PrimaryDevice::setBtScoHeadsetDebugName(const hidl_string& name) { return mDevice->setParam(AUDIO_PARAMETER_KEY_BT_SCO_HEADSET_NAME, name.c_str()); } @@ -307,7 +310,7 @@ Return<void> PrimaryDevice::debug(const hidl_handle& fd, const hidl_vec<hidl_str } } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace audio } // namespace hardware } // namespace android diff --git a/audio/core/all-versions/default/include/core/all-versions/default/Stream.impl.h b/audio/core/all-versions/default/Stream.cpp index 72d7a3760a..b995657087 100644 --- a/audio/core/all-versions/default/include/core/all-versions/default/Stream.impl.h +++ b/audio/core/all-versions/default/Stream.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,12 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#define LOG_TAG "StreamHAL" + +#include "core/default/Stream.h" +#include "common/all-versions/default/EffectMap.h" +#include "core/default/Conversions.h" +#include "core/default/Util.h" #include <inttypes.h> @@ -28,7 +33,7 @@ namespace android { namespace hardware { namespace audio { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { Stream::Stream(audio_stream_t* stream) : mStream(stream) {} @@ -42,7 +47,6 @@ Result Stream::analyzeStatus(const char* funcName, int status) { return util::analyzeStatus("stream", funcName, status); } - // static Result Stream::analyzeStatus(const char* funcName, int status, const std::vector<int>& ignoreErrors) { @@ -57,7 +61,7 @@ int Stream::halSetParameters(const char* keysAndValues) { return mStream->set_parameters(mStream, keysAndValues); } -// Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IStream follow. +// Methods from ::android::hardware::audio::CPP_VERSION::IStream follow. Return<uint64_t> Stream::getFrameSize() { // Needs to be implemented by interface subclasses. But can't be declared as pure virtual, // since interface subclasses implementation do not inherit from this class. @@ -79,7 +83,7 @@ Return<uint32_t> Stream::getSampleRate() { return mStream->get_sample_rate(mStream); } -#ifdef AUDIO_HAL_VERSION_2_0 +#if MAJOR_VERSION == 2 Return<void> Stream::getSupportedSampleRates(getSupportedSampleRates_cb _hidl_cb) { return getSupportedSampleRates(getFormat(), _hidl_cb); } @@ -107,9 +111,9 @@ Return<void> Stream::getSupportedSampleRates(AudioFormat format, result = Result::NOT_SUPPORTED; } } -#ifdef AUDIO_HAL_VERSION_2_0 +#if MAJOR_VERSION == 2 _hidl_cb(sampleRates); -#elif AUDIO_HAL_VERSION_4_0 +#elif MAJOR_VERSION >= 4 _hidl_cb(result, sampleRates); #endif return Void(); @@ -136,9 +140,9 @@ Return<void> Stream::getSupportedChannelMasks(AudioFormat format, result = Result::NOT_SUPPORTED; } } -#ifdef AUDIO_HAL_VERSION_2_0 +#if MAJOR_VERSION == 2 _hidl_cb(channelMasks); -#elif defined(AUDIO_HAL_VERSION_4_0) +#elif MAJOR_VERSION >= 4 _hidl_cb(result, channelMasks); #endif return Void(); @@ -217,7 +221,7 @@ Return<Result> Stream::setHwAvSync(uint32_t hwAvSync) { return setParam(AudioParameter::keyStreamHwAvSync, static_cast<int>(hwAvSync)); } -#ifdef AUDIO_HAL_VERSION_2_0 +#if MAJOR_VERSION == 2 Return<AudioDevice> Stream::getDevice() { int device = 0; Result retval = getParam(AudioParameter::keyRouting, &device); @@ -242,7 +246,7 @@ Return<Result> Stream::setConnectedState(const DeviceAddress& address, bool conn connected ? AudioParameter::keyStreamConnect : AudioParameter::keyStreamDisconnect, address); } -#elif defined(AUDIO_HAL_VERSION_4_0) +#elif MAJOR_VERSION >= 4 Return<void> Stream::getDevices(getDevices_cb _hidl_cb) { int device = 0; Result retval = getParam(AudioParameter::keyRouting, &device); @@ -314,14 +318,14 @@ Return<void> Stream::debug(const hidl_handle& fd, const hidl_vec<hidl_string>& / return Void(); } -#ifdef AUDIO_HAL_VERSION_2_0 +#if MAJOR_VERSION == 2 Return<void> Stream::debugDump(const hidl_handle& fd) { return debug(fd, {} /* options */); } #endif } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace audio } // namespace hardware } // namespace android diff --git a/audio/core/all-versions/default/include/core/all-versions/default/StreamIn.impl.h b/audio/core/all-versions/default/StreamIn.cpp index 64c85ab5fc..8446382977 100644 --- a/audio/core/all-versions/default/include/core/all-versions/default/StreamIn.impl.h +++ b/audio/core/all-versions/default/StreamIn.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,11 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#define LOG_TAG "StreamInHAL" + +#include "core/default/StreamIn.h" +#include "core/default/Conversions.h" +#include "core/default/Util.h" //#define LOG_NDEBUG 0 #define ATRACE_TAG ATRACE_TAG_AUDIO @@ -24,17 +28,15 @@ #include <utils/Trace.h> #include <memory> -using ::android::hardware::audio::AUDIO_HAL_VERSION::MessageQueueFlagBits; -#include "Conversions.h" +using ::android::hardware::audio::common::CPP_VERSION::ThreadInfo; +using ::android::hardware::audio::CPP_VERSION::MessageQueueFlagBits; namespace android { namespace hardware { namespace audio { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::ThreadInfo; - namespace { class ReadThread : public Thread { @@ -162,7 +164,7 @@ StreamIn::~StreamIn() { mStream = nullptr; } -// Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IStream follow. +// Methods from ::android::hardware::audio::CPP_VERSION::IStream follow. Return<uint64_t> StreamIn::getFrameSize() { return audio_stream_in_frame_size(mStream); } @@ -179,7 +181,7 @@ Return<uint32_t> StreamIn::getSampleRate() { return mStreamCommon->getSampleRate(); } -#ifdef AUDIO_HAL_VERSION_2_0 +#if MAJOR_VERSION == 2 Return<void> StreamIn::getSupportedChannelMasks(getSupportedChannelMasks_cb _hidl_cb) { return mStreamCommon->getSupportedChannelMasks(_hidl_cb); } @@ -241,7 +243,7 @@ Return<Result> StreamIn::setHwAvSync(uint32_t hwAvSync) { return mStreamCommon->setHwAvSync(hwAvSync); } -#ifdef AUDIO_HAL_VERSION_2_0 +#if MAJOR_VERSION == 2 Return<Result> StreamIn::setConnectedState(const DeviceAddress& address, bool connected) { return mStreamCommon->setConnectedState(address, connected); } @@ -265,7 +267,7 @@ Return<Result> StreamIn::setParameters(const hidl_vec<ParameterValue>& parameter Return<void> StreamIn::debugDump(const hidl_handle& fd) { return mStreamCommon->debugDump(fd); } -#elif defined(AUDIO_HAL_VERSION_4_0) +#elif MAJOR_VERSION >= 4 Return<void> StreamIn::getDevices(getDevices_cb _hidl_cb) { return mStreamCommon->getDevices(_hidl_cb); } @@ -313,7 +315,7 @@ Return<Result> StreamIn::close() { return Result::OK; } -// Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IStreamIn follow. +// Methods from ::android::hardware::audio::CPP_VERSION::IStreamIn follow. Return<void> StreamIn::getAudioSource(getAudioSource_cb _hidl_cb) { int halSource; Result retval = mStreamCommon->getParam(AudioParameter::keyInputSource, &halSource); @@ -342,7 +344,6 @@ Return<void> StreamIn::prepareForReading(uint32_t frameSize, uint32_t framesCoun auto sendError = [&threadInfo, &_hidl_cb](Result result) { _hidl_cb(result, CommandMQ::Descriptor(), DataMQ::Descriptor(), StatusMQ::Descriptor(), threadInfo); - }; // Create message queues. @@ -448,7 +449,7 @@ Return<void> StreamIn::debug(const hidl_handle& fd, const hidl_vec<hidl_string>& return mStreamCommon->debug(fd, options); } -#ifdef AUDIO_HAL_VERSION_4_0 +#if MAJOR_VERSION >= 4 Return<void> StreamIn::updateSinkMetadata(const SinkMetadata& sinkMetadata) { if (mStream->update_sink_metadata == nullptr) { return Void(); // not supported by the HAL @@ -460,7 +461,8 @@ Return<void> StreamIn::updateSinkMetadata(const SinkMetadata& sinkMetadata) { {.source = static_cast<audio_source_t>(metadata.source), .gain = metadata.gain}); } const sink_metadata_t halMetadata = { - .track_count = halTracks.size(), .tracks = halTracks.data(), + .track_count = halTracks.size(), + .tracks = halTracks.data(), }; mStream->update_sink_metadata(mStream, &halMetadata); return Void(); @@ -487,7 +489,7 @@ Return<void> StreamIn::getActiveMicrophones(getActiveMicrophones_cb _hidl_cb) { #endif } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace audio } // namespace hardware } // namespace android diff --git a/audio/core/all-versions/default/include/core/all-versions/default/StreamOut.impl.h b/audio/core/all-versions/default/StreamOut.cpp index 6fb157f7de..3a75948941 100644 --- a/audio/core/all-versions/default/include/core/all-versions/default/StreamOut.impl.h +++ b/audio/core/all-versions/default/StreamOut.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,10 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#define LOG_TAG "StreamOutHAL" + +#include "core/default/StreamOut.h" +#include "core/default/Util.h" //#define LOG_NDEBUG 0 #define ATRACE_TAG ATRACE_TAG_AUDIO @@ -28,10 +31,10 @@ namespace android { namespace hardware { namespace audio { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::ThreadInfo; +using ::android::hardware::audio::common::CPP_VERSION::ThreadInfo; namespace { @@ -165,7 +168,7 @@ StreamOut::~StreamOut() { mStream = nullptr; } -// Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IStream follow. +// Methods from ::android::hardware::audio::CPP_VERSION::IStream follow. Return<uint64_t> StreamOut::getFrameSize() { return audio_stream_out_frame_size(mStream); } @@ -182,7 +185,7 @@ Return<uint32_t> StreamOut::getSampleRate() { return mStreamCommon->getSampleRate(); } -#ifdef AUDIO_HAL_VERSION_2_0 +#if MAJOR_VERSION == 2 Return<void> StreamOut::getSupportedChannelMasks(getSupportedChannelMasks_cb _hidl_cb) { return mStreamCommon->getSupportedChannelMasks(_hidl_cb); } @@ -244,7 +247,7 @@ Return<Result> StreamOut::setHwAvSync(uint32_t hwAvSync) { return mStreamCommon->setHwAvSync(hwAvSync); } -#ifdef AUDIO_HAL_VERSION_2_0 +#if MAJOR_VERSION == 2 Return<Result> StreamOut::setConnectedState(const DeviceAddress& address, bool connected) { return mStreamCommon->setConnectedState(address, connected); } @@ -269,7 +272,7 @@ Return<Result> StreamOut::setParameters(const hidl_vec<ParameterValue>& paramete Return<void> StreamOut::debugDump(const hidl_handle& fd) { return mStreamCommon->debugDump(fd); } -#elif defined(AUDIO_HAL_VERSION_4_0) +#elif MAJOR_VERSION >= 4 Return<void> StreamOut::getDevices(getDevices_cb _hidl_cb) { return mStreamCommon->getDevices(_hidl_cb); } @@ -301,7 +304,7 @@ Return<Result> StreamOut::close() { return Result::OK; } -// Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IStreamOut follow. +// Methods from ::android::hardware::audio::CPP_VERSION::IStreamOut follow. Return<uint32_t> StreamOut::getLatency() { return mStream->get_latency(mStream); } @@ -326,7 +329,6 @@ Return<void> StreamOut::prepareForWriting(uint32_t frameSize, uint32_t framesCou auto sendError = [&threadInfo, &_hidl_cb](Result result) { _hidl_cb(result, CommandMQ::Descriptor(), DataMQ::Descriptor(), StatusMQ::Descriptor(), threadInfo); - }; // Create message queues. @@ -545,7 +547,7 @@ Return<void> StreamOut::debug(const hidl_handle& fd, const hidl_vec<hidl_string> return mStreamCommon->debug(fd, options); } -#ifdef AUDIO_HAL_VERSION_4_0 +#if MAJOR_VERSION >= 4 Return<void> StreamOut::updateSourceMetadata(const SourceMetadata& sourceMetadata) { if (mStream->update_source_metadata == nullptr) { return Void(); // not supported by the HAL @@ -560,7 +562,8 @@ Return<void> StreamOut::updateSourceMetadata(const SourceMetadata& sourceMetadat }); } const source_metadata_t halMetadata = { - .track_count = halTracks.size(), .tracks = halTracks.data(), + .track_count = halTracks.size(), + .tracks = halTracks.data(), }; mStream->update_source_metadata(mStream, &halMetadata); return Void(); @@ -571,7 +574,7 @@ Return<Result> StreamOut::selectPresentation(int32_t /*presentationId*/, int32_t #endif } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace audio } // namespace hardware } // namespace android diff --git a/audio/core/all-versions/default/include/core/all-versions/default/Conversions.h b/audio/core/all-versions/default/include/core/default/Conversions.h index b38eca35a1..2c33c6b2cc 100644 --- a/audio/core/all-versions/default/include/core/all-versions/default/Conversions.h +++ b/audio/core/all-versions/default/include/core/default/Conversions.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,10 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#ifndef ANDROID_HARDWARE_AUDIO_CONVERSIONS_H_ +#define ANDROID_HARDWARE_AUDIO_CONVERSIONS_H_ + +#include PATH(android/hardware/audio/FILE_VERSION/types.h) #include <string> @@ -23,20 +26,22 @@ namespace android { namespace hardware { namespace audio { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { -using ::android::hardware::audio::AUDIO_HAL_VERSION::DeviceAddress; +using ::android::hardware::audio::CPP_VERSION::DeviceAddress; std::string deviceAddressToHal(const DeviceAddress& address); -#ifdef AUDIO_HAL_VERSION_4_0 +#if MAJOR_VERSION >= 4 bool halToMicrophoneCharacteristics(MicrophoneInfo* pDst, const struct audio_microphone_characteristic_t& src); #endif } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace audio } // namespace hardware } // namespace android + +#endif // ANDROID_HARDWARE_AUDIO_CONVERSIONS_H_ diff --git a/audio/core/all-versions/default/include/core/all-versions/default/Device.h b/audio/core/all-versions/default/include/core/default/Device.h index eb53b482b2..9975d5bdeb 100644 --- a/audio/core/all-versions/default/include/core/all-versions/default/Device.h +++ b/audio/core/all-versions/default/include/core/default/Device.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,12 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#ifndef ANDROID_HARDWARE_AUDIO_DEVICE_H +#define ANDROID_HARDWARE_AUDIO_DEVICE_H + +#include PATH(android/hardware/audio/FILE_VERSION/IDevice.h) + +#include "ParametersUtil.h" #include <memory> @@ -30,41 +35,43 @@ namespace android { namespace hardware { namespace audio { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioConfig; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioHwSync; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioInputFlag; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioOutputFlag; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioPatchHandle; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioPort; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioPortConfig; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioSource; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::implementation::AudioInputFlagBitfield; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::implementation:: - AudioOutputFlagBitfield; -using ::android::hardware::audio::AUDIO_HAL_VERSION::DeviceAddress; -using ::android::hardware::audio::AUDIO_HAL_VERSION::IDevice; -using ::android::hardware::audio::AUDIO_HAL_VERSION::IStreamIn; -using ::android::hardware::audio::AUDIO_HAL_VERSION::IStreamOut; -using ::android::hardware::audio::AUDIO_HAL_VERSION::ParameterValue; -using ::android::hardware::audio::AUDIO_HAL_VERSION::Result; +using ::android::sp; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; -using ::android::hardware::hidl_vec; -using ::android::hardware::hidl_string; -using ::android::sp; - -#ifdef AUDIO_HAL_VERSION_4_0 -using ::android::hardware::audio::AUDIO_HAL_VERSION::SourceMetadata; -using ::android::hardware::audio::AUDIO_HAL_VERSION::SinkMetadata; +using ::android::hardware::audio::common::CPP_VERSION::AudioConfig; +using ::android::hardware::audio::common::CPP_VERSION::AudioHwSync; +using ::android::hardware::audio::common::CPP_VERSION::AudioInputFlag; +using ::android::hardware::audio::common::CPP_VERSION::AudioOutputFlag; +using ::android::hardware::audio::common::CPP_VERSION::AudioPatchHandle; +using ::android::hardware::audio::common::CPP_VERSION::AudioPort; +using ::android::hardware::audio::common::CPP_VERSION::AudioPortConfig; +using ::android::hardware::audio::common::CPP_VERSION::AudioSource; +using ::android::hardware::audio::common::CPP_VERSION::implementation::AudioInputFlagBitfield; +using ::android::hardware::audio::common::CPP_VERSION::implementation::AudioOutputFlagBitfield; +using ::android::hardware::audio::CPP_VERSION::DeviceAddress; +using ::android::hardware::audio::CPP_VERSION::IDevice; +using ::android::hardware::audio::CPP_VERSION::IStreamIn; +using ::android::hardware::audio::CPP_VERSION::IStreamOut; +using ::android::hardware::audio::CPP_VERSION::ParameterValue; +using ::android::hardware::audio::CPP_VERSION::Result; + +#if MAJOR_VERSION == 4 +using ::android::hardware::audio::CPP_VERSION::SinkMetadata; +using ::android::hardware::audio::CPP_VERSION::SourceMetadata; +#elif MAJOR_VERSION >= 5 +using ::android::hardware::audio::common::CPP_VERSION::SinkMetadata; +using ::android::hardware::audio::common::CPP_VERSION::SourceMetadata; #endif struct Device : public IDevice, public ParametersUtil { explicit Device(audio_hw_device_t* device); - // Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IDevice follow. + // Methods from ::android::hardware::audio::CPP_VERSION::IDevice follow. Return<Result> initCheck() override; Return<Result> setMasterVolume(float volume) override; Return<void> getMasterVolume(getMasterVolume_cb _hidl_cb) override; @@ -79,11 +86,11 @@ struct Device : public IDevice, public ParametersUtil { Return<void> openInputStream(int32_t ioHandle, const DeviceAddress& device, const AudioConfig& config, AudioInputFlagBitfield flags, AudioSource source, openInputStream_cb _hidl_cb); -#ifdef AUDIO_HAL_VERSION_2_0 +#if MAJOR_VERSION == 2 Return<void> openOutputStream(int32_t ioHandle, const DeviceAddress& device, const AudioConfig& config, AudioOutputFlagBitfield flags, openOutputStream_cb _hidl_cb) override; -#elif defined(AUDIO_HAL_VERSION_4_0) +#elif MAJOR_VERSION >= 4 Return<void> openOutputStream(int32_t ioHandle, const DeviceAddress& device, const AudioConfig& config, AudioOutputFlagBitfield flags, const SourceMetadata& sourceMetadata, @@ -104,13 +111,13 @@ struct Device : public IDevice, public ParametersUtil { Return<Result> setScreenState(bool turnedOn) override; -#ifdef AUDIO_HAL_VERSION_2_0 +#if MAJOR_VERSION == 2 Return<AudioHwSync> getHwAvSync() override; Return<void> getParameters(const hidl_vec<hidl_string>& keys, getParameters_cb _hidl_cb) override; Return<Result> setParameters(const hidl_vec<ParameterValue>& parameters) override; Return<void> debugDump(const hidl_handle& fd) override; -#elif defined(AUDIO_HAL_VERSION_4_0) +#elif MAJOR_VERSION >= 4 Return<void> getHwAvSync(getHwAvSync_cb _hidl_cb) override; Return<void> getParameters(const hidl_vec<ParameterValue>& context, const hidl_vec<hidl_string>& keys, @@ -124,7 +131,8 @@ struct Device : public IDevice, public ParametersUtil { Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& options) override; // Utility methods for extending interfaces. - Result analyzeStatus(const char* funcName, int status); + Result analyzeStatus(const char* funcName, int status, + const std::vector<int>& ignoreErrors = {}); void closeInputStream(audio_stream_in_t* stream); void closeOutputStream(audio_stream_out_t* stream); audio_hw_device_t* device() const { return mDevice; } @@ -142,7 +150,9 @@ struct Device : public IDevice, public ParametersUtil { }; } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace audio } // namespace hardware } // namespace android + +#endif // ANDROID_HARDWARE_AUDIO_DEVICE_H diff --git a/audio/core/all-versions/default/include/core/all-versions/default/DevicesFactory.h b/audio/core/all-versions/default/include/core/default/DevicesFactory.h index 1509ad170c..34138533b6 100644 --- a/audio/core/all-versions/default/include/core/all-versions/default/DevicesFactory.h +++ b/audio/core/all-versions/default/include/core/default/DevicesFactory.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,10 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#ifndef ANDROID_HARDWARE_AUDIO_DEVICESFACTORY_H +#define ANDROID_HARDWARE_AUDIO_DEVICESFACTORY_H + +#include PATH(android/hardware/audio/FILE_VERSION/IDevicesFactory.h) #include <hardware/audio.h> @@ -24,23 +27,22 @@ namespace android { namespace hardware { namespace audio { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { -using ::android::hardware::audio::AUDIO_HAL_VERSION::IDevice; -using ::android::hardware::audio::AUDIO_HAL_VERSION::IDevicesFactory; -using ::android::hardware::audio::AUDIO_HAL_VERSION::Result; +using ::android::sp; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; -using ::android::hardware::hidl_vec; -using ::android::hardware::hidl_string; -using ::android::sp; +using ::android::hardware::audio::CPP_VERSION::IDevice; +using ::android::hardware::audio::CPP_VERSION::IDevicesFactory; +using ::android::hardware::audio::CPP_VERSION::Result; struct DevicesFactory : public IDevicesFactory { -#ifdef AUDIO_HAL_VERSION_2_0 +#if MAJOR_VERSION == 2 Return<void> openDevice(IDevicesFactory::Device device, openDevice_cb _hidl_cb) override; -#endif -#ifdef AUDIO_HAL_VERSION_4_0 +#elif MAJOR_VERSION >= 4 Return<void> openDevice(const hidl_string& device, openDevice_cb _hidl_cb) override; Return<void> openPrimaryDevice(openPrimaryDevice_cb _hidl_cb) override; #endif @@ -56,7 +58,9 @@ struct DevicesFactory : public IDevicesFactory { extern "C" IDevicesFactory* HIDL_FETCH_IDevicesFactory(const char* name); } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace audio } // namespace hardware } // namespace android + +#endif // ANDROID_HARDWARE_AUDIO_DEVICESFACTORY_H diff --git a/audio/core/all-versions/default/include/core/all-versions/default/ParametersUtil.h b/audio/core/all-versions/default/include/core/default/ParametersUtil.h index 35ff1105ea..ba4ca0c96e 100644 --- a/audio/core/all-versions/default/include/core/all-versions/default/ParametersUtil.h +++ b/audio/core/all-versions/default/include/core/default/ParametersUtil.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,10 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#ifndef ANDROID_HARDWARE_AUDIO_PARAMETERS_UTIL_H_ +#define ANDROID_HARDWARE_AUDIO_PARAMETERS_UTIL_H_ + +#include PATH(android/hardware/audio/FILE_VERSION/types.h) #include <functional> #include <memory> @@ -25,14 +28,14 @@ namespace android { namespace hardware { namespace audio { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { -using ::android::hardware::audio::AUDIO_HAL_VERSION::DeviceAddress; -using ::android::hardware::audio::AUDIO_HAL_VERSION::ParameterValue; -using ::android::hardware::audio::AUDIO_HAL_VERSION::Result; using ::android::hardware::hidl_string; using ::android::hardware::hidl_vec; +using ::android::hardware::audio::CPP_VERSION::DeviceAddress; +using ::android::hardware::audio::CPP_VERSION::ParameterValue; +using ::android::hardware::audio::CPP_VERSION::Result; class ParametersUtil { public: @@ -60,7 +63,9 @@ class ParametersUtil { }; } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace audio } // namespace hardware } // namespace android + +#endif // ANDROID_HARDWARE_AUDIO_PARAMETERS_UTIL_H_ diff --git a/audio/core/all-versions/default/include/core/all-versions/default/PrimaryDevice.h b/audio/core/all-versions/default/include/core/default/PrimaryDevice.h index 42996d703e..2f7332eb12 100644 --- a/audio/core/all-versions/default/include/core/all-versions/default/PrimaryDevice.h +++ b/audio/core/all-versions/default/include/core/default/PrimaryDevice.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,12 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#ifndef ANDROID_HARDWARE_AUDIO_PRIMARYDEVICE_H +#define ANDROID_HARDWARE_AUDIO_PRIMARYDEVICE_H + +#include PATH(android/hardware/audio/FILE_VERSION/IPrimaryDevice.h) + +#include "Device.h" #include <hidl/Status.h> @@ -23,33 +28,33 @@ namespace android { namespace hardware { namespace audio { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioConfig; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioInputFlag; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioMode; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioOutputFlag; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioPort; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioPortConfig; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioSource; -using ::android::hardware::audio::AUDIO_HAL_VERSION::DeviceAddress; -using ::android::hardware::audio::AUDIO_HAL_VERSION::IDevice; -using ::android::hardware::audio::AUDIO_HAL_VERSION::IPrimaryDevice; -using ::android::hardware::audio::AUDIO_HAL_VERSION::IStreamIn; -using ::android::hardware::audio::AUDIO_HAL_VERSION::IStreamOut; -using ::android::hardware::audio::AUDIO_HAL_VERSION::ParameterValue; -using ::android::hardware::audio::AUDIO_HAL_VERSION::Result; +using ::android::sp; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; -using ::android::hardware::hidl_vec; -using ::android::hardware::hidl_string; -using ::android::sp; +using ::android::hardware::audio::common::CPP_VERSION::AudioConfig; +using ::android::hardware::audio::common::CPP_VERSION::AudioInputFlag; +using ::android::hardware::audio::common::CPP_VERSION::AudioMode; +using ::android::hardware::audio::common::CPP_VERSION::AudioOutputFlag; +using ::android::hardware::audio::common::CPP_VERSION::AudioPort; +using ::android::hardware::audio::common::CPP_VERSION::AudioPortConfig; +using ::android::hardware::audio::common::CPP_VERSION::AudioSource; +using ::android::hardware::audio::CPP_VERSION::DeviceAddress; +using ::android::hardware::audio::CPP_VERSION::IDevice; +using ::android::hardware::audio::CPP_VERSION::IPrimaryDevice; +using ::android::hardware::audio::CPP_VERSION::IStreamIn; +using ::android::hardware::audio::CPP_VERSION::IStreamOut; +using ::android::hardware::audio::CPP_VERSION::ParameterValue; +using ::android::hardware::audio::CPP_VERSION::Result; struct PrimaryDevice : public IPrimaryDevice { explicit PrimaryDevice(audio_hw_device_t* device); - // Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IDevice follow. + // Methods from ::android::hardware::audio::CPP_VERSION::IDevice follow. Return<Result> initCheck() override; Return<Result> setMasterVolume(float volume) override; Return<void> getMasterVolume(getMasterVolume_cb _hidl_cb) override; @@ -62,7 +67,7 @@ struct PrimaryDevice : public IPrimaryDevice { Return<void> openOutputStream(int32_t ioHandle, const DeviceAddress& device, const AudioConfig& config, AudioOutputFlagBitfield flags, -#ifdef AUDIO_HAL_VERSION_4_0 +#if MAJOR_VERSION >= 4 const SourceMetadata& sourceMetadata, #endif openOutputStream_cb _hidl_cb) override; @@ -70,7 +75,7 @@ struct PrimaryDevice : public IPrimaryDevice { Return<void> openInputStream(int32_t ioHandle, const DeviceAddress& device, const AudioConfig& config, AudioInputFlagBitfield flags, AudioSource source, openInputStream_cb _hidl_cb); -#ifdef AUDIO_HAL_VERSION_4_0 +#if MAJOR_VERSION >= 4 Return<void> openInputStream(int32_t ioHandle, const DeviceAddress& device, const AudioConfig& config, AudioInputFlagBitfield flags, const SinkMetadata& sinkMetadata, @@ -87,13 +92,13 @@ struct PrimaryDevice : public IPrimaryDevice { Return<Result> setScreenState(bool turnedOn) override; -#ifdef AUDIO_HAL_VERSION_2_0 +#if MAJOR_VERSION == 2 Return<AudioHwSync> getHwAvSync() override; Return<void> getParameters(const hidl_vec<hidl_string>& keys, getParameters_cb _hidl_cb) override; Return<Result> setParameters(const hidl_vec<ParameterValue>& parameters) override; Return<void> debugDump(const hidl_handle& fd) override; -#elif defined(AUDIO_HAL_VERSION_4_0) +#elif MAJOR_VERSION >= 4 Return<void> getHwAvSync(getHwAvSync_cb _hidl_cb) override; Return<void> getParameters(const hidl_vec<ParameterValue>& context, const hidl_vec<hidl_string>& keys, @@ -106,7 +111,7 @@ struct PrimaryDevice : public IPrimaryDevice { Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& options) override; - // Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IPrimaryDevice follow. + // Methods from ::android::hardware::audio::CPP_VERSION::IPrimaryDevice follow. Return<Result> setVoiceVolume(float volume) override; Return<Result> setMode(AudioMode mode) override; Return<void> getBtScoNrecEnabled(getBtScoNrecEnabled_cb _hidl_cb) override; @@ -118,7 +123,7 @@ struct PrimaryDevice : public IPrimaryDevice { Return<void> getHacEnabled(getHacEnabled_cb _hidl_cb) override; Return<Result> setHacEnabled(bool enabled) override; -#ifdef AUDIO_HAL_VERSION_4_0 +#if MAJOR_VERSION >= 4 Return<Result> setBtScoHeadsetDebugName(const hidl_string& name) override; Return<void> getBtHfpEnabled(getBtHfpEnabled_cb _hidl_cb) override; Return<Result> setBtHfpEnabled(bool enabled) override; @@ -134,7 +139,9 @@ struct PrimaryDevice : public IPrimaryDevice { }; } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace audio } // namespace hardware } // namespace android + +#endif // ANDROID_HARDWARE_AUDIO_PRIMARYDEVICE_H diff --git a/audio/core/all-versions/default/include/core/all-versions/default/Stream.h b/audio/core/all-versions/default/include/core/default/Stream.h index 7cf12dd433..34d146eb4f 100644 --- a/audio/core/all-versions/default/include/core/all-versions/default/Stream.h +++ b/audio/core/all-versions/default/include/core/default/Stream.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,12 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#ifndef ANDROID_HARDWARE_AUDIO_STREAM_H +#define ANDROID_HARDWARE_AUDIO_STREAM_H + +#include PATH(android/hardware/audio/FILE_VERSION/IStream.h) + +#include "ParametersUtil.h" #include <vector> @@ -28,22 +33,22 @@ namespace android { namespace hardware { namespace audio { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioChannelMask; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioDevice; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioFormat; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::implementation::AudioChannelBitfield; -using ::android::hardware::audio::AUDIO_HAL_VERSION::DeviceAddress; -using ::android::hardware::audio::AUDIO_HAL_VERSION::IStream; -using ::android::hardware::audio::AUDIO_HAL_VERSION::ParameterValue; -using ::android::hardware::audio::AUDIO_HAL_VERSION::Result; +using ::android::sp; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; -using ::android::hardware::hidl_vec; -using ::android::hardware::hidl_string; -using ::android::sp; +using ::android::hardware::audio::common::CPP_VERSION::AudioChannelMask; +using ::android::hardware::audio::common::CPP_VERSION::AudioDevice; +using ::android::hardware::audio::common::CPP_VERSION::AudioFormat; +using ::android::hardware::audio::common::CPP_VERSION::implementation::AudioChannelBitfield; +using ::android::hardware::audio::CPP_VERSION::DeviceAddress; +using ::android::hardware::audio::CPP_VERSION::IStream; +using ::android::hardware::audio::CPP_VERSION::ParameterValue; +using ::android::hardware::audio::CPP_VERSION::Result; struct Stream : public IStream, public ParametersUtil { explicit Stream(audio_stream_t* stream); @@ -55,12 +60,12 @@ struct Stream : public IStream, public ParametersUtil { */ static constexpr uint32_t MAX_BUFFER_SIZE = 2 << 30 /* == 1GiB */; - // Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IStream follow. + // Methods from ::android::hardware::audio::CPP_VERSION::IStream follow. Return<uint64_t> getFrameSize() override; Return<uint64_t> getFrameCount() override; Return<uint64_t> getBufferSize() override; Return<uint32_t> getSampleRate() override; -#ifdef AUDIO_HAL_VERSION_2_0 +#if MAJOR_VERSION == 2 Return<void> getSupportedSampleRates(getSupportedSampleRates_cb _hidl_cb) override; Return<void> getSupportedChannelMasks(getSupportedChannelMasks_cb _hidl_cb) override; #endif @@ -76,14 +81,14 @@ struct Stream : public IStream, public ParametersUtil { Return<Result> addEffect(uint64_t effectId) override; Return<Result> removeEffect(uint64_t effectId) override; Return<Result> standby() override; -#ifdef AUDIO_HAL_VERSION_2_0 +#if MAJOR_VERSION == 2 Return<AudioDevice> getDevice() override; Return<Result> setDevice(const DeviceAddress& address) override; Return<void> getParameters(const hidl_vec<hidl_string>& keys, getParameters_cb _hidl_cb) override; Return<Result> setParameters(const hidl_vec<ParameterValue>& parameters) override; Return<Result> setConnectedState(const DeviceAddress& address, bool connected) override; -#elif defined(AUDIO_HAL_VERSION_4_0) +#elif MAJOR_VERSION >= 4 Return<void> getDevices(getDevices_cb _hidl_cb) override; Return<Result> setDevices(const hidl_vec<DeviceAddress>& devices) override; Return<void> getParameters(const hidl_vec<ParameterValue>& context, @@ -100,7 +105,7 @@ struct Stream : public IStream, public ParametersUtil { Return<Result> close() override; Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& options) override; -#ifdef AUDIO_HAL_VERSION_2_0 +#if MAJOR_VERSION == 2 Return<void> debugDump(const hidl_handle& fd) override; #endif @@ -171,7 +176,7 @@ Return<void> StreamMmap<T>::createMmapBuffer(int32_t minSizeFrames, size_t frame halInfo.buffer_size_frames = abs(halInfo.buffer_size_frames); info.sharedMemory = // hidl_memory size must always be positive hidl_memory("audio_buffer", hidlHandle, frameSize * halInfo.buffer_size_frames); -#ifdef AUDIO_HAL_VERSION_2_0 +#if MAJOR_VERSION == 2 if (applicationShareable) { halInfo.buffer_size_frames *= -1; } @@ -210,7 +215,9 @@ Return<void> StreamMmap<T>::getMmapPosition(IStream::getMmapPosition_cb _hidl_cb } } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace audio } // namespace hardware } // namespace android + +#endif // ANDROID_HARDWARE_AUDIO_STREAM_H diff --git a/audio/core/all-versions/default/include/core/all-versions/default/StreamIn.h b/audio/core/all-versions/default/include/core/default/StreamIn.h index f226e63f70..057c6f31e9 100644 --- a/audio/core/all-versions/default/include/core/all-versions/default/StreamIn.h +++ b/audio/core/all-versions/default/include/core/default/StreamIn.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,13 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#ifndef ANDROID_HARDWARE_AUDIO_STREAMIN_H +#define ANDROID_HARDWARE_AUDIO_STREAMIN_H + +#include PATH(android/hardware/audio/FILE_VERSION/IStreamIn.h) + +#include "Device.h" +#include "Stream.h" #include <atomic> #include <memory> @@ -28,23 +34,23 @@ namespace android { namespace hardware { namespace audio { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioChannelMask; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioDevice; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioFormat; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioSource; -using ::android::hardware::audio::AUDIO_HAL_VERSION::DeviceAddress; -using ::android::hardware::audio::AUDIO_HAL_VERSION::IStream; -using ::android::hardware::audio::AUDIO_HAL_VERSION::IStreamIn; -using ::android::hardware::audio::AUDIO_HAL_VERSION::ParameterValue; -using ::android::hardware::audio::AUDIO_HAL_VERSION::Result; +using ::android::sp; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; -using ::android::hardware::hidl_vec; -using ::android::hardware::hidl_string; -using ::android::sp; +using ::android::hardware::audio::common::CPP_VERSION::AudioChannelMask; +using ::android::hardware::audio::common::CPP_VERSION::AudioDevice; +using ::android::hardware::audio::common::CPP_VERSION::AudioFormat; +using ::android::hardware::audio::common::CPP_VERSION::AudioSource; +using ::android::hardware::audio::CPP_VERSION::DeviceAddress; +using ::android::hardware::audio::CPP_VERSION::IStream; +using ::android::hardware::audio::CPP_VERSION::IStreamIn; +using ::android::hardware::audio::CPP_VERSION::ParameterValue; +using ::android::hardware::audio::CPP_VERSION::Result; struct StreamIn : public IStreamIn { typedef MessageQueue<ReadParameters, kSynchronizedReadWrite> CommandMQ; @@ -53,12 +59,12 @@ struct StreamIn : public IStreamIn { StreamIn(const sp<Device>& device, audio_stream_in_t* stream); - // Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IStream follow. + // Methods from ::android::hardware::audio::CPP_VERSION::IStream follow. Return<uint64_t> getFrameSize() override; Return<uint64_t> getFrameCount() override; Return<uint64_t> getBufferSize() override; Return<uint32_t> getSampleRate() override; -#ifdef AUDIO_HAL_VERSION_2_0 +#if MAJOR_VERSION == 2 Return<void> getSupportedSampleRates(getSupportedSampleRates_cb _hidl_cb) override; Return<void> getSupportedChannelMasks(getSupportedChannelMasks_cb _hidl_cb) override; #endif @@ -74,14 +80,14 @@ struct StreamIn : public IStreamIn { Return<Result> addEffect(uint64_t effectId) override; Return<Result> removeEffect(uint64_t effectId) override; Return<Result> standby() override; -#ifdef AUDIO_HAL_VERSION_2_0 +#if MAJOR_VERSION == 2 Return<AudioDevice> getDevice() override; Return<Result> setDevice(const DeviceAddress& address) override; Return<void> getParameters(const hidl_vec<hidl_string>& keys, getParameters_cb _hidl_cb) override; Return<Result> setParameters(const hidl_vec<ParameterValue>& parameters) override; Return<Result> setConnectedState(const DeviceAddress& address, bool connected) override; -#elif defined(AUDIO_HAL_VERSION_4_0) +#elif MAJOR_VERSION >= 4 Return<void> getDevices(getDevices_cb _hidl_cb) override; Return<Result> setDevices(const hidl_vec<DeviceAddress>& devices) override; Return<void> getParameters(const hidl_vec<ParameterValue>& context, @@ -94,11 +100,11 @@ struct StreamIn : public IStreamIn { Return<Result> close() override; Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& options) override; -#ifdef AUDIO_HAL_VERSION_2_0 +#if MAJOR_VERSION == 2 Return<void> debugDump(const hidl_handle& fd) override; #endif - // Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IStreamIn follow. + // Methods from ::android::hardware::audio::CPP_VERSION::IStreamIn follow. Return<void> getAudioSource(getAudioSource_cb _hidl_cb) override; Return<Result> setGain(float gain) override; Return<void> prepareForReading(uint32_t frameSize, uint32_t framesCount, @@ -109,7 +115,7 @@ struct StreamIn : public IStreamIn { Return<Result> stop() override; Return<void> createMmapBuffer(int32_t minSizeFrames, createMmapBuffer_cb _hidl_cb) override; Return<void> getMmapPosition(getMmapPosition_cb _hidl_cb) override; -#ifdef AUDIO_HAL_VERSION_4_0 +#if MAJOR_VERSION >= 4 Return<void> updateSinkMetadata(const SinkMetadata& sinkMetadata) override; Return<void> getActiveMicrophones(getActiveMicrophones_cb _hidl_cb) override; #endif @@ -134,7 +140,9 @@ struct StreamIn : public IStreamIn { }; } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace audio } // namespace hardware } // namespace android + +#endif // ANDROID_HARDWARE_AUDIO_STREAMIN_H diff --git a/audio/core/all-versions/default/include/core/all-versions/default/StreamOut.h b/audio/core/all-versions/default/include/core/default/StreamOut.h index 134d7b9bbe..bcae97fba1 100644 --- a/audio/core/all-versions/default/include/core/all-versions/default/StreamOut.h +++ b/audio/core/all-versions/default/include/core/default/StreamOut.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,13 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#ifndef ANDROID_HARDWARE_AUDIO_STREAMOUT_H +#define ANDROID_HARDWARE_AUDIO_STREAMOUT_H + +#include PATH(android/hardware/audio/FILE_VERSION/IStreamOut.h) + +#include "Device.h" +#include "Stream.h" #include <atomic> #include <memory> @@ -28,25 +34,25 @@ namespace android { namespace hardware { namespace audio { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioChannelMask; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioDevice; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioFormat; -using ::android::hardware::audio::AUDIO_HAL_VERSION::AudioDrain; -using ::android::hardware::audio::AUDIO_HAL_VERSION::DeviceAddress; -using ::android::hardware::audio::AUDIO_HAL_VERSION::IStream; -using ::android::hardware::audio::AUDIO_HAL_VERSION::IStreamOut; -using ::android::hardware::audio::AUDIO_HAL_VERSION::IStreamOutCallback; -using ::android::hardware::audio::AUDIO_HAL_VERSION::ParameterValue; -using ::android::hardware::audio::AUDIO_HAL_VERSION::Result; -using ::android::hardware::audio::AUDIO_HAL_VERSION::TimeSpec; +using ::android::sp; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; -using ::android::hardware::hidl_vec; -using ::android::hardware::hidl_string; -using ::android::sp; +using ::android::hardware::audio::common::CPP_VERSION::AudioChannelMask; +using ::android::hardware::audio::common::CPP_VERSION::AudioDevice; +using ::android::hardware::audio::common::CPP_VERSION::AudioFormat; +using ::android::hardware::audio::CPP_VERSION::AudioDrain; +using ::android::hardware::audio::CPP_VERSION::DeviceAddress; +using ::android::hardware::audio::CPP_VERSION::IStream; +using ::android::hardware::audio::CPP_VERSION::IStreamOut; +using ::android::hardware::audio::CPP_VERSION::IStreamOutCallback; +using ::android::hardware::audio::CPP_VERSION::ParameterValue; +using ::android::hardware::audio::CPP_VERSION::Result; +using ::android::hardware::audio::CPP_VERSION::TimeSpec; struct StreamOut : public IStreamOut { typedef MessageQueue<WriteCommand, kSynchronizedReadWrite> CommandMQ; @@ -55,12 +61,12 @@ struct StreamOut : public IStreamOut { StreamOut(const sp<Device>& device, audio_stream_out_t* stream); - // Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IStream follow. + // Methods from ::android::hardware::audio::CPP_VERSION::IStream follow. Return<uint64_t> getFrameSize() override; Return<uint64_t> getFrameCount() override; Return<uint64_t> getBufferSize() override; Return<uint32_t> getSampleRate() override; -#ifdef AUDIO_HAL_VERSION_2_0 +#if MAJOR_VERSION == 2 Return<void> getSupportedSampleRates(getSupportedSampleRates_cb _hidl_cb) override; Return<void> getSupportedChannelMasks(getSupportedChannelMasks_cb _hidl_cb) override; #endif @@ -76,14 +82,14 @@ struct StreamOut : public IStreamOut { Return<Result> addEffect(uint64_t effectId) override; Return<Result> removeEffect(uint64_t effectId) override; Return<Result> standby() override; -#ifdef AUDIO_HAL_VERSION_2_0 +#if MAJOR_VERSION == 2 Return<AudioDevice> getDevice() override; Return<Result> setDevice(const DeviceAddress& address) override; Return<void> getParameters(const hidl_vec<hidl_string>& keys, getParameters_cb _hidl_cb) override; Return<Result> setParameters(const hidl_vec<ParameterValue>& parameters) override; Return<Result> setConnectedState(const DeviceAddress& address, bool connected) override; -#elif defined(AUDIO_HAL_VERSION_4_0) +#elif MAJOR_VERSION >= 4 Return<void> getDevices(getDevices_cb _hidl_cb) override; Return<Result> setDevices(const hidl_vec<DeviceAddress>& devices) override; Return<void> getParameters(const hidl_vec<ParameterValue>& context, @@ -96,11 +102,11 @@ struct StreamOut : public IStreamOut { Return<Result> close() override; Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& options) override; -#ifdef AUDIO_HAL_VERSION_2_0 +#if MAJOR_VERSION == 2 Return<void> debugDump(const hidl_handle& fd) override; #endif - // Methods from ::android::hardware::audio::AUDIO_HAL_VERSION::IStreamOut follow. + // Methods from ::android::hardware::audio::CPP_VERSION::IStreamOut follow. Return<uint32_t> getLatency() override; Return<Result> setVolume(float left, float right) override; Return<void> prepareForWriting(uint32_t frameSize, uint32_t framesCount, @@ -120,7 +126,7 @@ struct StreamOut : public IStreamOut { Return<Result> stop() override; Return<void> createMmapBuffer(int32_t minSizeFrames, createMmapBuffer_cb _hidl_cb) override; Return<void> getMmapPosition(getMmapPosition_cb _hidl_cb) override; -#ifdef AUDIO_HAL_VERSION_4_0 +#if MAJOR_VERSION >= 4 Return<void> updateSourceMetadata(const SourceMetadata& sourceMetadata) override; Return<Result> selectPresentation(int32_t presentationId, int32_t programId) override; #endif @@ -148,7 +154,9 @@ struct StreamOut : public IStreamOut { }; } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace audio } // namespace hardware } // namespace android + +#endif // ANDROID_HARDWARE_AUDIO_STREAMOUT_H diff --git a/audio/core/all-versions/default/include/core/all-versions/default/Util.h b/audio/core/all-versions/default/include/core/default/Util.h index 350fd867e6..2b8c3fd5b2 100644 --- a/audio/core/all-versions/default/include/core/all-versions/default/Util.h +++ b/audio/core/all-versions/default/include/core/default/Util.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,10 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#ifndef ANDROID_HARDWARE_AUDIO_UTIL_H +#define ANDROID_HARDWARE_AUDIO_UTIL_H + +#include PATH(android/hardware/audio/FILE_VERSION/types.h) #include <algorithm> #include <vector> @@ -24,10 +27,10 @@ namespace android { namespace hardware { namespace audio { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { -using ::android::hardware::audio::AUDIO_HAL_VERSION::Result; +using ::android::hardware::audio::CPP_VERSION::Result; /** @return true if gain is between 0 and 1 included. */ constexpr bool isGainNormalized(float gain) { @@ -68,7 +71,9 @@ static inline Result analyzeStatus(const char* className, const char* funcName, } // namespace util } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace audio } // namespace hardware } // namespace android + +#endif // ANDROID_HARDWARE_AUDIO_UTIL_H diff --git a/audio/core/4.0/vts/OWNERS b/audio/core/all-versions/vts/OWNERS index 8711a9ff6a..0ea4666443 100644 --- a/audio/core/4.0/vts/OWNERS +++ b/audio/core/all-versions/vts/OWNERS @@ -2,4 +2,4 @@ elaurent@google.com krocard@google.com mnaganov@google.com yim@google.com -zhuoyao@google.com
\ No newline at end of file +zhuoyao@google.com diff --git a/audio/core/all-versions/vts/functional/2.0/AudioPrimaryHidlHalTest.cpp b/audio/core/all-versions/vts/functional/2.0/AudioPrimaryHidlHalTest.cpp new file mode 100644 index 0000000000..7906bf1b62 --- /dev/null +++ b/audio/core/all-versions/vts/functional/2.0/AudioPrimaryHidlHalTest.cpp @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2018 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 "AudioPrimaryHidlHalTest.h" + +static void testGetDevice(IStream* stream, AudioDevice expectedDevice) { + // Unfortunately the interface does not allow the implementation to return + // NOT_SUPPORTED + // Thus allow NONE as signaling that the call is not supported. + auto ret = stream->getDevice(); + ASSERT_IS_OK(ret); + AudioDevice device = ret; + ASSERT_TRUE(device == expectedDevice || device == AudioDevice::NONE) + << "Expected: " << ::testing::PrintToString(expectedDevice) + << "\n Actual: " << ::testing::PrintToString(device); +} + +TEST_IO_STREAM(GetDevice, "Check that the stream device == the one it was opened with", + areAudioPatchesSupported() ? doc::partialTest("Audio patches are supported") + : testGetDevice(stream.get(), address.device)) + +static void testSetDevice(IStream* stream, const DeviceAddress& address) { + DeviceAddress otherAddress = address; + otherAddress.device = (address.device & AudioDevice::BIT_IN) == 0 ? AudioDevice::OUT_SPEAKER + : AudioDevice::IN_BUILTIN_MIC; + EXPECT_OK(stream->setDevice(otherAddress)); + + ASSERT_OK(stream->setDevice(address)); // Go back to the original value +} + +TEST_IO_STREAM(SetDevice, "Check that the stream can be rerouted to SPEAKER or BUILTIN_MIC", + areAudioPatchesSupported() ? doc::partialTest("Audio patches are supported") + : testSetDevice(stream.get(), address)) + +static void testConnectedState(IStream* stream) { + DeviceAddress address = {}; + using AD = AudioDevice; + for (auto device : {AD::OUT_HDMI, AD::OUT_WIRED_HEADPHONE, AD::IN_USB_HEADSET}) { + address.device = device; + + ASSERT_OK(stream->setConnectedState(address, true)); + ASSERT_OK(stream->setConnectedState(address, false)); + } +} +TEST_IO_STREAM(SetConnectedState, + "Check that the stream can be notified of device connection and " + "deconnection", + testConnectedState(stream.get())) + +TEST_IO_STREAM(GetHwAvSync, "Get hardware sync can not fail", ASSERT_IS_OK(device->getHwAvSync())); + +TEST_F(AudioPrimaryHidlTest, setMode) { + doc::test("Make sure setMode always succeeds if mode is valid and fails otherwise"); + // Test Invalid values + for (AudioMode mode : {AudioMode::INVALID, AudioMode::CURRENT, AudioMode::CNT}) { + SCOPED_TRACE("mode=" + toString(mode)); + ASSERT_RESULT(Result::INVALID_ARGUMENTS, device->setMode(mode)); + } + // Test valid values + for (AudioMode mode : {AudioMode::IN_CALL, AudioMode::IN_COMMUNICATION, AudioMode::RINGTONE, + AudioMode::NORMAL /* Make sure to leave the test in normal mode */}) { + SCOPED_TRACE("mode=" + toString(mode)); + ASSERT_OK(device->setMode(mode)); + } +} diff --git a/audio/core/all-versions/vts/functional/2.0/AudioPrimaryHidlHalUtils.h b/audio/core/all-versions/vts/functional/2.0/AudioPrimaryHidlHalUtils.h new file mode 100644 index 0000000000..1cffd41831 --- /dev/null +++ b/audio/core/all-versions/vts/functional/2.0/AudioPrimaryHidlHalUtils.h @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2018 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 PATH(android/hardware/audio/FILE_VERSION/IStream.h) +#include PATH(android/hardware/audio/FILE_VERSION/types.h) +#include PATH(android/hardware/audio/common/FILE_VERSION/types.h) +#include <hidl/HidlSupport.h> + +using ::android::hardware::hidl_handle; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; +using ::android::hardware::audio::common::CPP_VERSION::AudioChannelMask; +using ::android::hardware::audio::common::CPP_VERSION::AudioFormat; +using ::android::hardware::audio::CPP_VERSION::IStream; +using ::android::hardware::audio::CPP_VERSION::ParameterValue; +using ::android::hardware::audio::CPP_VERSION::Result; + +using namespace ::android::hardware::audio::common::test::utility; + +struct Parameters { + template <class T, class ReturnIn> + static auto get(T t, hidl_vec<hidl_string> keys, ReturnIn returnIn) { + return t->getParameters(keys, returnIn); + } + template <class T> + static auto set(T t, hidl_vec<ParameterValue> values) { + return t->setParameters(values); + } +}; + +// The default hal should probably return a NOT_SUPPORTED if the hal +// does not expose +// capability retrieval. For now it returns an empty list if not +// implemented +struct GetSupported { + template <class Vec> + static Result convertToResult(const Vec& vec) { + return vec.size() == 0 ? Result::NOT_SUPPORTED : Result::OK; + } + + static Result sampleRates(IStream* stream, hidl_vec<uint32_t>& rates) { + EXPECT_OK(stream->getSupportedSampleRates(returnIn(rates))); + return convertToResult(rates); + } + + static Result channelMasks(IStream* stream, hidl_vec<AudioChannelMask>& channels) { + EXPECT_OK(stream->getSupportedChannelMasks(returnIn(channels))); + return convertToResult(channels); + } + + static Result formats(IStream* stream, hidl_vec<AudioFormat>& capabilities) { + EXPECT_OK(stream->getSupportedFormats(returnIn(capabilities))); + // TODO: this should be an optional function + return Result::OK; + } +}; + +template <class T> +auto dump(T t, hidl_handle handle) { + return t->debugDump(handle); +} diff --git a/audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalTest.cpp b/audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalTest.cpp new file mode 100644 index 0000000000..e7c1e58075 --- /dev/null +++ b/audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalTest.cpp @@ -0,0 +1,309 @@ +/* + * Copyright (C) 2018 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 "AudioPrimaryHidlHalTest.h" + +static void waitForDeviceDestruction() { + // FIXME: there is no way to know when the remote IDevice is being destroyed + // Binder does not support testing if an object is alive, thus + // wait for 100ms to let the binder destruction propagates and + // the remote device has the time to be destroyed. + // flushCommand makes sure all local command are sent, thus should reduce + // the latency between local and remote destruction. + IPCThreadState::self()->flushCommands(); + usleep(100); +} + +TEST_F(AudioHidlTest, OpenPrimaryDeviceUsingGetDevice) { + doc::test("Calling openDevice(\"primary\") should return the primary device."); + { + Result result; + sp<IDevice> baseDevice; + ASSERT_OK(devicesFactory->openDevice("primary", returnIn(result, baseDevice))); + ASSERT_OK(result); + ASSERT_TRUE(baseDevice != nullptr); + + Return<sp<IPrimaryDevice>> primaryDevice = IPrimaryDevice::castFrom(baseDevice); + ASSERT_TRUE(primaryDevice.isOk()); + ASSERT_TRUE(sp<IPrimaryDevice>(primaryDevice) != nullptr); + } // Destroy local IDevice proxy + waitForDeviceDestruction(); +} + +////////////////////////////////////////////////////////////////////////////// +/////////////////////////// get(Active)Microphones /////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +TEST_F(AudioPrimaryHidlTest, GetMicrophonesTest) { + doc::test("Make sure getMicrophones always succeeds"); + hidl_vec<MicrophoneInfo> microphones; + ASSERT_OK(device->getMicrophones(returnIn(res, microphones))); + ASSERT_OK(res); + if (microphones.size() > 0) { + // When there is microphone on the phone, try to open an input stream + // and query for the active microphones. + doc::test( + "Make sure getMicrophones always succeeds" + "and getActiveMicrophones always succeeds when recording from these microphones."); + AudioIoHandle ioHandle = (AudioIoHandle)AudioHandleConsts::AUDIO_IO_HANDLE_NONE; + AudioConfig config{}; + config.channelMask = mkEnumBitfield(AudioChannelMask::IN_MONO); + config.sampleRateHz = 8000; + config.format = AudioFormat::PCM_16_BIT; + auto flags = hidl_bitfield<AudioInputFlag>(AudioInputFlag::NONE); + const SinkMetadata initMetadata = {{{AudioSource::MIC, 1 /* gain */}}}; + EventFlag* efGroup; + for (auto microphone : microphones) { + if (microphone.deviceAddress.device != AudioDevice::IN_BUILTIN_MIC) { + continue; + } + sp<IStreamIn> stream; + AudioConfig suggestedConfig{}; + ASSERT_OK(device->openInputStream(ioHandle, microphone.deviceAddress, config, flags, + initMetadata, + returnIn(res, stream, suggestedConfig))); + if (res != Result::OK) { + ASSERT_TRUE(stream == nullptr); + AudioConfig suggestedConfigRetry{}; + ASSERT_OK(device->openInputStream(ioHandle, microphone.deviceAddress, + suggestedConfig, flags, initMetadata, + returnIn(res, stream, suggestedConfigRetry))); + } + ASSERT_OK(res); + hidl_vec<MicrophoneInfo> activeMicrophones; + Result readRes; + typedef MessageQueue<ReadParameters, kSynchronizedReadWrite> CommandMQ; + typedef MessageQueue<uint8_t, kSynchronizedReadWrite> DataMQ; + std::unique_ptr<CommandMQ> commandMQ; + std::unique_ptr<DataMQ> dataMQ; + size_t frameSize = stream->getFrameSize(); + size_t frameCount = stream->getBufferSize() / frameSize; + ASSERT_OK(stream->prepareForReading( + frameSize, frameCount, [&](auto r, auto& c, auto& d, auto&, auto&) { + readRes = r; + if (readRes == Result::OK) { + commandMQ.reset(new CommandMQ(c)); + dataMQ.reset(new DataMQ(d)); + if (dataMQ->isValid() && dataMQ->getEventFlagWord()) { + EventFlag::createEventFlag(dataMQ->getEventFlagWord(), &efGroup); + } + } + })); + ASSERT_OK(readRes); + ReadParameters params; + params.command = IStreamIn::ReadCommand::READ; + ASSERT_TRUE(commandMQ != nullptr); + ASSERT_TRUE(commandMQ->isValid()); + ASSERT_TRUE(commandMQ->write(¶ms)); + efGroup->wake(static_cast<uint32_t>(MessageQueueFlagBits::NOT_FULL)); + uint32_t efState = 0; + efGroup->wait(static_cast<uint32_t>(MessageQueueFlagBits::NOT_EMPTY), &efState); + if (efState & static_cast<uint32_t>(MessageQueueFlagBits::NOT_EMPTY)) { + ASSERT_OK(stream->getActiveMicrophones(returnIn(res, activeMicrophones))); + ASSERT_OK(res); + ASSERT_NE(0U, activeMicrophones.size()); + } + stream->close(); + if (efGroup) { + EventFlag::deleteEventFlag(&efGroup); + } + } + } +} + +TEST_F(AudioPrimaryHidlTest, SetConnectedState) { + doc::test("Check that the HAL can be notified of device connection and deconnection"); + using AD = AudioDevice; + for (auto deviceType : {AD::OUT_HDMI, AD::OUT_WIRED_HEADPHONE, AD::IN_USB_HEADSET}) { + SCOPED_TRACE("device=" + ::testing::PrintToString(deviceType)); + for (bool state : {true, false}) { + SCOPED_TRACE("state=" + ::testing::PrintToString(state)); + DeviceAddress address = {}; + address.device = deviceType; + auto ret = device->setConnectedState(address, state); + ASSERT_TRUE(ret.isOk()); + if (ret == Result::NOT_SUPPORTED) { + doc::partialTest("setConnectedState is not supported"); + break; // other deviceType might be supported + } + ASSERT_OK(ret); + } + } + + // Because there is no way of knowing if the devices were connected before + // calling setConnectedState, there is no way to restore the HAL to its + // initial state. To workaround this, destroy the HAL at the end of this test. + device.clear(); + waitForDeviceDestruction(); +} + +static void testGetDevices(IStream* stream, AudioDevice expectedDevice) { + hidl_vec<DeviceAddress> devices; + Result res; + ASSERT_OK(stream->getDevices(returnIn(res, devices))); + if (res == Result::NOT_SUPPORTED) { + return doc::partialTest("GetDevices is not supported"); + } + // The stream was constructed with one device, thus getDevices must only return one + ASSERT_EQ(1U, devices.size()); + AudioDevice device = devices[0].device; + ASSERT_TRUE(device == expectedDevice) + << "Expected: " << ::testing::PrintToString(expectedDevice) + << "\n Actual: " << ::testing::PrintToString(device); +} + +TEST_IO_STREAM(GetDevices, "Check that the stream device == the one it was opened with", + areAudioPatchesSupported() ? doc::partialTest("Audio patches are supported") + : testGetDevices(stream.get(), address.device)) + +static void testSetDevices(IStream* stream, const DeviceAddress& address) { + DeviceAddress otherAddress = address; + otherAddress.device = (address.device & AudioDevice::BIT_IN) == 0 ? AudioDevice::OUT_SPEAKER + : AudioDevice::IN_BUILTIN_MIC; + EXPECT_OK(stream->setDevices({otherAddress})); + + ASSERT_OK(stream->setDevices({address})); // Go back to the original value +} + +TEST_IO_STREAM(SetDevices, "Check that the stream can be rerouted to SPEAKER or BUILTIN_MIC", + areAudioPatchesSupported() ? doc::partialTest("Audio patches are supported") + : testSetDevices(stream.get(), address)) + +static void checkGetHwAVSync(IDevice* device) { + Result res; + AudioHwSync sync; + ASSERT_OK(device->getHwAvSync(returnIn(res, sync))); + if (res == Result::NOT_SUPPORTED) { + return doc::partialTest("getHwAvSync is not supported"); + } + ASSERT_OK(res); +} +TEST_IO_STREAM(GetHwAvSync, "Get hardware sync can not fail", checkGetHwAVSync(device.get())); + +TEST_P(InputStreamTest, updateSinkMetadata) { + doc::test("The HAL should not crash on metadata change"); + + hidl_enum_range<AudioSource> range; + // Test all possible track configuration + for (AudioSource source : range) { + for (float volume : {0.0, 0.5, 1.0}) { + const SinkMetadata metadata = {{{source, volume}}}; + ASSERT_OK(stream->updateSinkMetadata(metadata)) + << "source=" << toString(source) << ", volume=" << volume; + } + } + + // Do not test concurrent capture as this is not officially supported + + // Set no metadata as if all stream track had stopped + ASSERT_OK(stream->updateSinkMetadata({})); + + // Restore initial + ASSERT_OK(stream->updateSinkMetadata(initMetadata)); +} + +TEST_P(OutputStreamTest, SelectPresentation) { + doc::test("Verify that presentation selection does not crash"); + ASSERT_RESULT(okOrNotSupported, stream->selectPresentation(0, 0)); +} + +TEST_P(OutputStreamTest, updateSourceMetadata) { + doc::test("The HAL should not crash on metadata change"); + + hidl_enum_range<AudioUsage> usageRange; + hidl_enum_range<AudioContentType> contentRange; + // Test all possible track configuration + for (auto usage : usageRange) { + for (auto content : contentRange) { + for (float volume : {0.0, 0.5, 1.0}) { + const SourceMetadata metadata = {{{usage, content, volume}}}; + ASSERT_OK(stream->updateSourceMetadata(metadata)) + << "usage=" << toString(usage) << ", content=" << toString(content) + << ", volume=" << volume; + } + } + } + + // Set many track of different configuration + ASSERT_OK(stream->updateSourceMetadata( + {{{AudioUsage::MEDIA, AudioContentType::MUSIC, 0.1}, + {AudioUsage::VOICE_COMMUNICATION, AudioContentType::SPEECH, 1.0}, + {AudioUsage::ALARM, AudioContentType::SONIFICATION, 0.0}, + {AudioUsage::ASSISTANT, AudioContentType::UNKNOWN, 0.3}}})); + + // Set no metadata as if all stream track had stopped + ASSERT_OK(stream->updateSourceMetadata({})); + + // Restore initial + ASSERT_OK(stream->updateSourceMetadata(initMetadata)); +} + +TEST_F(AudioPrimaryHidlTest, setMode) { + doc::test("Make sure setMode always succeeds if mode is valid and fails otherwise"); + // Test Invalid values + for (int mode : {-2, -1, int(AudioMode::IN_COMMUNICATION) + 1}) { + ASSERT_RESULT(Result::INVALID_ARGUMENTS, device->setMode(AudioMode(mode))) + << "mode=" << mode; + } + // Test valid values + for (AudioMode mode : {AudioMode::IN_CALL, AudioMode::IN_COMMUNICATION, AudioMode::RINGTONE, + AudioMode::NORMAL /* Make sure to leave the test in normal mode */}) { + ASSERT_OK(device->setMode(mode)) << "mode=" << toString(mode); + } +} + +TEST_F(AudioPrimaryHidlTest, setBtHfpSampleRate) { + doc::test( + "Make sure setBtHfpSampleRate either succeeds or " + "indicates that it is not supported at all, or that the provided value is invalid"); + for (auto samplingRate : {8000, 16000, 22050, 24000}) { + ASSERT_RESULT(okOrNotSupportedOrInvalidArgs, device->setBtHfpSampleRate(samplingRate)); + } +} + +TEST_F(AudioPrimaryHidlTest, setBtHfpVolume) { + doc::test( + "Make sure setBtHfpVolume is either not supported or " + "only succeed if volume is in [0,1]"); + auto ret = device->setBtHfpVolume(0.0); + ASSERT_TRUE(ret.isOk()); + if (ret == Result::NOT_SUPPORTED) { + doc::partialTest("setBtHfpVolume is not supported"); + return; + } + testUnitaryGain([](float volume) { return device->setBtHfpVolume(volume); }); +} + +TEST_F(AudioPrimaryHidlTest, setBtScoHeadsetDebugName) { + doc::test( + "Make sure setBtScoHeadsetDebugName either succeeds or " + "indicates that it is not supported"); + ASSERT_RESULT(okOrNotSupported, device->setBtScoHeadsetDebugName("test")); +} + +TEST_F(AudioPrimaryHidlTest, updateRotation) { + doc::test("Check that the hal can receive the current rotation"); + for (Rotation rotation : {Rotation::DEG_0, Rotation::DEG_90, Rotation::DEG_180, + Rotation::DEG_270, Rotation::DEG_0}) { + ASSERT_RESULT(okOrNotSupported, device->updateRotation(rotation)); + } +} + +TEST_F(BoolAccessorPrimaryHidlTest, setGetBtHfpEnabled) { + doc::test("Query and set the BT HFP state"); + testAccessors<OPTIONAL>("BtHfpEnabled", Initial{false, OPTIONAL}, {true}, + &IPrimaryDevice::setBtHfpEnabled, &IPrimaryDevice::getBtHfpEnabled); +} diff --git a/audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalUtils.h b/audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalUtils.h new file mode 100644 index 0000000000..8415053ffc --- /dev/null +++ b/audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalUtils.h @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2018 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 PATH(android/hardware/audio/FILE_VERSION/IStream.h) +#include PATH(android/hardware/audio/FILE_VERSION/types.h) +#include PATH(android/hardware/audio/common/FILE_VERSION/types.h) +#include <hidl/HidlSupport.h> + +using ::android::hardware::hidl_bitfield; +using ::android::hardware::hidl_handle; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; +using ::android::hardware::audio::common::CPP_VERSION::AudioChannelMask; +using ::android::hardware::audio::common::CPP_VERSION::AudioFormat; +using ::android::hardware::audio::CPP_VERSION::IStream; +using ::android::hardware::audio::CPP_VERSION::ParameterValue; +using ::android::hardware::audio::CPP_VERSION::Result; + +using namespace ::android::hardware::audio::common::test::utility; + +using Rotation = ::android::hardware::audio::CPP_VERSION::IPrimaryDevice::Rotation; +using ::android::hardware::audio::common::CPP_VERSION::AudioContentType; +using ::android::hardware::audio::common::CPP_VERSION::AudioUsage; +using ::android::hardware::audio::CPP_VERSION::MicrophoneInfo; +#if MAJOR_VERSION < 5 +using ::android::hardware::audio::CPP_VERSION::SinkMetadata; +using ::android::hardware::audio::CPP_VERSION::SourceMetadata; +#else +using ::android::hardware::audio::common::CPP_VERSION::SinkMetadata; +using ::android::hardware::audio::common::CPP_VERSION::SourceMetadata; +#endif + +struct Parameters { + template <class T, class ReturnIn> + static auto get(T t, hidl_vec<hidl_string> keys, ReturnIn returnIn) { + hidl_vec<ParameterValue> context; + return t->getParameters(context, keys, returnIn); + } + template <class T> + static auto set(T t, hidl_vec<ParameterValue> values) { + hidl_vec<ParameterValue> context; + return t->setParameters(context, values); + } +}; + +struct GetSupported { + static auto getFormat(IStream* stream) { + auto ret = stream->getFormat(); + EXPECT_TRUE(ret.isOk()); + return ret.withDefault({}); + } + static Result sampleRates(IStream* stream, hidl_vec<uint32_t>& rates) { + Result res; + EXPECT_OK(stream->getSupportedSampleRates(getFormat(stream), returnIn(res, rates))); + return res; + } + + static Result channelMasks(IStream* stream, + hidl_vec<hidl_bitfield<AudioChannelMask>>& channels) { + Result res; + EXPECT_OK(stream->getSupportedChannelMasks(getFormat(stream), returnIn(res, channels))); + return res; + } + + static Result formats(IStream* stream, hidl_vec<AudioFormat>& capabilities) { + EXPECT_OK(stream->getSupportedFormats(returnIn(capabilities))); + // TODO: this should be an optional function + return Result::OK; + } +}; + +template <class T> +auto dump(T t, hidl_handle handle) { + return t->debug(handle, {/* options */}); +} diff --git a/audio/core/all-versions/vts/functional/Android.bp b/audio/core/all-versions/vts/functional/Android.bp new file mode 100644 index 0000000000..b04adf71a7 --- /dev/null +++ b/audio/core/all-versions/vts/functional/Android.bp @@ -0,0 +1,87 @@ +// +// Copyright (C) 2017 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. +// + +cc_defaults { + name: "VtsHalAudioTargetTest_defaults", + defaults: ["VtsHalTargetTestDefaults"], + static_libs: [ + "android.hardware.audio.common.test.utility", + "libaudiopolicycomponents", + "libicuuc", + "libicuuc_stubdata", + "libmedia_helper", + "libxml2", + ], + shared_libs: [ + "libfmq", + ], + header_libs: [ + "android.hardware.audio.common.util@all-versions", + ], + test_suites: ["general-tests"], +} + +cc_test { + name: "VtsHalAudioV2_0TargetTest", + defaults: ["VtsHalAudioTargetTest_defaults"], + srcs: [ + "2.0/AudioPrimaryHidlHalTest.cpp", + ], + static_libs: [ + "android.hardware.audio@2.0", + "android.hardware.audio.common@2.0", + ], + cflags: [ + "-DMAJOR_VERSION=2", + "-DMINOR_VERSION=0", + "-include common/all-versions/VersionMacro.h", + ] +} + +cc_test { + name: "VtsHalAudioV4_0TargetTest", + defaults: ["VtsHalAudioTargetTest_defaults"], + srcs: [ + "4.0/AudioPrimaryHidlHalTest.cpp", + ], + static_libs: [ + "android.hardware.audio@4.0", + "android.hardware.audio.common@4.0", + ], + cflags: [ + "-DMAJOR_VERSION=4", + "-DMINOR_VERSION=0", + "-include common/all-versions/VersionMacro.h", + ] +} + +cc_test { + name: "VtsHalAudioV5_0TargetTest", + defaults: ["VtsHalAudioTargetTest_defaults"], + srcs: [ + // for now the tests are the same as V4 + "4.0/AudioPrimaryHidlHalTest.cpp", + ], + static_libs: [ + "android.hardware.audio@5.0", + "android.hardware.audio.common@5.0", + ], + cflags: [ + "-DMAJOR_VERSION=5", + "-DMINOR_VERSION=0", + "-include common/all-versions/VersionMacro.h", + ] +} diff --git a/audio/core/4.0/vts/functional/AudioPrimaryHidlHalTest.cpp b/audio/core/all-versions/vts/functional/AudioPrimaryHidlHalTest.h index 8a8338bb43..eeffb60fa8 100644 --- a/audio/core/4.0/vts/functional/AudioPrimaryHidlHalTest.cpp +++ b/audio/core/all-versions/vts/functional/AudioPrimaryHidlHalTest.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -#define LOG_TAG "VtsHalAudioV4_0TargetTest" +#define LOG_TAG "VtsHalAudioVTargetTest" #include <algorithm> #include <cmath> @@ -35,11 +35,13 @@ #include <android-base/logging.h> -#include <android/hardware/audio/4.0/IDevice.h> -#include <android/hardware/audio/4.0/IDevicesFactory.h> -#include <android/hardware/audio/4.0/IPrimaryDevice.h> -#include <android/hardware/audio/4.0/types.h> -#include <android/hardware/audio/common/4.0/types.h> +#include PATH(android/hardware/audio/FILE_VERSION/IDevice.h) +#include PATH(android/hardware/audio/FILE_VERSION/IDevicesFactory.h) +#include PATH(android/hardware/audio/FILE_VERSION/IPrimaryDevice.h) +#include PATH(android/hardware/audio/FILE_VERSION/types.h) +#include PATH(android/hardware/audio/common/FILE_VERSION/types.h) + +#include <Serializer.h> #include <fmq/EventFlag.h> #include <fmq/MessageQueue.h> @@ -48,66 +50,72 @@ #include "utility/AssertOk.h" #include "utility/Documentation.h" #include "utility/EnvironmentTearDown.h" -#define AUDIO_HAL_VERSION V4_0 #include "utility/PrettyPrintAudioTypes.h" #include "utility/ReturnIn.h" +#include "utility/ValidateXml.h" + +/** Provide version specific functions that are used in the generic tests */ +#if MAJOR_VERSION == 2 +#include "2.0/AudioPrimaryHidlHalUtils.h" +#elif MAJOR_VERSION >= 4 +#include "4.0/AudioPrimaryHidlHalUtils.h" +#endif using std::initializer_list; +using std::list; using std::string; using std::to_string; using std::vector; -using std::list; +using ::android::AudioPolicyConfig; +using ::android::HwModule; +using ::android::NO_INIT; +using ::android::OK; using ::android::sp; +using ::android::status_t; using ::android::hardware::EventFlag; using ::android::hardware::hidl_bitfield; using ::android::hardware::hidl_enum_range; using ::android::hardware::hidl_handle; using ::android::hardware::hidl_string; using ::android::hardware::hidl_vec; -using ::android::hardware::kSynchronizedReadWrite; using ::android::hardware::IPCThreadState; +using ::android::hardware::kSynchronizedReadWrite; using ::android::hardware::MessageQueue; using ::android::hardware::MQDescriptorSync; using ::android::hardware::Return; -using ::android::hardware::audio::V4_0::AudioDrain; -using ::android::hardware::audio::V4_0::DeviceAddress; -using ::android::hardware::audio::V4_0::IDevice; -using ::android::hardware::audio::V4_0::IPrimaryDevice; -using Rotation = ::android::hardware::audio::V4_0::IPrimaryDevice::Rotation; -using TtyMode = ::android::hardware::audio::V4_0::IPrimaryDevice::TtyMode; -using ::android::hardware::audio::V4_0::IDevicesFactory; -using ::android::hardware::audio::V4_0::IStream; -using ::android::hardware::audio::V4_0::IStreamIn; -using ::android::hardware::audio::V4_0::MessageQueueFlagBits; -using ::android::hardware::audio::V4_0::TimeSpec; -using ReadParameters = ::android::hardware::audio::V4_0::IStreamIn::ReadParameters; -using ReadStatus = ::android::hardware::audio::V4_0::IStreamIn::ReadStatus; -using ::android::hardware::audio::V4_0::IStreamOut; -using ::android::hardware::audio::V4_0::IStreamOutCallback; -using ::android::hardware::audio::V4_0::MicrophoneInfo; -using ::android::hardware::audio::V4_0::MmapBufferInfo; -using ::android::hardware::audio::V4_0::MmapPosition; -using ::android::hardware::audio::V4_0::ParameterValue; -using ::android::hardware::audio::V4_0::Result; -using ::android::hardware::audio::V4_0::SourceMetadata; -using ::android::hardware::audio::V4_0::SinkMetadata; -using ::android::hardware::audio::common::V4_0::AudioChannelMask; -using ::android::hardware::audio::common::V4_0::AudioConfig; -using ::android::hardware::audio::common::V4_0::AudioContentType; -using ::android::hardware::audio::common::V4_0::AudioDevice; -using ::android::hardware::audio::common::V4_0::AudioFormat; -using ::android::hardware::audio::common::V4_0::AudioHandleConsts; -using ::android::hardware::audio::common::V4_0::AudioHwSync; -using ::android::hardware::audio::common::V4_0::AudioInputFlag; -using ::android::hardware::audio::common::V4_0::AudioIoHandle; -using ::android::hardware::audio::common::V4_0::AudioMode; -using ::android::hardware::audio::common::V4_0::AudioOffloadInfo; -using ::android::hardware::audio::common::V4_0::AudioOutputFlag; -using ::android::hardware::audio::common::V4_0::AudioSource; -using ::android::hardware::audio::common::V4_0::AudioUsage; -using ::android::hardware::audio::common::V4_0::ThreadInfo; -using ::android::hardware::audio::common::utils::mkBitfield; +using ::android::hardware::audio::CPP_VERSION::AudioDrain; +using ::android::hardware::audio::CPP_VERSION::DeviceAddress; +using ::android::hardware::audio::CPP_VERSION::IDevice; +using ::android::hardware::audio::CPP_VERSION::IPrimaryDevice; +using TtyMode = ::android::hardware::audio::CPP_VERSION::IPrimaryDevice::TtyMode; +using ::android::hardware::audio::CPP_VERSION::IDevicesFactory; +using ::android::hardware::audio::CPP_VERSION::IStream; +using ::android::hardware::audio::CPP_VERSION::IStreamIn; +using ::android::hardware::audio::CPP_VERSION::MessageQueueFlagBits; +using ::android::hardware::audio::CPP_VERSION::TimeSpec; +using ReadParameters = ::android::hardware::audio::CPP_VERSION::IStreamIn::ReadParameters; +using ReadStatus = ::android::hardware::audio::CPP_VERSION::IStreamIn::ReadStatus; +using ::android::hardware::audio::common::CPP_VERSION::AudioChannelMask; +using ::android::hardware::audio::common::CPP_VERSION::AudioConfig; +using ::android::hardware::audio::common::CPP_VERSION::AudioDevice; +using ::android::hardware::audio::common::CPP_VERSION::AudioFormat; +using ::android::hardware::audio::common::CPP_VERSION::AudioHandleConsts; +using ::android::hardware::audio::common::CPP_VERSION::AudioHwSync; +using ::android::hardware::audio::common::CPP_VERSION::AudioInputFlag; +using ::android::hardware::audio::common::CPP_VERSION::AudioIoHandle; +using ::android::hardware::audio::common::CPP_VERSION::AudioMode; +using ::android::hardware::audio::common::CPP_VERSION::AudioOffloadInfo; +using ::android::hardware::audio::common::CPP_VERSION::AudioOutputFlag; +using ::android::hardware::audio::common::CPP_VERSION::AudioSource; +using ::android::hardware::audio::common::CPP_VERSION::ThreadInfo; +using ::android::hardware::audio::common::utils::mkEnumBitfield; +using ::android::hardware::audio::CPP_VERSION::IStreamOut; +using ::android::hardware::audio::CPP_VERSION::IStreamOutCallback; +using ::android::hardware::audio::CPP_VERSION::MmapBufferInfo; +using ::android::hardware::audio::CPP_VERSION::MmapPosition; +using ::android::hardware::audio::CPP_VERSION::ParameterValue; +using ::android::hardware::audio::CPP_VERSION::Result; using namespace ::android::hardware::audio::common::test::utility; @@ -120,6 +128,10 @@ static auto okOrInvalidStateOrNotSupported = {Result::OK, Result::INVALID_STATE, static auto invalidArgsOrNotSupported = {Result::INVALID_ARGUMENTS, Result::NOT_SUPPORTED}; static auto invalidStateOrNotSupported = {Result::INVALID_STATE, Result::NOT_SUPPORTED}; +////////////////////////////////////////////////////////////////////////////// +//////////////////////////////// Environment ///////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + class AudioHidlTestEnvironment : public ::Environment { public: virtual void registerTestServices() override { registerTestService<IDevicesFactory>(); } @@ -135,11 +147,103 @@ class HidlTest : public ::testing::VtsHalHidlTargetTestBase { }; ////////////////////////////////////////////////////////////////////////////// +////////////////////////// Audio policy configuration //////////////////////// +////////////////////////////////////////////////////////////////////////////// + +static const std::vector<const char*> kConfigLocations = {"/odm/etc", "/vendor/etc", "/system/etc"}; +static constexpr char kConfigFileName[] = "audio_policy_configuration.xml"; + +// Stringify the argument. +#define QUOTE(x) #x +#define STRINGIFY(x) QUOTE(x) + +TEST(CheckConfig, audioPolicyConfigurationValidation) { + RecordProperty("description", + "Verify that the audio policy configuration file " + "is valid according to the schema"); + + const char* xsd = "/data/local/tmp/audio_policy_configuration_" STRINGIFY(CPP_VERSION) ".xsd"; + EXPECT_ONE_VALID_XML_MULTIPLE_LOCATIONS(kConfigFileName, kConfigLocations, xsd); +} + +struct PolicyConfigData { + android::HwModuleCollection hwModules; + android::DeviceVector availableOutputDevices; + android::DeviceVector availableInputDevices; + sp<android::DeviceDescriptor> defaultOutputDevice; + android::VolumeCurvesCollection volumes; +}; + +class PolicyConfig : private PolicyConfigData, public AudioPolicyConfig { + public: + PolicyConfig() + : AudioPolicyConfig(hwModules, availableOutputDevices, availableInputDevices, + defaultOutputDevice, &volumes) { + for (const char* location : kConfigLocations) { + std::string path = std::string(location) + '/' + kConfigFileName; + if (access(path.c_str(), F_OK) == 0) { + mFilePath = path; + break; + } + } + mStatus = android::deserializeAudioPolicyFile(mFilePath.c_str(), this); + if (mStatus == OK) { + mPrimaryModule = getHwModules().getModuleFromName("primary"); + } + } + status_t getStatus() const { return mStatus; } + std::string getError() const { + if (mFilePath.empty()) { + return std::string{"Could not find "} + kConfigFileName + + " file in: " + testing::PrintToString(kConfigLocations); + } else { + return "Invalid config file: " + mFilePath; + } + } + const std::string& getFilePath() const { return mFilePath; } + sp<const HwModule> getPrimaryModule() const { return mPrimaryModule; } + + private: + status_t mStatus = NO_INIT; + std::string mFilePath; + sp<HwModule> mPrimaryModule = nullptr; +}; + +// Cached policy config after parsing for faster test startup +const PolicyConfig& getCachedPolicyConfig() { + static std::unique_ptr<PolicyConfig> policyConfig = [] { + auto config = std::make_unique<PolicyConfig>(); + environment->registerTearDown([] { policyConfig.reset(); }); + return config; + }(); + return *policyConfig; +} + +class AudioPolicyConfigTest : public HidlTest { + public: + void SetUp() override { + ASSERT_NO_FATAL_FAILURE(HidlTest::SetUp()); // setup base + + auto& policyConfig = getCachedPolicyConfig(); + ASSERT_EQ(0, policyConfig.getStatus()) << policyConfig.getError(); + + mPrimaryConfig = policyConfig.getPrimaryModule(); + ASSERT_TRUE(mPrimaryConfig) << "Could not find primary module in configuration file: " + << policyConfig.getFilePath(); + } + sp<const HwModule> mPrimaryConfig = nullptr; +}; + +TEST_F(AudioPolicyConfigTest, LoadAudioPolicyXMLConfiguration) { + doc::test("Test parsing audio_policy_configuration.xml (called in SetUp)"); +} + +////////////////////////////////////////////////////////////////////////////// ////////////////////// getService audio_devices_factory ////////////////////// ////////////////////////////////////////////////////////////////////////////// // Test all audio devices -class AudioHidlTest : public HidlTest { +class AudioHidlTest : public AudioPolicyConfigTest { public: void SetUp() override { ASSERT_NO_FATAL_FAILURE(HidlTest::SetUp()); // setup base @@ -166,34 +270,16 @@ TEST_F(AudioHidlTest, OpenDeviceInvalidParameter) { doc::test("Test passing an invalid parameter to openDevice"); Result result; sp<IDevice> device; - ASSERT_OK(devicesFactory->openDevice("Non existing device", returnIn(result, device))); +#if MAJOR_VERSION == 2 + auto invalidDevice = IDevicesFactory::Device(-1); +#elif MAJOR_VERSION >= 4 + auto invalidDevice = "Non existing device"; +#endif + ASSERT_OK(devicesFactory->openDevice(invalidDevice, returnIn(result, device))); ASSERT_EQ(Result::INVALID_ARGUMENTS, result); ASSERT_TRUE(device == nullptr); } -TEST_F(AudioHidlTest, OpenPrimaryDeviceUsingGetDevice) { - doc::test("Calling openDevice(\"primary\") should return the primary device."); - { - Result result; - sp<IDevice> baseDevice; - ASSERT_OK(devicesFactory->openDevice("primary", returnIn(result, baseDevice))); - ASSERT_OK(result); - ASSERT_TRUE(baseDevice != nullptr); - - Return<sp<IPrimaryDevice>> primaryDevice = IPrimaryDevice::castFrom(baseDevice); - ASSERT_TRUE(primaryDevice.isOk()); - ASSERT_TRUE(sp<IPrimaryDevice>(primaryDevice) != nullptr); - } // Destroy local IDevice proxy - // FIXME: there is no way to know when the remote IDevice is being destroyed - // Binder does not support testing if an object is alive, thus - // wait for 100ms to let the binder destruction propagates and - // the remote device has the time to be destroyed. - // flushCommand makes sure all local command are sent, thus should reduce - // the latency between local and remote destruction. - IPCThreadState::self()->flushCommands(); - usleep(100); -} - ////////////////////////////////////////////////////////////////////////////// /////////////////////////////// openDevice primary /////////////////////////// ////////////////////////////////////////////////////////////////////////////// @@ -206,11 +292,8 @@ class AudioPrimaryHidlTest : public AudioHidlTest { ASSERT_NO_FATAL_FAILURE(AudioHidlTest::SetUp()); // setup base if (device == nullptr) { - Result result; - ASSERT_OK(devicesFactory->openPrimaryDevice(returnIn(result, device))); - ASSERT_OK(result); + initPrimaryDevice(); ASSERT_TRUE(device != nullptr); - environment->registerTearDown([] { device.clear(); }); } } @@ -218,6 +301,23 @@ class AudioPrimaryHidlTest : public AudioHidlTest { protected: // Cache the device opening to speed up each test by ~0.5s static sp<IPrimaryDevice> device; + + private: + void initPrimaryDevice() { + Result result; +#if MAJOR_VERSION == 2 + sp<IDevice> baseDevice; + ASSERT_OK(devicesFactory->openDevice(IDevicesFactory::Device::PRIMARY, + returnIn(result, baseDevice))); + ASSERT_OK(result); + ASSERT_TRUE(baseDevice != nullptr); + + device = IPrimaryDevice::castFrom(baseDevice); +#elif MAJOR_VERSION >= 4 + ASSERT_OK(devicesFactory->openPrimaryDevice(returnIn(result, device))); + ASSERT_OK(result); +#endif + } }; sp<IPrimaryDevice> AudioPrimaryHidlTest::device; @@ -350,6 +450,20 @@ TEST_F(AudioPatchPrimaryHidlTest, AudioPatches) { class AudioConfigPrimaryTest : public AudioPatchPrimaryHidlTest { public: + // for retro compatibility only test the primary device IN_BUILTIN_MIC + // FIXME: in the next audio HAL version, test all available devices + static bool primaryHasMic() { + auto& policyConfig = getCachedPolicyConfig(); + if (policyConfig.getStatus() != OK || policyConfig.getPrimaryModule() == nullptr) { + return true; // Could not get the information, run all tests + } + auto getMic = [](auto& devs) { return devs.getDevice(AUDIO_DEVICE_IN_BUILTIN_MIC, {}); }; + auto primaryMic = getMic(policyConfig.getPrimaryModule()->getDeclaredDevices()); + auto availableMic = getMic(policyConfig.getAvailableInputDevices()); + + return primaryMic != nullptr && primaryMic->equals(availableMic); + } + // Cache result ? static const vector<AudioConfig> getRequiredSupportPlaybackAudioConfig() { return combineAudioConfig({AudioChannelMask::OUT_STEREO, AudioChannelMask::OUT_MONO}, @@ -369,10 +483,12 @@ class AudioConfigPrimaryTest : public AudioPatchPrimaryHidlTest { } static const vector<AudioConfig> getRequiredSupportCaptureAudioConfig() { + if (!primaryHasMic()) return {}; return combineAudioConfig({AudioChannelMask::IN_MONO}, {8000, 11025, 16000, 44100}, {AudioFormat::PCM_16_BIT}); } static const vector<AudioConfig> getRecommendedSupportCaptureAudioConfig() { + if (!primaryHasMic()) return {}; return combineAudioConfig({AudioChannelMask::IN_STEREO}, {22050, 48000}, {AudioFormat::PCM_16_BIT}); } @@ -392,7 +508,7 @@ class AudioConfigPrimaryTest : public AudioPatchPrimaryHidlTest { for (auto format : formats) { AudioConfig config{}; // leave offloadInfo to 0 - config.channelMask = mkBitfield(channelMask); + config.channelMask = mkEnumBitfield(channelMask); config.sampleRateHz = sampleRate; config.format = format; // FIXME: leave frameCount to 0 ? @@ -413,8 +529,8 @@ static string generateTestName(const testing::TestParamInfo<AudioConfig>& info) const AudioConfig& config = info.param; return to_string(info.index) + "__" + to_string(config.sampleRateHz) + "_" + // "MONO" is more clear than "FRONT_LEFT" - ((config.channelMask == mkBitfield(AudioChannelMask::OUT_MONO) || - config.channelMask == mkBitfield(AudioChannelMask::IN_MONO)) + ((config.channelMask == mkEnumBitfield(AudioChannelMask::OUT_MONO) || + config.channelMask == mkEnumBitfield(AudioChannelMask::IN_MONO)) ? "MONO" : ::testing::PrintToString(config.channelMask)); } @@ -501,91 +617,10 @@ TEST_F(AudioPrimaryHidlTest, getParameters) { hidl_vec<ParameterValue> context; hidl_vec<hidl_string> keys; hidl_vec<ParameterValue> values; - ASSERT_OK(device->getParameters(context, keys, returnIn(res, values))); - ASSERT_OK(device->setParameters(context, values)); + ASSERT_OK(Parameters::get(device, keys, returnIn(res, values))); + ASSERT_OK(Parameters::set(device, values)); values.resize(0); - ASSERT_OK(device->setParameters(context, values)); -} - -////////////////////////////////////////////////////////////////////////////// -/////////////////////////// get(Active)Microphones /////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -TEST_F(AudioPrimaryHidlTest, GetMicrophonesTest) { - doc::test("Make sure getMicrophones always succeeds"); - hidl_vec<MicrophoneInfo> microphones; - ASSERT_OK(device->getMicrophones(returnIn(res, microphones))); - ASSERT_OK(res); - if (microphones.size() > 0) { - // When there is microphone on the phone, try to open an input stream - // and query for the active microphones. - doc::test( - "Make sure getMicrophones always succeeds" - "and getActiveMicrophones always succeeds when recording from these microphones."); - AudioIoHandle ioHandle = (AudioIoHandle)AudioHandleConsts::AUDIO_IO_HANDLE_NONE; - AudioConfig config{}; - config.channelMask = mkBitfield(AudioChannelMask::IN_MONO); - config.sampleRateHz = 8000; - config.format = AudioFormat::PCM_16_BIT; - auto flags = hidl_bitfield<AudioInputFlag>(AudioInputFlag::NONE); - const SinkMetadata initialMetadata = {{{AudioSource::MIC, 1 /* gain */}}}; - EventFlag* efGroup; - for (auto microphone : microphones) { - if (microphone.deviceAddress.device != AudioDevice::IN_BUILTIN_MIC) { - continue; - } - sp<IStreamIn> stream; - AudioConfig suggestedConfig{}; - ASSERT_OK(device->openInputStream(ioHandle, microphone.deviceAddress, config, flags, - initialMetadata, - returnIn(res, stream, suggestedConfig))); - if (res != Result::OK) { - ASSERT_TRUE(stream == nullptr); - AudioConfig suggestedConfigRetry{}; - ASSERT_OK(device->openInputStream(ioHandle, microphone.deviceAddress, - suggestedConfig, flags, initialMetadata, - returnIn(res, stream, suggestedConfigRetry))); - } - ASSERT_OK(res); - hidl_vec<MicrophoneInfo> activeMicrophones; - Result readRes; - typedef MessageQueue<ReadParameters, kSynchronizedReadWrite> CommandMQ; - typedef MessageQueue<uint8_t, kSynchronizedReadWrite> DataMQ; - std::unique_ptr<CommandMQ> commandMQ; - std::unique_ptr<DataMQ> dataMQ; - size_t frameSize = stream->getFrameSize(); - size_t frameCount = stream->getBufferSize() / frameSize; - ASSERT_OK(stream->prepareForReading( - frameSize, frameCount, [&](auto r, auto& c, auto& d, auto&, auto&) { - readRes = r; - if (readRes == Result::OK) { - commandMQ.reset(new CommandMQ(c)); - dataMQ.reset(new DataMQ(d)); - if (dataMQ->isValid() && dataMQ->getEventFlagWord()) { - EventFlag::createEventFlag(dataMQ->getEventFlagWord(), &efGroup); - } - } - })); - ASSERT_OK(readRes); - ReadParameters params; - params.command = IStreamIn::ReadCommand::READ; - ASSERT_TRUE(commandMQ != nullptr); - ASSERT_TRUE(commandMQ->isValid()); - ASSERT_TRUE(commandMQ->write(¶ms)); - efGroup->wake(static_cast<uint32_t>(MessageQueueFlagBits::NOT_FULL)); - uint32_t efState = 0; - efGroup->wait(static_cast<uint32_t>(MessageQueueFlagBits::NOT_EMPTY), &efState); - if (efState & static_cast<uint32_t>(MessageQueueFlagBits::NOT_EMPTY)) { - ASSERT_OK(stream->getActiveMicrophones(returnIn(res, activeMicrophones))); - ASSERT_OK(res); - ASSERT_NE(0U, activeMicrophones.size()); - } - stream->close(); - if (efGroup) { - EventFlag::deleteEventFlag(&efGroup); - } - } - } + ASSERT_OK(Parameters::set(device, values)); } ////////////////////////////////////////////////////////////////////////////// @@ -628,32 +663,12 @@ static void testDebugDump(DebugDump debugDump) { TEST_F(AudioPrimaryHidlTest, DebugDump) { doc::test("Check that the hal can dump its state without error"); - testDebugDump([](const auto& handle) { return device->debug(handle, {/* options */}); }); + testDebugDump([](const auto& handle) { return dump(device, handle); }); } TEST_F(AudioPrimaryHidlTest, DebugDumpInvalidArguments) { doc::test("Check that the hal dump doesn't crash on invalid arguments"); - ASSERT_OK(device->debug(hidl_handle(), {/* options */})); -} - -TEST_F(AudioPrimaryHidlTest, SetConnectedState) { - doc::test("Check that the HAL can be notified of device connection and deconnection"); - using AD = AudioDevice; - for (auto deviceType : {AD::OUT_HDMI, AD::OUT_WIRED_HEADPHONE, AD::IN_USB_HEADSET}) { - SCOPED_TRACE("device=" + ::testing::PrintToString(deviceType)); - for (bool state : {true, false}) { - SCOPED_TRACE("state=" + ::testing::PrintToString(state)); - DeviceAddress address = {}; - address.device = deviceType; - auto ret = device->setConnectedState(address, state); - ASSERT_TRUE(ret.isOk()); - if (ret == Result::NOT_SUPPORTED) { - doc::partialTest("setConnectedState is not supported"); - return; - } - ASSERT_OK(ret); - } - } + ASSERT_OK(dump(device, hidl_handle())); } ////////////////////////////////////////////////////////////////////////////// @@ -723,18 +738,25 @@ class OutputStreamTest : public OpenStreamTest<IStreamOut> { address.device = AudioDevice::OUT_DEFAULT; const AudioConfig& config = GetParam(); // TODO: test all flag combination - auto flags = hidl_bitfield<AudioOutputFlag>(AudioOutputFlag::NONE); + auto flags = mkEnumBitfield(AudioOutputFlag::NONE); testOpen( [&](AudioIoHandle handle, AudioConfig config, auto cb) { - return device->openOutputStream(handle, address, config, flags, initialMetadata, - cb); +#if MAJOR_VERSION == 2 + return device->openOutputStream(handle, address, config, flags, cb); +#elif MAJOR_VERSION >= 4 + return device->openOutputStream(handle, address, config, flags, initMetadata, cb); +#endif }, config); } +#if MAJOR_VERSION >= 4 protected: - const SourceMetadata initialMetadata = { - {{AudioUsage::MEDIA, AudioContentType::MUSIC, 1 /* gain */}}}; + const SourceMetadata initMetadata = { + { { AudioUsage::MEDIA, + AudioContentType::MUSIC, + 1 /* gain */ } }}; +#endif }; TEST_P(OutputStreamTest, OpenOutputStreamTest) { doc::test( @@ -764,16 +786,20 @@ class InputStreamTest : public OpenStreamTest<IStreamIn> { address.device = AudioDevice::IN_DEFAULT; const AudioConfig& config = GetParam(); // TODO: test all supported flags and source - auto flags = hidl_bitfield<AudioInputFlag>(AudioInputFlag::NONE); + auto flags = mkEnumBitfield(AudioInputFlag::NONE); testOpen( [&](AudioIoHandle handle, AudioConfig config, auto cb) { - return device->openInputStream(handle, address, config, flags, initialMetadata, cb); + return device->openInputStream(handle, address, config, flags, initMetadata, cb); }, config); } protected: - const SinkMetadata initialMetadata = {{{AudioSource::DEFAULT, 1 /* gain */}}}; +#if MAJOR_VERSION == 2 + const AudioSource initMetadata = AudioSource::DEFAULT; +#elif MAJOR_VERSION >= 4 + const SinkMetadata initMetadata = {{{AudioSource::DEFAULT, 1 /* gain */}}}; +#endif }; TEST_P(InputStreamTest, OpenInputStreamTest) { @@ -842,19 +868,20 @@ TEST_IO_STREAM(GetFrameSize, "Check that the stream frame size == the one it was TEST_IO_STREAM(GetBufferSize, "Check that the stream buffer size== the one it was opened with", ASSERT_GE(extract(stream->getBufferSize()), extract(stream->getFrameSize()))); -template <class Property, class CapablityGetter> +template <class Property, class CapabilityGetter> static void testCapabilityGetter(const string& name, IStream* stream, - CapablityGetter capablityGetter, + CapabilityGetter capabilityGetter, Return<Property> (IStream::*getter)(), Return<Result> (IStream::*setter)(Property), bool currentMustBeSupported = true) { hidl_vec<Property> capabilities; - auto ret = capablityGetter(stream, capabilities); - if (ret == Result::NOT_SUPPORTED) { + auto ret = capabilityGetter(stream, capabilities); + ASSERT_RESULT(okOrNotSupported, ret); + bool notSupported = ret == Result::NOT_SUPPORTED; + if (notSupported) { doc::partialTest(name + " is not supported"); return; }; - ASSERT_OK(ret); if (currentMustBeSupported) { ASSERT_NE(0U, capabilities.size()) << name << " must not return an empty list"; @@ -878,29 +905,9 @@ static void testCapabilityGetter(const string& name, IStream* stream, } } -Result getSupportedSampleRates(IStream* stream, hidl_vec<uint32_t>& rates) { - Result res; - EXPECT_OK(stream->getSupportedSampleRates(extract(stream->getFormat()), returnIn(res, rates))); - return res; -} - -Result getSupportedChannelMasks(IStream* stream, - hidl_vec<hidl_bitfield<AudioChannelMask>>& channels) { - Result res; - EXPECT_OK( - stream->getSupportedChannelMasks(extract(stream->getFormat()), returnIn(res, channels))); - return res; -} - -Result getSupportedFormats(IStream* stream, hidl_vec<AudioFormat>& capabilities) { - EXPECT_OK(stream->getSupportedFormats(returnIn(capabilities))); - // TODO: this should be an optional function - return Result::OK; -} - TEST_IO_STREAM(SupportedSampleRate, "Check that the stream sample rate is declared as supported", testCapabilityGetter("getSupportedSampleRate", stream.get(), - &getSupportedSampleRates, &IStream::getSampleRate, + &GetSupported::sampleRates, &IStream::getSampleRate, &IStream::setSampleRate, // getSupportedSampleRate returns the native sampling rates, // (the sampling rates that can be played without resampling) @@ -909,48 +916,16 @@ TEST_IO_STREAM(SupportedSampleRate, "Check that the stream sample rate is declar TEST_IO_STREAM(SupportedChannelMask, "Check that the stream channel mask is declared as supported", testCapabilityGetter("getSupportedChannelMask", stream.get(), - &getSupportedChannelMasks, &IStream::getChannelMask, + &GetSupported::channelMasks, &IStream::getChannelMask, &IStream::setChannelMask)) TEST_IO_STREAM(SupportedFormat, "Check that the stream format is declared as supported", - testCapabilityGetter("getSupportedFormat", stream.get(), &getSupportedFormats, + testCapabilityGetter("getSupportedFormat", stream.get(), &GetSupported::formats, &IStream::getFormat, &IStream::setFormat)) -static void testGetDevices(IStream* stream, AudioDevice expectedDevice) { - hidl_vec<DeviceAddress> devices; - Result res; - ASSERT_OK(stream->getDevices(returnIn(res, devices))); - if (res == Result::NOT_SUPPORTED) { - return doc::partialTest("GetDevices is not supported"); - } - // The stream was constructed with one device, thus getDevices must only return one - ASSERT_EQ(1U, devices.size()); - AudioDevice device = devices[0].device; - ASSERT_TRUE(device == expectedDevice) - << "Expected: " << ::testing::PrintToString(expectedDevice) - << "\n Actual: " << ::testing::PrintToString(device); -} - -TEST_IO_STREAM(GetDevices, "Check that the stream device == the one it was opened with", - areAudioPatchesSupported() ? doc::partialTest("Audio patches are supported") - : testGetDevices(stream.get(), address.device)) - -static void testSetDevices(IStream* stream, const DeviceAddress& address) { - DeviceAddress otherAddress = address; - otherAddress.device = (address.device & AudioDevice::BIT_IN) == 0 ? AudioDevice::OUT_SPEAKER - : AudioDevice::IN_BUILTIN_MIC; - EXPECT_OK(stream->setDevices({otherAddress})); - - ASSERT_OK(stream->setDevices({address})); // Go back to the original value -} - -TEST_IO_STREAM(SetDevices, "Check that the stream can be rerouted to SPEAKER or BUILTIN_MIC", - areAudioPatchesSupported() ? doc::partialTest("Audio patches are supported") - : testSetDevices(stream.get(), address)) - static void testGetAudioProperties(IStream* stream, AudioConfig expectedConfig) { uint32_t sampleRateHz; - hidl_bitfield<AudioChannelMask> mask; + auto mask = mkEnumBitfield<AudioChannelMask>({}); AudioFormat format; stream->getAudioProperties(returnIn(sampleRateHz, mask, format)); @@ -969,23 +944,11 @@ TEST_IO_STREAM(GetAudioProperties, TEST_IO_STREAM(SetHwAvSync, "Try to set hardware sync to an invalid value", ASSERT_RESULT(okOrNotSupportedOrInvalidArgs, stream->setHwAvSync(666))) -static void checkGetHwAVSync(IDevice* device) { - Result res; - AudioHwSync sync; - ASSERT_OK(device->getHwAvSync(returnIn(res, sync))); - if (res == Result::NOT_SUPPORTED) { - return doc::partialTest("getHwAvSync is not supported"); - } - ASSERT_OK(res); -} -TEST_IO_STREAM(GetHwAvSync, "Get hardware sync can not fail", checkGetHwAVSync(device.get())); - static void checkGetNoParameter(IStream* stream, hidl_vec<hidl_string> keys, initializer_list<Result> expectedResults) { - hidl_vec<ParameterValue> context; hidl_vec<ParameterValue> parameters; Result res; - ASSERT_OK(stream->getParameters(context, keys, returnIn(res, parameters))); + ASSERT_OK(Parameters::get(stream, keys, returnIn(res, parameters))); ASSERT_RESULT(expectedResults, res); if (res == Result::OK) { for (auto& parameter : parameters) { @@ -1006,7 +969,7 @@ TEST_IO_STREAM(getNonExistingParameter, "Retrieve the values of an non existing {Result::NOT_SUPPORTED})) TEST_IO_STREAM(setEmptySetParameter, "Set the values of an empty set of parameters", - ASSERT_RESULT(Result::OK, stream->setParameters({}, {}))) + ASSERT_RESULT(Result::OK, Parameters::set(stream, {}))) TEST_IO_STREAM(setNonExistingParameter, "Set the values of an non existing parameter", // Unfortunately, the set_parameter legacy interface did not return any @@ -1014,14 +977,14 @@ TEST_IO_STREAM(setNonExistingParameter, "Set the values of an non existing param // To allow implementation to just wrapped the legacy one, consider OK as a // valid result for setting a non existing parameter. ASSERT_RESULT(okOrNotSupportedOrInvalidArgs, - stream->setParameters({}, {{"non existing key", "0"}}))) + Parameters::set(stream, {{"non existing key", "0"}}))) TEST_IO_STREAM(DebugDump, "Check that a stream can dump its state without error", - testDebugDump([this](const auto& handle) { return stream->debug(handle, {}); })) + testDebugDump([this](const auto& handle) { return dump(stream, handle); })) TEST_IO_STREAM(DebugDumpInvalidArguments, "Check that the stream dump doesn't crash on invalid arguments", - ASSERT_OK(stream->debug(hidl_handle(), {}))) + ASSERT_OK(dump(stream, hidl_handle()))) ////////////////////////////////////////////////////////////////////////////// ////////////////////////////// addRemoveEffect /////////////////////////////// @@ -1171,28 +1134,6 @@ TEST_P(InputStreamTest, getCapturePosition) { } } -TEST_P(InputStreamTest, updateSinkMetadata) { - doc::test("The HAL should not crash on metadata change"); - - hidl_enum_range<AudioSource> range; - // Test all possible track configuration - for (AudioSource source : range) { - for (float volume : {0.0, 0.5, 1.0}) { - const SinkMetadata metadata = {{{source, volume}}}; - ASSERT_OK(stream->updateSinkMetadata(metadata)) - << "source=" << toString(source) << ", volume=" << volume; - } - } - - // Do not test concurrent capture as this is not officially supported - - // Set no metadata as if all stream track had stopped - ASSERT_OK(stream->updateSinkMetadata({})); - - // Restore initial - ASSERT_OK(stream->updateSinkMetadata(initialMetadata)); -} - ////////////////////////////////////////////////////////////////////////////// ///////////////////////////////// StreamOut ////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// @@ -1410,42 +1351,6 @@ TEST_P(OutputStreamTest, GetPresentationPositionStop) { ASSERT_PRED2([](auto c, auto m) { return c - m < 1e+6; }, currentTime, mesureTime); } -TEST_P(OutputStreamTest, SelectPresentation) { - doc::test("Verify that presentation selection does not crash"); - ASSERT_RESULT(okOrNotSupported, stream->selectPresentation(0, 0)); -} - -TEST_P(OutputStreamTest, updateSourceMetadata) { - doc::test("The HAL should not crash on metadata change"); - - hidl_enum_range<AudioUsage> usageRange; - hidl_enum_range<AudioContentType> contentRange; - // Test all possible track configuration - for (auto usage : usageRange) { - for (auto content : contentRange) { - for (float volume : {0.0, 0.5, 1.0}) { - const SourceMetadata metadata = {{{usage, content, volume}}}; - ASSERT_OK(stream->updateSourceMetadata(metadata)) - << "usage=" << toString(usage) << ", content=" << toString(content) - << ", volume=" << volume; - } - } - } - - // Set many track of different configuration - ASSERT_OK(stream->updateSourceMetadata( - {{{AudioUsage::MEDIA, AudioContentType::MUSIC, 0.1}, - {AudioUsage::VOICE_COMMUNICATION, AudioContentType::SPEECH, 1.0}, - {AudioUsage::ALARM, AudioContentType::SONIFICATION, 0.0}, - {AudioUsage::ASSISTANT, AudioContentType::UNKNOWN, 0.3}}})); - - // Set no metadata as if all stream track had stopped - ASSERT_OK(stream->updateSourceMetadata({})); - - // Restore initial - ASSERT_OK(stream->updateSourceMetadata(initialMetadata)); -} - ////////////////////////////////////////////////////////////////////////////// /////////////////////////////// PrimaryDevice //////////////////////////////// ////////////////////////////////////////////////////////////////////////////// @@ -1455,57 +1360,6 @@ TEST_F(AudioPrimaryHidlTest, setVoiceVolume) { testUnitaryGain([](float volume) { return device->setVoiceVolume(volume); }); } -TEST_F(AudioPrimaryHidlTest, setMode) { - doc::test("Make sure setMode always succeeds if mode is valid and fails otherwise"); - // Test Invalid values - for (int mode : {-2, -1, int(AudioMode::IN_COMMUNICATION) + 1}) { - ASSERT_RESULT(Result::INVALID_ARGUMENTS, device->setMode(AudioMode(mode))) - << "mode=" << mode; - } - // Test valid values - for (AudioMode mode : {AudioMode::IN_CALL, AudioMode::IN_COMMUNICATION, AudioMode::RINGTONE, - AudioMode::NORMAL /* Make sure to leave the test in normal mode */}) { - ASSERT_OK(device->setMode(mode)) << "mode=" << toString(mode); - } -} - -TEST_F(AudioPrimaryHidlTest, setBtHfpSampleRate) { - doc::test( - "Make sure setBtHfpSampleRate either succeeds or " - "indicates that it is not supported at all, or that the provided value is invalid"); - for (auto samplingRate : {8000, 16000, 22050, 24000}) { - ASSERT_RESULT(okOrNotSupportedOrInvalidArgs, device->setBtHfpSampleRate(samplingRate)); - } -} - -TEST_F(AudioPrimaryHidlTest, setBtHfpVolume) { - doc::test( - "Make sure setBtHfpVolume is either not supported or " - "only succeed if volume is in [0,1]"); - auto ret = device->setBtHfpVolume(0.0); - ASSERT_TRUE(ret.isOk()); - if (ret == Result::NOT_SUPPORTED) { - doc::partialTest("setBtHfpVolume is not supported"); - return; - } - testUnitaryGain([](float volume) { return device->setBtHfpVolume(volume); }); -} - -TEST_F(AudioPrimaryHidlTest, setBtScoHeadsetDebugName) { - doc::test( - "Make sure setBtScoHeadsetDebugName either succeeds or " - "indicates that it is not supported"); - ASSERT_RESULT(okOrNotSupported, device->setBtScoHeadsetDebugName("test")); -} - -TEST_F(AudioPrimaryHidlTest, updateRotation) { - doc::test("Check that the hal can receive the current rotation"); - for (Rotation rotation : {Rotation::DEG_0, Rotation::DEG_90, Rotation::DEG_180, - Rotation::DEG_270, Rotation::DEG_0}) { - ASSERT_RESULT(okOrNotSupported, device->updateRotation(rotation)); - } -} - TEST_F(BoolAccessorPrimaryHidlTest, BtScoNrecEnabled) { doc::test("Query and set the BT SCO NR&EC state"); testAccessors<OPTIONAL>("BtScoNrecEnabled", Initial{false, OPTIONAL}, {true}, @@ -1520,12 +1374,6 @@ TEST_F(BoolAccessorPrimaryHidlTest, setGetBtScoWidebandEnabled) { &IPrimaryDevice::getBtScoWidebandEnabled); } -TEST_F(BoolAccessorPrimaryHidlTest, setGetBtHfpEnabled) { - doc::test("Query and set the BT HFP state"); - testAccessors<OPTIONAL>("BtHfpEnabled", Initial{false, OPTIONAL}, {true}, - &IPrimaryDevice::setBtHfpEnabled, &IPrimaryDevice::getBtHfpEnabled); -} - using TtyModeAccessorPrimaryHidlTest = AccessorPrimaryHidlTest<TtyMode>; TEST_F(TtyModeAccessorPrimaryHidlTest, setGetTtyMode) { doc::test("Query and set the TTY mode state"); diff --git a/audio/effect/2.0/default/AcousticEchoCancelerEffect.cpp b/audio/effect/2.0/default/AcousticEchoCancelerEffect.cpp deleted file mode 100644 index cadc2f1b43..0000000000 --- a/audio/effect/2.0/default/AcousticEchoCancelerEffect.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2017 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 "AEC_Effect_HAL" - -#include "AcousticEchoCancelerEffect.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <effect/all-versions/default/AcousticEchoCancelerEffect.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/effect/2.0/default/AcousticEchoCancelerEffect.h b/audio/effect/2.0/default/AcousticEchoCancelerEffect.h deleted file mode 100644 index d36335c7b3..0000000000 --- a/audio/effect/2.0/default/AcousticEchoCancelerEffect.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_ACOUSTICECHOCANCELEREFFECT_H -#define ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_ACOUSTICECHOCANCELEREFFECT_H - -#include <android/hardware/audio/effect/2.0/IAcousticEchoCancelerEffect.h> - -#include "Effect.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <effect/all-versions/default/AcousticEchoCancelerEffect.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_ACOUSTICECHOCANCELEREFFECT_H diff --git a/audio/effect/2.0/default/Android.bp b/audio/effect/2.0/default/Android.bp deleted file mode 100644 index db0098849c..0000000000 --- a/audio/effect/2.0/default/Android.bp +++ /dev/null @@ -1,50 +0,0 @@ -cc_library_shared { - name: "android.hardware.audio.effect@2.0-impl", - defaults: ["hidl_defaults"], - vendor: true, - relative_install_path: "hw", - srcs: [ - "AcousticEchoCancelerEffect.cpp", - "AudioBufferManager.cpp", - "AutomaticGainControlEffect.cpp", - "BassBoostEffect.cpp", - "Conversions.cpp", - "DownmixEffect.cpp", - "Effect.cpp", - "EffectsFactory.cpp", - "EnvironmentalReverbEffect.cpp", - "EqualizerEffect.cpp", - "LoudnessEnhancerEffect.cpp", - "NoiseSuppressionEffect.cpp", - "PresetReverbEffect.cpp", - "VirtualizerEffect.cpp", - "VisualizerEffect.cpp", - ], - - shared_libs: [ - "libbase", - "libcutils", - "libeffects", - "libfmq", - "libhidlbase", - "libhidlmemory", - "libhidltransport", - "liblog", - "libutils", - "android.hardware.audio.common-util", - "android.hardware.audio.common@2.0", - "android.hardware.audio.common@2.0-util", - "android.hardware.audio.effect@2.0", - "android.hidl.memory@1.0", - ], - - header_libs: [ - "android.hardware.audio.common.util@all-versions", - "android.hardware.audio.effect@all-versions-impl", - "libaudio_system_headers", - "libaudioclient_headers", - "libeffects_headers", - "libhardware_headers", - "libmedia_headers", - ], -} diff --git a/audio/effect/2.0/default/AudioBufferManager.cpp b/audio/effect/2.0/default/AudioBufferManager.cpp deleted file mode 100644 index 39918dd1c7..0000000000 --- a/audio/effect/2.0/default/AudioBufferManager.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2017 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 "AudioBufferManager.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <effect/all-versions/default/AudioBufferManager.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/effect/2.0/default/AudioBufferManager.h b/audio/effect/2.0/default/AudioBufferManager.h deleted file mode 100644 index 789fbd1c8f..0000000000 --- a/audio/effect/2.0/default/AudioBufferManager.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_AUDIO_BUFFER_MANAGER_H_ -#define ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_AUDIO_BUFFER_MANAGER_H_ - -#include <android/hardware/audio/effect/2.0/types.h> - -#define AUDIO_HAL_VERSION V2_0 -#include <effect/all-versions/default/AudioBufferManager.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_AUDIO_BUFFER_MANAGER_H_ diff --git a/audio/effect/2.0/default/AutomaticGainControlEffect.cpp b/audio/effect/2.0/default/AutomaticGainControlEffect.cpp deleted file mode 100644 index 7e00a8065f..0000000000 --- a/audio/effect/2.0/default/AutomaticGainControlEffect.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2017 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 "AGC_Effect_HAL" - -#include "AutomaticGainControlEffect.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <effect/all-versions/default/AutomaticGainControlEffect.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/effect/2.0/default/AutomaticGainControlEffect.h b/audio/effect/2.0/default/AutomaticGainControlEffect.h deleted file mode 100644 index ef440d2e40..0000000000 --- a/audio/effect/2.0/default/AutomaticGainControlEffect.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_AUTOMATICGAINCONTROLEFFECT_H -#define ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_AUTOMATICGAINCONTROLEFFECT_H - -#include <android/hardware/audio/effect/2.0/IAutomaticGainControlEffect.h> - -#include "Effect.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <effect/all-versions/default/AutomaticGainControlEffect.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_AUTOMATICGAINCONTROLEFFECT_H diff --git a/audio/effect/2.0/default/BassBoostEffect.cpp b/audio/effect/2.0/default/BassBoostEffect.cpp deleted file mode 100644 index df9e892d60..0000000000 --- a/audio/effect/2.0/default/BassBoostEffect.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2017 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 "BassBoost_HAL" - -#include "BassBoostEffect.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <effect/all-versions/default/BassBoostEffect.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/effect/2.0/default/BassBoostEffect.h b/audio/effect/2.0/default/BassBoostEffect.h deleted file mode 100644 index 83179e28ef..0000000000 --- a/audio/effect/2.0/default/BassBoostEffect.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_BASSBOOSTEFFECT_H -#define ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_BASSBOOSTEFFECT_H - -#include <android/hardware/audio/effect/2.0/IBassBoostEffect.h> - -#include <hidl/MQDescriptor.h> - -#include "Effect.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <effect/all-versions/default/BassBoostEffect.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_BASSBOOSTEFFECT_H diff --git a/audio/effect/2.0/default/Conversions.cpp b/audio/effect/2.0/default/Conversions.cpp deleted file mode 100644 index b59752c982..0000000000 --- a/audio/effect/2.0/default/Conversions.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2017 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 "Conversions.h" -#include "HidlUtils.h" - -using ::android::hardware::audio::common::V2_0::HidlUtils; - -#define AUDIO_HAL_VERSION V2_0 -#include <effect/all-versions/default/Conversions.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/effect/2.0/default/Conversions.h b/audio/effect/2.0/default/Conversions.h deleted file mode 100644 index 94c7f66ea6..0000000000 --- a/audio/effect/2.0/default/Conversions.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_CONVERSIONS_H_ -#define ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_CONVERSIONS_H_ - -#include <android/hardware/audio/effect/2.0/types.h> - -#define AUDIO_HAL_VERSION V2_0 -#include <effect/all-versions/default/Conversions.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_CONVERSIONS_H_ diff --git a/audio/effect/2.0/default/DownmixEffect.cpp b/audio/effect/2.0/default/DownmixEffect.cpp deleted file mode 100644 index 1a51e13641..0000000000 --- a/audio/effect/2.0/default/DownmixEffect.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2017 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 "Downmix_HAL" - -#include "DownmixEffect.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <effect/all-versions/default/DownmixEffect.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/effect/2.0/default/DownmixEffect.h b/audio/effect/2.0/default/DownmixEffect.h deleted file mode 100644 index 6dbbb32836..0000000000 --- a/audio/effect/2.0/default/DownmixEffect.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_DOWNMIXEFFECT_H -#define ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_DOWNMIXEFFECT_H - -#include <android/hardware/audio/effect/2.0/IDownmixEffect.h> - -#include "Effect.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <effect/all-versions/default/DownmixEffect.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_DOWNMIXEFFECT_H diff --git a/audio/effect/2.0/default/Effect.cpp b/audio/effect/2.0/default/Effect.cpp deleted file mode 100644 index e234e520b8..0000000000 --- a/audio/effect/2.0/default/Effect.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2017 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 <memory.h> - -#define LOG_TAG "EffectHAL" -#define ATRACE_TAG ATRACE_TAG_AUDIO - -#include "Conversions.h" -#include "Effect.h" -#include "common/all-versions/default/EffectMap.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <effect/all-versions/default/Effect.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/effect/2.0/default/Effect.h b/audio/effect/2.0/default/Effect.h deleted file mode 100644 index a4d194dab9..0000000000 --- a/audio/effect/2.0/default/Effect.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_EFFECT_H -#define ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_EFFECT_H - -#include <android/hardware/audio/effect/2.0/IEffect.h> - -#include "AudioBufferManager.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <effect/all-versions/default/Effect.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_EFFECT_H diff --git a/audio/effect/2.0/default/EffectsFactory.cpp b/audio/effect/2.0/default/EffectsFactory.cpp deleted file mode 100644 index a48a85f7c2..0000000000 --- a/audio/effect/2.0/default/EffectsFactory.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2017 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 "EffectFactoryHAL" -#include "EffectsFactory.h" -#include "AcousticEchoCancelerEffect.h" -#include "AutomaticGainControlEffect.h" -#include "BassBoostEffect.h" -#include "Conversions.h" -#include "DownmixEffect.h" -#include "Effect.h" -#include "EnvironmentalReverbEffect.h" -#include "EqualizerEffect.h" -#include "HidlUtils.h" -#include "LoudnessEnhancerEffect.h" -#include "NoiseSuppressionEffect.h" -#include "PresetReverbEffect.h" -#include "VirtualizerEffect.h" -#include "VisualizerEffect.h" -#include "common/all-versions/default/EffectMap.h" - -using ::android::hardware::audio::common::V2_0::HidlUtils; - -#define AUDIO_HAL_VERSION V2_0 -#include <effect/all-versions/default/EffectsFactory.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/effect/2.0/default/EffectsFactory.h b/audio/effect/2.0/default/EffectsFactory.h deleted file mode 100644 index f1bfbcff4c..0000000000 --- a/audio/effect/2.0/default/EffectsFactory.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_EFFECTSFACTORY_H -#define ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_EFFECTSFACTORY_H - -#include <system/audio_effect.h> - -#include <android/hardware/audio/effect/2.0/IEffectsFactory.h> - -#include <hidl/MQDescriptor.h> -#define AUDIO_HAL_VERSION V2_0 -#include <effect/all-versions/default/EffectsFactory.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_EFFECTSFACTORY_H diff --git a/audio/effect/2.0/default/EnvironmentalReverbEffect.cpp b/audio/effect/2.0/default/EnvironmentalReverbEffect.cpp deleted file mode 100644 index 017dd1f4cb..0000000000 --- a/audio/effect/2.0/default/EnvironmentalReverbEffect.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2017 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 "EnvReverb_HAL" -#include <android/log.h> - -#include "EnvironmentalReverbEffect.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <effect/all-versions/default/EnvironmentalReverbEffect.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/effect/2.0/default/EnvironmentalReverbEffect.h b/audio/effect/2.0/default/EnvironmentalReverbEffect.h deleted file mode 100644 index d93a53f42f..0000000000 --- a/audio/effect/2.0/default/EnvironmentalReverbEffect.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_ENVIRONMENTALREVERBEFFECT_H -#define ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_ENVIRONMENTALREVERBEFFECT_H - -#include <system/audio_effects/effect_environmentalreverb.h> - -#include <android/hardware/audio/effect/2.0/IEnvironmentalReverbEffect.h> - -#include "Effect.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <effect/all-versions/default/EnvironmentalReverbEffect.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_ENVIRONMENTALREVERBEFFECT_H diff --git a/audio/effect/2.0/default/EqualizerEffect.cpp b/audio/effect/2.0/default/EqualizerEffect.cpp deleted file mode 100644 index d6e056c421..0000000000 --- a/audio/effect/2.0/default/EqualizerEffect.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2017 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 "Equalizer_HAL" - -#include "EqualizerEffect.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <effect/all-versions/default/EqualizerEffect.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/effect/2.0/default/EqualizerEffect.h b/audio/effect/2.0/default/EqualizerEffect.h deleted file mode 100644 index 54cdd50e13..0000000000 --- a/audio/effect/2.0/default/EqualizerEffect.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_EQUALIZEREFFECT_H -#define ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_EQUALIZEREFFECT_H - -#include <android/hardware/audio/effect/2.0/IEqualizerEffect.h> - -#include "Effect.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <effect/all-versions/default/EqualizerEffect.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_EQUALIZEREFFECT_H diff --git a/audio/effect/2.0/default/LoudnessEnhancerEffect.cpp b/audio/effect/2.0/default/LoudnessEnhancerEffect.cpp deleted file mode 100644 index 2dca0f4c39..0000000000 --- a/audio/effect/2.0/default/LoudnessEnhancerEffect.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2017 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 "LoudnessEnhancer_HAL" - -#include "LoudnessEnhancerEffect.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <effect/all-versions/default/LoudnessEnhancerEffect.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/effect/2.0/default/LoudnessEnhancerEffect.h b/audio/effect/2.0/default/LoudnessEnhancerEffect.h deleted file mode 100644 index 992e238ef1..0000000000 --- a/audio/effect/2.0/default/LoudnessEnhancerEffect.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_LOUDNESSENHANCEREFFECT_H -#define ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_LOUDNESSENHANCEREFFECT_H - -#include <android/hardware/audio/effect/2.0/ILoudnessEnhancerEffect.h> - -#include "Effect.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <effect/all-versions/default/LoudnessEnhancerEffect.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_LOUDNESSENHANCEREFFECT_H diff --git a/audio/effect/2.0/default/NoiseSuppressionEffect.cpp b/audio/effect/2.0/default/NoiseSuppressionEffect.cpp deleted file mode 100644 index 089e811e09..0000000000 --- a/audio/effect/2.0/default/NoiseSuppressionEffect.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2017 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 "NS_Effect_HAL" - -#include "NoiseSuppressionEffect.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <effect/all-versions/default/NoiseSuppressionEffect.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/effect/2.0/default/NoiseSuppressionEffect.h b/audio/effect/2.0/default/NoiseSuppressionEffect.h deleted file mode 100644 index 0eee4b51b2..0000000000 --- a/audio/effect/2.0/default/NoiseSuppressionEffect.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_NOISESUPPRESSIONEFFECT_H -#define ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_NOISESUPPRESSIONEFFECT_H - -#include <android/hardware/audio/effect/2.0/INoiseSuppressionEffect.h> - -#include "Effect.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <effect/all-versions/default/NoiseSuppressionEffect.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_NOISESUPPRESSIONEFFECT_H diff --git a/audio/effect/2.0/default/OWNERS b/audio/effect/2.0/default/OWNERS deleted file mode 100644 index 6fdc97ca29..0000000000 --- a/audio/effect/2.0/default/OWNERS +++ /dev/null @@ -1,3 +0,0 @@ -elaurent@google.com -krocard@google.com -mnaganov@google.com diff --git a/audio/effect/2.0/default/PresetReverbEffect.cpp b/audio/effect/2.0/default/PresetReverbEffect.cpp deleted file mode 100644 index 0648f6a8eb..0000000000 --- a/audio/effect/2.0/default/PresetReverbEffect.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2017 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 "PresetReverb_HAL" - -#include "PresetReverbEffect.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <effect/all-versions/default/PresetReverbEffect.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/effect/2.0/default/PresetReverbEffect.h b/audio/effect/2.0/default/PresetReverbEffect.h deleted file mode 100644 index 1ea1626ffa..0000000000 --- a/audio/effect/2.0/default/PresetReverbEffect.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_PRESETREVERBEFFECT_H -#define ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_PRESETREVERBEFFECT_H - -#include <android/hardware/audio/effect/2.0/IPresetReverbEffect.h> - -#include "Effect.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <effect/all-versions/default/PresetReverbEffect.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_PRESETREVERBEFFECT_H diff --git a/audio/effect/2.0/default/VirtualizerEffect.cpp b/audio/effect/2.0/default/VirtualizerEffect.cpp deleted file mode 100644 index 63d3eb925f..0000000000 --- a/audio/effect/2.0/default/VirtualizerEffect.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2017 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 "Virtualizer_HAL" - -#include "VirtualizerEffect.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <effect/all-versions/default/VirtualizerEffect.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/effect/2.0/default/VirtualizerEffect.h b/audio/effect/2.0/default/VirtualizerEffect.h deleted file mode 100644 index 04f93c4c72..0000000000 --- a/audio/effect/2.0/default/VirtualizerEffect.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_VIRTUALIZEREFFECT_H -#define ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_VIRTUALIZEREFFECT_H - -#include <android/hardware/audio/effect/2.0/IVirtualizerEffect.h> - -#include "Effect.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <effect/all-versions/default/VirtualizerEffect.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_VIRTUALIZEREFFECT_H diff --git a/audio/effect/2.0/default/VisualizerEffect.cpp b/audio/effect/2.0/default/VisualizerEffect.cpp deleted file mode 100644 index 523552466d..0000000000 --- a/audio/effect/2.0/default/VisualizerEffect.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2017 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 "Visualizer_HAL" - -#include "VisualizerEffect.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <effect/all-versions/default/VisualizerEffect.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/effect/2.0/default/VisualizerEffect.h b/audio/effect/2.0/default/VisualizerEffect.h deleted file mode 100644 index 940f15de9b..0000000000 --- a/audio/effect/2.0/default/VisualizerEffect.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2017 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_VISUALIZEREFFECT_H -#define ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_VISUALIZEREFFECT_H - -#include <android/hardware/audio/effect/2.0/IVisualizerEffect.h> - -#include "Effect.h" - -#define AUDIO_HAL_VERSION V2_0 -#include <effect/all-versions/default/VisualizerEffect.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V2_0_VISUALIZEREFFECT_H diff --git a/audio/effect/2.0/vts/functional/Android.bp b/audio/effect/2.0/vts/functional/Android.bp deleted file mode 100644 index 51d2e11a19..0000000000 --- a/audio/effect/2.0/vts/functional/Android.bp +++ /dev/null @@ -1,35 +0,0 @@ -// -// Copyright (C) 2016 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. -// - -cc_test { - name: "VtsHalAudioEffectV2_0TargetTest", - defaults: ["VtsHalTargetTestDefaults"], - srcs: [ - "VtsHalAudioEffectV2_0TargetTest.cpp", - "ValidateAudioEffectsConfiguration.cpp" - ], - static_libs: [ - "android.hardware.audio.common.test.utility", - "android.hardware.audio.common@2.0", - "android.hardware.audio.effect@2.0", - "android.hidl.allocator@1.0", - "android.hidl.memory@1.0", - "libeffectsconfig", - "libicuuc", - "libicuuc_stubdata", - "libxml2", - ], -} diff --git a/audio/effect/2.0/vts/functional/VtsHalAudioEffectV2_0TargetTest.cpp b/audio/effect/2.0/vts/functional/VtsHalAudioEffectV2_0TargetTest.cpp deleted file mode 100644 index c90c4fab2e..0000000000 --- a/audio/effect/2.0/vts/functional/VtsHalAudioEffectV2_0TargetTest.cpp +++ /dev/null @@ -1,849 +0,0 @@ -/* - * Copyright (C) 2017 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 "AudioEffectHidlHalTest" -#include <android-base/logging.h> -#include <system/audio.h> - -#include <android/hardware/audio/effect/2.0/IEffect.h> -#include <android/hardware/audio/effect/2.0/IEffectsFactory.h> -#include <android/hardware/audio/effect/2.0/IEqualizerEffect.h> -#include <android/hardware/audio/effect/2.0/ILoudnessEnhancerEffect.h> -#include <android/hardware/audio/effect/2.0/types.h> -#include <android/hidl/allocator/1.0/IAllocator.h> -#include <android/hidl/memory/1.0/IMemory.h> - -#include <VtsHalHidlTargetTestBase.h> -#include <VtsHalHidlTargetTestEnvBase.h> - -using android::hardware::audio::common::V2_0::AudioDevice; -using android::hardware::audio::common::V2_0::AudioHandleConsts; -using android::hardware::audio::common::V2_0::AudioMode; -using android::hardware::audio::common::V2_0::AudioSource; -using android::hardware::audio::common::V2_0::Uuid; -using android::hardware::audio::effect::V2_0::AudioBuffer; -using android::hardware::audio::effect::V2_0::EffectAuxChannelsConfig; -using android::hardware::audio::effect::V2_0::EffectBufferConfig; -using android::hardware::audio::effect::V2_0::EffectConfig; -using android::hardware::audio::effect::V2_0::EffectDescriptor; -using android::hardware::audio::effect::V2_0::EffectOffloadParameter; -using android::hardware::audio::effect::V2_0::IEffect; -using android::hardware::audio::effect::V2_0::IEffectsFactory; -using android::hardware::audio::effect::V2_0::IEqualizerEffect; -using android::hardware::audio::effect::V2_0::ILoudnessEnhancerEffect; -using android::hardware::audio::effect::V2_0::Result; -using android::hardware::MQDescriptorSync; -using android::hardware::Return; -using android::hardware::Void; -using android::hardware::hidl_handle; -using android::hardware::hidl_memory; -using android::hardware::hidl_string; -using android::hardware::hidl_vec; -using android::hidl::allocator::V1_0::IAllocator; -using android::hidl::memory::V1_0::IMemory; -using android::sp; - -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a))) -#endif - -// Test environment for Audio Effects Factory HIDL HAL. -class AudioEffectsFactoryHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { - public: - // get the test environment singleton - static AudioEffectsFactoryHidlEnvironment* Instance() { - static AudioEffectsFactoryHidlEnvironment* instance = - new AudioEffectsFactoryHidlEnvironment; - return instance; - } - - virtual void registerTestServices() override { registerTestService<IEffectsFactory>(); } -}; - -// The main test class for Audio Effects Factory HIDL HAL. -class AudioEffectsFactoryHidlTest : public ::testing::VtsHalHidlTargetTestBase { - public: - void SetUp() override { - effectsFactory = ::testing::VtsHalHidlTargetTestBase::getService<IEffectsFactory>( - AudioEffectsFactoryHidlEnvironment::Instance()->getServiceName<IEffectsFactory>()); - ASSERT_NE(effectsFactory, nullptr); - } - - void TearDown() override { effectsFactory.clear(); } - - protected: - static void description(const std::string& description) { - RecordProperty("description", description); - } - - sp<IEffectsFactory> effectsFactory; -}; - -TEST_F(AudioEffectsFactoryHidlTest, EnumerateEffects) { - description("Verify that EnumerateEffects returns at least one effect"); - Result retval = Result::NOT_INITIALIZED; - size_t effectCount = 0; - Return<void> ret = effectsFactory->getAllDescriptors( - [&](Result r, const hidl_vec<EffectDescriptor>& result) { - retval = r; - effectCount = result.size(); - }); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::OK, retval); - EXPECT_GT(effectCount, 0u); -} - -TEST_F(AudioEffectsFactoryHidlTest, CreateEffect) { - description("Verify that an effect can be created via CreateEffect"); - bool gotEffect = false; - Uuid effectUuid; - Return<void> ret = effectsFactory->getAllDescriptors( - [&](Result r, const hidl_vec<EffectDescriptor>& result) { - if (r == Result::OK && result.size() > 0) { - gotEffect = true; - effectUuid = result[0].uuid; - } - }); - ASSERT_TRUE(ret.isOk()); - ASSERT_TRUE(gotEffect); - Result retval = Result::NOT_INITIALIZED; - sp<IEffect> effect; - ret = effectsFactory->createEffect( - effectUuid, 1 /*session*/, 1 /*ioHandle*/, - [&](Result r, const sp<IEffect>& result, uint64_t /*effectId*/) { - retval = r; - if (r == Result::OK) { - effect = result; - } - }); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::OK, retval); - EXPECT_NE(nullptr, effect.get()); -} - -TEST_F(AudioEffectsFactoryHidlTest, GetDescriptor) { - description( - "Verify that effects factory can provide an effect descriptor via " - "GetDescriptor"); - hidl_vec<EffectDescriptor> allDescriptors; - Return<void> ret = effectsFactory->getAllDescriptors( - [&](Result r, const hidl_vec<EffectDescriptor>& result) { - if (r == Result::OK) { - allDescriptors = result; - } - }); - ASSERT_TRUE(ret.isOk()); - ASSERT_GT(allDescriptors.size(), 0u); - for (size_t i = 0; i < allDescriptors.size(); ++i) { - ret = effectsFactory->getDescriptor( - allDescriptors[i].uuid, [&](Result r, const EffectDescriptor& result) { - EXPECT_EQ(r, Result::OK); - EXPECT_EQ(result, allDescriptors[i]); - }); - } - EXPECT_TRUE(ret.isOk()); -} - -TEST_F(AudioEffectsFactoryHidlTest, DebugDumpInvalidArgument) { - description("Verify that debugDump doesn't crash on invalid arguments"); - Return<void> ret = effectsFactory->debugDump(hidl_handle()); - ASSERT_TRUE(ret.isOk()); -} - -// Equalizer effect is required by CDD, but only the type is fixed. -// This is the same UUID as AudioEffect.EFFECT_TYPE_EQUALIZER in Java. -static const Uuid EQUALIZER_EFFECT_TYPE = { - 0x0bed4300, 0xddd6, 0x11db, 0x8f34, - std::array<uint8_t, 6>{{0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}}; -// Loudness Enhancer effect is required by CDD, but only the type is fixed. -// This is the same UUID as AudioEffect.EFFECT_TYPE_LOUDNESS_ENHANCER in Java. -static const Uuid LOUDNESS_ENHANCER_EFFECT_TYPE = { - 0xfe3199be, 0xaed0, 0x413f, 0x87bb, - std::array<uint8_t, 6>{{0x11, 0x26, 0x0e, 0xb6, 0x3c, 0xf1}}}; - -// The main test class for Audio Effect HIDL HAL. -class AudioEffectHidlTest : public ::testing::VtsHalHidlTargetTestBase { - public: - void SetUp() override { - effectsFactory = - ::testing::VtsHalHidlTargetTestBase::getService<IEffectsFactory>(); - ASSERT_NE(nullptr, effectsFactory.get()); - - findAndCreateEffect(getEffectType()); - ASSERT_NE(nullptr, effect.get()); - - Return<Result> ret = effect->init(); - ASSERT_TRUE(ret.isOk()); - ASSERT_EQ(Result::OK, ret); - } - - void TearDown() override { - effect.clear(); - effectsFactory.clear(); - } - - protected: - static void description(const std::string& description) { - RecordProperty("description", description); - } - - virtual Uuid getEffectType() { return EQUALIZER_EFFECT_TYPE; } - - void findAndCreateEffect(const Uuid& type); - void findEffectInstance(const Uuid& type, Uuid* uuid); - void getChannelCount(uint32_t* channelCount); - - sp<IEffectsFactory> effectsFactory; - sp<IEffect> effect; -}; - -void AudioEffectHidlTest::findAndCreateEffect(const Uuid& type) { - Uuid effectUuid; - findEffectInstance(type, &effectUuid); - Return<void> ret = effectsFactory->createEffect( - effectUuid, 1 /*session*/, 1 /*ioHandle*/, - [&](Result r, const sp<IEffect>& result, uint64_t /*effectId*/) { - if (r == Result::OK) { - effect = result; - } - }); - ASSERT_TRUE(ret.isOk()); -} - -void AudioEffectHidlTest::findEffectInstance(const Uuid& type, Uuid* uuid) { - bool effectFound = false; - Return<void> ret = effectsFactory->getAllDescriptors( - [&](Result r, const hidl_vec<EffectDescriptor>& result) { - if (r == Result::OK) { - for (const auto& desc : result) { - if (desc.type == type) { - effectFound = true; - *uuid = desc.uuid; - break; - } - } - } - }); - ASSERT_TRUE(ret.isOk()); - ASSERT_TRUE(effectFound); -} - -void AudioEffectHidlTest::getChannelCount(uint32_t* channelCount) { - Result retval; - EffectConfig currentConfig; - Return<void> ret = effect->getConfig([&](Result r, const EffectConfig& conf) { - retval = r; - if (r == Result::OK) { - currentConfig = conf; - } - }); - ASSERT_TRUE(ret.isOk()); - ASSERT_EQ(Result::OK, retval); - ASSERT_TRUE(audio_channel_mask_is_valid( - static_cast<audio_channel_mask_t>(currentConfig.outputCfg.channels))); - *channelCount = audio_channel_count_from_out_mask( - static_cast<audio_channel_mask_t>(currentConfig.outputCfg.channels)); -} - -TEST_F(AudioEffectHidlTest, Close) { - description("Verify that an effect can be closed"); - Return<Result> ret = effect->close(); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::OK, ret); -} - -TEST_F(AudioEffectHidlTest, GetDescriptor) { - description( - "Verify that an effect can return its own descriptor via GetDescriptor"); - Result retval = Result::NOT_INITIALIZED; - Uuid actualType; - Return<void> ret = - effect->getDescriptor([&](Result r, const EffectDescriptor& desc) { - retval = r; - if (r == Result::OK) { - actualType = desc.type; - } - }); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::OK, retval); - EXPECT_EQ(getEffectType(), actualType); -} - -TEST_F(AudioEffectHidlTest, GetSetConfig) { - description( - "Verify that it is possible to manipulate effect config via Get / " - "SetConfig"); - Result retval = Result::NOT_INITIALIZED; - EffectConfig currentConfig; - Return<void> ret = effect->getConfig([&](Result r, const EffectConfig& conf) { - retval = r; - if (r == Result::OK) { - currentConfig = conf; - } - }); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::OK, retval); - Return<Result> ret2 = effect->setConfig(currentConfig, nullptr, nullptr); - EXPECT_TRUE(ret2.isOk()); - EXPECT_EQ(Result::OK, ret2); -} - -TEST_F(AudioEffectHidlTest, GetConfigReverse) { - description("Verify that GetConfigReverse does not crash"); - Return<void> ret = - effect->getConfigReverse([&](Result, const EffectConfig&) {}); - EXPECT_TRUE(ret.isOk()); -} - -TEST_F(AudioEffectHidlTest, GetSupportedAuxChannelsConfigs) { - description("Verify that GetSupportedAuxChannelsConfigs does not crash"); - Return<void> ret = effect->getSupportedAuxChannelsConfigs( - 0, [&](Result, const hidl_vec<EffectAuxChannelsConfig>&) {}); - EXPECT_TRUE(ret.isOk()); -} - -TEST_F(AudioEffectHidlTest, GetAuxChannelsConfig) { - description("Verify that GetAuxChannelsConfig does not crash"); - Return<void> ret = effect->getAuxChannelsConfig( - [&](Result, const EffectAuxChannelsConfig&) {}); - EXPECT_TRUE(ret.isOk()); -} - -TEST_F(AudioEffectHidlTest, SetAuxChannelsConfig) { - description("Verify that SetAuxChannelsConfig does not crash"); - Return<Result> ret = effect->setAuxChannelsConfig(EffectAuxChannelsConfig()); - EXPECT_TRUE(ret.isOk()); -} - -// Not generated automatically because AudioBuffer contains -// instances of hidl_memory which can't be compared properly -// in general case due to presence of handles. -// -// However, in this particular case, handles must not present -// thus comparison is possible. -// -// operator== must be defined in the same namespace as the structures. -namespace android { -namespace hardware { -namespace audio { -namespace effect { -namespace V2_0 { -inline bool operator==(const AudioBuffer& lhs, const AudioBuffer& rhs) { - return lhs.id == rhs.id && lhs.frameCount == rhs.frameCount && - lhs.data.handle() == nullptr && rhs.data.handle() == nullptr; -} - -inline bool operator==(const EffectBufferConfig& lhs, - const EffectBufferConfig& rhs) { - return lhs.buffer == rhs.buffer && lhs.samplingRateHz == rhs.samplingRateHz && - lhs.channels == rhs.channels && lhs.format == rhs.format && - lhs.accessMode == rhs.accessMode && lhs.mask == rhs.mask; -} - -inline bool operator==(const EffectConfig& lhs, const EffectConfig& rhs) { - return lhs.inputCfg == rhs.inputCfg && lhs.outputCfg == rhs.outputCfg; -} -} // namespace V2_0 -} // namespace effect -} // namespace audio -} // namespace hardware -} // namespace android - -TEST_F(AudioEffectHidlTest, Reset) { - description("Verify that Reset preserves effect configuration"); - Result retval = Result::NOT_INITIALIZED; - EffectConfig originalConfig; - Return<void> ret = effect->getConfig([&](Result r, const EffectConfig& conf) { - retval = r; - if (r == Result::OK) { - originalConfig = conf; - } - }); - ASSERT_TRUE(ret.isOk()); - ASSERT_EQ(Result::OK, retval); - Return<Result> ret2 = effect->reset(); - EXPECT_TRUE(ret2.isOk()); - EXPECT_EQ(Result::OK, ret2); - EffectConfig configAfterReset; - ret = effect->getConfig([&](Result r, const EffectConfig& conf) { - retval = r; - if (r == Result::OK) { - configAfterReset = conf; - } - }); - EXPECT_EQ(originalConfig, configAfterReset); -} - -TEST_F(AudioEffectHidlTest, DisableEnableDisable) { - description("Verify Disable -> Enable -> Disable sequence for an effect"); - Return<Result> ret = effect->disable(); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::INVALID_ARGUMENTS, ret); - ret = effect->enable(); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::OK, ret); - ret = effect->disable(); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::OK, ret); -} - -TEST_F(AudioEffectHidlTest, SetDevice) { - description("Verify that SetDevice works for an output chain effect"); - Return<Result> ret = effect->setDevice(AudioDevice::OUT_SPEAKER); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::OK, ret); -} - -TEST_F(AudioEffectHidlTest, SetAndGetVolume) { - description("Verify that SetAndGetVolume method works for an effect"); - uint32_t channelCount; - getChannelCount(&channelCount); - hidl_vec<uint32_t> volumes; - volumes.resize(channelCount); - for (uint32_t i = 0; i < channelCount; ++i) { - volumes[i] = 0; - } - Result retval = Result::NOT_INITIALIZED; - Return<void> ret = effect->setAndGetVolume( - volumes, [&](Result r, const hidl_vec<uint32_t>&) { retval = r; }); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::OK, retval); -} - -TEST_F(AudioEffectHidlTest, VolumeChangeNotification) { - description("Verify that effect accepts VolumeChangeNotification"); - uint32_t channelCount; - getChannelCount(&channelCount); - hidl_vec<uint32_t> volumes; - volumes.resize(channelCount); - for (uint32_t i = 0; i < channelCount; ++i) { - volumes[i] = 0; - } - Return<Result> ret = effect->volumeChangeNotification(volumes); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::OK, ret); -} - -TEST_F(AudioEffectHidlTest, SetAudioMode) { - description("Verify that SetAudioMode works for an effect"); - Return<Result> ret = effect->setAudioMode(AudioMode::NORMAL); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::OK, ret); -} - -TEST_F(AudioEffectHidlTest, SetConfigReverse) { - description("Verify that SetConfigReverse does not crash"); - Return<Result> ret = - effect->setConfigReverse(EffectConfig(), nullptr, nullptr); - EXPECT_TRUE(ret.isOk()); -} - -TEST_F(AudioEffectHidlTest, SetInputDevice) { - description("Verify that SetInputDevice does not crash"); - Return<Result> ret = effect->setInputDevice(AudioDevice::IN_BUILTIN_MIC); - EXPECT_TRUE(ret.isOk()); -} - -TEST_F(AudioEffectHidlTest, SetAudioSource) { - description("Verify that SetAudioSource does not crash"); - Return<Result> ret = effect->setAudioSource(AudioSource::MIC); - EXPECT_TRUE(ret.isOk()); -} - -TEST_F(AudioEffectHidlTest, Offload) { - description("Verify that calling Offload method does not crash"); - EffectOffloadParameter offloadParam; - offloadParam.isOffload = false; - offloadParam.ioHandle = - static_cast<int>(AudioHandleConsts::AUDIO_IO_HANDLE_NONE); - Return<Result> ret = effect->offload(offloadParam); - EXPECT_TRUE(ret.isOk()); -} - -TEST_F(AudioEffectHidlTest, PrepareForProcessing) { - description("Verify that PrepareForProcessing method works for an effect"); - Result retval = Result::NOT_INITIALIZED; - Return<void> ret = effect->prepareForProcessing( - [&](Result r, const MQDescriptorSync<Result>&) { retval = r; }); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::OK, retval); -} - -TEST_F(AudioEffectHidlTest, SetProcessBuffers) { - description("Verify that SetProcessBuffers works for an effect"); - sp<IAllocator> ashmem = IAllocator::getService("ashmem"); - ASSERT_NE(nullptr, ashmem.get()); - bool success = false; - AudioBuffer buffer; - Return<void> ret = - ashmem->allocate(1024, [&](bool s, const hidl_memory& memory) { - success = s; - if (s) { - buffer.data = memory; - } - }); - ASSERT_TRUE(ret.isOk()); - ASSERT_TRUE(success); - Return<Result> ret2 = effect->setProcessBuffers(buffer, buffer); - EXPECT_TRUE(ret2.isOk()); - EXPECT_EQ(Result::OK, ret2); -} - -TEST_F(AudioEffectHidlTest, Command) { - description("Verify that Command does not crash"); - Return<void> ret = effect->command(0, hidl_vec<uint8_t>(), 0, - [&](int32_t, const hidl_vec<uint8_t>&) {}); - EXPECT_TRUE(ret.isOk()); -} - -TEST_F(AudioEffectHidlTest, SetParameter) { - description("Verify that SetParameter does not crash"); - Return<Result> ret = - effect->setParameter(hidl_vec<uint8_t>(), hidl_vec<uint8_t>()); - EXPECT_TRUE(ret.isOk()); -} - -TEST_F(AudioEffectHidlTest, GetParameter) { - description("Verify that GetParameter does not crash"); - Return<void> ret = effect->getParameter( - hidl_vec<uint8_t>(), 0, [&](Result, const hidl_vec<uint8_t>&) {}); - EXPECT_TRUE(ret.isOk()); -} - -TEST_F(AudioEffectHidlTest, GetSupportedConfigsForFeature) { - description("Verify that GetSupportedConfigsForFeature does not crash"); - Return<void> ret = effect->getSupportedConfigsForFeature( - 0, 0, 0, [&](Result, uint32_t, const hidl_vec<uint8_t>&) {}); - EXPECT_TRUE(ret.isOk()); -} - -TEST_F(AudioEffectHidlTest, GetCurrentConfigForFeature) { - description("Verify that GetCurrentConfigForFeature does not crash"); - Return<void> ret = effect->getCurrentConfigForFeature( - 0, 0, [&](Result, const hidl_vec<uint8_t>&) {}); - EXPECT_TRUE(ret.isOk()); -} - -TEST_F(AudioEffectHidlTest, SetCurrentConfigForFeature) { - description("Verify that SetCurrentConfigForFeature does not crash"); - Return<Result> ret = - effect->setCurrentConfigForFeature(0, hidl_vec<uint8_t>()); - EXPECT_TRUE(ret.isOk()); -} - - -// The main test class for Equalizer Audio Effect HIDL HAL. -class EqualizerAudioEffectHidlTest : public AudioEffectHidlTest { - public: - void SetUp() override { - AudioEffectHidlTest::SetUp(); - equalizer = IEqualizerEffect::castFrom(effect); - ASSERT_NE(nullptr, equalizer.get()); - } - - protected: - Uuid getEffectType() override { return EQUALIZER_EFFECT_TYPE; } - void getNumBands(uint16_t* numBands); - void getLevelRange(int16_t* minLevel, int16_t* maxLevel); - void getBandFrequencyRange(uint16_t band, uint32_t* minFreq, - uint32_t* centerFreq, uint32_t* maxFreq); - void getPresetCount(size_t* count); - - sp<IEqualizerEffect> equalizer; -}; - -void EqualizerAudioEffectHidlTest::getNumBands(uint16_t* numBands) { - Result retval = Result::NOT_INITIALIZED; - Return<void> ret = equalizer->getNumBands([&](Result r, uint16_t b) { - retval = r; - if (retval == Result::OK) { - *numBands = b; - } - }); - ASSERT_TRUE(ret.isOk()); - ASSERT_EQ(Result::OK, retval); -} - -void EqualizerAudioEffectHidlTest::getLevelRange(int16_t* minLevel, - int16_t* maxLevel) { - Result retval = Result::NOT_INITIALIZED; - Return<void> ret = - equalizer->getLevelRange([&](Result r, int16_t min, int16_t max) { - retval = r; - if (retval == Result::OK) { - *minLevel = min; - *maxLevel = max; - } - }); - ASSERT_TRUE(ret.isOk()); - ASSERT_EQ(Result::OK, retval); -} - -void EqualizerAudioEffectHidlTest::getBandFrequencyRange(uint16_t band, - uint32_t* minFreq, - uint32_t* centerFreq, - uint32_t* maxFreq) { - Result retval = Result::NOT_INITIALIZED; - Return<void> ret = equalizer->getBandFrequencyRange( - band, [&](Result r, uint32_t min, uint32_t max) { - retval = r; - if (retval == Result::OK) { - *minFreq = min; - *maxFreq = max; - } - }); - ASSERT_TRUE(ret.isOk()); - ASSERT_EQ(Result::OK, retval); - ret = equalizer->getBandCenterFrequency(band, [&](Result r, uint32_t center) { - retval = r; - if (retval == Result::OK) { - *centerFreq = center; - } - }); - ASSERT_TRUE(ret.isOk()); - ASSERT_EQ(Result::OK, retval); -} - -void EqualizerAudioEffectHidlTest::getPresetCount(size_t* count) { - Result retval = Result::NOT_INITIALIZED; - Return<void> ret = equalizer->getPresetNames( - [&](Result r, const hidl_vec<hidl_string>& names) { - retval = r; - if (retval == Result::OK) { - *count = names.size(); - } - }); - ASSERT_TRUE(ret.isOk()); - ASSERT_EQ(Result::OK, retval); -} - -TEST_F(EqualizerAudioEffectHidlTest, GetNumBands) { - description("Verify that Equalizer effect reports at least one band"); - uint16_t numBands = 0; - getNumBands(&numBands); - EXPECT_GT(numBands, 0); -} - -TEST_F(EqualizerAudioEffectHidlTest, GetLevelRange) { - description("Verify that Equalizer effect reports adequate band level range"); - int16_t minLevel = 0x7fff, maxLevel = 0; - getLevelRange(&minLevel, &maxLevel); - EXPECT_GT(maxLevel, minLevel); -} - -TEST_F(EqualizerAudioEffectHidlTest, GetSetBandLevel) { - description( - "Verify that manipulating band levels works for Equalizer effect"); - uint16_t numBands = 0; - getNumBands(&numBands); - ASSERT_GT(numBands, 0); - int16_t levels[3]{0x7fff, 0, 0}; - getLevelRange(&levels[0], &levels[2]); - ASSERT_GT(levels[2], levels[0]); - levels[1] = (levels[2] + levels[0]) / 2; - for (uint16_t i = 0; i < numBands; ++i) { - for (size_t j = 0; j < ARRAY_SIZE(levels); ++j) { - Return<Result> ret = equalizer->setBandLevel(i, levels[j]); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::OK, ret); - Result retval = Result::NOT_INITIALIZED; - int16_t actualLevel; - Return<void> ret2 = equalizer->getBandLevel(i, [&](Result r, int16_t l) { - retval = r; - if (retval == Result::OK) { - actualLevel = l; - } - }); - EXPECT_TRUE(ret2.isOk()); - EXPECT_EQ(Result::OK, retval); - EXPECT_EQ(levels[j], actualLevel); - } - } -} - -TEST_F(EqualizerAudioEffectHidlTest, GetBandCenterFrequencyAndRange) { - description( - "Verify that Equalizer effect reports adequate band frequency range"); - uint16_t numBands = 0; - getNumBands(&numBands); - ASSERT_GT(numBands, 0); - for (uint16_t i = 0; i < numBands; ++i) { - uint32_t minFreq = 0xffffffff, centerFreq = 0xffffffff, - maxFreq = 0xffffffff; - getBandFrequencyRange(i, &minFreq, ¢erFreq, &maxFreq); - // Note: NXP legacy implementation reports "1" as upper bound for last band, - // so this check fails. - EXPECT_GE(maxFreq, centerFreq); - EXPECT_GE(centerFreq, minFreq); - } -} - -TEST_F(EqualizerAudioEffectHidlTest, GetBandForFrequency) { - description( - "Verify that Equalizer effect supports GetBandForFrequency correctly"); - uint16_t numBands = 0; - getNumBands(&numBands); - ASSERT_GT(numBands, 0); - for (uint16_t i = 0; i < numBands; ++i) { - uint32_t freqs[3]{0, 0, 0}; - getBandFrequencyRange(i, &freqs[0], &freqs[1], &freqs[2]); - // NXP legacy implementation reports "1" as upper bound for last band, some - // of the checks fail. - for (size_t j = 0; j < ARRAY_SIZE(freqs); ++j) { - if (j == 0) { - freqs[j]++; - } // Min frequency is an open interval. - Result retval = Result::NOT_INITIALIZED; - uint16_t actualBand = numBands + 1; - Return<void> ret = - equalizer->getBandForFrequency(freqs[j], [&](Result r, uint16_t b) { - retval = r; - if (retval == Result::OK) { - actualBand = b; - } - }); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::OK, retval); - EXPECT_EQ(i, actualBand) << "Frequency: " << freqs[j]; - } - } -} - -TEST_F(EqualizerAudioEffectHidlTest, GetPresetNames) { - description("Verify that Equalizer effect reports at least one preset"); - size_t presetCount; - getPresetCount(&presetCount); - EXPECT_GT(presetCount, 0u); -} - -TEST_F(EqualizerAudioEffectHidlTest, GetSetCurrentPreset) { - description( - "Verify that manipulating the current preset for Equalizer effect"); - size_t presetCount; - getPresetCount(&presetCount); - ASSERT_GT(presetCount, 0u); - for (uint16_t i = 0; i < presetCount; ++i) { - Return<Result> ret = equalizer->setCurrentPreset(i); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::OK, ret); - Result retval = Result::NOT_INITIALIZED; - uint16_t actualPreset = 0xffff; - Return<void> ret2 = equalizer->getCurrentPreset([&](Result r, uint16_t p) { - retval = r; - if (retval == Result::OK) { - actualPreset = p; - } - }); - EXPECT_TRUE(ret2.isOk()); - EXPECT_EQ(Result::OK, retval); - EXPECT_EQ(i, actualPreset); - } -} - -TEST_F(EqualizerAudioEffectHidlTest, GetSetAllProperties) { - description( - "Verify that setting band levels and presets works via Get / " - "SetAllProperties for Equalizer effect"); - using AllProperties = - android::hardware::audio::effect::V2_0::IEqualizerEffect::AllProperties; - uint16_t numBands = 0; - getNumBands(&numBands); - ASSERT_GT(numBands, 0); - AllProperties props; - props.bandLevels.resize(numBands); - for (size_t i = 0; i < numBands; ++i) { - props.bandLevels[i] = 0; - } - - AllProperties actualProps; - Result retval = Result::NOT_INITIALIZED; - - // Verify setting of the band levels via properties. - props.curPreset = -1; - Return<Result> ret = equalizer->setAllProperties(props); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::OK, ret); - Return<void> ret2 = - equalizer->getAllProperties([&](Result r, AllProperties p) { - retval = r; - if (retval == Result::OK) { - actualProps = p; - } - }); - EXPECT_TRUE(ret2.isOk()); - EXPECT_EQ(Result::OK, retval); - EXPECT_EQ(props.bandLevels, actualProps.bandLevels); - - // Verify setting of the current preset via properties. - props.curPreset = 0; // Assuming there is at least one preset. - ret = equalizer->setAllProperties(props); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::OK, ret); - ret2 = equalizer->getAllProperties([&](Result r, AllProperties p) { - retval = r; - if (retval == Result::OK) { - actualProps = p; - } - }); - EXPECT_TRUE(ret2.isOk()); - EXPECT_EQ(Result::OK, retval); - EXPECT_EQ(props.curPreset, actualProps.curPreset); -} - -// The main test class for Equalizer Audio Effect HIDL HAL. -class LoudnessEnhancerAudioEffectHidlTest : public AudioEffectHidlTest { - public: - void SetUp() override { - AudioEffectHidlTest::SetUp(); - enhancer = ILoudnessEnhancerEffect::castFrom(effect); - ASSERT_NE(nullptr, enhancer.get()); - } - - protected: - Uuid getEffectType() override { return LOUDNESS_ENHANCER_EFFECT_TYPE; } - - sp<ILoudnessEnhancerEffect> enhancer; -}; - -TEST_F(LoudnessEnhancerAudioEffectHidlTest, GetSetTargetGain) { - description( - "Verify that manipulating the target gain works for Loudness Enhancer " - "effect"); - const int32_t gain = 100; - Return<Result> ret = enhancer->setTargetGain(gain); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::OK, ret); - int32_t actualGain = 0; - Result retval; - Return<void> ret2 = enhancer->getTargetGain([&](Result r, int32_t g) { - retval = r; - if (retval == Result::OK) { - actualGain = g; - } - }); - EXPECT_TRUE(ret2.isOk()); - EXPECT_EQ(Result::OK, retval); - EXPECT_EQ(gain, actualGain); -} - -int main(int argc, char** argv) { - ::testing::AddGlobalTestEnvironment(AudioEffectsFactoryHidlEnvironment::Instance()); - ::testing::InitGoogleTest(&argc, argv); - AudioEffectsFactoryHidlEnvironment::Instance()->init(&argc, argv); - int status = RUN_ALL_TESTS(); - LOG(INFO) << "Test result = " << status; - return status; -} diff --git a/audio/effect/2.0/xml/audio_effects_conf_V2_0.xsd b/audio/effect/2.0/xml/audio_effects_conf.xsd index df281b32d1..df281b32d1 100644 --- a/audio/effect/2.0/xml/audio_effects_conf_V2_0.xsd +++ b/audio/effect/2.0/xml/audio_effects_conf.xsd diff --git a/audio/effect/4.0/default/AcousticEchoCancelerEffect.cpp b/audio/effect/4.0/default/AcousticEchoCancelerEffect.cpp deleted file mode 100644 index 242740e582..0000000000 --- a/audio/effect/4.0/default/AcousticEchoCancelerEffect.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2018 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 "AEC_Effect_HAL" - -#include "AcousticEchoCancelerEffect.h" - -#define AUDIO_HAL_VERSION V4_0 -#include <effect/all-versions/default/AcousticEchoCancelerEffect.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/effect/4.0/default/Android.bp b/audio/effect/4.0/default/Android.bp deleted file mode 100644 index dcb2269a9b..0000000000 --- a/audio/effect/4.0/default/Android.bp +++ /dev/null @@ -1,50 +0,0 @@ -cc_library_shared { - name: "android.hardware.audio.effect@4.0-impl", - defaults: ["hidl_defaults"], - vendor: true, - relative_install_path: "hw", - srcs: [ - "AcousticEchoCancelerEffect.cpp", - "AudioBufferManager.cpp", - "AutomaticGainControlEffect.cpp", - "BassBoostEffect.cpp", - "Conversions.cpp", - "DownmixEffect.cpp", - "Effect.cpp", - "EffectsFactory.cpp", - "EnvironmentalReverbEffect.cpp", - "EqualizerEffect.cpp", - "LoudnessEnhancerEffect.cpp", - "NoiseSuppressionEffect.cpp", - "PresetReverbEffect.cpp", - "VirtualizerEffect.cpp", - "VisualizerEffect.cpp", - ], - - shared_libs: [ - "libbase", - "libcutils", - "libeffects", - "libfmq", - "libhidlbase", - "libhidlmemory", - "libhidltransport", - "liblog", - "libutils", - "android.hardware.audio.common-util", - "android.hardware.audio.common@4.0", - "android.hardware.audio.common@4.0-util", - "android.hardware.audio.effect@4.0", - "android.hidl.memory@1.0", - ], - - header_libs: [ - "android.hardware.audio.common.util@all-versions", - "android.hardware.audio.effect@all-versions-impl", - "libaudio_system_headers", - "libaudioclient_headers", - "libeffects_headers", - "libhardware_headers", - "libmedia_headers", - ], -} diff --git a/audio/effect/4.0/default/AudioBufferManager.cpp b/audio/effect/4.0/default/AudioBufferManager.cpp deleted file mode 100644 index 2d75f3fdbb..0000000000 --- a/audio/effect/4.0/default/AudioBufferManager.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2018 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 "AudioBufferManager.h" - -#define AUDIO_HAL_VERSION V4_0 -#include <effect/all-versions/default/AudioBufferManager.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/effect/4.0/default/AutomaticGainControlEffect.cpp b/audio/effect/4.0/default/AutomaticGainControlEffect.cpp deleted file mode 100644 index 9d21c8ae6b..0000000000 --- a/audio/effect/4.0/default/AutomaticGainControlEffect.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2018 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 "AGC_Effect_HAL" - -#include "AutomaticGainControlEffect.h" - -#define AUDIO_HAL_VERSION V4_0 -#include <effect/all-versions/default/AutomaticGainControlEffect.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/effect/4.0/default/AutomaticGainControlEffect.h b/audio/effect/4.0/default/AutomaticGainControlEffect.h deleted file mode 100644 index 7f12007f8f..0000000000 --- a/audio/effect/4.0/default/AutomaticGainControlEffect.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2018 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_AUTOMATICGAINCONTROLEFFECT_H -#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_AUTOMATICGAINCONTROLEFFECT_H - -#include <android/hardware/audio/effect/4.0/IAutomaticGainControlEffect.h> - -#include "Effect.h" - -#define AUDIO_HAL_VERSION V4_0 -#include <effect/all-versions/default/AutomaticGainControlEffect.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_AUTOMATICGAINCONTROLEFFECT_H diff --git a/audio/effect/4.0/default/BassBoostEffect.cpp b/audio/effect/4.0/default/BassBoostEffect.cpp deleted file mode 100644 index 74a626b79e..0000000000 --- a/audio/effect/4.0/default/BassBoostEffect.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2018 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 "BassBoost_HAL" - -#include "BassBoostEffect.h" - -#define AUDIO_HAL_VERSION V4_0 -#include <effect/all-versions/default/BassBoostEffect.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/effect/4.0/default/BassBoostEffect.h b/audio/effect/4.0/default/BassBoostEffect.h deleted file mode 100644 index 206a75fab4..0000000000 --- a/audio/effect/4.0/default/BassBoostEffect.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2018 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_BASSBOOSTEFFECT_H -#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_BASSBOOSTEFFECT_H - -#include <android/hardware/audio/effect/4.0/IBassBoostEffect.h> - -#include <hidl/MQDescriptor.h> - -#include "Effect.h" - -#define AUDIO_HAL_VERSION V4_0 -#include <effect/all-versions/default/BassBoostEffect.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_BASSBOOSTEFFECT_H diff --git a/audio/effect/4.0/default/Conversions.cpp b/audio/effect/4.0/default/Conversions.cpp deleted file mode 100644 index 91285ae6b8..0000000000 --- a/audio/effect/4.0/default/Conversions.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2018 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 "Conversions.h" -#include "HidlUtils.h" - -using ::android::hardware::audio::common::V4_0::HidlUtils; - -#define AUDIO_HAL_VERSION V4_0 -#include <effect/all-versions/default/Conversions.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/effect/4.0/default/Conversions.h b/audio/effect/4.0/default/Conversions.h deleted file mode 100644 index 50e380fe2e..0000000000 --- a/audio/effect/4.0/default/Conversions.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (C) 2018 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_CONVERSIONS_H_ -#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_CONVERSIONS_H_ - -#include <android/hardware/audio/effect/4.0/types.h> - -#define AUDIO_HAL_VERSION V4_0 -#include <effect/all-versions/default/Conversions.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_CONVERSIONS_H_ diff --git a/audio/effect/4.0/default/DownmixEffect.cpp b/audio/effect/4.0/default/DownmixEffect.cpp deleted file mode 100644 index 07fcab2f1c..0000000000 --- a/audio/effect/4.0/default/DownmixEffect.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2018 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 "Downmix_HAL" - -#include "DownmixEffect.h" - -#define AUDIO_HAL_VERSION V4_0 -#include <effect/all-versions/default/DownmixEffect.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/effect/4.0/default/DownmixEffect.h b/audio/effect/4.0/default/DownmixEffect.h deleted file mode 100644 index 5ae820b76f..0000000000 --- a/audio/effect/4.0/default/DownmixEffect.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2018 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_DOWNMIXEFFECT_H -#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_DOWNMIXEFFECT_H - -#include <android/hardware/audio/effect/4.0/IDownmixEffect.h> - -#include "Effect.h" - -#define AUDIO_HAL_VERSION V4_0 -#include <effect/all-versions/default/DownmixEffect.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_DOWNMIXEFFECT_H diff --git a/audio/effect/4.0/default/Effect.h b/audio/effect/4.0/default/Effect.h deleted file mode 100644 index 9ca79c4596..0000000000 --- a/audio/effect/4.0/default/Effect.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2018 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_EFFECT_H -#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_EFFECT_H - -#include <android/hardware/audio/effect/4.0/IEffect.h> - -#include "AudioBufferManager.h" - -#define AUDIO_HAL_VERSION V4_0 -#include <effect/all-versions/default/Effect.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_EFFECT_H diff --git a/audio/effect/4.0/default/EffectsFactory.cpp b/audio/effect/4.0/default/EffectsFactory.cpp deleted file mode 100644 index ee0413df8f..0000000000 --- a/audio/effect/4.0/default/EffectsFactory.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (C) 2018 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 "EffectFactoryHAL" -#include "EffectsFactory.h" -#include "AcousticEchoCancelerEffect.h" -#include "AutomaticGainControlEffect.h" -#include "BassBoostEffect.h" -#include "Conversions.h" -#include "DownmixEffect.h" -#include "Effect.h" -#include "EnvironmentalReverbEffect.h" -#include "EqualizerEffect.h" -#include "HidlUtils.h" -#include "LoudnessEnhancerEffect.h" -#include "NoiseSuppressionEffect.h" -#include "PresetReverbEffect.h" -#include "VirtualizerEffect.h" -#include "VisualizerEffect.h" -#include "common/all-versions/default/EffectMap.h" - -using ::android::hardware::audio::common::V4_0::HidlUtils; - -#define AUDIO_HAL_VERSION V4_0 -#include <effect/all-versions/default/EffectsFactory.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/effect/4.0/default/EffectsFactory.h b/audio/effect/4.0/default/EffectsFactory.h deleted file mode 100644 index 48e4b4cb9f..0000000000 --- a/audio/effect/4.0/default/EffectsFactory.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (C) 2018 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_EFFECTSFACTORY_H -#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_EFFECTSFACTORY_H - -#include <system/audio_effect.h> - -#include <android/hardware/audio/effect/4.0/IEffectsFactory.h> - -#include <hidl/MQDescriptor.h> -#define AUDIO_HAL_VERSION V4_0 -#include <effect/all-versions/default/EffectsFactory.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_EFFECTSFACTORY_H diff --git a/audio/effect/4.0/default/EnvironmentalReverbEffect.cpp b/audio/effect/4.0/default/EnvironmentalReverbEffect.cpp deleted file mode 100644 index cc3102d1f8..0000000000 --- a/audio/effect/4.0/default/EnvironmentalReverbEffect.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) 2018 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 "EnvReverb_HAL" -#include <android/log.h> - -#include "EnvironmentalReverbEffect.h" - -#define AUDIO_HAL_VERSION V4_0 -#include <effect/all-versions/default/EnvironmentalReverbEffect.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/effect/4.0/default/EnvironmentalReverbEffect.h b/audio/effect/4.0/default/EnvironmentalReverbEffect.h deleted file mode 100644 index c0fb25c02c..0000000000 --- a/audio/effect/4.0/default/EnvironmentalReverbEffect.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2018 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_ENVIRONMENTALREVERBEFFECT_H -#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_ENVIRONMENTALREVERBEFFECT_H - -#include <system/audio_effects/effect_environmentalreverb.h> - -#include <android/hardware/audio/effect/4.0/IEnvironmentalReverbEffect.h> - -#include "Effect.h" - -#define AUDIO_HAL_VERSION V4_0 -#include <effect/all-versions/default/EnvironmentalReverbEffect.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_ENVIRONMENTALREVERBEFFECT_H diff --git a/audio/effect/4.0/default/EqualizerEffect.cpp b/audio/effect/4.0/default/EqualizerEffect.cpp deleted file mode 100644 index d0a40bc3cd..0000000000 --- a/audio/effect/4.0/default/EqualizerEffect.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2018 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 "Equalizer_HAL" - -#include "EqualizerEffect.h" - -#define AUDIO_HAL_VERSION V4_0 -#include <effect/all-versions/default/EqualizerEffect.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/effect/4.0/default/EqualizerEffect.h b/audio/effect/4.0/default/EqualizerEffect.h deleted file mode 100644 index 7c9463b01e..0000000000 --- a/audio/effect/4.0/default/EqualizerEffect.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2018 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_EQUALIZEREFFECT_H -#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_EQUALIZEREFFECT_H - -#include <android/hardware/audio/effect/4.0/IEqualizerEffect.h> - -#include "Effect.h" - -#define AUDIO_HAL_VERSION V4_0 -#include <effect/all-versions/default/EqualizerEffect.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_EQUALIZEREFFECT_H diff --git a/audio/effect/4.0/default/LoudnessEnhancerEffect.cpp b/audio/effect/4.0/default/LoudnessEnhancerEffect.cpp deleted file mode 100644 index e3c5184225..0000000000 --- a/audio/effect/4.0/default/LoudnessEnhancerEffect.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2018 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 "LoudnessEnhancer_HAL" - -#include "LoudnessEnhancerEffect.h" - -#define AUDIO_HAL_VERSION V4_0 -#include <effect/all-versions/default/LoudnessEnhancerEffect.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/effect/4.0/default/LoudnessEnhancerEffect.h b/audio/effect/4.0/default/LoudnessEnhancerEffect.h deleted file mode 100644 index 64fa26add8..0000000000 --- a/audio/effect/4.0/default/LoudnessEnhancerEffect.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2018 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_LOUDNESSENHANCEREFFECT_H -#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_LOUDNESSENHANCEREFFECT_H - -#include <android/hardware/audio/effect/4.0/ILoudnessEnhancerEffect.h> - -#include "Effect.h" - -#define AUDIO_HAL_VERSION V4_0 -#include <effect/all-versions/default/LoudnessEnhancerEffect.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_LOUDNESSENHANCEREFFECT_H diff --git a/audio/effect/4.0/default/NoiseSuppressionEffect.cpp b/audio/effect/4.0/default/NoiseSuppressionEffect.cpp deleted file mode 100644 index e83a8e3373..0000000000 --- a/audio/effect/4.0/default/NoiseSuppressionEffect.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2018 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 "NS_Effect_HAL" - -#include "NoiseSuppressionEffect.h" - -#define AUDIO_HAL_VERSION V4_0 -#include <effect/all-versions/default/NoiseSuppressionEffect.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/effect/4.0/default/NoiseSuppressionEffect.h b/audio/effect/4.0/default/NoiseSuppressionEffect.h deleted file mode 100644 index 36d45afaf7..0000000000 --- a/audio/effect/4.0/default/NoiseSuppressionEffect.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2018 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_NOISESUPPRESSIONEFFECT_H -#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_NOISESUPPRESSIONEFFECT_H - -#include <android/hardware/audio/effect/4.0/INoiseSuppressionEffect.h> - -#include "Effect.h" - -#define AUDIO_HAL_VERSION V4_0 -#include <effect/all-versions/default/NoiseSuppressionEffect.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_NOISESUPPRESSIONEFFECT_H diff --git a/audio/effect/4.0/default/OWNERS b/audio/effect/4.0/default/OWNERS deleted file mode 100644 index 6fdc97ca29..0000000000 --- a/audio/effect/4.0/default/OWNERS +++ /dev/null @@ -1,3 +0,0 @@ -elaurent@google.com -krocard@google.com -mnaganov@google.com diff --git a/audio/effect/4.0/default/PresetReverbEffect.cpp b/audio/effect/4.0/default/PresetReverbEffect.cpp deleted file mode 100644 index 0c23be73af..0000000000 --- a/audio/effect/4.0/default/PresetReverbEffect.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2018 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 "PresetReverb_HAL" - -#include "PresetReverbEffect.h" - -#define AUDIO_HAL_VERSION V4_0 -#include <effect/all-versions/default/PresetReverbEffect.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/effect/4.0/default/PresetReverbEffect.h b/audio/effect/4.0/default/PresetReverbEffect.h deleted file mode 100644 index 3eeae0a04b..0000000000 --- a/audio/effect/4.0/default/PresetReverbEffect.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2018 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_PRESETREVERBEFFECT_H -#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_PRESETREVERBEFFECT_H - -#include <android/hardware/audio/effect/4.0/IPresetReverbEffect.h> - -#include "Effect.h" - -#define AUDIO_HAL_VERSION V4_0 -#include <effect/all-versions/default/PresetReverbEffect.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_PRESETREVERBEFFECT_H diff --git a/audio/effect/4.0/default/VirtualizerEffect.cpp b/audio/effect/4.0/default/VirtualizerEffect.cpp deleted file mode 100644 index f50e8adb7b..0000000000 --- a/audio/effect/4.0/default/VirtualizerEffect.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2018 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 "Virtualizer_HAL" - -#include "VirtualizerEffect.h" - -#define AUDIO_HAL_VERSION V4_0 -#include <effect/all-versions/default/VirtualizerEffect.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/effect/4.0/default/VirtualizerEffect.h b/audio/effect/4.0/default/VirtualizerEffect.h deleted file mode 100644 index 8e7114e569..0000000000 --- a/audio/effect/4.0/default/VirtualizerEffect.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2018 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_VIRTUALIZEREFFECT_H -#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_VIRTUALIZEREFFECT_H - -#include <android/hardware/audio/effect/4.0/IVirtualizerEffect.h> - -#include "Effect.h" - -#define AUDIO_HAL_VERSION V4_0 -#include <effect/all-versions/default/VirtualizerEffect.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_VIRTUALIZEREFFECT_H diff --git a/audio/effect/4.0/default/VisualizerEffect.cpp b/audio/effect/4.0/default/VisualizerEffect.cpp deleted file mode 100644 index 8d4f100ced..0000000000 --- a/audio/effect/4.0/default/VisualizerEffect.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (C) 2018 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 "Visualizer_HAL" - -#include "VisualizerEffect.h" - -#define AUDIO_HAL_VERSION V4_0 -#include <effect/all-versions/default/VisualizerEffect.impl.h> -#undef AUDIO_HAL_VERSION diff --git a/audio/effect/4.0/default/VisualizerEffect.h b/audio/effect/4.0/default/VisualizerEffect.h deleted file mode 100644 index 6b5ab9c393..0000000000 --- a/audio/effect/4.0/default/VisualizerEffect.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2018 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. - */ - -#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_VISUALIZEREFFECT_H -#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_VISUALIZEREFFECT_H - -#include <android/hardware/audio/effect/4.0/IVisualizerEffect.h> - -#include "Effect.h" - -#define AUDIO_HAL_VERSION V4_0 -#include <effect/all-versions/default/VisualizerEffect.h> -#undef AUDIO_HAL_VERSION - -#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_VISUALIZEREFFECT_H diff --git a/audio/effect/4.0/vts/OWNERS b/audio/effect/4.0/vts/OWNERS deleted file mode 100644 index 8711a9ff6a..0000000000 --- a/audio/effect/4.0/vts/OWNERS +++ /dev/null @@ -1,5 +0,0 @@ -elaurent@google.com -krocard@google.com -mnaganov@google.com -yim@google.com -zhuoyao@google.com
\ No newline at end of file diff --git a/audio/effect/4.0/vts/functional/ValidateAudioEffectsConfiguration.cpp b/audio/effect/4.0/vts/functional/ValidateAudioEffectsConfiguration.cpp deleted file mode 100644 index 6338563c2e..0000000000 --- a/audio/effect/4.0/vts/functional/ValidateAudioEffectsConfiguration.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (C) 2017 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 <unistd.h> -#include <iterator> - -#include <media/EffectsConfig.h> - -#include "utility/ValidateXml.h" - -TEST(CheckConfig, audioEffectsConfigurationValidation) { - RecordProperty("description", - "Verify that the effects configuration file is valid according to the schema"); - using namespace android::effectsConfig; - - std::vector<const char*> locations(std::begin(DEFAULT_LOCATIONS), std::end(DEFAULT_LOCATIONS)); - EXPECT_ONE_VALID_XML_MULTIPLE_LOCATIONS(DEFAULT_NAME, locations, - "/data/local/tmp/audio_effects_conf_V4_0.xsd"); -} diff --git a/audio/effect/4.0/vts/functional/VtsHalAudioEffectV4_0TargetTest.cpp b/audio/effect/4.0/vts/functional/VtsHalAudioEffectV4_0TargetTest.cpp deleted file mode 100644 index ec783c4bfa..0000000000 --- a/audio/effect/4.0/vts/functional/VtsHalAudioEffectV4_0TargetTest.cpp +++ /dev/null @@ -1,852 +0,0 @@ -/* - * Copyright (C) 2017 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 "AudioEffectHidlHalTest" -#include <android-base/logging.h> -#include <system/audio.h> - -#include <android/hardware/audio/effect/4.0/IEffect.h> -#include <android/hardware/audio/effect/4.0/IEffectsFactory.h> -#include <android/hardware/audio/effect/4.0/IEqualizerEffect.h> -#include <android/hardware/audio/effect/4.0/ILoudnessEnhancerEffect.h> -#include <android/hardware/audio/effect/4.0/types.h> -#include <android/hidl/allocator/1.0/IAllocator.h> -#include <android/hidl/memory/1.0/IMemory.h> - -#include <common/all-versions/VersionUtils.h> - -#include <VtsHalHidlTargetTestBase.h> -#include <VtsHalHidlTargetTestEnvBase.h> - -using android::hardware::audio::common::V4_0::AudioDevice; -using android::hardware::audio::common::V4_0::AudioHandleConsts; -using android::hardware::audio::common::V4_0::AudioMode; -using android::hardware::audio::common::V4_0::AudioSource; -using android::hardware::audio::common::V4_0::Uuid; -using android::hardware::audio::common::utils::mkBitfield; -using android::hardware::audio::effect::V4_0::AudioBuffer; -using android::hardware::audio::effect::V4_0::EffectAuxChannelsConfig; -using android::hardware::audio::effect::V4_0::EffectBufferConfig; -using android::hardware::audio::effect::V4_0::EffectConfig; -using android::hardware::audio::effect::V4_0::EffectDescriptor; -using android::hardware::audio::effect::V4_0::EffectOffloadParameter; -using android::hardware::audio::effect::V4_0::IEffect; -using android::hardware::audio::effect::V4_0::IEffectsFactory; -using android::hardware::audio::effect::V4_0::IEqualizerEffect; -using android::hardware::audio::effect::V4_0::ILoudnessEnhancerEffect; -using android::hardware::audio::effect::V4_0::Result; -using android::hardware::MQDescriptorSync; -using android::hardware::Return; -using android::hardware::Void; -using android::hardware::hidl_handle; -using android::hardware::hidl_memory; -using android::hardware::hidl_string; -using android::hardware::hidl_vec; -using android::hidl::allocator::V1_0::IAllocator; -using android::hidl::memory::V1_0::IMemory; -using android::sp; - -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a))) -#endif - -// Test environment for Audio Effects Factory HIDL HAL. -class AudioEffectsFactoryHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { - public: - // get the test environment singleton - static AudioEffectsFactoryHidlEnvironment* Instance() { - static AudioEffectsFactoryHidlEnvironment* instance = - new AudioEffectsFactoryHidlEnvironment; - return instance; - } - - virtual void registerTestServices() override { registerTestService<IEffectsFactory>(); } -}; - -// The main test class for Audio Effects Factory HIDL HAL. -class AudioEffectsFactoryHidlTest : public ::testing::VtsHalHidlTargetTestBase { - public: - void SetUp() override { - effectsFactory = ::testing::VtsHalHidlTargetTestBase::getService<IEffectsFactory>( - AudioEffectsFactoryHidlEnvironment::Instance()->getServiceName<IEffectsFactory>()); - ASSERT_NE(effectsFactory, nullptr); - } - - void TearDown() override { effectsFactory.clear(); } - - protected: - static void description(const std::string& description) { - RecordProperty("description", description); - } - - sp<IEffectsFactory> effectsFactory; -}; - -TEST_F(AudioEffectsFactoryHidlTest, EnumerateEffects) { - description("Verify that EnumerateEffects returns at least one effect"); - Result retval = Result::NOT_INITIALIZED; - size_t effectCount = 0; - Return<void> ret = effectsFactory->getAllDescriptors( - [&](Result r, const hidl_vec<EffectDescriptor>& result) { - retval = r; - effectCount = result.size(); - }); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::OK, retval); - EXPECT_GT(effectCount, 0u); -} - -TEST_F(AudioEffectsFactoryHidlTest, CreateEffect) { - description("Verify that an effect can be created via CreateEffect"); - bool gotEffect = false; - Uuid effectUuid; - Return<void> ret = effectsFactory->getAllDescriptors( - [&](Result r, const hidl_vec<EffectDescriptor>& result) { - if (r == Result::OK && result.size() > 0) { - gotEffect = true; - effectUuid = result[0].uuid; - } - }); - ASSERT_TRUE(ret.isOk()); - ASSERT_TRUE(gotEffect); - Result retval = Result::NOT_INITIALIZED; - sp<IEffect> effect; - ret = effectsFactory->createEffect( - effectUuid, 1 /*session*/, 1 /*ioHandle*/, - [&](Result r, const sp<IEffect>& result, uint64_t /*effectId*/) { - retval = r; - if (r == Result::OK) { - effect = result; - } - }); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::OK, retval); - EXPECT_NE(nullptr, effect.get()); -} - -TEST_F(AudioEffectsFactoryHidlTest, GetDescriptor) { - description( - "Verify that effects factory can provide an effect descriptor via " - "GetDescriptor"); - hidl_vec<EffectDescriptor> allDescriptors; - Return<void> ret = effectsFactory->getAllDescriptors( - [&](Result r, const hidl_vec<EffectDescriptor>& result) { - if (r == Result::OK) { - allDescriptors = result; - } - }); - ASSERT_TRUE(ret.isOk()); - ASSERT_GT(allDescriptors.size(), 0u); - for (size_t i = 0; i < allDescriptors.size(); ++i) { - ret = effectsFactory->getDescriptor( - allDescriptors[i].uuid, [&](Result r, const EffectDescriptor& result) { - EXPECT_EQ(r, Result::OK); - EXPECT_EQ(result, allDescriptors[i]); - }); - } - EXPECT_TRUE(ret.isOk()); -} - -TEST_F(AudioEffectsFactoryHidlTest, DebugDumpInvalidArgument) { - description("Verify that debugDump doesn't crash on invalid arguments"); - Return<void> ret = effectsFactory->debug(hidl_handle(), {}); - ASSERT_TRUE(ret.isOk()); -} - -// Equalizer effect is required by CDD, but only the type is fixed. -// This is the same UUID as AudioEffect.EFFECT_TYPE_EQUALIZER in Java. -static const Uuid EQUALIZER_EFFECT_TYPE = { - 0x0bed4300, 0xddd6, 0x11db, 0x8f34, - std::array<uint8_t, 6>{{0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}}; -// Loudness Enhancer effect is required by CDD, but only the type is fixed. -// This is the same UUID as AudioEffect.EFFECT_TYPE_LOUDNESS_ENHANCER in Java. -static const Uuid LOUDNESS_ENHANCER_EFFECT_TYPE = { - 0xfe3199be, 0xaed0, 0x413f, 0x87bb, - std::array<uint8_t, 6>{{0x11, 0x26, 0x0e, 0xb6, 0x3c, 0xf1}}}; - -// The main test class for Audio Effect HIDL HAL. -class AudioEffectHidlTest : public ::testing::VtsHalHidlTargetTestBase { - public: - void SetUp() override { - effectsFactory = - ::testing::VtsHalHidlTargetTestBase::getService<IEffectsFactory>(); - ASSERT_NE(nullptr, effectsFactory.get()); - - findAndCreateEffect(getEffectType()); - ASSERT_NE(nullptr, effect.get()); - - Return<Result> ret = effect->init(); - ASSERT_TRUE(ret.isOk()); - ASSERT_EQ(Result::OK, ret); - } - - void TearDown() override { - effect.clear(); - effectsFactory.clear(); - } - - protected: - static void description(const std::string& description) { - RecordProperty("description", description); - } - - virtual Uuid getEffectType() { return EQUALIZER_EFFECT_TYPE; } - - void findAndCreateEffect(const Uuid& type); - void findEffectInstance(const Uuid& type, Uuid* uuid); - void getChannelCount(uint32_t* channelCount); - - sp<IEffectsFactory> effectsFactory; - sp<IEffect> effect; -}; - -void AudioEffectHidlTest::findAndCreateEffect(const Uuid& type) { - Uuid effectUuid; - findEffectInstance(type, &effectUuid); - Return<void> ret = effectsFactory->createEffect( - effectUuid, 1 /*session*/, 1 /*ioHandle*/, - [&](Result r, const sp<IEffect>& result, uint64_t /*effectId*/) { - if (r == Result::OK) { - effect = result; - } - }); - ASSERT_TRUE(ret.isOk()); -} - -void AudioEffectHidlTest::findEffectInstance(const Uuid& type, Uuid* uuid) { - bool effectFound = false; - Return<void> ret = effectsFactory->getAllDescriptors( - [&](Result r, const hidl_vec<EffectDescriptor>& result) { - if (r == Result::OK) { - for (const auto& desc : result) { - if (desc.type == type) { - effectFound = true; - *uuid = desc.uuid; - break; - } - } - } - }); - ASSERT_TRUE(ret.isOk()); - ASSERT_TRUE(effectFound); -} - -void AudioEffectHidlTest::getChannelCount(uint32_t* channelCount) { - Result retval; - EffectConfig currentConfig; - Return<void> ret = effect->getConfig([&](Result r, const EffectConfig& conf) { - retval = r; - if (r == Result::OK) { - currentConfig = conf; - } - }); - ASSERT_TRUE(ret.isOk()); - ASSERT_EQ(Result::OK, retval); - ASSERT_TRUE(audio_channel_mask_is_valid( - static_cast<audio_channel_mask_t>(currentConfig.outputCfg.channels))); - *channelCount = audio_channel_count_from_out_mask( - static_cast<audio_channel_mask_t>(currentConfig.outputCfg.channels)); -} - -TEST_F(AudioEffectHidlTest, Close) { - description("Verify that an effect can be closed"); - Return<Result> ret = effect->close(); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::OK, ret); -} - -TEST_F(AudioEffectHidlTest, GetDescriptor) { - description( - "Verify that an effect can return its own descriptor via GetDescriptor"); - Result retval = Result::NOT_INITIALIZED; - Uuid actualType; - Return<void> ret = - effect->getDescriptor([&](Result r, const EffectDescriptor& desc) { - retval = r; - if (r == Result::OK) { - actualType = desc.type; - } - }); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::OK, retval); - EXPECT_EQ(getEffectType(), actualType); -} - -TEST_F(AudioEffectHidlTest, GetSetConfig) { - description( - "Verify that it is possible to manipulate effect config via Get / " - "SetConfig"); - Result retval = Result::NOT_INITIALIZED; - EffectConfig currentConfig; - Return<void> ret = effect->getConfig([&](Result r, const EffectConfig& conf) { - retval = r; - if (r == Result::OK) { - currentConfig = conf; - } - }); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::OK, retval); - Return<Result> ret2 = effect->setConfig(currentConfig, nullptr, nullptr); - EXPECT_TRUE(ret2.isOk()); - EXPECT_EQ(Result::OK, ret2); -} - -TEST_F(AudioEffectHidlTest, GetConfigReverse) { - description("Verify that GetConfigReverse does not crash"); - Return<void> ret = - effect->getConfigReverse([&](Result, const EffectConfig&) {}); - EXPECT_TRUE(ret.isOk()); -} - -TEST_F(AudioEffectHidlTest, GetSupportedAuxChannelsConfigs) { - description("Verify that GetSupportedAuxChannelsConfigs does not crash"); - Return<void> ret = effect->getSupportedAuxChannelsConfigs( - 0, [&](Result, const hidl_vec<EffectAuxChannelsConfig>&) {}); - EXPECT_TRUE(ret.isOk()); -} - -TEST_F(AudioEffectHidlTest, GetAuxChannelsConfig) { - description("Verify that GetAuxChannelsConfig does not crash"); - Return<void> ret = effect->getAuxChannelsConfig( - [&](Result, const EffectAuxChannelsConfig&) {}); - EXPECT_TRUE(ret.isOk()); -} - -TEST_F(AudioEffectHidlTest, SetAuxChannelsConfig) { - description("Verify that SetAuxChannelsConfig does not crash"); - Return<Result> ret = effect->setAuxChannelsConfig(EffectAuxChannelsConfig()); - EXPECT_TRUE(ret.isOk()); -} - -// Not generated automatically because AudioBuffer contains -// instances of hidl_memory which can't be compared properly -// in general case due to presence of handles. -// -// However, in this particular case, handles must not present -// thus comparison is possible. -// -// operator== must be defined in the same namespace as the structures. -namespace android { -namespace hardware { -namespace audio { -namespace effect { -namespace V4_0 { -inline bool operator==(const AudioBuffer& lhs, const AudioBuffer& rhs) { - return lhs.id == rhs.id && lhs.frameCount == rhs.frameCount && - lhs.data.handle() == nullptr && rhs.data.handle() == nullptr; -} - -inline bool operator==(const EffectBufferConfig& lhs, - const EffectBufferConfig& rhs) { - return lhs.buffer == rhs.buffer && lhs.samplingRateHz == rhs.samplingRateHz && - lhs.channels == rhs.channels && lhs.format == rhs.format && - lhs.accessMode == rhs.accessMode && lhs.mask == rhs.mask; -} - -inline bool operator==(const EffectConfig& lhs, const EffectConfig& rhs) { - return lhs.inputCfg == rhs.inputCfg && lhs.outputCfg == rhs.outputCfg; -} -} // namespace V4_0 -} // namespace effect -} // namespace audio -} // namespace hardware -} // namespace android - -TEST_F(AudioEffectHidlTest, Reset) { - description("Verify that Reset preserves effect configuration"); - Result retval = Result::NOT_INITIALIZED; - EffectConfig originalConfig; - Return<void> ret = effect->getConfig([&](Result r, const EffectConfig& conf) { - retval = r; - if (r == Result::OK) { - originalConfig = conf; - } - }); - ASSERT_TRUE(ret.isOk()); - ASSERT_EQ(Result::OK, retval); - Return<Result> ret2 = effect->reset(); - EXPECT_TRUE(ret2.isOk()); - EXPECT_EQ(Result::OK, ret2); - EffectConfig configAfterReset; - ret = effect->getConfig([&](Result r, const EffectConfig& conf) { - retval = r; - if (r == Result::OK) { - configAfterReset = conf; - } - }); - EXPECT_EQ(originalConfig, configAfterReset); -} - -TEST_F(AudioEffectHidlTest, DisableEnableDisable) { - description("Verify Disable -> Enable -> Disable sequence for an effect"); - Return<Result> ret = effect->disable(); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::INVALID_ARGUMENTS, ret); - ret = effect->enable(); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::OK, ret); - ret = effect->disable(); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::OK, ret); -} - -TEST_F(AudioEffectHidlTest, SetDevice) { - description("Verify that SetDevice works for an output chain effect"); - Return<Result> ret = effect->setDevice(mkBitfield(AudioDevice::OUT_SPEAKER)); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::OK, ret); -} - -TEST_F(AudioEffectHidlTest, SetAndGetVolume) { - description("Verify that SetAndGetVolume method works for an effect"); - uint32_t channelCount; - getChannelCount(&channelCount); - hidl_vec<uint32_t> volumes; - volumes.resize(channelCount); - for (uint32_t i = 0; i < channelCount; ++i) { - volumes[i] = 0; - } - Result retval = Result::NOT_INITIALIZED; - Return<void> ret = effect->setAndGetVolume( - volumes, [&](Result r, const hidl_vec<uint32_t>&) { retval = r; }); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::OK, retval); -} - -TEST_F(AudioEffectHidlTest, VolumeChangeNotification) { - description("Verify that effect accepts VolumeChangeNotification"); - uint32_t channelCount; - getChannelCount(&channelCount); - hidl_vec<uint32_t> volumes; - volumes.resize(channelCount); - for (uint32_t i = 0; i < channelCount; ++i) { - volumes[i] = 0; - } - Return<Result> ret = effect->volumeChangeNotification(volumes); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::OK, ret); -} - -TEST_F(AudioEffectHidlTest, SetAudioMode) { - description("Verify that SetAudioMode works for an effect"); - Return<Result> ret = effect->setAudioMode(AudioMode::NORMAL); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::OK, ret); -} - -TEST_F(AudioEffectHidlTest, SetConfigReverse) { - description("Verify that SetConfigReverse does not crash"); - Return<Result> ret = - effect->setConfigReverse(EffectConfig(), nullptr, nullptr); - EXPECT_TRUE(ret.isOk()); -} - -TEST_F(AudioEffectHidlTest, SetInputDevice) { - description("Verify that SetInputDevice does not crash"); - Return<Result> ret = effect->setInputDevice(mkBitfield(AudioDevice::IN_BUILTIN_MIC)); - EXPECT_TRUE(ret.isOk()); -} - -TEST_F(AudioEffectHidlTest, SetAudioSource) { - description("Verify that SetAudioSource does not crash"); - Return<Result> ret = effect->setAudioSource(AudioSource::MIC); - EXPECT_TRUE(ret.isOk()); -} - -TEST_F(AudioEffectHidlTest, Offload) { - description("Verify that calling Offload method does not crash"); - EffectOffloadParameter offloadParam; - offloadParam.isOffload = false; - offloadParam.ioHandle = - static_cast<int>(AudioHandleConsts::AUDIO_IO_HANDLE_NONE); - Return<Result> ret = effect->offload(offloadParam); - EXPECT_TRUE(ret.isOk()); -} - -TEST_F(AudioEffectHidlTest, PrepareForProcessing) { - description("Verify that PrepareForProcessing method works for an effect"); - Result retval = Result::NOT_INITIALIZED; - Return<void> ret = effect->prepareForProcessing( - [&](Result r, const MQDescriptorSync<Result>&) { retval = r; }); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::OK, retval); -} - -TEST_F(AudioEffectHidlTest, SetProcessBuffers) { - description("Verify that SetProcessBuffers works for an effect"); - sp<IAllocator> ashmem = IAllocator::getService("ashmem"); - ASSERT_NE(nullptr, ashmem.get()); - bool success = false; - AudioBuffer buffer; - Return<void> ret = - ashmem->allocate(1024, [&](bool s, const hidl_memory& memory) { - success = s; - if (s) { - buffer.data = memory; - } - }); - ASSERT_TRUE(ret.isOk()); - ASSERT_TRUE(success); - Return<Result> ret2 = effect->setProcessBuffers(buffer, buffer); - EXPECT_TRUE(ret2.isOk()); - EXPECT_EQ(Result::OK, ret2); -} - -TEST_F(AudioEffectHidlTest, Command) { - description("Verify that Command does not crash"); - Return<void> ret = effect->command(0, hidl_vec<uint8_t>(), 0, - [&](int32_t, const hidl_vec<uint8_t>&) {}); - EXPECT_TRUE(ret.isOk()); -} - -TEST_F(AudioEffectHidlTest, SetParameter) { - description("Verify that SetParameter does not crash"); - Return<Result> ret = - effect->setParameter(hidl_vec<uint8_t>(), hidl_vec<uint8_t>()); - EXPECT_TRUE(ret.isOk()); -} - -TEST_F(AudioEffectHidlTest, GetParameter) { - description("Verify that GetParameter does not crash"); - Return<void> ret = effect->getParameter( - hidl_vec<uint8_t>(), 0, [&](Result, const hidl_vec<uint8_t>&) {}); - EXPECT_TRUE(ret.isOk()); -} - -TEST_F(AudioEffectHidlTest, GetSupportedConfigsForFeature) { - description("Verify that GetSupportedConfigsForFeature does not crash"); - Return<void> ret = effect->getSupportedConfigsForFeature( - 0, 0, 0, [&](Result, uint32_t, const hidl_vec<uint8_t>&) {}); - EXPECT_TRUE(ret.isOk()); -} - -TEST_F(AudioEffectHidlTest, GetCurrentConfigForFeature) { - description("Verify that GetCurrentConfigForFeature does not crash"); - Return<void> ret = effect->getCurrentConfigForFeature( - 0, 0, [&](Result, const hidl_vec<uint8_t>&) {}); - EXPECT_TRUE(ret.isOk()); -} - -TEST_F(AudioEffectHidlTest, SetCurrentConfigForFeature) { - description("Verify that SetCurrentConfigForFeature does not crash"); - Return<Result> ret = - effect->setCurrentConfigForFeature(0, hidl_vec<uint8_t>()); - EXPECT_TRUE(ret.isOk()); -} - - -// The main test class for Equalizer Audio Effect HIDL HAL. -class EqualizerAudioEffectHidlTest : public AudioEffectHidlTest { - public: - void SetUp() override { - AudioEffectHidlTest::SetUp(); - equalizer = IEqualizerEffect::castFrom(effect); - ASSERT_NE(nullptr, equalizer.get()); - } - - protected: - Uuid getEffectType() override { return EQUALIZER_EFFECT_TYPE; } - void getNumBands(uint16_t* numBands); - void getLevelRange(int16_t* minLevel, int16_t* maxLevel); - void getBandFrequencyRange(uint16_t band, uint32_t* minFreq, - uint32_t* centerFreq, uint32_t* maxFreq); - void getPresetCount(size_t* count); - - sp<IEqualizerEffect> equalizer; -}; - -void EqualizerAudioEffectHidlTest::getNumBands(uint16_t* numBands) { - Result retval = Result::NOT_INITIALIZED; - Return<void> ret = equalizer->getNumBands([&](Result r, uint16_t b) { - retval = r; - if (retval == Result::OK) { - *numBands = b; - } - }); - ASSERT_TRUE(ret.isOk()); - ASSERT_EQ(Result::OK, retval); -} - -void EqualizerAudioEffectHidlTest::getLevelRange(int16_t* minLevel, - int16_t* maxLevel) { - Result retval = Result::NOT_INITIALIZED; - Return<void> ret = - equalizer->getLevelRange([&](Result r, int16_t min, int16_t max) { - retval = r; - if (retval == Result::OK) { - *minLevel = min; - *maxLevel = max; - } - }); - ASSERT_TRUE(ret.isOk()); - ASSERT_EQ(Result::OK, retval); -} - -void EqualizerAudioEffectHidlTest::getBandFrequencyRange(uint16_t band, - uint32_t* minFreq, - uint32_t* centerFreq, - uint32_t* maxFreq) { - Result retval = Result::NOT_INITIALIZED; - Return<void> ret = equalizer->getBandFrequencyRange( - band, [&](Result r, uint32_t min, uint32_t max) { - retval = r; - if (retval == Result::OK) { - *minFreq = min; - *maxFreq = max; - } - }); - ASSERT_TRUE(ret.isOk()); - ASSERT_EQ(Result::OK, retval); - ret = equalizer->getBandCenterFrequency(band, [&](Result r, uint32_t center) { - retval = r; - if (retval == Result::OK) { - *centerFreq = center; - } - }); - ASSERT_TRUE(ret.isOk()); - ASSERT_EQ(Result::OK, retval); -} - -void EqualizerAudioEffectHidlTest::getPresetCount(size_t* count) { - Result retval = Result::NOT_INITIALIZED; - Return<void> ret = equalizer->getPresetNames( - [&](Result r, const hidl_vec<hidl_string>& names) { - retval = r; - if (retval == Result::OK) { - *count = names.size(); - } - }); - ASSERT_TRUE(ret.isOk()); - ASSERT_EQ(Result::OK, retval); -} - -TEST_F(EqualizerAudioEffectHidlTest, GetNumBands) { - description("Verify that Equalizer effect reports at least one band"); - uint16_t numBands = 0; - getNumBands(&numBands); - EXPECT_GT(numBands, 0); -} - -TEST_F(EqualizerAudioEffectHidlTest, GetLevelRange) { - description("Verify that Equalizer effect reports adequate band level range"); - int16_t minLevel = 0x7fff, maxLevel = 0; - getLevelRange(&minLevel, &maxLevel); - EXPECT_GT(maxLevel, minLevel); -} - -TEST_F(EqualizerAudioEffectHidlTest, GetSetBandLevel) { - description( - "Verify that manipulating band levels works for Equalizer effect"); - uint16_t numBands = 0; - getNumBands(&numBands); - ASSERT_GT(numBands, 0); - int16_t levels[3]{0x7fff, 0, 0}; - getLevelRange(&levels[0], &levels[2]); - ASSERT_GT(levels[2], levels[0]); - levels[1] = (levels[2] + levels[0]) / 2; - for (uint16_t i = 0; i < numBands; ++i) { - for (size_t j = 0; j < ARRAY_SIZE(levels); ++j) { - Return<Result> ret = equalizer->setBandLevel(i, levels[j]); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::OK, ret); - Result retval = Result::NOT_INITIALIZED; - int16_t actualLevel; - Return<void> ret2 = equalizer->getBandLevel(i, [&](Result r, int16_t l) { - retval = r; - if (retval == Result::OK) { - actualLevel = l; - } - }); - EXPECT_TRUE(ret2.isOk()); - EXPECT_EQ(Result::OK, retval); - EXPECT_EQ(levels[j], actualLevel); - } - } -} - -TEST_F(EqualizerAudioEffectHidlTest, GetBandCenterFrequencyAndRange) { - description( - "Verify that Equalizer effect reports adequate band frequency range"); - uint16_t numBands = 0; - getNumBands(&numBands); - ASSERT_GT(numBands, 0); - for (uint16_t i = 0; i < numBands; ++i) { - uint32_t minFreq = 0xffffffff, centerFreq = 0xffffffff, - maxFreq = 0xffffffff; - getBandFrequencyRange(i, &minFreq, ¢erFreq, &maxFreq); - // Note: NXP legacy implementation reports "1" as upper bound for last band, - // so this check fails. - EXPECT_GE(maxFreq, centerFreq); - EXPECT_GE(centerFreq, minFreq); - } -} - -TEST_F(EqualizerAudioEffectHidlTest, GetBandForFrequency) { - description( - "Verify that Equalizer effect supports GetBandForFrequency correctly"); - uint16_t numBands = 0; - getNumBands(&numBands); - ASSERT_GT(numBands, 0); - for (uint16_t i = 0; i < numBands; ++i) { - uint32_t freqs[3]{0, 0, 0}; - getBandFrequencyRange(i, &freqs[0], &freqs[1], &freqs[2]); - // NXP legacy implementation reports "1" as upper bound for last band, some - // of the checks fail. - for (size_t j = 0; j < ARRAY_SIZE(freqs); ++j) { - if (j == 0) { - freqs[j]++; - } // Min frequency is an open interval. - Result retval = Result::NOT_INITIALIZED; - uint16_t actualBand = numBands + 1; - Return<void> ret = - equalizer->getBandForFrequency(freqs[j], [&](Result r, uint16_t b) { - retval = r; - if (retval == Result::OK) { - actualBand = b; - } - }); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::OK, retval); - EXPECT_EQ(i, actualBand) << "Frequency: " << freqs[j]; - } - } -} - -TEST_F(EqualizerAudioEffectHidlTest, GetPresetNames) { - description("Verify that Equalizer effect reports at least one preset"); - size_t presetCount; - getPresetCount(&presetCount); - EXPECT_GT(presetCount, 0u); -} - -TEST_F(EqualizerAudioEffectHidlTest, GetSetCurrentPreset) { - description( - "Verify that manipulating the current preset for Equalizer effect"); - size_t presetCount; - getPresetCount(&presetCount); - ASSERT_GT(presetCount, 0u); - for (uint16_t i = 0; i < presetCount; ++i) { - Return<Result> ret = equalizer->setCurrentPreset(i); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::OK, ret); - Result retval = Result::NOT_INITIALIZED; - uint16_t actualPreset = 0xffff; - Return<void> ret2 = equalizer->getCurrentPreset([&](Result r, uint16_t p) { - retval = r; - if (retval == Result::OK) { - actualPreset = p; - } - }); - EXPECT_TRUE(ret2.isOk()); - EXPECT_EQ(Result::OK, retval); - EXPECT_EQ(i, actualPreset); - } -} - -TEST_F(EqualizerAudioEffectHidlTest, GetSetAllProperties) { - description( - "Verify that setting band levels and presets works via Get / " - "SetAllProperties for Equalizer effect"); - using AllProperties = - android::hardware::audio::effect::V4_0::IEqualizerEffect::AllProperties; - uint16_t numBands = 0; - getNumBands(&numBands); - ASSERT_GT(numBands, 0); - AllProperties props; - props.bandLevels.resize(numBands); - for (size_t i = 0; i < numBands; ++i) { - props.bandLevels[i] = 0; - } - - AllProperties actualProps; - Result retval = Result::NOT_INITIALIZED; - - // Verify setting of the band levels via properties. - props.curPreset = -1; - Return<Result> ret = equalizer->setAllProperties(props); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::OK, ret); - Return<void> ret2 = - equalizer->getAllProperties([&](Result r, AllProperties p) { - retval = r; - if (retval == Result::OK) { - actualProps = p; - } - }); - EXPECT_TRUE(ret2.isOk()); - EXPECT_EQ(Result::OK, retval); - EXPECT_EQ(props.bandLevels, actualProps.bandLevels); - - // Verify setting of the current preset via properties. - props.curPreset = 0; // Assuming there is at least one preset. - ret = equalizer->setAllProperties(props); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::OK, ret); - ret2 = equalizer->getAllProperties([&](Result r, AllProperties p) { - retval = r; - if (retval == Result::OK) { - actualProps = p; - } - }); - EXPECT_TRUE(ret2.isOk()); - EXPECT_EQ(Result::OK, retval); - EXPECT_EQ(props.curPreset, actualProps.curPreset); -} - -// The main test class for Equalizer Audio Effect HIDL HAL. -class LoudnessEnhancerAudioEffectHidlTest : public AudioEffectHidlTest { - public: - void SetUp() override { - AudioEffectHidlTest::SetUp(); - enhancer = ILoudnessEnhancerEffect::castFrom(effect); - ASSERT_NE(nullptr, enhancer.get()); - } - - protected: - Uuid getEffectType() override { return LOUDNESS_ENHANCER_EFFECT_TYPE; } - - sp<ILoudnessEnhancerEffect> enhancer; -}; - -TEST_F(LoudnessEnhancerAudioEffectHidlTest, GetSetTargetGain) { - description( - "Verify that manipulating the target gain works for Loudness Enhancer " - "effect"); - const int32_t gain = 100; - Return<Result> ret = enhancer->setTargetGain(gain); - EXPECT_TRUE(ret.isOk()); - EXPECT_EQ(Result::OK, ret); - int32_t actualGain = 0; - Result retval; - Return<void> ret2 = enhancer->getTargetGain([&](Result r, int32_t g) { - retval = r; - if (retval == Result::OK) { - actualGain = g; - } - }); - EXPECT_TRUE(ret2.isOk()); - EXPECT_EQ(Result::OK, retval); - EXPECT_EQ(gain, actualGain); -} - -int main(int argc, char** argv) { - ::testing::AddGlobalTestEnvironment(AudioEffectsFactoryHidlEnvironment::Instance()); - ::testing::InitGoogleTest(&argc, argv); - AudioEffectsFactoryHidlEnvironment::Instance()->init(&argc, argv); - int status = RUN_ALL_TESTS(); - LOG(INFO) << "Test result = " << status; - return status; -} diff --git a/audio/effect/4.0/xml/audio_effects_conf.xsd b/audio/effect/4.0/xml/audio_effects_conf.xsd new file mode 120000 index 0000000000..9d85fa7c68 --- /dev/null +++ b/audio/effect/4.0/xml/audio_effects_conf.xsd @@ -0,0 +1 @@ +../../2.0/xml/audio_effects_conf.xsd
\ No newline at end of file diff --git a/audio/effect/4.0/xml/audio_effects_conf_V4_0.xsd b/audio/effect/4.0/xml/audio_effects_conf_V4_0.xsd deleted file mode 120000 index 82d569a783..0000000000 --- a/audio/effect/4.0/xml/audio_effects_conf_V4_0.xsd +++ /dev/null @@ -1 +0,0 @@ -../../2.0/xml/audio_effects_conf_V2_0.xsd
\ No newline at end of file diff --git a/audio/effect/5.0/Android.bp b/audio/effect/5.0/Android.bp new file mode 100644 index 0000000000..d60d94aa9e --- /dev/null +++ b/audio/effect/5.0/Android.bp @@ -0,0 +1,47 @@ +// This file is autogenerated by hidl-gen -Landroidbp. + +hidl_interface { + name: "android.hardware.audio.effect@5.0", + root: "android.hardware", + vndk: { + enabled: true, + }, + srcs: [ + "types.hal", + "IAcousticEchoCancelerEffect.hal", + "IAutomaticGainControlEffect.hal", + "IBassBoostEffect.hal", + "IDownmixEffect.hal", + "IEffect.hal", + "IEffectBufferProviderCallback.hal", + "IEffectsFactory.hal", + "IEnvironmentalReverbEffect.hal", + "IEqualizerEffect.hal", + "ILoudnessEnhancerEffect.hal", + "INoiseSuppressionEffect.hal", + "IPresetReverbEffect.hal", + "IVirtualizerEffect.hal", + "IVisualizerEffect.hal", + ], + interfaces: [ + "android.hardware.audio.common@5.0", + "android.hidl.base@1.0", + ], + types: [ + "AudioBuffer", + "EffectAuxChannelsConfig", + "EffectBufferAccess", + "EffectBufferConfig", + "EffectConfig", + "EffectConfigParameters", + "EffectDescriptor", + "EffectFeature", + "EffectFlags", + "EffectOffloadParameter", + "MessageQueueFlagBits", + "Result", + ], + gen_java: false, + gen_java_constants: true, +} + diff --git a/audio/effect/4.0/default/AudioBufferManager.h b/audio/effect/5.0/IAcousticEchoCancelerEffect.hal index 1f151e6b99..61cdc95b0b 100644 --- a/audio/effect/4.0/default/AudioBufferManager.h +++ b/audio/effect/5.0/IAcousticEchoCancelerEffect.hal @@ -14,13 +14,19 @@ * limitations under the License. */ -#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_AUDIO_BUFFER_MANAGER_H_ -#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_AUDIO_BUFFER_MANAGER_H_ +package android.hardware.audio.effect@5.0; -#include <android/hardware/audio/effect/4.0/types.h> +import android.hardware.audio.common@5.0; +import IEffect; -#define AUDIO_HAL_VERSION V4_0 -#include <effect/all-versions/default/AudioBufferManager.h> -#undef AUDIO_HAL_VERSION +interface IAcousticEchoCancelerEffect extends IEffect { + /** + * Sets echo delay value in milliseconds. + */ + setEchoDelay(uint32_t echoDelayMs) generates (Result retval); -#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_AUDIO_BUFFER_MANAGER_H_ + /** + * Gets echo delay value in milliseconds. + */ + getEchoDelay() generates (Result retval, uint32_t echoDelayMs); +}; diff --git a/audio/effect/5.0/IAutomaticGainControlEffect.hal b/audio/effect/5.0/IAutomaticGainControlEffect.hal new file mode 100644 index 0000000000..ae354ecb90 --- /dev/null +++ b/audio/effect/5.0/IAutomaticGainControlEffect.hal @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2018 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.effect@5.0; + +import android.hardware.audio.common@5.0; +import IEffect; + +interface IAutomaticGainControlEffect extends IEffect { + /** + * Sets target level in millibels. + */ + setTargetLevel(int16_t targetLevelMb) generates (Result retval); + + /** + * Gets target level. + */ + getTargetLevel() generates (Result retval, int16_t targetLevelMb); + + /** + * Sets gain in the compression range in millibels. + */ + setCompGain(int16_t compGainMb) generates (Result retval); + + /** + * Gets gain in the compression range. + */ + getCompGain() generates (Result retval, int16_t compGainMb); + + /** + * Enables or disables limiter. + */ + setLimiterEnabled(bool enabled) generates (Result retval); + + /** + * Returns whether limiter is enabled. + */ + isLimiterEnabled() generates (Result retval, bool enabled); + + struct AllProperties { + int16_t targetLevelMb; + int16_t compGainMb; + bool limiterEnabled; + }; + + /** + * Sets all properties at once. + */ + setAllProperties(AllProperties properties) generates (Result retval); + + /** + * Gets all properties at once. + */ + getAllProperties() generates (Result retval, AllProperties properties); +}; diff --git a/audio/effect/5.0/IBassBoostEffect.hal b/audio/effect/5.0/IBassBoostEffect.hal new file mode 100644 index 0000000000..4b3b629e80 --- /dev/null +++ b/audio/effect/5.0/IBassBoostEffect.hal @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2018 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.effect@5.0; + +import android.hardware.audio.common@5.0; +import IEffect; + +interface IBassBoostEffect extends IEffect { + /** + * Returns whether setting bass boost strength is supported. + */ + isStrengthSupported() generates (Result retval, bool strengthSupported); + + enum StrengthRange : uint16_t { + MIN = 0, + MAX = 1000 + }; + + /** + * Sets bass boost strength. + * + * @param strength strength of the effect. The valid range for strength + * strength is [0, 1000], where 0 per mille designates the + * mildest effect and 1000 per mille designates the + * strongest. + * @return retval operation completion status. + */ + setStrength(uint16_t strength) generates (Result retval); + + /** + * Gets virtualization strength. + */ + getStrength() generates (Result retval, uint16_t strength); +}; diff --git a/audio/effect/4.0/default/AcousticEchoCancelerEffect.h b/audio/effect/5.0/IDownmixEffect.hal index 0ac0a1e0df..43d4b23af1 100644 --- a/audio/effect/4.0/default/AcousticEchoCancelerEffect.h +++ b/audio/effect/5.0/IDownmixEffect.hal @@ -14,15 +14,24 @@ * limitations under the License. */ -#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_ACOUSTICECHOCANCELEREFFECT_H -#define ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_ACOUSTICECHOCANCELEREFFECT_H +package android.hardware.audio.effect@5.0; -#include <android/hardware/audio/effect/4.0/IAcousticEchoCancelerEffect.h> +import android.hardware.audio.common@5.0; +import IEffect; -#include "Effect.h" +interface IDownmixEffect extends IEffect { + enum Type : int32_t { + STRIP, // throw away the extra channels + FOLD // mix the extra channels with FL/FR + }; -#define AUDIO_HAL_VERSION V4_0 -#include <effect/all-versions/default/AcousticEchoCancelerEffect.h> -#undef AUDIO_HAL_VERSION + /** + * Sets the current downmix preset. + */ + setType(Type preset) generates (Result retval); -#endif // ANDROID_HARDWARE_AUDIO_EFFECT_V4_0_ACOUSTICECHOCANCELEREFFECT_H + /** + * Gets the current downmix preset. + */ + getType() generates (Result retval, Type preset); +}; diff --git a/audio/effect/5.0/IEffect.hal b/audio/effect/5.0/IEffect.hal new file mode 100644 index 0000000000..9c5096368d --- /dev/null +++ b/audio/effect/5.0/IEffect.hal @@ -0,0 +1,418 @@ +/* + * Copyright (C) 2018 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.effect@5.0; + +import android.hardware.audio.common@5.0; +import IEffectBufferProviderCallback; + +interface IEffect { + /** + * Initialize effect engine--all configurations return to default. + * + * @return retval operation completion status. + */ + @entry + init() generates (Result retval); + + /** + * Apply new audio parameters configurations for input and output buffers. + * The provider callbacks may be empty, but in this case the buffer + * must be provided in the EffectConfig structure. + * + * @param config configuration descriptor. + * @param inputBufferProvider optional buffer provider reference. + * @param outputBufferProvider optional buffer provider reference. + * @return retval operation completion status. + */ + setConfig(EffectConfig config, + IEffectBufferProviderCallback inputBufferProvider, + IEffectBufferProviderCallback outputBufferProvider) + generates (Result retval); + + /** + * Reset the effect engine. Keep configuration but resets state and buffer + * content. + * + * @return retval operation completion status. + */ + reset() generates (Result retval); + + /** + * Enable processing. + * + * @return retval operation completion status. + */ + @callflow(next={"prepareForProcessing"}) + enable() generates (Result retval); + + /** + * Disable processing. + * + * @return retval operation completion status. + */ + @callflow(next={"close"}) + disable() generates (Result retval); + + /** + * Set the rendering device the audio output path is connected to. The + * effect implementation must set EFFECT_FLAG_DEVICE_IND flag in its + * descriptor to receive this command when the device changes. + * + * Note: this method is only supported for effects inserted into + * the output chain. + * + * @param device output device specification. + * @return retval operation completion status. + */ + setDevice(bitfield<AudioDevice> device) generates (Result retval); + + /** + * Set and get volume. Used by audio framework to delegate volume control to + * effect engine. The effect implementation must set EFFECT_FLAG_VOLUME_CTRL + * flag in its descriptor to receive this command. The effect engine must + * return the volume that should be applied before the effect is + * processed. The overall volume (the volume actually applied by the effect + * engine multiplied by the returned value) should match the value indicated + * in the command. + * + * @param volumes vector containing volume for each channel defined in + * EffectConfig for output buffer expressed in 8.24 fixed + * point format. + * @return result updated volume values. + * @return retval operation completion status. + */ + setAndGetVolume(vec<uint32_t> volumes) + generates (Result retval, vec<uint32_t> result); + + /** + * Notify the effect of the volume change. The effect implementation must + * set EFFECT_FLAG_VOLUME_IND flag in its descriptor to receive this + * command. + * + * @param volumes vector containing volume for each channel defined in + * EffectConfig for output buffer expressed in 8.24 fixed + * point format. + * @return retval operation completion status. + */ + volumeChangeNotification(vec<uint32_t> volumes) + generates (Result retval); + + /** + * Set the audio mode. The effect implementation must set + * EFFECT_FLAG_AUDIO_MODE_IND flag in its descriptor to receive this command + * when the audio mode changes. + * + * @param mode desired audio mode. + * @return retval operation completion status. + */ + setAudioMode(AudioMode mode) generates (Result retval); + + /** + * Apply new audio parameters configurations for input and output buffers of + * reverse stream. An example of reverse stream is the echo reference + * supplied to an Acoustic Echo Canceler. + * + * @param config configuration descriptor. + * @param inputBufferProvider optional buffer provider reference. + * @param outputBufferProvider optional buffer provider reference. + * @return retval operation completion status. + */ + setConfigReverse(EffectConfig config, + IEffectBufferProviderCallback inputBufferProvider, + IEffectBufferProviderCallback outputBufferProvider) + generates (Result retval); + + /** + * Set the capture device the audio input path is connected to. The effect + * implementation must set EFFECT_FLAG_DEVICE_IND flag in its descriptor to + * receive this command when the device changes. + * + * Note: this method is only supported for effects inserted into + * the input chain. + * + * @param device input device specification. + * @return retval operation completion status. + */ + setInputDevice(bitfield<AudioDevice> device) generates (Result retval); + + /** + * Read audio parameters configurations for input and output buffers. + * + * @return retval operation completion status. + * @return config configuration descriptor. + */ + getConfig() generates (Result retval, EffectConfig config); + + /** + * Read audio parameters configurations for input and output buffers of + * reverse stream. + * + * @return retval operation completion status. + * @return config configuration descriptor. + */ + getConfigReverse() generates (Result retval, EffectConfig config); + + /** + * Queries for supported combinations of main and auxiliary channels + * (e.g. for a multi-microphone noise suppressor). + * + * @param maxConfigs maximum number of the combinations to return. + * @return retval absence of the feature support is indicated using + * NOT_SUPPORTED code. RESULT_TOO_BIG is returned if + * the number of supported combinations exceeds 'maxConfigs'. + * @return result list of configuration descriptors. + */ + getSupportedAuxChannelsConfigs(uint32_t maxConfigs) + generates (Result retval, vec<EffectAuxChannelsConfig> result); + + /** + * Retrieves the current configuration of main and auxiliary channels. + * + * @return retval absence of the feature support is indicated using + * NOT_SUPPORTED code. + * @return result configuration descriptor. + */ + getAuxChannelsConfig() + generates (Result retval, EffectAuxChannelsConfig result); + + /** + * Sets the current configuration of main and auxiliary channels. + * + * @return retval operation completion status; absence of the feature + * support is indicated using NOT_SUPPORTED code. + */ + setAuxChannelsConfig(EffectAuxChannelsConfig config) + generates (Result retval); + + /** + * Set the audio source the capture path is configured for (Camcorder, voice + * recognition...). + * + * Note: this method is only supported for effects inserted into + * the input chain. + * + * @param source source descriptor. + * @return retval operation completion status. + */ + setAudioSource(AudioSource source) generates (Result retval); + + /** + * This command indicates if the playback thread the effect is attached to + * is offloaded or not, and updates the I/O handle of the playback thread + * the effect is attached to. + * + * @param param effect offload descriptor. + * @return retval operation completion status. + */ + offload(EffectOffloadParameter param) generates (Result retval); + + /** + * Returns the effect descriptor. + * + * @return retval operation completion status. + * @return descriptor effect descriptor. + */ + getDescriptor() generates (Result retval, EffectDescriptor descriptor); + + /** + * Set up required transports for passing audio buffers to the effect. + * + * The transport consists of shared memory and a message queue for reporting + * effect processing operation status. The shared memory is set up + * separately using 'setProcessBuffers' method. + * + * Processing is requested by setting 'REQUEST_PROCESS' or + * 'REQUEST_PROCESS_REVERSE' EventFlags associated with the status message + * queue. The result of processing may be one of the following: + * OK if there were no errors during processing; + * INVALID_ARGUMENTS if audio buffers are invalid; + * INVALID_STATE if the engine has finished the disable phase; + * NOT_INITIALIZED if the audio buffers were not set; + * NOT_SUPPORTED if the requested processing type is not supported by + * the effect. + * + * @return retval OK if both message queues were created successfully. + * INVALID_STATE if the method was already called. + * INVALID_ARGUMENTS if there was a problem setting up + * the queue. + * @return statusMQ a message queue used for passing status from the effect. + */ + @callflow(next={"setProcessBuffers"}) + prepareForProcessing() generates (Result retval, fmq_sync<Result> statusMQ); + + /** + * Set up input and output buffers for processing audio data. The effect + * may modify both the input and the output buffer during the operation. + * Buffers may be set multiple times during effect lifetime. + * + * The input and the output buffer may be reused between different effects, + * and the input buffer may be used as an output buffer. Buffers are + * distinguished using 'AudioBuffer.id' field. + * + * @param inBuffer input audio buffer. + * @param outBuffer output audio buffer. + * @return retval OK if both buffers were mapped successfully. + * INVALID_ARGUMENTS if there was a problem with mapping + * any of the buffers. + */ + setProcessBuffers(AudioBuffer inBuffer, AudioBuffer outBuffer) + generates (Result retval); + + /** + * Execute a vendor specific command on the effect. The command code + * and data, as well as result data are not interpreted by Android + * Framework and are passed as-is between the application and the effect. + * + * The effect must use standard POSIX.1-2001 error codes for the operation + * completion status. + * + * Use this method only if the effect is provided by a third party, and + * there is no interface defined for it. This method only works for effects + * implemented in software. + * + * @param commandId the ID of the command. + * @param data command data. + * @param resultMaxSize maximum size in bytes of the result; can be 0. + * @return status command completion status. + * @return result result data. + */ + command(uint32_t commandId, vec<uint8_t> data, uint32_t resultMaxSize) + generates (int32_t status, vec<uint8_t> result); + + /** + * Set a vendor-specific parameter and apply it immediately. The parameter + * code and data are not interpreted by Android Framework and are passed + * as-is between the application and the effect. + * + * The effect must use INVALID_ARGUMENTS return code if the parameter ID is + * unknown or if provided parameter data is invalid. If the effect does not + * support setting vendor-specific parameters, it must return NOT_SUPPORTED. + * + * Use this method only if the effect is provided by a third party, and + * there is no interface defined for it. This method only works for effects + * implemented in software. + * + * @param parameter identifying data of the parameter. + * @param value the value of the parameter. + * @return retval operation completion status. + */ + setParameter(vec<uint8_t> parameter, vec<uint8_t> value) + generates (Result retval); + + /** + * Get a vendor-specific parameter value. The parameter code and returned + * data are not interpreted by Android Framework and are passed as-is + * between the application and the effect. + * + * The effect must use INVALID_ARGUMENTS return code if the parameter ID is + * unknown. If the effect does not support setting vendor-specific + * parameters, it must return NOT_SUPPORTED. + * + * Use this method only if the effect is provided by a third party, and + * there is no interface defined for it. This method only works for effects + * implemented in software. + * + * @param parameter identifying data of the parameter. + * @param valueMaxSize maximum size in bytes of the value. + * @return retval operation completion status. + * @return result the value of the parameter. + */ + getParameter(vec<uint8_t> parameter, uint32_t valueMaxSize) + generates (Result retval, vec<uint8_t> value); + + /** + * Get supported configs for a vendor-specific feature. The configs returned + * are not interpreted by Android Framework and are passed as-is between the + * application and the effect. + * + * The effect must use INVALID_ARGUMENTS return code if the feature ID is + * unknown. If the effect does not support getting vendor-specific feature + * configs, it must return NOT_SUPPORTED. If the feature is supported but + * the total number of supported configurations exceeds the maximum number + * indicated by the caller, the method must return RESULT_TOO_BIG. + * + * Use this method only if the effect is provided by a third party, and + * there is no interface defined for it. This method only works for effects + * implemented in software. + * + * @param featureId feature identifier. + * @param maxConfigs maximum number of configs to return. + * @param configSize size of each config in bytes. + * @return retval operation completion status. + * @return configsCount number of configs returned. + * @return configsData data for all the configs returned. + */ + getSupportedConfigsForFeature( + uint32_t featureId, + uint32_t maxConfigs, + uint32_t configSize) generates ( + Result retval, + uint32_t configsCount, + vec<uint8_t> configsData); + + /** + * Get the current config for a vendor-specific feature. The config returned + * is not interpreted by Android Framework and is passed as-is between the + * application and the effect. + * + * The effect must use INVALID_ARGUMENTS return code if the feature ID is + * unknown. If the effect does not support getting vendor-specific + * feature configs, it must return NOT_SUPPORTED. + * + * Use this method only if the effect is provided by a third party, and + * there is no interface defined for it. This method only works for effects + * implemented in software. + * + * @param featureId feature identifier. + * @param configSize size of the config in bytes. + * @return retval operation completion status. + * @return configData config data. + */ + getCurrentConfigForFeature(uint32_t featureId, uint32_t configSize) + generates (Result retval, vec<uint8_t> configData); + + /** + * Set the current config for a vendor-specific feature. The config data + * is not interpreted by Android Framework and is passed as-is between the + * application and the effect. + * + * The effect must use INVALID_ARGUMENTS return code if the feature ID is + * unknown. If the effect does not support getting vendor-specific + * feature configs, it must return NOT_SUPPORTED. + * + * Use this method only if the effect is provided by a third party, and + * there is no interface defined for it. This method only works for effects + * implemented in software. + * + * @param featureId feature identifier. + * @param configData config data. + * @return retval operation completion status. + */ + setCurrentConfigForFeature(uint32_t featureId, vec<uint8_t> configData) + generates (Result retval); + + /** + * Called by the framework to deinitialize the effect and free up + * all the currently allocated resources. It is recommended to close + * the effect on the client side as soon as it is becomes unused. + * + * @return retval OK in case the success. + * INVALID_STATE if the effect was already closed. + */ + @exit + close() generates (Result retval); +}; diff --git a/audio/effect/5.0/IEffectBufferProviderCallback.hal b/audio/effect/5.0/IEffectBufferProviderCallback.hal new file mode 100644 index 0000000000..aabd15e9dc --- /dev/null +++ b/audio/effect/5.0/IEffectBufferProviderCallback.hal @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2018 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.effect@5.0; + +/** + * This callback interface contains functions that can be used by the effect + * engine 'process' function to exchange input and output audio buffers. + */ +interface IEffectBufferProviderCallback { + /** + * Called to retrieve a buffer where data should read from by 'process' + * function. + * + * @return buffer audio buffer for processing + */ + getBuffer() generates (AudioBuffer buffer); + + /** + * Called to provide a buffer with the data written by 'process' function. + * + * @param buffer audio buffer for processing + */ + putBuffer(AudioBuffer buffer); +}; diff --git a/audio/effect/5.0/IEffectsFactory.hal b/audio/effect/5.0/IEffectsFactory.hal new file mode 100644 index 0000000000..a88b3812bb --- /dev/null +++ b/audio/effect/5.0/IEffectsFactory.hal @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 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.effect@5.0; + +import android.hardware.audio.common@5.0; +import IEffect; + +interface IEffectsFactory { + /** + * Returns descriptors of different effects in all loaded libraries. + * + * @return retval operation completion status. + * @return result list of effect descriptors. + */ + getAllDescriptors() generates(Result retval, vec<EffectDescriptor> result); + + /** + * Returns a descriptor of a particular effect. + * + * @return retval operation completion status. + * @return result effect descriptor. + */ + getDescriptor(Uuid uid) generates(Result retval, EffectDescriptor result); + + /** + * Creates an effect engine of the specified type. To release the effect + * engine, it is necessary to release references to the returned effect + * object. + * + * @param uid effect uuid. + * @param session audio session to which this effect instance will be + * attached. All effects created with the same session ID + * are connected in series and process the same signal + * stream. + * @param ioHandle identifies the output or input stream this effect is + * directed to in audio HAL. + * @return retval operation completion status. + * @return result the interface for the created effect. + * @return effectId the unique ID of the effect to be used with + * IStream::addEffect and IStream::removeEffect methods. + */ + createEffect(Uuid uid, AudioSession session, AudioIoHandle ioHandle) + generates (Result retval, IEffect result, uint64_t effectId); +}; diff --git a/audio/effect/5.0/IEnvironmentalReverbEffect.hal b/audio/effect/5.0/IEnvironmentalReverbEffect.hal new file mode 100644 index 0000000000..ffc4312abb --- /dev/null +++ b/audio/effect/5.0/IEnvironmentalReverbEffect.hal @@ -0,0 +1,178 @@ +/* + * Copyright (C) 2018 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.effect@5.0; + +import android.hardware.audio.common@5.0; +import IEffect; + +interface IEnvironmentalReverbEffect extends IEffect { + /** + * Sets whether the effect should be bypassed. + */ + setBypass(bool bypass) generates (Result retval); + + /** + * Gets whether the effect should be bypassed. + */ + getBypass() generates (Result retval, bool bypass); + + enum ParamRange : int16_t { + ROOM_LEVEL_MIN = -6000, + ROOM_LEVEL_MAX = 0, + ROOM_HF_LEVEL_MIN = -4000, + ROOM_HF_LEVEL_MAX = 0, + DECAY_TIME_MIN = 100, + DECAY_TIME_MAX = 20000, + DECAY_HF_RATIO_MIN = 100, + DECAY_HF_RATIO_MAX = 1000, + REFLECTIONS_LEVEL_MIN = -6000, + REFLECTIONS_LEVEL_MAX = 0, + REFLECTIONS_DELAY_MIN = 0, + REFLECTIONS_DELAY_MAX = 65, + REVERB_LEVEL_MIN = -6000, + REVERB_LEVEL_MAX = 0, + REVERB_DELAY_MIN = 0, + REVERB_DELAY_MAX = 65, + DIFFUSION_MIN = 0, + DIFFUSION_MAX = 1000, + DENSITY_MIN = 0, + DENSITY_MAX = 1000 + }; + + /** + * Sets the room level. + */ + setRoomLevel(int16_t roomLevel) generates (Result retval); + + /** + * Gets the room level. + */ + getRoomLevel() generates (Result retval, int16_t roomLevel); + + /** + * Sets the room high frequencies level. + */ + setRoomHfLevel(int16_t roomHfLevel) generates (Result retval); + + /** + * Gets the room high frequencies level. + */ + getRoomHfLevel() generates (Result retval, int16_t roomHfLevel); + + /** + * Sets the room decay time. + */ + setDecayTime(uint32_t decayTime) generates (Result retval); + + /** + * Gets the room decay time. + */ + getDecayTime() generates (Result retval, uint32_t decayTime); + + /** + * Sets the ratio of high frequencies decay. + */ + setDecayHfRatio(int16_t decayHfRatio) generates (Result retval); + + /** + * Gets the ratio of high frequencies decay. + */ + getDecayHfRatio() generates (Result retval, int16_t decayHfRatio); + + /** + * Sets the level of reflections in the room. + */ + setReflectionsLevel(int16_t reflectionsLevel) generates (Result retval); + + /** + * Gets the level of reflections in the room. + */ + getReflectionsLevel() generates (Result retval, int16_t reflectionsLevel); + + /** + * Sets the reflections delay in the room. + */ + setReflectionsDelay(uint32_t reflectionsDelay) generates (Result retval); + + /** + * Gets the reflections delay in the room. + */ + getReflectionsDelay() generates (Result retval, uint32_t reflectionsDelay); + + /** + * Sets the reverb level of the room. + */ + setReverbLevel(int16_t reverbLevel) generates (Result retval); + + /** + * Gets the reverb level of the room. + */ + getReverbLevel() generates (Result retval, int16_t reverbLevel); + + /** + * Sets the reverb delay of the room. + */ + setReverbDelay(uint32_t reverDelay) generates (Result retval); + + /** + * Gets the reverb delay of the room. + */ + getReverbDelay() generates (Result retval, uint32_t reverbDelay); + + /** + * Sets room diffusion. + */ + setDiffusion(int16_t diffusion) generates (Result retval); + + /** + * Gets room diffusion. + */ + getDiffusion() generates (Result retval, int16_t diffusion); + + /** + * Sets room wall density. + */ + setDensity(int16_t density) generates (Result retval); + + /** + * Gets room wall density. + */ + getDensity() generates (Result retval, int16_t density); + + struct AllProperties { + int16_t roomLevel; // in millibels, range -6000 to 0 + int16_t roomHfLevel; // in millibels, range -4000 to 0 + uint32_t decayTime; // in milliseconds, range 100 to 20000 + int16_t decayHfRatio; // in permilles, range 100 to 1000 + int16_t reflectionsLevel; // in millibels, range -6000 to 0 + uint32_t reflectionsDelay; // in milliseconds, range 0 to 65 + int16_t reverbLevel; // in millibels, range -6000 to 0 + uint32_t reverbDelay; // in milliseconds, range 0 to 65 + int16_t diffusion; // in permilles, range 0 to 1000 + int16_t density; // in permilles, range 0 to 1000 + }; + + /** + * Sets all properties at once. + */ + setAllProperties(AllProperties properties) generates (Result retval); + + /** + * Gets all properties at once. + */ + getAllProperties() generates (Result retval, AllProperties properties); +}; diff --git a/audio/effect/5.0/IEqualizerEffect.hal b/audio/effect/5.0/IEqualizerEffect.hal new file mode 100644 index 0000000000..c9829f3539 --- /dev/null +++ b/audio/effect/5.0/IEqualizerEffect.hal @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2018 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.effect@5.0; + +import android.hardware.audio.common@5.0; +import IEffect; + +interface IEqualizerEffect extends IEffect { + /** + * Gets the number of frequency bands that the equalizer supports. + */ + getNumBands() generates (Result retval, uint16_t numBands); + + /** + * Returns the minimum and maximum band levels supported. + */ + getLevelRange() + generates (Result retval, int16_t minLevel, int16_t maxLevel); + + /** + * Sets the gain for the given equalizer band. + */ + setBandLevel(uint16_t band, int16_t level) generates (Result retval); + + /** + * Gets the gain for the given equalizer band. + */ + getBandLevel(uint16_t band) generates (Result retval, int16_t level); + + /** + * Gets the center frequency of the given band, in milliHertz. + */ + getBandCenterFrequency(uint16_t band) + generates (Result retval, uint32_t centerFreqmHz); + + /** + * Gets the frequency range of the given frequency band, in milliHertz. + */ + getBandFrequencyRange(uint16_t band) + generates (Result retval, uint32_t minFreqmHz, uint32_t maxFreqmHz); + + /** + * Gets the band that has the most effect on the given frequency + * in milliHertz. + */ + getBandForFrequency(uint32_t freqmHz) + generates (Result retval, uint16_t band); + + /** + * Gets the names of all presets the equalizer supports. + */ + getPresetNames() generates (Result retval, vec<string> names); + + /** + * Sets the current preset using the index of the preset in the names + * vector returned via 'getPresetNames'. + */ + setCurrentPreset(uint16_t preset) generates (Result retval); + + /** + * Gets the current preset. + */ + getCurrentPreset() generates (Result retval, uint16_t preset); + + struct AllProperties { + uint16_t curPreset; + vec<int16_t> bandLevels; + }; + + /** + * Sets all properties at once. + */ + setAllProperties(AllProperties properties) generates (Result retval); + + /** + * Gets all properties at once. + */ + getAllProperties() generates (Result retval, AllProperties properties); +}; diff --git a/audio/core/2.0/default/include/core/2.0/default/Util.h b/audio/effect/5.0/ILoudnessEnhancerEffect.hal index 1f0e284d0a..eaf89495fc 100644 --- a/audio/core/2.0/default/include/core/2.0/default/Util.h +++ b/audio/effect/5.0/ILoudnessEnhancerEffect.hal @@ -14,13 +14,19 @@ * limitations under the License. */ -#ifndef ANDROID_HARDWARE_AUDIO_V2_0_UTIL_H -#define ANDROID_HARDWARE_AUDIO_V2_0_UTIL_H +package android.hardware.audio.effect@5.0; -#include <android/hardware/audio/2.0/types.h> +import android.hardware.audio.common@5.0; +import IEffect; -#define AUDIO_HAL_VERSION V2_0 -#include <core/all-versions/default/Util.h> -#undef AUDIO_HAL_VERSION +interface ILoudnessEnhancerEffect extends IEffect { + /** + * Sets target gain expressed in millibels. + */ + setTargetGain(int32_t targetGainMb) generates (Result retval); -#endif // ANDROID_HARDWARE_AUDIO_V2_0_UTIL_H + /** + * Gets target gain expressed in millibels. + */ + getTargetGain() generates (Result retval, int32_t targetGainMb); +}; diff --git a/audio/effect/5.0/INoiseSuppressionEffect.hal b/audio/effect/5.0/INoiseSuppressionEffect.hal new file mode 100644 index 0000000000..5de794f4e1 --- /dev/null +++ b/audio/effect/5.0/INoiseSuppressionEffect.hal @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2018 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.effect@5.0; + +import android.hardware.audio.common@5.0; +import IEffect; + +interface INoiseSuppressionEffect extends IEffect { + enum Level : int32_t { + LOW, + MEDIUM, + HIGH + }; + + /** + * Sets suppression level. + */ + setSuppressionLevel(Level level) generates (Result retval); + + /** + * Gets suppression level. + */ + getSuppressionLevel() generates (Result retval, Level level); + + enum Type : int32_t { + SINGLE_CHANNEL, + MULTI_CHANNEL + }; + + /** + * Set suppression type. + */ + setSuppressionType(Type type) generates (Result retval); + + /** + * Get suppression type. + */ + getSuppressionType() generates (Result retval, Type type); + + struct AllProperties { + Level level; + Type type; + }; + + /** + * Sets all properties at once. + */ + setAllProperties(AllProperties properties) generates (Result retval); + + /** + * Gets all properties at once. + */ + getAllProperties() generates (Result retval, AllProperties properties); +}; diff --git a/audio/effect/5.0/IPresetReverbEffect.hal b/audio/effect/5.0/IPresetReverbEffect.hal new file mode 100644 index 0000000000..af3b3ac264 --- /dev/null +++ b/audio/effect/5.0/IPresetReverbEffect.hal @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2018 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.effect@5.0; + +import android.hardware.audio.common@5.0; +import IEffect; + +interface IPresetReverbEffect extends IEffect { + enum Preset : int32_t { + NONE, // no reverb or reflections + SMALLROOM, // a small room less than five meters in length + MEDIUMROOM, // a medium room with a length of ten meters or less + LARGEROOM, // a large-sized room suitable for live performances + MEDIUMHALL, // a medium-sized hall + LARGEHALL, // a large-sized hall suitable for a full orchestra + PLATE, // synthesis of the traditional plate reverb + LAST = PLATE + }; + + /** + * Sets the current preset. + */ + setPreset(Preset preset) generates (Result retval); + + /** + * Gets the current preset. + */ + getPreset() generates (Result retval, Preset preset); +}; diff --git a/audio/effect/5.0/IVirtualizerEffect.hal b/audio/effect/5.0/IVirtualizerEffect.hal new file mode 100644 index 0000000000..9402958ea3 --- /dev/null +++ b/audio/effect/5.0/IVirtualizerEffect.hal @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2018 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.effect@5.0; + +import android.hardware.audio.common@5.0; +import IEffect; + +interface IVirtualizerEffect extends IEffect { + /** + * Returns whether setting virtualization strength is supported. + */ + isStrengthSupported() generates (bool strengthSupported); + + enum StrengthRange : uint16_t { + MIN = 0, + MAX = 1000 + }; + + /** + * Sets virtualization strength. + * + * @param strength strength of the effect. The valid range for strength + * strength is [0, 1000], where 0 per mille designates the + * mildest effect and 1000 per mille designates the + * strongest. + * @return retval operation completion status. + */ + setStrength(uint16_t strength) generates (Result retval); + + /** + * Gets virtualization strength. + */ + getStrength() generates (Result retval, uint16_t strength); + + struct SpeakerAngle { + /** Speaker channel mask */ + bitfield<AudioChannelMask> mask; + // all angles are expressed in degrees and + // are relative to the listener. + int16_t azimuth; // 0 is the direction the listener faces + // 180 is behind the listener + // -90 is to their left + int16_t elevation; // 0 is the horizontal plane + // +90 is above the listener, -90 is below + }; + /** + * Retrieves virtual speaker angles for the given channel mask on the + * specified device. + */ + getVirtualSpeakerAngles(bitfield<AudioChannelMask> mask, AudioDevice device) + generates (Result retval, vec<SpeakerAngle> speakerAngles); + + /** + * Forces the virtualizer effect for the given output device. + */ + forceVirtualizationMode(AudioDevice device) generates (Result retval); + + /** + * Returns audio device reflecting the current virtualization mode, + * AUDIO_DEVICE_NONE when not virtualizing. + */ + getVirtualizationMode() generates (Result retval, AudioDevice device); +}; diff --git a/audio/effect/5.0/IVisualizerEffect.hal b/audio/effect/5.0/IVisualizerEffect.hal new file mode 100644 index 0000000000..38752a9d93 --- /dev/null +++ b/audio/effect/5.0/IVisualizerEffect.hal @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2018 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.effect@5.0; + +import android.hardware.audio.common@5.0; +import IEffect; + +interface IVisualizerEffect extends IEffect { + enum CaptureSizeRange : int32_t { + MAX = 1024, // maximum capture size in samples + MIN = 128 // minimum capture size in samples + }; + + /** + * Sets the number PCM samples in the capture. + */ + setCaptureSize(uint16_t captureSize) generates (Result retval); + + /** + * Gets the number PCM samples in the capture. + */ + getCaptureSize() generates (Result retval, uint16_t captureSize); + + enum ScalingMode : int32_t { + // Keep in sync with SCALING_MODE_... in + // frameworks/base/media/java/android/media/audiofx/Visualizer.java + NORMALIZED = 0, + AS_PLAYED = 1 + }; + + /** + * Specifies the way the captured data is scaled. + */ + setScalingMode(ScalingMode scalingMode) generates (Result retval); + + /** + * Retrieves the way the captured data is scaled. + */ + getScalingMode() generates (Result retval, ScalingMode scalingMode); + + /** + * Informs the visualizer about the downstream latency. + */ + setLatency(uint32_t latencyMs) generates (Result retval); + + /** + * Gets the downstream latency. + */ + getLatency() generates (Result retval, uint32_t latencyMs); + + enum MeasurementMode : int32_t { + // Keep in sync with MEASUREMENT_MODE_... in + // frameworks/base/media/java/android/media/audiofx/Visualizer.java + NONE = 0x0, + PEAK_RMS = 0x1 + }; + + /** + * Specifies which measurements are to be made. + */ + setMeasurementMode(MeasurementMode measurementMode) + generates (Result retval); + + /** + * Retrieves which measurements are to be made. + */ + getMeasurementMode() generates ( + Result retval, MeasurementMode measurementMode); + + /** + * Retrieves the latest PCM snapshot captured by the visualizer engine. The + * number of samples to capture is specified by 'setCaptureSize' parameter. + * + * @return retval operation completion status. + * @return samples samples in 8 bit unsigned format (0 = 0x80) + */ + capture() generates (Result retval, vec<uint8_t> samples); + + struct Measurement { + MeasurementMode mode; // discriminator + union Values { + struct PeakAndRms { + int32_t peakMb; // millibels + int32_t rmsMb; // millibels + } peakAndRms; + } value; + }; + /** + * Retrieves the latest measurements. The measurements to be made + * are specified by 'setMeasurementMode' parameter. + * + * @return retval operation completion status. + * @return result measurement. + */ + measure() generates (Result retval, Measurement result); +}; diff --git a/audio/effect/5.0/types.hal b/audio/effect/5.0/types.hal new file mode 100644 index 0000000000..84e11086b4 --- /dev/null +++ b/audio/effect/5.0/types.hal @@ -0,0 +1,299 @@ +/* + * Copyright (C) 2018 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.effect@5.0; + +import android.hardware.audio.common@5.0; + +enum Result : int32_t { + OK, + NOT_INITIALIZED, + INVALID_ARGUMENTS, + INVALID_STATE, + NOT_SUPPORTED, + RESULT_TOO_BIG +}; + +/** + * Effect engine capabilities/requirements flags. + * + * Definitions for flags field of effect descriptor. + * + * +----------------+--------+-------------------------------------------------- + * | description | bits | values + * +----------------+--------+-------------------------------------------------- + * | connection | 0..2 | 0 insert: after track process + * | mode | | 1 auxiliary: connect to track auxiliary + * | | | output and use send level + * | | | 2 replace: replaces track process function; + * | | | must implement SRC, volume and mono to stereo. + * | | | 3 pre processing: applied below audio HAL on in + * | | | 4 post processing: applied below audio HAL on out + * | | | 5 - 7 reserved + * +----------------+--------+-------------------------------------------------- + * | insertion | 3..5 | 0 none + * | preference | | 1 first of the chain + * | | | 2 last of the chain + * | | | 3 exclusive (only effect in the insert chain) + * | | | 4..7 reserved + * +----------------+--------+-------------------------------------------------- + * | Volume | 6..8 | 0 none + * | management | | 1 implements volume control + * | | | 2 requires volume indication + * | | | 4 reserved + * +----------------+--------+-------------------------------------------------- + * | Device | 9..11 | 0 none + * | indication | | 1 requires device updates + * | | | 2, 4 reserved + * +----------------+--------+-------------------------------------------------- + * | Sample input | 12..13 | 1 direct: process() function or + * | mode | | EFFECT_CMD_SET_CONFIG command must specify + * | | | a buffer descriptor + * | | | 2 provider: process() function uses the + * | | | bufferProvider indicated by the + * | | | EFFECT_CMD_SET_CONFIG command to request input. + * | | | buffers. + * | | | 3 both: both input modes are supported + * +----------------+--------+-------------------------------------------------- + * | Sample output | 14..15 | 1 direct: process() function or + * | mode | | EFFECT_CMD_SET_CONFIG command must specify + * | | | a buffer descriptor + * | | | 2 provider: process() function uses the + * | | | bufferProvider indicated by the + * | | | EFFECT_CMD_SET_CONFIG command to request output + * | | | buffers. + * | | | 3 both: both output modes are supported + * +----------------+--------+-------------------------------------------------- + * | Hardware | 16..17 | 0 No hardware acceleration + * | acceleration | | 1 non tunneled hw acceleration: the process() + * | | | function reads the samples, send them to HW + * | | | accelerated effect processor, reads back + * | | | the processed samples and returns them + * | | | to the output buffer. + * | | | 2 tunneled hw acceleration: the process() + * | | | function is transparent. The effect interface + * | | | is only used to control the effect engine. + * | | | This mode is relevant for global effects + * | | | actually applied by the audio hardware on + * | | | the output stream. + * +----------------+--------+-------------------------------------------------- + * | Audio Mode | 18..19 | 0 none + * | indication | | 1 requires audio mode updates + * | | | 2..3 reserved + * +----------------+--------+-------------------------------------------------- + * | Audio source | 20..21 | 0 none + * | indication | | 1 requires audio source updates + * | | | 2..3 reserved + * +----------------+--------+-------------------------------------------------- + * | Effect offload | 22 | 0 The effect cannot be offloaded to an audio DSP + * | supported | | 1 The effect can be offloaded to an audio DSP + * +----------------+--------+-------------------------------------------------- + * | Process | 23 | 0 The effect implements a process function. + * | function | | 1 The effect does not implement a process + * | not | | function: enabling the effect has no impact + * | implemented | | on latency or CPU load. + * | | | Effect implementations setting this flag do not + * | | | have to implement a process function. + * +----------------+--------+-------------------------------------------------- + */ +@export(name="", value_prefix="EFFECT_FLAG_") +enum EffectFlags : int32_t { + // Insert mode + TYPE_SHIFT = 0, + TYPE_SIZE = 3, + TYPE_MASK = ((1 << TYPE_SIZE) -1) << TYPE_SHIFT, + TYPE_INSERT = 0 << TYPE_SHIFT, + TYPE_AUXILIARY = 1 << TYPE_SHIFT, + TYPE_REPLACE = 2 << TYPE_SHIFT, + TYPE_PRE_PROC = 3 << TYPE_SHIFT, + TYPE_POST_PROC = 4 << TYPE_SHIFT, + + // Insert preference + INSERT_SHIFT = TYPE_SHIFT + TYPE_SIZE, + INSERT_SIZE = 3, + INSERT_MASK = ((1 << INSERT_SIZE) -1) << INSERT_SHIFT, + INSERT_ANY = 0 << INSERT_SHIFT, + INSERT_FIRST = 1 << INSERT_SHIFT, + INSERT_LAST = 2 << INSERT_SHIFT, + INSERT_EXCLUSIVE = 3 << INSERT_SHIFT, + + // Volume control + VOLUME_SHIFT = INSERT_SHIFT + INSERT_SIZE, + VOLUME_SIZE = 3, + VOLUME_MASK = ((1 << VOLUME_SIZE) -1) << VOLUME_SHIFT, + VOLUME_CTRL = 1 << VOLUME_SHIFT, + VOLUME_IND = 2 << VOLUME_SHIFT, + VOLUME_NONE = 0 << VOLUME_SHIFT, + + // Device indication + DEVICE_SHIFT = VOLUME_SHIFT + VOLUME_SIZE, + DEVICE_SIZE = 3, + DEVICE_MASK = ((1 << DEVICE_SIZE) -1) << DEVICE_SHIFT, + DEVICE_IND = 1 << DEVICE_SHIFT, + DEVICE_NONE = 0 << DEVICE_SHIFT, + + // Sample input modes + INPUT_SHIFT = DEVICE_SHIFT + DEVICE_SIZE, + INPUT_SIZE = 2, + INPUT_MASK = ((1 << INPUT_SIZE) -1) << INPUT_SHIFT, + INPUT_DIRECT = 1 << INPUT_SHIFT, + INPUT_PROVIDER = 2 << INPUT_SHIFT, + INPUT_BOTH = 3 << INPUT_SHIFT, + + // Sample output modes + OUTPUT_SHIFT = INPUT_SHIFT + INPUT_SIZE, + OUTPUT_SIZE = 2, + OUTPUT_MASK = ((1 << OUTPUT_SIZE) -1) << OUTPUT_SHIFT, + OUTPUT_DIRECT = 1 << OUTPUT_SHIFT, + OUTPUT_PROVIDER = 2 << OUTPUT_SHIFT, + OUTPUT_BOTH = 3 << OUTPUT_SHIFT, + + // Hardware acceleration mode + HW_ACC_SHIFT = OUTPUT_SHIFT + OUTPUT_SIZE, + HW_ACC_SIZE = 2, + HW_ACC_MASK = ((1 << HW_ACC_SIZE) -1) << HW_ACC_SHIFT, + HW_ACC_SIMPLE = 1 << HW_ACC_SHIFT, + HW_ACC_TUNNEL = 2 << HW_ACC_SHIFT, + + // Audio mode indication + AUDIO_MODE_SHIFT = HW_ACC_SHIFT + HW_ACC_SIZE, + AUDIO_MODE_SIZE = 2, + AUDIO_MODE_MASK = ((1 << AUDIO_MODE_SIZE) -1) << AUDIO_MODE_SHIFT, + AUDIO_MODE_IND = 1 << AUDIO_MODE_SHIFT, + AUDIO_MODE_NONE = 0 << AUDIO_MODE_SHIFT, + + // Audio source indication + AUDIO_SOURCE_SHIFT = AUDIO_MODE_SHIFT + AUDIO_MODE_SIZE, + AUDIO_SOURCE_SIZE = 2, + AUDIO_SOURCE_MASK = ((1 << AUDIO_SOURCE_SIZE) -1) << AUDIO_SOURCE_SHIFT, + AUDIO_SOURCE_IND = 1 << AUDIO_SOURCE_SHIFT, + AUDIO_SOURCE_NONE = 0 << AUDIO_SOURCE_SHIFT, + + // Effect offload indication + OFFLOAD_SHIFT = AUDIO_SOURCE_SHIFT + AUDIO_SOURCE_SIZE, + OFFLOAD_SIZE = 1, + OFFLOAD_MASK = ((1 << OFFLOAD_SIZE) -1) << OFFLOAD_SHIFT, + OFFLOAD_SUPPORTED = 1 << OFFLOAD_SHIFT, + + // Effect has no process indication + NO_PROCESS_SHIFT = OFFLOAD_SHIFT + OFFLOAD_SIZE, + NO_PROCESS_SIZE = 1, + NO_PROCESS_MASK = ((1 << NO_PROCESS_SIZE) -1) << NO_PROCESS_SHIFT, + NO_PROCESS = 1 << NO_PROCESS_SHIFT +}; + +/** + * The effect descriptor contains necessary information to facilitate the + * enumeration of the effect engines present in a library. + */ +struct EffectDescriptor { + Uuid type; // UUID of to the OpenSL ES interface implemented + // by this effect + Uuid uuid; // UUID for this particular implementation + bitfield<EffectFlags> flags; // effect engine capabilities/requirements flags + uint16_t cpuLoad; // CPU load indication expressed in 0.1 MIPS units + // as estimated on an ARM9E core (ARMv5TE) with 0 WS + uint16_t memoryUsage; // data memory usage expressed in KB and includes + // only dynamically allocated memory + uint8_t[64] name; // human readable effect name + uint8_t[64] implementor; // human readable effect implementor name +}; + +/** + * A buffer is a chunk of audio data for processing. Multi-channel audio is + * always interleaved. The channel order is from LSB to MSB with regard to the + * channel mask definition in audio.h, audio_channel_mask_t, e.g.: + * Stereo: L, R; 5.1: FL, FR, FC, LFE, BL, BR. + * + * The buffer size is expressed in frame count, a frame being composed of + * samples for all channels at a given time. Frame size for unspecified format + * (AUDIO_FORMAT_OTHER) is 8 bit by definition. + */ +struct AudioBuffer { + uint64_t id; + uint32_t frameCount; + memory data; +}; + +@export(name="effect_buffer_access_e", value_prefix="EFFECT_BUFFER_") +enum EffectBufferAccess : int32_t { + ACCESS_WRITE, + ACCESS_READ, + ACCESS_ACCUMULATE +}; + +/** + * Determines what fields of EffectBufferConfig need to be considered. + */ +@export(name="", value_prefix="EFFECT_CONFIG_") +enum EffectConfigParameters : int32_t { + BUFFER = 0x0001, // buffer field + SMP_RATE = 0x0002, // samplingRate + CHANNELS = 0x0004, // channels + FORMAT = 0x0008, // format + ACC_MODE = 0x0010, // accessMode + // Note that the 2.0 ALL have been moved to an helper function +}; + +/** + * The buffer config structure specifies the input or output audio format + * to be used by the effect engine. + */ +struct EffectBufferConfig { + AudioBuffer buffer; + uint32_t samplingRateHz; + bitfield<AudioChannelMask> channels; + AudioFormat format; + EffectBufferAccess accessMode; + bitfield<EffectConfigParameters> mask; +}; + +struct EffectConfig { + EffectBufferConfig inputCfg; + EffectBufferConfig outputCfg; +}; + +@export(name="effect_feature_e", value_prefix="EFFECT_FEATURE_") +enum EffectFeature : int32_t { + AUX_CHANNELS, // supports auxiliary channels + // (e.g. dual mic noise suppressor) + CNT +}; + +struct EffectAuxChannelsConfig { + bitfield<AudioChannelMask> mainChannels; // channel mask for main channels + bitfield<AudioChannelMask> auxChannels; // channel mask for auxiliary channels +}; + +struct EffectOffloadParameter { + bool isOffload; // true if the playback thread the effect + // is attached to is offloaded + AudioIoHandle ioHandle; // io handle of the playback thread + // the effect is attached to +}; + +/** + * The message queue flags used to synchronize reads and writes from + * the status message queue used by effects. + */ +enum MessageQueueFlagBits : uint32_t { + DONE_PROCESSING = 1 << 0, + REQUEST_PROCESS = 1 << 1, + REQUEST_PROCESS_REVERSE = 1 << 2, + REQUEST_QUIT = 1 << 3, + REQUEST_PROCESS_ALL = + REQUEST_PROCESS | REQUEST_PROCESS_REVERSE | REQUEST_QUIT +}; diff --git a/audio/effect/5.0/xml/audio_effects_conf.xsd b/audio/effect/5.0/xml/audio_effects_conf.xsd new file mode 120000 index 0000000000..9d85fa7c68 --- /dev/null +++ b/audio/effect/5.0/xml/audio_effects_conf.xsd @@ -0,0 +1 @@ +../../2.0/xml/audio_effects_conf.xsd
\ No newline at end of file diff --git a/audio/effect/all-versions/OWNERS b/audio/effect/all-versions/OWNERS deleted file mode 100644 index 6fdc97ca29..0000000000 --- a/audio/effect/all-versions/OWNERS +++ /dev/null @@ -1,3 +0,0 @@ -elaurent@google.com -krocard@google.com -mnaganov@google.com diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/AcousticEchoCancelerEffect.impl.h b/audio/effect/all-versions/default/AcousticEchoCancelerEffect.cpp index 8ad80a22a0..0b60622c05 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/AcousticEchoCancelerEffect.impl.h +++ b/audio/effect/all-versions/default/AcousticEchoCancelerEffect.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,9 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#define LOG_TAG "AEC_Effect_HAL" + +#include "AcousticEchoCancelerEffect.h" #include <android/log.h> #include <system/audio_effects/effect_aec.h> @@ -25,7 +27,7 @@ namespace android { namespace hardware { namespace audio { namespace effect { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { AcousticEchoCancelerEffect::AcousticEchoCancelerEffect(effect_handle_t handle) @@ -33,7 +35,7 @@ AcousticEchoCancelerEffect::AcousticEchoCancelerEffect(effect_handle_t handle) AcousticEchoCancelerEffect::~AcousticEchoCancelerEffect() {} -// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow. +// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow. Return<Result> AcousticEchoCancelerEffect::init() { return mEffect->init(); } @@ -163,7 +165,7 @@ Return<Result> AcousticEchoCancelerEffect::close() { return mEffect->close(); } -// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IAcousticEchoCancelerEffect +// Methods from ::android::hardware::audio::effect::CPP_VERSION::IAcousticEchoCancelerEffect // follow. Return<Result> AcousticEchoCancelerEffect::setEchoDelay(uint32_t echoDelayMs) { return mEffect->setParam(AEC_PARAM_ECHO_DELAY, echoDelayMs); @@ -174,7 +176,7 @@ Return<void> AcousticEchoCancelerEffect::getEchoDelay(getEchoDelay_cb _hidl_cb) } } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace effect } // namespace audio } // namespace hardware diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/AcousticEchoCancelerEffect.h b/audio/effect/all-versions/default/AcousticEchoCancelerEffect.h index 852cb3fd15..c18f88b276 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/AcousticEchoCancelerEffect.h +++ b/audio/effect/all-versions/default/AcousticEchoCancelerEffect.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,12 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_ACOUSTICECHOCANCELEREFFECT_H +#define ANDROID_HARDWARE_AUDIO_EFFECT_ACOUSTICECHOCANCELEREFFECT_H + +#include PATH(android/hardware/audio/effect/FILE_VERSION/IAcousticEchoCancelerEffect.h) + +#include "Effect.h" #include <hidl/Status.h> @@ -26,21 +31,21 @@ namespace android { namespace hardware { namespace audio { namespace effect { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IAcousticEchoCancelerEffect; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::Result; +using ::android::sp; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; -using ::android::hardware::hidl_vec; -using ::android::hardware::hidl_string; -using ::android::sp; +using ::android::hardware::audio::effect::CPP_VERSION::IAcousticEchoCancelerEffect; +using ::android::hardware::audio::effect::CPP_VERSION::Result; struct AcousticEchoCancelerEffect : public IAcousticEchoCancelerEffect { explicit AcousticEchoCancelerEffect(effect_handle_t handle); - // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow. + // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow. Return<Result> init() override; Return<Result> setConfig( const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider, @@ -85,7 +90,7 @@ struct AcousticEchoCancelerEffect : public IAcousticEchoCancelerEffect { Return<Result> close() override; // Methods from - // ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IAcousticEchoCancelerEffect follow. + // ::android::hardware::audio::effect::CPP_VERSION::IAcousticEchoCancelerEffect follow. Return<Result> setEchoDelay(uint32_t echoDelayMs) override; Return<void> getEchoDelay(getEchoDelay_cb _hidl_cb) override; @@ -96,8 +101,10 @@ struct AcousticEchoCancelerEffect : public IAcousticEchoCancelerEffect { }; } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace effect } // namespace audio } // namespace hardware } // namespace android + +#endif // ANDROID_HARDWARE_AUDIO_EFFECT_ACOUSTICECHOCANCELEREFFECT_H diff --git a/audio/effect/all-versions/default/Android.bp b/audio/effect/all-versions/default/Android.bp index ed2a093050..f23a463bc5 100644 --- a/audio/effect/all-versions/default/Android.bp +++ b/audio/effect/all-versions/default/Android.bp @@ -1,10 +1,25 @@ -cc_library_headers { - name: "android.hardware.audio.effect@all-versions-impl", +cc_defaults { + name: "android.hardware.audio.effect-impl_default", defaults: ["hidl_defaults"], vendor: true, relative_install_path: "hw", - - export_include_dirs: ["include"], + srcs: [ + "AcousticEchoCancelerEffect.cpp", + "AudioBufferManager.cpp", + "AutomaticGainControlEffect.cpp", + "BassBoostEffect.cpp", + "Conversions.cpp", + "DownmixEffect.cpp", + "Effect.cpp", + "EffectsFactory.cpp", + "EnvironmentalReverbEffect.cpp", + "EqualizerEffect.cpp", + "LoudnessEnhancerEffect.cpp", + "NoiseSuppressionEffect.cpp", + "PresetReverbEffect.cpp", + "VirtualizerEffect.cpp", + "VisualizerEffect.cpp", + ], shared_libs: [ "libbase", @@ -21,11 +36,59 @@ cc_library_headers { ], header_libs: [ + "android.hardware.audio.common.util@all-versions", "libaudio_system_headers", "libaudioclient_headers", "libeffects_headers", "libhardware_headers", "libmedia_headers", - "android.hardware.audio.common.util@all-versions", ], } + +cc_library_shared { + name: "android.hardware.audio.effect@2.0-impl", + defaults: ["android.hardware.audio.effect-impl_default"], + shared_libs: [ + "android.hardware.audio.common@2.0", + "android.hardware.audio.common@2.0-util", + "android.hardware.audio.effect@2.0", + ], + + cflags: [ + "-DMAJOR_VERSION=2", + "-DMINOR_VERSION=0", + "-include common/all-versions/VersionMacro.h", + ] +} + +cc_library_shared { + name: "android.hardware.audio.effect@4.0-impl", + defaults: ["android.hardware.audio.effect-impl_default"], + shared_libs: [ + "android.hardware.audio.common@4.0", + "android.hardware.audio.common@4.0-util", + "android.hardware.audio.effect@4.0", + ], + + cflags: [ + "-DMAJOR_VERSION=4", + "-DMINOR_VERSION=0", + "-include common/all-versions/VersionMacro.h", + ] +} + +cc_library_shared { + name: "android.hardware.audio.effect@5.0-impl", + defaults: ["android.hardware.audio.effect-impl_default"], + shared_libs: [ + "android.hardware.audio.common@5.0", + "android.hardware.audio.common@5.0-util", + "android.hardware.audio.effect@5.0", + ], + + cflags: [ + "-DMAJOR_VERSION=5", + "-DMINOR_VERSION=0", + "-include common/all-versions/VersionMacro.h", + ] +} diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/AudioBufferManager.impl.h b/audio/effect/all-versions/default/AudioBufferManager.cpp index 71ccd2d520..9a638fda2c 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/AudioBufferManager.impl.h +++ b/audio/effect/all-versions/default/AudioBufferManager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,7 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#include "AudioBufferManager.h" #include <atomic> @@ -53,7 +53,7 @@ void AudioBufferManager::removeEntry(uint64_t id) { namespace hardware { namespace audio { namespace effect { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { AudioBufferWrapper::AudioBufferWrapper(const AudioBuffer& buffer) @@ -83,7 +83,7 @@ bool AudioBufferWrapper::init() { } } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace effect } // namespace audio } // namespace hardware diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/AudioBufferManager.h b/audio/effect/all-versions/default/AudioBufferManager.h index 34dea2d03b..8b956cdb9b 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/AudioBufferManager.h +++ b/audio/effect/all-versions/default/AudioBufferManager.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,10 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_AUDIO_BUFFER_MANAGER_H_ +#define ANDROID_HARDWARE_AUDIO_EFFECT_AUDIO_BUFFER_MANAGER_H_ + +#include PATH(android/hardware/audio/effect/FILE_VERSION/types.h) #include <mutex> @@ -24,14 +27,14 @@ #include <utils/RefBase.h> #include <utils/Singleton.h> -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::AudioBuffer; +using ::android::hardware::audio::effect::CPP_VERSION::AudioBuffer; using ::android::hidl::memory::V1_0::IMemory; namespace android { namespace hardware { namespace audio { namespace effect { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { class AudioBufferWrapper : public RefBase { @@ -51,13 +54,13 @@ class AudioBufferWrapper : public RefBase { }; } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace effect } // namespace audio } // namespace hardware } // namespace android -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::implementation::AudioBufferWrapper; +using ::android::hardware::audio::effect::CPP_VERSION::implementation::AudioBufferWrapper; namespace android { @@ -67,7 +70,7 @@ class AudioBufferManager : public Singleton<AudioBufferManager> { bool wrap(const AudioBuffer& buffer, sp<AudioBufferWrapper>* wrapper); private: - friend class hardware::audio::effect::AUDIO_HAL_VERSION::implementation::AudioBufferWrapper; + friend class hardware::audio::effect::CPP_VERSION::implementation::AudioBufferWrapper; // Called by AudioBufferWrapper. void removeEntry(uint64_t id); @@ -77,3 +80,5 @@ class AudioBufferManager : public Singleton<AudioBufferManager> { }; } // namespace android + +#endif // ANDROID_HARDWARE_AUDIO_EFFECT_AUDIO_BUFFER_MANAGER_H_ diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/AutomaticGainControlEffect.impl.h b/audio/effect/all-versions/default/AutomaticGainControlEffect.cpp index e2e751e86b..651dd1b228 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/AutomaticGainControlEffect.impl.h +++ b/audio/effect/all-versions/default/AutomaticGainControlEffect.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,9 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#define LOG_TAG "AGC_Effect_HAL" + +#include "AutomaticGainControlEffect.h" #include <android/log.h> @@ -24,7 +26,7 @@ namespace android { namespace hardware { namespace audio { namespace effect { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { AutomaticGainControlEffect::AutomaticGainControlEffect(effect_handle_t handle) @@ -46,7 +48,7 @@ void AutomaticGainControlEffect::propertiesToHal( halProperties->limiterEnabled = properties.limiterEnabled; } -// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow. +// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow. Return<Result> AutomaticGainControlEffect::init() { return mEffect->init(); } @@ -176,7 +178,7 @@ Return<Result> AutomaticGainControlEffect::close() { return mEffect->close(); } -// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IAutomaticGainControlEffect +// Methods from ::android::hardware::audio::effect::CPP_VERSION::IAutomaticGainControlEffect // follow. Return<Result> AutomaticGainControlEffect::setTargetLevel(int16_t targetLevelMb) { return mEffect->setParam(AGC_PARAM_TARGET_LEVEL, targetLevelMb); @@ -219,7 +221,7 @@ Return<void> AutomaticGainControlEffect::getAllProperties(getAllProperties_cb _h } } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace effect } // namespace audio } // namespace hardware diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/AutomaticGainControlEffect.h b/audio/effect/all-versions/default/AutomaticGainControlEffect.h index 5ac43eb9bc..a281b1ddcd 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/AutomaticGainControlEffect.h +++ b/audio/effect/all-versions/default/AutomaticGainControlEffect.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,12 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_AUTOMATICGAINCONTROLEFFECT_H +#define ANDROID_HARDWARE_AUDIO_EFFECT_AUTOMATICGAINCONTROLEFFECT_H + +#include PATH(android/hardware/audio/effect/FILE_VERSION/IAutomaticGainControlEffect.h) + +#include "Effect.h" #include <system/audio_effects/effect_agc.h> @@ -28,21 +33,21 @@ namespace android { namespace hardware { namespace audio { namespace effect { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IAutomaticGainControlEffect; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::Result; +using ::android::sp; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; -using ::android::hardware::hidl_vec; -using ::android::hardware::hidl_string; -using ::android::sp; +using ::android::hardware::audio::effect::CPP_VERSION::IAutomaticGainControlEffect; +using ::android::hardware::audio::effect::CPP_VERSION::Result; struct AutomaticGainControlEffect : public IAutomaticGainControlEffect { explicit AutomaticGainControlEffect(effect_handle_t handle); - // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow. + // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow. Return<Result> init() override; Return<Result> setConfig( const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider, @@ -87,7 +92,7 @@ struct AutomaticGainControlEffect : public IAutomaticGainControlEffect { Return<Result> close() override; // Methods from - // ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IAutomaticGainControlEffect follow. + // ::android::hardware::audio::effect::CPP_VERSION::IAutomaticGainControlEffect follow. Return<Result> setTargetLevel(int16_t targetLevelMb) override; Return<void> getTargetLevel(getTargetLevel_cb _hidl_cb) override; Return<Result> setCompGain(int16_t compGainMb) override; @@ -110,8 +115,10 @@ struct AutomaticGainControlEffect : public IAutomaticGainControlEffect { }; } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace effect } // namespace audio } // namespace hardware } // namespace android + +#endif // ANDROID_HARDWARE_AUDIO_EFFECT_AUTOMATICGAINCONTROLEFFECT_H diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/BassBoostEffect.impl.h b/audio/effect/all-versions/default/BassBoostEffect.cpp index 7bcb4a3497..6f7763db8e 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/BassBoostEffect.impl.h +++ b/audio/effect/all-versions/default/BassBoostEffect.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,9 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#define LOG_TAG "BassBoost_HAL" + +#include "BassBoostEffect.h" #include <android/log.h> #include <system/audio_effects/effect_bassboost.h> @@ -25,14 +27,14 @@ namespace android { namespace hardware { namespace audio { namespace effect { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { BassBoostEffect::BassBoostEffect(effect_handle_t handle) : mEffect(new Effect(handle)) {} BassBoostEffect::~BassBoostEffect() {} -// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow. +// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow. Return<Result> BassBoostEffect::init() { return mEffect->init(); } @@ -159,7 +161,7 @@ Return<Result> BassBoostEffect::close() { return mEffect->close(); } -// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IBassBoostEffect follow. +// Methods from ::android::hardware::audio::effect::CPP_VERSION::IBassBoostEffect follow. Return<void> BassBoostEffect::isStrengthSupported(isStrengthSupported_cb _hidl_cb) { return mEffect->getIntegerParam(BASSBOOST_PARAM_STRENGTH_SUPPORTED, _hidl_cb); } @@ -173,7 +175,7 @@ Return<void> BassBoostEffect::getStrength(getStrength_cb _hidl_cb) { } } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace effect } // namespace audio } // namespace hardware diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/BassBoostEffect.h b/audio/effect/all-versions/default/BassBoostEffect.h index 29173ddebe..a184ac2cc8 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/BassBoostEffect.h +++ b/audio/effect/all-versions/default/BassBoostEffect.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,14 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_BASSBOOSTEFFECT_H +#define ANDROID_HARDWARE_AUDIO_EFFECT_BASSBOOSTEFFECT_H + +#include PATH(android/hardware/audio/effect/FILE_VERSION/IBassBoostEffect.h) + +#include <hidl/MQDescriptor.h> + +#include "Effect.h" #include <hidl/Status.h> @@ -26,21 +33,21 @@ namespace android { namespace hardware { namespace audio { namespace effect { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IBassBoostEffect; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::Result; +using ::android::sp; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; -using ::android::hardware::hidl_vec; -using ::android::hardware::hidl_string; -using ::android::sp; +using ::android::hardware::audio::effect::CPP_VERSION::IBassBoostEffect; +using ::android::hardware::audio::effect::CPP_VERSION::Result; struct BassBoostEffect : public IBassBoostEffect { explicit BassBoostEffect(effect_handle_t handle); - // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow. + // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow. Return<Result> init() override; Return<Result> setConfig( const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider, @@ -84,7 +91,7 @@ struct BassBoostEffect : public IBassBoostEffect { const hidl_vec<uint8_t>& configData) override; Return<Result> close() override; - // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IBassBoostEffect follow. + // Methods from ::android::hardware::audio::effect::CPP_VERSION::IBassBoostEffect follow. Return<void> isStrengthSupported(isStrengthSupported_cb _hidl_cb) override; Return<Result> setStrength(uint16_t strength) override; Return<void> getStrength(getStrength_cb _hidl_cb) override; @@ -96,8 +103,10 @@ struct BassBoostEffect : public IBassBoostEffect { }; } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace effect } // namespace audio } // namespace hardware } // namespace android + +#endif // ANDROID_HARDWARE_AUDIO_EFFECT_BASSBOOSTEFFECT_H diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/Conversions.impl.h b/audio/effect/all-versions/default/Conversions.cpp index de67d89dda..50b0562502 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/Conversions.impl.h +++ b/audio/effect/all-versions/default/Conversions.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,28 +14,31 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#include "Conversions.h" +#include "HidlUtils.h" + +using ::android::hardware::audio::common::CPP_VERSION::HidlUtils; #include <memory.h> #include <stdio.h> #include <common/all-versions/VersionUtils.h> -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::HidlUtils; -using ::android::hardware::audio::common::utils::mkEnumConverter; +using ::android::hardware::audio::common::CPP_VERSION::HidlUtils; +using ::android::hardware::audio::common::utils::EnumBitfield; namespace android { namespace hardware { namespace audio { namespace effect { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { void effectDescriptorFromHal(const effect_descriptor_t& halDescriptor, EffectDescriptor* descriptor) { HidlUtils::uuidFromHal(halDescriptor.type, &descriptor->type); HidlUtils::uuidFromHal(halDescriptor.uuid, &descriptor->uuid); - descriptor->flags = mkEnumConverter<EffectFlags>(halDescriptor.flags); + descriptor->flags = EnumBitfield<EffectFlags>(halDescriptor.flags); descriptor->cpuLoad = halDescriptor.cpuLoad; descriptor->memoryUsage = halDescriptor.memoryUsage; memcpy(descriptor->name.data(), halDescriptor.name, descriptor->name.size()); @@ -52,7 +55,7 @@ std::string uuidToString(const effect_uuid_t& halUuid) { } } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace effect } // namespace audio } // namespace hardware diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/Conversions.h b/audio/effect/all-versions/default/Conversions.h index 3f9317f763..75aab24efe 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/Conversions.h +++ b/audio/effect/all-versions/default/Conversions.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,10 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_CONVERSIONS_H_ +#define ANDROID_HARDWARE_AUDIO_EFFECT_CONVERSIONS_H_ + +#include PATH(android/hardware/audio/effect/FILE_VERSION/types.h) #include <string> @@ -24,18 +27,20 @@ namespace android { namespace hardware { namespace audio { namespace effect { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectDescriptor; +using ::android::hardware::audio::effect::CPP_VERSION::EffectDescriptor; void effectDescriptorFromHal(const effect_descriptor_t& halDescriptor, EffectDescriptor* descriptor); std::string uuidToString(const effect_uuid_t& halUuid); } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace effect } // namespace audio } // namespace hardware } // namespace android + +#endif // ANDROID_HARDWARE_AUDIO_EFFECT_CONVERSIONS_H_ diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/DownmixEffect.impl.h b/audio/effect/all-versions/default/DownmixEffect.cpp index abef10ea09..94da70e0df 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/DownmixEffect.impl.h +++ b/audio/effect/all-versions/default/DownmixEffect.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,9 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#define LOG_TAG "Downmix_HAL" + +#include "DownmixEffect.h" #include <android/log.h> #include <system/audio_effects/effect_downmix.h> @@ -25,14 +27,14 @@ namespace android { namespace hardware { namespace audio { namespace effect { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { DownmixEffect::DownmixEffect(effect_handle_t handle) : mEffect(new Effect(handle)) {} DownmixEffect::~DownmixEffect() {} -// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow. +// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow. Return<Result> DownmixEffect::init() { return mEffect->init(); } @@ -159,7 +161,7 @@ Return<Result> DownmixEffect::close() { return mEffect->close(); } -// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IDownmixEffect follow. +// Methods from ::android::hardware::audio::effect::CPP_VERSION::IDownmixEffect follow. Return<Result> DownmixEffect::setType(IDownmixEffect::Type preset) { return mEffect->setParam(DOWNMIX_PARAM_TYPE, static_cast<downmix_type_t>(preset)); } @@ -172,7 +174,7 @@ Return<void> DownmixEffect::getType(getType_cb _hidl_cb) { } } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace effect } // namespace audio } // namespace hardware diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/DownmixEffect.h b/audio/effect/all-versions/default/DownmixEffect.h index 3e3aa78477..6d34c28dd2 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/DownmixEffect.h +++ b/audio/effect/all-versions/default/DownmixEffect.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,12 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_DOWNMIXEFFECT_H +#define ANDROID_HARDWARE_AUDIO_EFFECT_DOWNMIXEFFECT_H + +#include PATH(android/hardware/audio/effect/FILE_VERSION/IDownmixEffect.h) + +#include "Effect.h" #include <hidl/Status.h> @@ -26,21 +31,21 @@ namespace android { namespace hardware { namespace audio { namespace effect { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IDownmixEffect; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::Result; +using ::android::sp; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; -using ::android::hardware::hidl_vec; -using ::android::hardware::hidl_string; -using ::android::sp; +using ::android::hardware::audio::effect::CPP_VERSION::IDownmixEffect; +using ::android::hardware::audio::effect::CPP_VERSION::Result; struct DownmixEffect : public IDownmixEffect { explicit DownmixEffect(effect_handle_t handle); - // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow. + // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow. Return<Result> init() override; Return<Result> setConfig( const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider, @@ -84,7 +89,7 @@ struct DownmixEffect : public IDownmixEffect { const hidl_vec<uint8_t>& configData) override; Return<Result> close() override; - // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IDownmixEffect follow. + // Methods from ::android::hardware::audio::effect::CPP_VERSION::IDownmixEffect follow. Return<Result> setType(IDownmixEffect::Type preset) override; Return<void> getType(getType_cb _hidl_cb) override; @@ -95,8 +100,10 @@ struct DownmixEffect : public IDownmixEffect { }; } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace effect } // namespace audio } // namespace hardware } // namespace android + +#endif // ANDROID_HARDWARE_AUDIO_EFFECT_DOWNMIXEFFECT_H diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/Effect.impl.h b/audio/effect/all-versions/default/Effect.cpp index 61c9805663..3e5148fabb 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/Effect.impl.h +++ b/audio/effect/all-versions/default/Effect.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,14 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#include <memory.h> + +#define LOG_TAG "EffectHAL" +#define ATRACE_TAG ATRACE_TAG_AUDIO + +#include "Conversions.h" +#include "Effect.h" +#include "common/all-versions/default/EffectMap.h" #include <memory.h> @@ -30,13 +37,13 @@ namespace android { namespace hardware { namespace audio { namespace effect { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioChannelMask; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioFormat; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::implementation::AudioChannelBitfield; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::MessageQueueFlagBits; +using ::android::hardware::audio::common::CPP_VERSION::AudioChannelMask; +using ::android::hardware::audio::common::CPP_VERSION::AudioFormat; +using ::android::hardware::audio::common::CPP_VERSION::implementation::AudioChannelBitfield; +using ::android::hardware::audio::effect::CPP_VERSION::MessageQueueFlagBits; namespace { @@ -479,7 +486,7 @@ Result Effect::setParameterImpl(uint32_t paramSize, const void* paramData, uint3 &halParamBuffer[0]); } -// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow. +// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow. Return<Result> Effect::init() { return sendCommandReturningStatus(EFFECT_CMD_INIT, "INIT"); } @@ -707,7 +714,7 @@ Return<Result> Effect::close() { } } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace effect } // namespace audio } // namespace hardware diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/Effect.h b/audio/effect/all-versions/default/Effect.h index b546e0eb32..f6a12d95e5 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/Effect.h +++ b/audio/effect/all-versions/default/Effect.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,12 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_EFFECT_H +#define ANDROID_HARDWARE_AUDIO_EFFECT_EFFECT_H + +#include PATH(android/hardware/audio/effect/FILE_VERSION/IEffect.h) + +#include "AudioBufferManager.h" #include <atomic> #include <memory> @@ -34,28 +39,28 @@ namespace android { namespace hardware { namespace audio { namespace effect { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioDevice; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioMode; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioSource; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::Uuid; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::implementation::AudioDeviceBitfield; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::AudioBuffer; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectAuxChannelsConfig; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectConfig; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectDescriptor; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectFeature; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectOffloadParameter; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffectBufferProviderCallback; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::Result; +using ::android::sp; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; -using ::android::hardware::hidl_vec; -using ::android::hardware::hidl_string; -using ::android::sp; +using ::android::hardware::audio::common::CPP_VERSION::AudioDevice; +using ::android::hardware::audio::common::CPP_VERSION::AudioMode; +using ::android::hardware::audio::common::CPP_VERSION::AudioSource; +using ::android::hardware::audio::common::CPP_VERSION::Uuid; +using ::android::hardware::audio::common::CPP_VERSION::implementation::AudioDeviceBitfield; +using ::android::hardware::audio::effect::CPP_VERSION::AudioBuffer; +using ::android::hardware::audio::effect::CPP_VERSION::EffectAuxChannelsConfig; +using ::android::hardware::audio::effect::CPP_VERSION::EffectConfig; +using ::android::hardware::audio::effect::CPP_VERSION::EffectDescriptor; +using ::android::hardware::audio::effect::CPP_VERSION::EffectFeature; +using ::android::hardware::audio::effect::CPP_VERSION::EffectOffloadParameter; +using ::android::hardware::audio::effect::CPP_VERSION::IEffect; +using ::android::hardware::audio::effect::CPP_VERSION::IEffectBufferProviderCallback; +using ::android::hardware::audio::effect::CPP_VERSION::Result; struct Effect : public IEffect { typedef MessageQueue<Result, kSynchronizedReadWrite> StatusMQ; @@ -64,7 +69,7 @@ struct Effect : public IEffect { explicit Effect(effect_handle_t handle); - // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow. + // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow. Return<Result> init() override; Return<Result> setConfig( const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider, @@ -234,8 +239,10 @@ struct Effect : public IEffect { }; } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace effect } // namespace audio } // namespace hardware } // namespace android + +#endif // ANDROID_HARDWARE_AUDIO_EFFECT_EFFECT_H diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/EffectsFactory.impl.h b/audio/effect/all-versions/default/EffectsFactory.cpp index b0351c968f..d2d8a466b3 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/EffectsFactory.impl.h +++ b/audio/effect/all-versions/default/EffectsFactory.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,25 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#define LOG_TAG "EffectFactoryHAL" +#include "EffectsFactory.h" +#include "AcousticEchoCancelerEffect.h" +#include "AutomaticGainControlEffect.h" +#include "BassBoostEffect.h" +#include "Conversions.h" +#include "DownmixEffect.h" +#include "Effect.h" +#include "EnvironmentalReverbEffect.h" +#include "EqualizerEffect.h" +#include "HidlUtils.h" +#include "LoudnessEnhancerEffect.h" +#include "NoiseSuppressionEffect.h" +#include "PresetReverbEffect.h" +#include "VirtualizerEffect.h" +#include "VisualizerEffect.h" +#include "common/all-versions/default/EffectMap.h" + +using ::android::hardware::audio::common::CPP_VERSION::HidlUtils; #include <android/log.h> #include <media/EffectsFactoryApi.h> @@ -30,13 +48,13 @@ #include <system/audio_effects/effect_virtualizer.h> #include <system/audio_effects/effect_visualizer.h> -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::HidlUtils; +using ::android::hardware::audio::common::CPP_VERSION::HidlUtils; namespace android { namespace hardware { namespace audio { namespace effect { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { // static @@ -69,7 +87,7 @@ sp<IEffect> EffectsFactory::dispatchEffectInstanceCreation(const effect_descript return new Effect(handle); } -// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffectsFactory follow. +// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffectsFactory follow. Return<void> EffectsFactory::getAllDescriptors(getAllDescriptors_cb _hidl_cb) { Result retval(Result::OK); hidl_vec<EffectDescriptor> result; @@ -184,12 +202,12 @@ Return<void> EffectsFactory::debug(const hidl_handle& fd, return Void(); } -IEffectsFactory* HIDL_FETCH_IEffectsFactory(const char* /* name */) { - return new EffectsFactory(); +IEffectsFactory* HIDL_FETCH_IEffectsFactory(const char* name) { + return strcmp(name, "default") == 0 ? new EffectsFactory() : nullptr; } } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace effect } // namespace audio } // namespace hardware diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/EffectsFactory.h b/audio/effect/all-versions/default/EffectsFactory.h index 526abbb89a..0cbfaa20b7 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/EffectsFactory.h +++ b/audio/effect/all-versions/default/EffectsFactory.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,14 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_EFFECTSFACTORY_H +#define ANDROID_HARDWARE_AUDIO_EFFECT_EFFECTSFACTORY_H + +#include <system/audio_effect.h> + +#include PATH(android/hardware/audio/effect/FILE_VERSION/IEffectsFactory.h) + +#include <hidl/MQDescriptor.h> #include <hardware/audio_effect.h> #include <system/audio_effect.h> @@ -26,27 +33,28 @@ namespace android { namespace hardware { namespace audio { namespace effect { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::Uuid; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectDescriptor; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffectsFactory; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::Result; +using ::android::sp; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; -using ::android::hardware::hidl_vec; -using ::android::hardware::hidl_string; -using ::android::sp; +using ::android::hardware::audio::common::CPP_VERSION::Uuid; +using ::android::hardware::audio::effect::CPP_VERSION::EffectDescriptor; +using ::android::hardware::audio::effect::CPP_VERSION::IEffect; +using ::android::hardware::audio::effect::CPP_VERSION::IEffectsFactory; +using ::android::hardware::audio::effect::CPP_VERSION::Result; struct EffectsFactory : public IEffectsFactory { - // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffectsFactory follow. + // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffectsFactory follow. Return<void> getAllDescriptors(getAllDescriptors_cb _hidl_cb) override; Return<void> getDescriptor(const Uuid& uid, getDescriptor_cb _hidl_cb) override; Return<void> createEffect(const Uuid& uid, int32_t session, int32_t ioHandle, createEffect_cb _hidl_cb) override; - Return<void> debugDump(const hidl_handle& fd); //< in V2_0::IEffectsFactory only, alias of debug + Return<void> debugDump( + const hidl_handle& fd); //< in CPP_VERSION::IEffectsFactory only, alias of debug Return<void> debug(const hidl_handle& fd, const hidl_vec<hidl_string>& options) override; private: @@ -57,8 +65,10 @@ struct EffectsFactory : public IEffectsFactory { extern "C" IEffectsFactory* HIDL_FETCH_IEffectsFactory(const char* name); } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace effect } // namespace audio } // namespace hardware } // namespace android + +#endif // ANDROID_HARDWARE_AUDIO_EFFECT_EFFECTSFACTORY_H diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/EnvironmentalReverbEffect.impl.h b/audio/effect/all-versions/default/EnvironmentalReverbEffect.cpp index 39a4092e8c..1ade7b810b 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/EnvironmentalReverbEffect.impl.h +++ b/audio/effect/all-versions/default/EnvironmentalReverbEffect.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,10 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#define LOG_TAG "EnvReverb_HAL" +#include <android/log.h> + +#include "EnvironmentalReverbEffect.h" #include <android/log.h> @@ -24,7 +27,7 @@ namespace android { namespace hardware { namespace audio { namespace effect { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { EnvironmentalReverbEffect::EnvironmentalReverbEffect(effect_handle_t handle) @@ -60,7 +63,7 @@ void EnvironmentalReverbEffect::propertiesToHal( halProperties->density = properties.density; } -// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow. +// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow. Return<Result> EnvironmentalReverbEffect::init() { return mEffect->init(); } @@ -190,7 +193,7 @@ Return<Result> EnvironmentalReverbEffect::close() { return mEffect->close(); } -// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEnvironmentalReverbEffect +// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEnvironmentalReverbEffect // follow. Return<Result> EnvironmentalReverbEffect::setBypass(bool bypass) { return mEffect->setParam(REVERB_PARAM_BYPASS, bypass); @@ -297,7 +300,7 @@ Return<void> EnvironmentalReverbEffect::getAllProperties(getAllProperties_cb _hi } } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace effect } // namespace audio } // namespace hardware diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/EnvironmentalReverbEffect.h b/audio/effect/all-versions/default/EnvironmentalReverbEffect.h index d2f8cc3a84..7e6597bae6 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/EnvironmentalReverbEffect.h +++ b/audio/effect/all-versions/default/EnvironmentalReverbEffect.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,14 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_ENVIRONMENTALREVERBEFFECT_H +#define ANDROID_HARDWARE_AUDIO_EFFECT_ENVIRONMENTALREVERBEFFECT_H + +#include <system/audio_effects/effect_environmentalreverb.h> + +#include PATH(android/hardware/audio/effect/FILE_VERSION/IEnvironmentalReverbEffect.h) + +#include "Effect.h" #include <system/audio_effects/effect_environmentalreverb.h> @@ -28,31 +35,31 @@ namespace android { namespace hardware { namespace audio { namespace effect { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioDevice; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioMode; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioSource; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::AudioBuffer; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectAuxChannelsConfig; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectConfig; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectDescriptor; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectOffloadParameter; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffectBufferProviderCallback; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEnvironmentalReverbEffect; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::Result; +using ::android::sp; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; -using ::android::hardware::hidl_vec; -using ::android::hardware::hidl_string; -using ::android::sp; +using ::android::hardware::audio::common::CPP_VERSION::AudioDevice; +using ::android::hardware::audio::common::CPP_VERSION::AudioMode; +using ::android::hardware::audio::common::CPP_VERSION::AudioSource; +using ::android::hardware::audio::effect::CPP_VERSION::AudioBuffer; +using ::android::hardware::audio::effect::CPP_VERSION::EffectAuxChannelsConfig; +using ::android::hardware::audio::effect::CPP_VERSION::EffectConfig; +using ::android::hardware::audio::effect::CPP_VERSION::EffectDescriptor; +using ::android::hardware::audio::effect::CPP_VERSION::EffectOffloadParameter; +using ::android::hardware::audio::effect::CPP_VERSION::IEffect; +using ::android::hardware::audio::effect::CPP_VERSION::IEffectBufferProviderCallback; +using ::android::hardware::audio::effect::CPP_VERSION::IEnvironmentalReverbEffect; +using ::android::hardware::audio::effect::CPP_VERSION::Result; struct EnvironmentalReverbEffect : public IEnvironmentalReverbEffect { explicit EnvironmentalReverbEffect(effect_handle_t handle); - // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow. + // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow. Return<Result> init() override; Return<Result> setConfig( const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider, @@ -97,7 +104,7 @@ struct EnvironmentalReverbEffect : public IEnvironmentalReverbEffect { Return<Result> close() override; // Methods from - // ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEnvironmentalReverbEffect follow. + // ::android::hardware::audio::effect::CPP_VERSION::IEnvironmentalReverbEffect follow. Return<Result> setBypass(bool bypass) override; Return<void> getBypass(getBypass_cb _hidl_cb) override; Return<Result> setRoomLevel(int16_t roomLevel) override; @@ -136,8 +143,10 @@ struct EnvironmentalReverbEffect : public IEnvironmentalReverbEffect { }; } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace effect } // namespace audio } // namespace hardware } // namespace android + +#endif // ANDROID_HARDWARE_AUDIO_EFFECT_ENVIRONMENTALREVERBEFFECT_H diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/EqualizerEffect.impl.h b/audio/effect/all-versions/default/EqualizerEffect.cpp index db6bed8d2e..f6177b79b4 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/EqualizerEffect.impl.h +++ b/audio/effect/all-versions/default/EqualizerEffect.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,9 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#define LOG_TAG "Equalizer_HAL" + +#include "EqualizerEffect.h" #include <memory.h> @@ -26,7 +28,7 @@ namespace android { namespace hardware { namespace audio { namespace effect { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { EqualizerEffect::EqualizerEffect(effect_handle_t handle) : mEffect(new Effect(handle)) {} @@ -55,7 +57,7 @@ std::vector<uint8_t> EqualizerEffect::propertiesToHal( return halBuffer; } -// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow. +// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow. Return<Result> EqualizerEffect::init() { return mEffect->init(); } @@ -182,7 +184,7 @@ Return<Result> EqualizerEffect::close() { return mEffect->close(); } -// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEqualizerEffect follow. +// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEqualizerEffect follow. Return<void> EqualizerEffect::getNumBands(getNumBands_cb _hidl_cb) { return mEffect->getIntegerParam(EQ_PARAM_NUM_BANDS, _hidl_cb); } @@ -285,7 +287,7 @@ Return<void> EqualizerEffect::getAllProperties(getAllProperties_cb _hidl_cb) { } } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace effect } // namespace audio } // namespace hardware diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/EqualizerEffect.h b/audio/effect/all-versions/default/EqualizerEffect.h index de520521fa..5e1e2b984b 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/EqualizerEffect.h +++ b/audio/effect/all-versions/default/EqualizerEffect.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,12 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_EQUALIZEREFFECT_H +#define ANDROID_HARDWARE_AUDIO_EFFECT_EQUALIZEREFFECT_H + +#include PATH(android/hardware/audio/effect/FILE_VERSION/IEqualizerEffect.h) + +#include "Effect.h" #include <vector> @@ -30,31 +35,31 @@ namespace android { namespace hardware { namespace audio { namespace effect { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioDevice; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioMode; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioSource; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::AudioBuffer; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectAuxChannelsConfig; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectConfig; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectDescriptor; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectOffloadParameter; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffectBufferProviderCallback; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEqualizerEffect; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::Result; +using ::android::sp; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; -using ::android::hardware::hidl_vec; -using ::android::hardware::hidl_string; -using ::android::sp; +using ::android::hardware::audio::common::CPP_VERSION::AudioDevice; +using ::android::hardware::audio::common::CPP_VERSION::AudioMode; +using ::android::hardware::audio::common::CPP_VERSION::AudioSource; +using ::android::hardware::audio::effect::CPP_VERSION::AudioBuffer; +using ::android::hardware::audio::effect::CPP_VERSION::EffectAuxChannelsConfig; +using ::android::hardware::audio::effect::CPP_VERSION::EffectConfig; +using ::android::hardware::audio::effect::CPP_VERSION::EffectDescriptor; +using ::android::hardware::audio::effect::CPP_VERSION::EffectOffloadParameter; +using ::android::hardware::audio::effect::CPP_VERSION::IEffect; +using ::android::hardware::audio::effect::CPP_VERSION::IEffectBufferProviderCallback; +using ::android::hardware::audio::effect::CPP_VERSION::IEqualizerEffect; +using ::android::hardware::audio::effect::CPP_VERSION::Result; struct EqualizerEffect : public IEqualizerEffect { explicit EqualizerEffect(effect_handle_t handle); - // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow. + // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow. Return<Result> init() override; Return<Result> setConfig( const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider, @@ -98,7 +103,7 @@ struct EqualizerEffect : public IEqualizerEffect { const hidl_vec<uint8_t>& configData) override; Return<Result> close() override; - // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEqualizerEffect follow. + // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEqualizerEffect follow. Return<void> getNumBands(getNumBands_cb _hidl_cb) override; Return<void> getLevelRange(getLevelRange_cb _hidl_cb) override; Return<Result> setBandLevel(uint16_t band, int16_t level) override; @@ -124,8 +129,10 @@ struct EqualizerEffect : public IEqualizerEffect { }; } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace effect } // namespace audio } // namespace hardware } // namespace android + +#endif // ANDROID_HARDWARE_AUDIO_EFFECT_EQUALIZEREFFECT_H diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/LoudnessEnhancerEffect.impl.h b/audio/effect/all-versions/default/LoudnessEnhancerEffect.cpp index 88210e954b..6918bdf533 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/LoudnessEnhancerEffect.impl.h +++ b/audio/effect/all-versions/default/LoudnessEnhancerEffect.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,9 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#define LOG_TAG "LoudnessEnhancer_HAL" + +#include "LoudnessEnhancerEffect.h" #include <system/audio_effects/effect_loudnessenhancer.h> @@ -27,7 +29,7 @@ namespace android { namespace hardware { namespace audio { namespace effect { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { LoudnessEnhancerEffect::LoudnessEnhancerEffect(effect_handle_t handle) @@ -35,7 +37,7 @@ LoudnessEnhancerEffect::LoudnessEnhancerEffect(effect_handle_t handle) LoudnessEnhancerEffect::~LoudnessEnhancerEffect() {} -// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow. +// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow. Return<Result> LoudnessEnhancerEffect::init() { return mEffect->init(); } @@ -162,7 +164,7 @@ Return<Result> LoudnessEnhancerEffect::close() { return mEffect->close(); } -// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::ILoudnessEnhancerEffect +// Methods from ::android::hardware::audio::effect::CPP_VERSION::ILoudnessEnhancerEffect // follow. Return<Result> LoudnessEnhancerEffect::setTargetGain(int32_t targetGainMb) { return mEffect->setParam(LOUDNESS_ENHANCER_DEFAULT_TARGET_GAIN_MB, targetGainMb); @@ -182,7 +184,7 @@ Return<void> LoudnessEnhancerEffect::getTargetGain(getTargetGain_cb _hidl_cb) { } } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace effect } // namespace audio } // namespace hardware diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/LoudnessEnhancerEffect.h b/audio/effect/all-versions/default/LoudnessEnhancerEffect.h index b59b077e76..6eb8a8c293 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/LoudnessEnhancerEffect.h +++ b/audio/effect/all-versions/default/LoudnessEnhancerEffect.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,12 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_LOUDNESSENHANCEREFFECT_H +#define ANDROID_HARDWARE_AUDIO_EFFECT_LOUDNESSENHANCEREFFECT_H + +#include PATH(android/hardware/audio/effect/FILE_VERSION/ILoudnessEnhancerEffect.h) + +#include "Effect.h" #include <hidl/Status.h> @@ -26,31 +31,31 @@ namespace android { namespace hardware { namespace audio { namespace effect { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioDevice; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioMode; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioSource; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::AudioBuffer; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectAuxChannelsConfig; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectConfig; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectDescriptor; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectOffloadParameter; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffectBufferProviderCallback; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::ILoudnessEnhancerEffect; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::Result; +using ::android::sp; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; -using ::android::hardware::hidl_vec; -using ::android::hardware::hidl_string; -using ::android::sp; +using ::android::hardware::audio::common::CPP_VERSION::AudioDevice; +using ::android::hardware::audio::common::CPP_VERSION::AudioMode; +using ::android::hardware::audio::common::CPP_VERSION::AudioSource; +using ::android::hardware::audio::effect::CPP_VERSION::AudioBuffer; +using ::android::hardware::audio::effect::CPP_VERSION::EffectAuxChannelsConfig; +using ::android::hardware::audio::effect::CPP_VERSION::EffectConfig; +using ::android::hardware::audio::effect::CPP_VERSION::EffectDescriptor; +using ::android::hardware::audio::effect::CPP_VERSION::EffectOffloadParameter; +using ::android::hardware::audio::effect::CPP_VERSION::IEffect; +using ::android::hardware::audio::effect::CPP_VERSION::IEffectBufferProviderCallback; +using ::android::hardware::audio::effect::CPP_VERSION::ILoudnessEnhancerEffect; +using ::android::hardware::audio::effect::CPP_VERSION::Result; struct LoudnessEnhancerEffect : public ILoudnessEnhancerEffect { explicit LoudnessEnhancerEffect(effect_handle_t handle); - // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow. + // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow. Return<Result> init() override; Return<Result> setConfig( const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider, @@ -94,7 +99,7 @@ struct LoudnessEnhancerEffect : public ILoudnessEnhancerEffect { const hidl_vec<uint8_t>& configData) override; Return<Result> close() override; - // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::ILoudnessEnhancerEffect + // Methods from ::android::hardware::audio::effect::CPP_VERSION::ILoudnessEnhancerEffect // follow. Return<Result> setTargetGain(int32_t targetGainMb) override; Return<void> getTargetGain(getTargetGain_cb _hidl_cb) override; @@ -106,8 +111,10 @@ struct LoudnessEnhancerEffect : public ILoudnessEnhancerEffect { }; } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace effect } // namespace audio } // namespace hardware } // namespace android + +#endif // ANDROID_HARDWARE_AUDIO_EFFECT_LOUDNESSENHANCEREFFECT_H diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/NoiseSuppressionEffect.impl.h b/audio/effect/all-versions/default/NoiseSuppressionEffect.cpp index f32399c51c..4756719661 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/NoiseSuppressionEffect.impl.h +++ b/audio/effect/all-versions/default/NoiseSuppressionEffect.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,9 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#define LOG_TAG "NS_Effect_HAL" + +#include "NoiseSuppressionEffect.h" #include <android/log.h> @@ -24,7 +26,7 @@ namespace android { namespace hardware { namespace audio { namespace effect { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { NoiseSuppressionEffect::NoiseSuppressionEffect(effect_handle_t handle) @@ -44,7 +46,7 @@ void NoiseSuppressionEffect::propertiesToHal( halProperties->type = static_cast<uint32_t>(properties.type); } -// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow. +// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow. Return<Result> NoiseSuppressionEffect::init() { return mEffect->init(); } @@ -171,7 +173,7 @@ Return<Result> NoiseSuppressionEffect::close() { return mEffect->close(); } -// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::INoiseSuppressionEffect +// Methods from ::android::hardware::audio::effect::CPP_VERSION::INoiseSuppressionEffect // follow. Return<Result> NoiseSuppressionEffect::setSuppressionLevel(INoiseSuppressionEffect::Level level) { return mEffect->setParam(NS_PARAM_LEVEL, static_cast<int32_t>(level)); @@ -212,7 +214,7 @@ Return<void> NoiseSuppressionEffect::getAllProperties(getAllProperties_cb _hidl_ } } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace effect } // namespace audio } // namespace hardware diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/NoiseSuppressionEffect.h b/audio/effect/all-versions/default/NoiseSuppressionEffect.h index af1635b717..af62dd1af4 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/NoiseSuppressionEffect.h +++ b/audio/effect/all-versions/default/NoiseSuppressionEffect.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,12 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_NOISESUPPRESSIONEFFECT_H +#define ANDROID_HARDWARE_AUDIO_EFFECT_NOISESUPPRESSIONEFFECT_H + +#include PATH(android/hardware/audio/effect/FILE_VERSION/INoiseSuppressionEffect.h) + +#include "Effect.h" #include <system/audio_effects/effect_ns.h> @@ -28,31 +33,31 @@ namespace android { namespace hardware { namespace audio { namespace effect { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioDevice; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioMode; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioSource; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::AudioBuffer; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectAuxChannelsConfig; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectConfig; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectDescriptor; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectOffloadParameter; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffectBufferProviderCallback; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::INoiseSuppressionEffect; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::Result; +using ::android::sp; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; -using ::android::hardware::hidl_vec; -using ::android::hardware::hidl_string; -using ::android::sp; +using ::android::hardware::audio::common::CPP_VERSION::AudioDevice; +using ::android::hardware::audio::common::CPP_VERSION::AudioMode; +using ::android::hardware::audio::common::CPP_VERSION::AudioSource; +using ::android::hardware::audio::effect::CPP_VERSION::AudioBuffer; +using ::android::hardware::audio::effect::CPP_VERSION::EffectAuxChannelsConfig; +using ::android::hardware::audio::effect::CPP_VERSION::EffectConfig; +using ::android::hardware::audio::effect::CPP_VERSION::EffectDescriptor; +using ::android::hardware::audio::effect::CPP_VERSION::EffectOffloadParameter; +using ::android::hardware::audio::effect::CPP_VERSION::IEffect; +using ::android::hardware::audio::effect::CPP_VERSION::IEffectBufferProviderCallback; +using ::android::hardware::audio::effect::CPP_VERSION::INoiseSuppressionEffect; +using ::android::hardware::audio::effect::CPP_VERSION::Result; struct NoiseSuppressionEffect : public INoiseSuppressionEffect { explicit NoiseSuppressionEffect(effect_handle_t handle); - // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow. + // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow. Return<Result> init() override; Return<Result> setConfig( const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider, @@ -96,7 +101,7 @@ struct NoiseSuppressionEffect : public INoiseSuppressionEffect { const hidl_vec<uint8_t>& configData) override; Return<Result> close() override; - // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::INoiseSuppressionEffect + // Methods from ::android::hardware::audio::effect::CPP_VERSION::INoiseSuppressionEffect // follow. Return<Result> setSuppressionLevel(INoiseSuppressionEffect::Level level) override; Return<void> getSuppressionLevel(getSuppressionLevel_cb _hidl_cb) override; @@ -118,8 +123,10 @@ struct NoiseSuppressionEffect : public INoiseSuppressionEffect { }; } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace effect } // namespace audio } // namespace hardware } // namespace android + +#endif // ANDROID_HARDWARE_AUDIO_EFFECT_NOISESUPPRESSIONEFFECT_H diff --git a/audio/core/2.0/default/OWNERS b/audio/effect/all-versions/default/OWNERS index 6fdc97ca29..6fdc97ca29 100644 --- a/audio/core/2.0/default/OWNERS +++ b/audio/effect/all-versions/default/OWNERS diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/PresetReverbEffect.impl.h b/audio/effect/all-versions/default/PresetReverbEffect.cpp index eab68fb703..97723f5fbb 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/PresetReverbEffect.impl.h +++ b/audio/effect/all-versions/default/PresetReverbEffect.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,9 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#define LOG_TAG "PresetReverb_HAL" + +#include "PresetReverbEffect.h" #include <android/log.h> #include <system/audio_effects/effect_presetreverb.h> @@ -25,14 +27,14 @@ namespace android { namespace hardware { namespace audio { namespace effect { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { PresetReverbEffect::PresetReverbEffect(effect_handle_t handle) : mEffect(new Effect(handle)) {} PresetReverbEffect::~PresetReverbEffect() {} -// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow. +// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow. Return<Result> PresetReverbEffect::init() { return mEffect->init(); } @@ -159,7 +161,7 @@ Return<Result> PresetReverbEffect::close() { return mEffect->close(); } -// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IPresetReverbEffect follow. +// Methods from ::android::hardware::audio::effect::CPP_VERSION::IPresetReverbEffect follow. Return<Result> PresetReverbEffect::setPreset(IPresetReverbEffect::Preset preset) { return mEffect->setParam(REVERB_PARAM_PRESET, static_cast<t_reverb_presets>(preset)); } @@ -172,7 +174,7 @@ Return<void> PresetReverbEffect::getPreset(getPreset_cb _hidl_cb) { } } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace effect } // namespace audio } // namespace hardware diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/PresetReverbEffect.h b/audio/effect/all-versions/default/PresetReverbEffect.h index 1a91ab49b2..aa864b0b55 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/PresetReverbEffect.h +++ b/audio/effect/all-versions/default/PresetReverbEffect.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,12 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_PRESETREVERBEFFECT_H +#define ANDROID_HARDWARE_AUDIO_EFFECT_PRESETREVERBEFFECT_H + +#include PATH(android/hardware/audio/effect/FILE_VERSION/IPresetReverbEffect.h) + +#include "Effect.h" #include <hidl/Status.h> @@ -26,31 +31,31 @@ namespace android { namespace hardware { namespace audio { namespace effect { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioDevice; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioMode; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioSource; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::AudioBuffer; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectAuxChannelsConfig; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectConfig; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectDescriptor; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectOffloadParameter; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffectBufferProviderCallback; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IPresetReverbEffect; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::Result; +using ::android::sp; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; -using ::android::hardware::hidl_vec; -using ::android::hardware::hidl_string; -using ::android::sp; +using ::android::hardware::audio::common::CPP_VERSION::AudioDevice; +using ::android::hardware::audio::common::CPP_VERSION::AudioMode; +using ::android::hardware::audio::common::CPP_VERSION::AudioSource; +using ::android::hardware::audio::effect::CPP_VERSION::AudioBuffer; +using ::android::hardware::audio::effect::CPP_VERSION::EffectAuxChannelsConfig; +using ::android::hardware::audio::effect::CPP_VERSION::EffectConfig; +using ::android::hardware::audio::effect::CPP_VERSION::EffectDescriptor; +using ::android::hardware::audio::effect::CPP_VERSION::EffectOffloadParameter; +using ::android::hardware::audio::effect::CPP_VERSION::IEffect; +using ::android::hardware::audio::effect::CPP_VERSION::IEffectBufferProviderCallback; +using ::android::hardware::audio::effect::CPP_VERSION::IPresetReverbEffect; +using ::android::hardware::audio::effect::CPP_VERSION::Result; struct PresetReverbEffect : public IPresetReverbEffect { explicit PresetReverbEffect(effect_handle_t handle); - // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow. + // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow. Return<Result> init() override; Return<Result> setConfig( const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider, @@ -94,7 +99,7 @@ struct PresetReverbEffect : public IPresetReverbEffect { const hidl_vec<uint8_t>& configData) override; Return<Result> close() override; - // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IPresetReverbEffect + // Methods from ::android::hardware::audio::effect::CPP_VERSION::IPresetReverbEffect // follow. Return<Result> setPreset(IPresetReverbEffect::Preset preset) override; Return<void> getPreset(getPreset_cb _hidl_cb) override; @@ -106,8 +111,10 @@ struct PresetReverbEffect : public IPresetReverbEffect { }; } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace effect } // namespace audio } // namespace hardware } // namespace android + +#endif // ANDROID_HARDWARE_AUDIO_EFFECT_PRESETREVERBEFFECT_H diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/VirtualizerEffect.impl.h b/audio/effect/all-versions/default/VirtualizerEffect.cpp index 23b09a89dd..4d597c76e8 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/VirtualizerEffect.impl.h +++ b/audio/effect/all-versions/default/VirtualizerEffect.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,9 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#define LOG_TAG "Virtualizer_HAL" + +#include "VirtualizerEffect.h" #include <memory.h> @@ -27,7 +29,7 @@ namespace android { namespace hardware { namespace audio { namespace effect { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { VirtualizerEffect::VirtualizerEffect(effect_handle_t handle) : mEffect(new Effect(handle)) {} @@ -44,7 +46,7 @@ void VirtualizerEffect::speakerAnglesFromHal(const int32_t* halAngles, uint32_t } } -// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow. +// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow. Return<Result> VirtualizerEffect::init() { return mEffect->init(); } @@ -171,7 +173,7 @@ Return<Result> VirtualizerEffect::close() { return mEffect->close(); } -// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IVirtualizerEffect follow. +// Methods from ::android::hardware::audio::effect::CPP_VERSION::IVirtualizerEffect follow. Return<bool> VirtualizerEffect::isStrengthSupported() { bool halSupported = false; mEffect->getParam(VIRTUALIZER_PARAM_STRENGTH_SUPPORTED, halSupported); @@ -224,7 +226,7 @@ Return<void> VirtualizerEffect::getVirtualizationMode(getVirtualizationMode_cb _ } } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace effect } // namespace audio } // namespace hardware diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/VirtualizerEffect.h b/audio/effect/all-versions/default/VirtualizerEffect.h index c0d5a0034d..87b53d66ab 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/VirtualizerEffect.h +++ b/audio/effect/all-versions/default/VirtualizerEffect.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,12 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_VIRTUALIZEREFFECT_H +#define ANDROID_HARDWARE_AUDIO_EFFECT_VIRTUALIZEREFFECT_H + +#include PATH(android/hardware/audio/effect/FILE_VERSION/IVirtualizerEffect.h) + +#include "Effect.h" #include <hidl/Status.h> @@ -26,33 +31,33 @@ namespace android { namespace hardware { namespace audio { namespace effect { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioChannelMask; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioDevice; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioMode; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioSource; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::implementation::AudioChannelBitfield; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::AudioBuffer; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectAuxChannelsConfig; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectConfig; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectDescriptor; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectOffloadParameter; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffectBufferProviderCallback; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IVirtualizerEffect; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::Result; +using ::android::sp; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; -using ::android::hardware::hidl_vec; -using ::android::hardware::hidl_string; -using ::android::sp; +using ::android::hardware::audio::common::CPP_VERSION::AudioChannelMask; +using ::android::hardware::audio::common::CPP_VERSION::AudioDevice; +using ::android::hardware::audio::common::CPP_VERSION::AudioMode; +using ::android::hardware::audio::common::CPP_VERSION::AudioSource; +using ::android::hardware::audio::common::CPP_VERSION::implementation::AudioChannelBitfield; +using ::android::hardware::audio::effect::CPP_VERSION::AudioBuffer; +using ::android::hardware::audio::effect::CPP_VERSION::EffectAuxChannelsConfig; +using ::android::hardware::audio::effect::CPP_VERSION::EffectConfig; +using ::android::hardware::audio::effect::CPP_VERSION::EffectDescriptor; +using ::android::hardware::audio::effect::CPP_VERSION::EffectOffloadParameter; +using ::android::hardware::audio::effect::CPP_VERSION::IEffect; +using ::android::hardware::audio::effect::CPP_VERSION::IEffectBufferProviderCallback; +using ::android::hardware::audio::effect::CPP_VERSION::IVirtualizerEffect; +using ::android::hardware::audio::effect::CPP_VERSION::Result; struct VirtualizerEffect : public IVirtualizerEffect { explicit VirtualizerEffect(effect_handle_t handle); - // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow. + // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow. Return<Result> init() override; Return<Result> setConfig( const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider, @@ -96,7 +101,7 @@ struct VirtualizerEffect : public IVirtualizerEffect { const hidl_vec<uint8_t>& configData) override; Return<Result> close() override; - // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IVirtualizerEffect + // Methods from ::android::hardware::audio::effect::CPP_VERSION::IVirtualizerEffect // follow. Return<bool> isStrengthSupported() override; Return<Result> setStrength(uint16_t strength) override; @@ -116,8 +121,10 @@ struct VirtualizerEffect : public IVirtualizerEffect { }; } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace effect } // namespace audio } // namespace hardware } // namespace android + +#endif // ANDROID_HARDWARE_AUDIO_EFFECT_VIRTUALIZEREFFECT_H diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/VisualizerEffect.impl.h b/audio/effect/all-versions/default/VisualizerEffect.cpp index 9f2195b5cb..77bf46bcd3 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/VisualizerEffect.impl.h +++ b/audio/effect/all-versions/default/VisualizerEffect.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,9 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#define LOG_TAG "Visualizer_HAL" + +#include "VisualizerEffect.h" #include <android/log.h> #include <system/audio_effects/effect_visualizer.h> @@ -25,7 +27,7 @@ namespace android { namespace hardware { namespace audio { namespace effect { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { VisualizerEffect::VisualizerEffect(effect_handle_t handle) @@ -33,7 +35,7 @@ VisualizerEffect::VisualizerEffect(effect_handle_t handle) VisualizerEffect::~VisualizerEffect() {} -// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow. +// Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow. Return<Result> VisualizerEffect::init() { return mEffect->init(); } @@ -160,7 +162,7 @@ Return<Result> VisualizerEffect::close() { return mEffect->close(); } -// Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IVisualizerEffect follow. +// Methods from ::android::hardware::audio::effect::CPP_VERSION::IVisualizerEffect follow. Return<Result> VisualizerEffect::setCaptureSize(uint16_t captureSize) { Result retval = mEffect->setParam(VISUALIZER_PARAM_CAPTURE_SIZE, captureSize); if (retval == Result::OK) { @@ -247,7 +249,7 @@ Return<void> VisualizerEffect::measure(measure_cb _hidl_cb) { } } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace effect } // namespace audio } // namespace hardware diff --git a/audio/effect/all-versions/default/include/effect/all-versions/default/VisualizerEffect.h b/audio/effect/all-versions/default/VisualizerEffect.h index 114d3b7ae5..0a13a2bf1f 100644 --- a/audio/effect/all-versions/default/include/effect/all-versions/default/VisualizerEffect.h +++ b/audio/effect/all-versions/default/VisualizerEffect.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016 The Android Open Source Project + * Copyright (C) 2018 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. @@ -14,7 +14,12 @@ * limitations under the License. */ -#include <common/all-versions/IncludeGuard.h> +#ifndef ANDROID_HARDWARE_AUDIO_EFFECT_VISUALIZEREFFECT_H +#define ANDROID_HARDWARE_AUDIO_EFFECT_VISUALIZEREFFECT_H + +#include PATH(android/hardware/audio/effect/FILE_VERSION/IVisualizerEffect.h) + +#include "Effect.h" #include <hidl/Status.h> @@ -26,31 +31,31 @@ namespace android { namespace hardware { namespace audio { namespace effect { -namespace AUDIO_HAL_VERSION { +namespace CPP_VERSION { namespace implementation { -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioDevice; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioMode; -using ::android::hardware::audio::common::AUDIO_HAL_VERSION::AudioSource; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::AudioBuffer; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectAuxChannelsConfig; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectConfig; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectDescriptor; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::EffectOffloadParameter; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffectBufferProviderCallback; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IVisualizerEffect; -using ::android::hardware::audio::effect::AUDIO_HAL_VERSION::Result; +using ::android::sp; +using ::android::hardware::hidl_string; +using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; -using ::android::hardware::hidl_vec; -using ::android::hardware::hidl_string; -using ::android::sp; +using ::android::hardware::audio::common::CPP_VERSION::AudioDevice; +using ::android::hardware::audio::common::CPP_VERSION::AudioMode; +using ::android::hardware::audio::common::CPP_VERSION::AudioSource; +using ::android::hardware::audio::effect::CPP_VERSION::AudioBuffer; +using ::android::hardware::audio::effect::CPP_VERSION::EffectAuxChannelsConfig; +using ::android::hardware::audio::effect::CPP_VERSION::EffectConfig; +using ::android::hardware::audio::effect::CPP_VERSION::EffectDescriptor; +using ::android::hardware::audio::effect::CPP_VERSION::EffectOffloadParameter; +using ::android::hardware::audio::effect::CPP_VERSION::IEffect; +using ::android::hardware::audio::effect::CPP_VERSION::IEffectBufferProviderCallback; +using ::android::hardware::audio::effect::CPP_VERSION::IVisualizerEffect; +using ::android::hardware::audio::effect::CPP_VERSION::Result; struct VisualizerEffect : public IVisualizerEffect { explicit VisualizerEffect(effect_handle_t handle); - // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IEffect follow. + // Methods from ::android::hardware::audio::effect::CPP_VERSION::IEffect follow. Return<Result> init() override; Return<Result> setConfig( const EffectConfig& config, const sp<IEffectBufferProviderCallback>& inputBufferProvider, @@ -94,7 +99,7 @@ struct VisualizerEffect : public IVisualizerEffect { const hidl_vec<uint8_t>& configData) override; Return<Result> close() override; - // Methods from ::android::hardware::audio::effect::AUDIO_HAL_VERSION::IVisualizerEffect follow. + // Methods from ::android::hardware::audio::effect::CPP_VERSION::IVisualizerEffect follow. Return<Result> setCaptureSize(uint16_t captureSize) override; Return<void> getCaptureSize(getCaptureSize_cb _hidl_cb) override; Return<Result> setScalingMode(IVisualizerEffect::ScalingMode scalingMode) override; @@ -115,8 +120,10 @@ struct VisualizerEffect : public IVisualizerEffect { }; } // namespace implementation -} // namespace AUDIO_HAL_VERSION +} // namespace CPP_VERSION } // namespace effect } // namespace audio } // namespace hardware } // namespace android + +#endif // ANDROID_HARDWARE_AUDIO_EFFECT_VISUALIZEREFFECT_H diff --git a/audio/effect/2.0/vts/OWNERS b/audio/effect/all-versions/vts/OWNERS index 8711a9ff6a..0ea4666443 100644 --- a/audio/effect/2.0/vts/OWNERS +++ b/audio/effect/all-versions/vts/OWNERS @@ -2,4 +2,4 @@ elaurent@google.com krocard@google.com mnaganov@google.com yim@google.com -zhuoyao@google.com
\ No newline at end of file +zhuoyao@google.com diff --git a/audio/effect/4.0/vts/functional/Android.bp b/audio/effect/all-versions/vts/functional/Android.bp index 96ded69d22..88d49d80fc 100644 --- a/audio/effect/4.0/vts/functional/Android.bp +++ b/audio/effect/all-versions/vts/functional/Android.bp @@ -14,17 +14,15 @@ // limitations under the License. // -cc_test { - name: "VtsHalAudioEffectV4_0TargetTest", +cc_defaults { + name: "VtsHalAudioEffectTargetTest_default", defaults: ["VtsHalTargetTestDefaults"], srcs: [ - "VtsHalAudioEffectV4_0TargetTest.cpp", + "VtsHalAudioEffectTargetTest.cpp", "ValidateAudioEffectsConfiguration.cpp" ], static_libs: [ "android.hardware.audio.common.test.utility", - "android.hardware.audio.common@4.0", - "android.hardware.audio.effect@4.0", "android.hidl.allocator@1.0", "android.hidl.memory@1.0", "libeffectsconfig", @@ -35,4 +33,48 @@ cc_test { header_libs: [ "android.hardware.audio.common.util@all-versions", ], + test_suites: ["general-tests"], +} + +cc_test { + name: "VtsHalAudioEffectV2_0TargetTest", + defaults: ["VtsHalAudioEffectTargetTest_default"], + static_libs: [ + "android.hardware.audio.common@2.0", + "android.hardware.audio.effect@2.0", + ], + cflags: [ + "-DMAJOR_VERSION=2", + "-DMINOR_VERSION=0", + "-include common/all-versions/VersionMacro.h", + ] } + +cc_test { + name: "VtsHalAudioEffectV4_0TargetTest", + defaults: ["VtsHalAudioEffectTargetTest_default"], + static_libs: [ + "android.hardware.audio.common@4.0", + "android.hardware.audio.effect@4.0", + ], + cflags: [ + "-DMAJOR_VERSION=4", + "-DMINOR_VERSION=0", + "-include common/all-versions/VersionMacro.h", + ] +} + +cc_test { + name: "VtsHalAudioEffectV5_0TargetTest", + defaults: ["VtsHalAudioEffectTargetTest_default"], + static_libs: [ + "android.hardware.audio.common@5.0", + "android.hardware.audio.effect@5.0", + ], + cflags: [ + "-DMAJOR_VERSION=5", + "-DMINOR_VERSION=0", + "-include common/all-versions/VersionMacro.h", + ] +} + diff --git a/audio/effect/2.0/vts/functional/ValidateAudioEffectsConfiguration.cpp b/audio/effect/all-versions/vts/functional/ValidateAudioEffectsConfiguration.cpp index bf080d3edc..f9e4aa30eb 100644 --- a/audio/effect/2.0/vts/functional/ValidateAudioEffectsConfiguration.cpp +++ b/audio/effect/all-versions/vts/functional/ValidateAudioEffectsConfiguration.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2017 The Android Open Source Project + * Copyright (C) 2018 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. @@ -21,12 +21,22 @@ #include "utility/ValidateXml.h" +// Stringify the argument. +#define QUOTE(x) #x +#define STRINGIFY(x) QUOTE(x) + TEST(CheckConfig, audioEffectsConfigurationValidation) { RecordProperty("description", "Verify that the effects configuration file is valid according to the schema"); using namespace android::effectsConfig; std::vector<const char*> locations(std::begin(DEFAULT_LOCATIONS), std::end(DEFAULT_LOCATIONS)); - EXPECT_VALID_XML_MULTIPLE_LOCATIONS(DEFAULT_NAME, locations, - "/data/local/tmp/audio_effects_conf_V2_0.xsd"); + const char* xsd = "/data/local/tmp/audio_effects_conf_" STRINGIFY(CPP_VERSION) ".xsd"; +#if MAJOR_VERSION == 2 + // In V2, audio effect XML is not required. .conf is still allowed though deprecated + EXPECT_VALID_XML_MULTIPLE_LOCATIONS(DEFAULT_NAME, locations, xsd); +#elif MAJOR_VERSION >= 4 + // Starting with V4, audio effect XML is required + EXPECT_ONE_VALID_XML_MULTIPLE_LOCATIONS(DEFAULT_NAME, locations, xsd); +#endif } diff --git a/audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp b/audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp new file mode 100644 index 0000000000..cf7fedf33f --- /dev/null +++ b/audio/effect/all-versions/vts/functional/VtsHalAudioEffectTargetTest.cpp @@ -0,0 +1,832 @@ +/* + * Copyright (C) 2018 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 "AudioEffectHidlHalTest" +#include <android-base/logging.h> +#include <system/audio.h> + +#include PATH(android/hardware/audio/effect/FILE_VERSION/IEffect.h) +#include PATH(android/hardware/audio/effect/FILE_VERSION/IEffectsFactory.h) +#include PATH(android/hardware/audio/effect/FILE_VERSION/IEqualizerEffect.h) +#include PATH(android/hardware/audio/effect/FILE_VERSION/ILoudnessEnhancerEffect.h) +#include PATH(android/hardware/audio/effect/FILE_VERSION/types.h) +#include <android/hidl/allocator/1.0/IAllocator.h> +#include <android/hidl/memory/1.0/IMemory.h> + +#include <common/all-versions/VersionUtils.h> + +#include <VtsHalHidlTargetTestBase.h> +#include <VtsHalHidlTargetTestEnvBase.h> + +using android::sp; +using android::hardware::hidl_handle; +using android::hardware::hidl_memory; +using android::hardware::hidl_string; +using android::hardware::hidl_vec; +using android::hardware::MQDescriptorSync; +using android::hardware::Return; +using android::hardware::Void; +using android::hardware::audio::common::CPP_VERSION::AudioDevice; +using android::hardware::audio::common::CPP_VERSION::AudioHandleConsts; +using android::hardware::audio::common::CPP_VERSION::AudioMode; +using android::hardware::audio::common::CPP_VERSION::AudioSource; +using android::hardware::audio::common::CPP_VERSION::Uuid; +using android::hardware::audio::common::utils::mkEnumBitfield; +using android::hardware::audio::effect::CPP_VERSION::AudioBuffer; +using android::hardware::audio::effect::CPP_VERSION::EffectAuxChannelsConfig; +using android::hardware::audio::effect::CPP_VERSION::EffectBufferConfig; +using android::hardware::audio::effect::CPP_VERSION::EffectConfig; +using android::hardware::audio::effect::CPP_VERSION::EffectDescriptor; +using android::hardware::audio::effect::CPP_VERSION::EffectOffloadParameter; +using android::hardware::audio::effect::CPP_VERSION::IEffect; +using android::hardware::audio::effect::CPP_VERSION::IEffectsFactory; +using android::hardware::audio::effect::CPP_VERSION::IEqualizerEffect; +using android::hardware::audio::effect::CPP_VERSION::ILoudnessEnhancerEffect; +using android::hardware::audio::effect::CPP_VERSION::Result; +using android::hidl::allocator::V1_0::IAllocator; +using android::hidl::memory::V1_0::IMemory; + +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a))) +#endif + +// Test environment for Audio Effects Factory HIDL HAL. +class AudioEffectsFactoryHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase { + public: + // get the test environment singleton + static AudioEffectsFactoryHidlEnvironment* Instance() { + static AudioEffectsFactoryHidlEnvironment* instance = + new AudioEffectsFactoryHidlEnvironment; + return instance; + } + + virtual void registerTestServices() override { registerTestService<IEffectsFactory>(); } +}; + +// The main test class for Audio Effects Factory HIDL HAL. +class AudioEffectsFactoryHidlTest : public ::testing::VtsHalHidlTargetTestBase { + public: + void SetUp() override { + effectsFactory = ::testing::VtsHalHidlTargetTestBase::getService<IEffectsFactory>( + AudioEffectsFactoryHidlEnvironment::Instance()->getServiceName<IEffectsFactory>()); + ASSERT_NE(effectsFactory, nullptr); + } + + void TearDown() override { effectsFactory.clear(); } + + protected: + static void description(const std::string& description) { + RecordProperty("description", description); + } + + sp<IEffectsFactory> effectsFactory; +}; + +TEST_F(AudioEffectsFactoryHidlTest, EnumerateEffects) { + description("Verify that EnumerateEffects returns at least one effect"); + Result retval = Result::NOT_INITIALIZED; + size_t effectCount = 0; + Return<void> ret = + effectsFactory->getAllDescriptors([&](Result r, const hidl_vec<EffectDescriptor>& result) { + retval = r; + effectCount = result.size(); + }); + EXPECT_TRUE(ret.isOk()); + EXPECT_EQ(Result::OK, retval); + EXPECT_GT(effectCount, 0u); +} + +TEST_F(AudioEffectsFactoryHidlTest, CreateEffect) { + description("Verify that an effect can be created via CreateEffect"); + bool gotEffect = false; + Uuid effectUuid; + Return<void> ret = + effectsFactory->getAllDescriptors([&](Result r, const hidl_vec<EffectDescriptor>& result) { + if (r == Result::OK && result.size() > 0) { + gotEffect = true; + effectUuid = result[0].uuid; + } + }); + ASSERT_TRUE(ret.isOk()); + ASSERT_TRUE(gotEffect); + Result retval = Result::NOT_INITIALIZED; + sp<IEffect> effect; + ret = effectsFactory->createEffect( + effectUuid, 1 /*session*/, 1 /*ioHandle*/, + [&](Result r, const sp<IEffect>& result, uint64_t /*effectId*/) { + retval = r; + if (r == Result::OK) { + effect = result; + } + }); + EXPECT_TRUE(ret.isOk()); + EXPECT_EQ(Result::OK, retval); + EXPECT_NE(nullptr, effect.get()); +} + +TEST_F(AudioEffectsFactoryHidlTest, GetDescriptor) { + description( + "Verify that effects factory can provide an effect descriptor via " + "GetDescriptor"); + hidl_vec<EffectDescriptor> allDescriptors; + Return<void> ret = + effectsFactory->getAllDescriptors([&](Result r, const hidl_vec<EffectDescriptor>& result) { + if (r == Result::OK) { + allDescriptors = result; + } + }); + ASSERT_TRUE(ret.isOk()); + ASSERT_GT(allDescriptors.size(), 0u); + for (size_t i = 0; i < allDescriptors.size(); ++i) { + ret = effectsFactory->getDescriptor(allDescriptors[i].uuid, + [&](Result r, const EffectDescriptor& result) { + EXPECT_EQ(r, Result::OK); + EXPECT_EQ(result, allDescriptors[i]); + }); + } + EXPECT_TRUE(ret.isOk()); +} + +TEST_F(AudioEffectsFactoryHidlTest, DebugDumpInvalidArgument) { + description("Verify that debugDump doesn't crash on invalid arguments"); +#if MAJOR_VERSION == 2 + Return<void> ret = effectsFactory->debugDump(hidl_handle()); +#elif MAJOR_VERSION >= 4 + Return<void> ret = effectsFactory->debug(hidl_handle(), {}); +#endif + ASSERT_TRUE(ret.isOk()); +} + +// Equalizer effect is required by CDD, but only the type is fixed. +// This is the same UUID as AudioEffect.EFFECT_TYPE_EQUALIZER in Java. +static const Uuid EQUALIZER_EFFECT_TYPE = { + 0x0bed4300, 0xddd6, 0x11db, 0x8f34, + std::array<uint8_t, 6>{{0x00, 0x02, 0xa5, 0xd5, 0xc5, 0x1b}}}; +// Loudness Enhancer effect is required by CDD, but only the type is fixed. +// This is the same UUID as AudioEffect.EFFECT_TYPE_LOUDNESS_ENHANCER in Java. +static const Uuid LOUDNESS_ENHANCER_EFFECT_TYPE = { + 0xfe3199be, 0xaed0, 0x413f, 0x87bb, + std::array<uint8_t, 6>{{0x11, 0x26, 0x0e, 0xb6, 0x3c, 0xf1}}}; + +// The main test class for Audio Effect HIDL HAL. +class AudioEffectHidlTest : public ::testing::VtsHalHidlTargetTestBase { + public: + void SetUp() override { + effectsFactory = ::testing::VtsHalHidlTargetTestBase::getService<IEffectsFactory>(); + ASSERT_NE(nullptr, effectsFactory.get()); + + findAndCreateEffect(getEffectType()); + ASSERT_NE(nullptr, effect.get()); + + Return<Result> ret = effect->init(); + ASSERT_TRUE(ret.isOk()); + ASSERT_EQ(Result::OK, ret); + } + + void TearDown() override { + effect.clear(); + effectsFactory.clear(); + } + + protected: + static void description(const std::string& description) { + RecordProperty("description", description); + } + + virtual Uuid getEffectType() { return EQUALIZER_EFFECT_TYPE; } + + void findAndCreateEffect(const Uuid& type); + void findEffectInstance(const Uuid& type, Uuid* uuid); + void getChannelCount(uint32_t* channelCount); + + sp<IEffectsFactory> effectsFactory; + sp<IEffect> effect; +}; + +void AudioEffectHidlTest::findAndCreateEffect(const Uuid& type) { + Uuid effectUuid; + findEffectInstance(type, &effectUuid); + Return<void> ret = effectsFactory->createEffect( + effectUuid, 1 /*session*/, 1 /*ioHandle*/, + [&](Result r, const sp<IEffect>& result, uint64_t /*effectId*/) { + if (r == Result::OK) { + effect = result; + } + }); + ASSERT_TRUE(ret.isOk()); +} + +void AudioEffectHidlTest::findEffectInstance(const Uuid& type, Uuid* uuid) { + bool effectFound = false; + Return<void> ret = + effectsFactory->getAllDescriptors([&](Result r, const hidl_vec<EffectDescriptor>& result) { + if (r == Result::OK) { + for (const auto& desc : result) { + if (desc.type == type) { + effectFound = true; + *uuid = desc.uuid; + break; + } + } + } + }); + ASSERT_TRUE(ret.isOk()); + ASSERT_TRUE(effectFound); +} + +void AudioEffectHidlTest::getChannelCount(uint32_t* channelCount) { + Result retval; + EffectConfig currentConfig; + Return<void> ret = effect->getConfig([&](Result r, const EffectConfig& conf) { + retval = r; + if (r == Result::OK) { + currentConfig = conf; + } + }); + ASSERT_TRUE(ret.isOk()); + ASSERT_EQ(Result::OK, retval); + ASSERT_TRUE(audio_channel_mask_is_valid( + static_cast<audio_channel_mask_t>(currentConfig.outputCfg.channels))); + *channelCount = audio_channel_count_from_out_mask( + static_cast<audio_channel_mask_t>(currentConfig.outputCfg.channels)); +} + +TEST_F(AudioEffectHidlTest, Close) { + description("Verify that an effect can be closed"); + Return<Result> ret = effect->close(); + EXPECT_TRUE(ret.isOk()); + EXPECT_EQ(Result::OK, ret); +} + +TEST_F(AudioEffectHidlTest, GetDescriptor) { + description("Verify that an effect can return its own descriptor via GetDescriptor"); + Result retval = Result::NOT_INITIALIZED; + Uuid actualType; + Return<void> ret = effect->getDescriptor([&](Result r, const EffectDescriptor& desc) { + retval = r; + if (r == Result::OK) { + actualType = desc.type; + } + }); + EXPECT_TRUE(ret.isOk()); + EXPECT_EQ(Result::OK, retval); + EXPECT_EQ(getEffectType(), actualType); +} + +TEST_F(AudioEffectHidlTest, GetSetConfig) { + description( + "Verify that it is possible to manipulate effect config via Get / " + "SetConfig"); + Result retval = Result::NOT_INITIALIZED; + EffectConfig currentConfig; + Return<void> ret = effect->getConfig([&](Result r, const EffectConfig& conf) { + retval = r; + if (r == Result::OK) { + currentConfig = conf; + } + }); + EXPECT_TRUE(ret.isOk()); + EXPECT_EQ(Result::OK, retval); + Return<Result> ret2 = effect->setConfig(currentConfig, nullptr, nullptr); + EXPECT_TRUE(ret2.isOk()); + EXPECT_EQ(Result::OK, ret2); +} + +TEST_F(AudioEffectHidlTest, GetConfigReverse) { + description("Verify that GetConfigReverse does not crash"); + Return<void> ret = effect->getConfigReverse([&](Result, const EffectConfig&) {}); + EXPECT_TRUE(ret.isOk()); +} + +TEST_F(AudioEffectHidlTest, GetSupportedAuxChannelsConfigs) { + description("Verify that GetSupportedAuxChannelsConfigs does not crash"); + Return<void> ret = effect->getSupportedAuxChannelsConfigs( + 0, [&](Result, const hidl_vec<EffectAuxChannelsConfig>&) {}); + EXPECT_TRUE(ret.isOk()); +} + +TEST_F(AudioEffectHidlTest, GetAuxChannelsConfig) { + description("Verify that GetAuxChannelsConfig does not crash"); + Return<void> ret = effect->getAuxChannelsConfig([&](Result, const EffectAuxChannelsConfig&) {}); + EXPECT_TRUE(ret.isOk()); +} + +TEST_F(AudioEffectHidlTest, SetAuxChannelsConfig) { + description("Verify that SetAuxChannelsConfig does not crash"); + Return<Result> ret = effect->setAuxChannelsConfig(EffectAuxChannelsConfig()); + EXPECT_TRUE(ret.isOk()); +} + +// Not generated automatically because AudioBuffer contains +// instances of hidl_memory which can't be compared properly +// in general case due to presence of handles. +// +// However, in this particular case, handles must not present +// thus comparison is possible. +// +// operator== must be defined in the same namespace as the structures. +namespace android { +namespace hardware { +namespace audio { +namespace effect { +namespace CPP_VERSION { +inline bool operator==(const AudioBuffer& lhs, const AudioBuffer& rhs) { + return lhs.id == rhs.id && lhs.frameCount == rhs.frameCount && lhs.data.handle() == nullptr && + rhs.data.handle() == nullptr; +} + +inline bool operator==(const EffectBufferConfig& lhs, const EffectBufferConfig& rhs) { + return lhs.buffer == rhs.buffer && lhs.samplingRateHz == rhs.samplingRateHz && + lhs.channels == rhs.channels && lhs.format == rhs.format && + lhs.accessMode == rhs.accessMode && lhs.mask == rhs.mask; +} + +inline bool operator==(const EffectConfig& lhs, const EffectConfig& rhs) { + return lhs.inputCfg == rhs.inputCfg && lhs.outputCfg == rhs.outputCfg; +} +} // namespace CPP_VERSION +} // namespace effect +} // namespace audio +} // namespace hardware +} // namespace android + +TEST_F(AudioEffectHidlTest, Reset) { + description("Verify that Reset preserves effect configuration"); + Result retval = Result::NOT_INITIALIZED; + EffectConfig originalConfig; + Return<void> ret = effect->getConfig([&](Result r, const EffectConfig& conf) { + retval = r; + if (r == Result::OK) { + originalConfig = conf; + } + }); + ASSERT_TRUE(ret.isOk()); + ASSERT_EQ(Result::OK, retval); + Return<Result> ret2 = effect->reset(); + EXPECT_TRUE(ret2.isOk()); + EXPECT_EQ(Result::OK, ret2); + EffectConfig configAfterReset; + ret = effect->getConfig([&](Result r, const EffectConfig& conf) { + retval = r; + if (r == Result::OK) { + configAfterReset = conf; + } + }); + EXPECT_EQ(originalConfig, configAfterReset); +} + +TEST_F(AudioEffectHidlTest, DisableEnableDisable) { + description("Verify Disable -> Enable -> Disable sequence for an effect"); + Return<Result> ret = effect->disable(); + EXPECT_TRUE(ret.isOk()); + EXPECT_EQ(Result::INVALID_ARGUMENTS, ret); + ret = effect->enable(); + EXPECT_TRUE(ret.isOk()); + EXPECT_EQ(Result::OK, ret); + ret = effect->disable(); + EXPECT_TRUE(ret.isOk()); + EXPECT_EQ(Result::OK, ret); +} + +TEST_F(AudioEffectHidlTest, SetDevice) { + description("Verify that SetDevice works for an output chain effect"); + Return<Result> ret = effect->setDevice(mkEnumBitfield(AudioDevice::OUT_SPEAKER)); + EXPECT_TRUE(ret.isOk()); + EXPECT_EQ(Result::OK, ret); +} + +TEST_F(AudioEffectHidlTest, SetAndGetVolume) { + description("Verify that SetAndGetVolume method works for an effect"); + uint32_t channelCount; + getChannelCount(&channelCount); + hidl_vec<uint32_t> volumes; + volumes.resize(channelCount); + for (uint32_t i = 0; i < channelCount; ++i) { + volumes[i] = 0; + } + Result retval = Result::NOT_INITIALIZED; + Return<void> ret = + effect->setAndGetVolume(volumes, [&](Result r, const hidl_vec<uint32_t>&) { retval = r; }); + EXPECT_TRUE(ret.isOk()); + EXPECT_EQ(Result::OK, retval); +} + +TEST_F(AudioEffectHidlTest, VolumeChangeNotification) { + description("Verify that effect accepts VolumeChangeNotification"); + uint32_t channelCount; + getChannelCount(&channelCount); + hidl_vec<uint32_t> volumes; + volumes.resize(channelCount); + for (uint32_t i = 0; i < channelCount; ++i) { + volumes[i] = 0; + } + Return<Result> ret = effect->volumeChangeNotification(volumes); + EXPECT_TRUE(ret.isOk()); + EXPECT_EQ(Result::OK, ret); +} + +TEST_F(AudioEffectHidlTest, SetAudioMode) { + description("Verify that SetAudioMode works for an effect"); + Return<Result> ret = effect->setAudioMode(AudioMode::NORMAL); + EXPECT_TRUE(ret.isOk()); + EXPECT_EQ(Result::OK, ret); +} + +TEST_F(AudioEffectHidlTest, SetConfigReverse) { + description("Verify that SetConfigReverse does not crash"); + Return<Result> ret = effect->setConfigReverse(EffectConfig(), nullptr, nullptr); + EXPECT_TRUE(ret.isOk()); +} + +TEST_F(AudioEffectHidlTest, SetInputDevice) { + description("Verify that SetInputDevice does not crash"); + Return<Result> ret = effect->setInputDevice(mkEnumBitfield(AudioDevice::IN_BUILTIN_MIC)); + EXPECT_TRUE(ret.isOk()); +} + +TEST_F(AudioEffectHidlTest, SetAudioSource) { + description("Verify that SetAudioSource does not crash"); + Return<Result> ret = effect->setAudioSource(AudioSource::MIC); + EXPECT_TRUE(ret.isOk()); +} + +TEST_F(AudioEffectHidlTest, Offload) { + description("Verify that calling Offload method does not crash"); + EffectOffloadParameter offloadParam; + offloadParam.isOffload = false; + offloadParam.ioHandle = static_cast<int>(AudioHandleConsts::AUDIO_IO_HANDLE_NONE); + Return<Result> ret = effect->offload(offloadParam); + EXPECT_TRUE(ret.isOk()); +} + +TEST_F(AudioEffectHidlTest, PrepareForProcessing) { + description("Verify that PrepareForProcessing method works for an effect"); + Result retval = Result::NOT_INITIALIZED; + Return<void> ret = effect->prepareForProcessing( + [&](Result r, const MQDescriptorSync<Result>&) { retval = r; }); + EXPECT_TRUE(ret.isOk()); + EXPECT_EQ(Result::OK, retval); +} + +TEST_F(AudioEffectHidlTest, SetProcessBuffers) { + description("Verify that SetProcessBuffers works for an effect"); + sp<IAllocator> ashmem = IAllocator::getService("ashmem"); + ASSERT_NE(nullptr, ashmem.get()); + bool success = false; + AudioBuffer buffer; + Return<void> ret = ashmem->allocate(1024, [&](bool s, const hidl_memory& memory) { + success = s; + if (s) { + buffer.data = memory; + } + }); + ASSERT_TRUE(ret.isOk()); + ASSERT_TRUE(success); + Return<Result> ret2 = effect->setProcessBuffers(buffer, buffer); + EXPECT_TRUE(ret2.isOk()); + EXPECT_EQ(Result::OK, ret2); +} + +TEST_F(AudioEffectHidlTest, Command) { + description("Verify that Command does not crash"); + Return<void> ret = + effect->command(0, hidl_vec<uint8_t>(), 0, [&](int32_t, const hidl_vec<uint8_t>&) {}); + EXPECT_TRUE(ret.isOk()); +} + +TEST_F(AudioEffectHidlTest, SetParameter) { + description("Verify that SetParameter does not crash"); + Return<Result> ret = effect->setParameter(hidl_vec<uint8_t>(), hidl_vec<uint8_t>()); + EXPECT_TRUE(ret.isOk()); +} + +TEST_F(AudioEffectHidlTest, GetParameter) { + description("Verify that GetParameter does not crash"); + Return<void> ret = + effect->getParameter(hidl_vec<uint8_t>(), 0, [&](Result, const hidl_vec<uint8_t>&) {}); + EXPECT_TRUE(ret.isOk()); +} + +TEST_F(AudioEffectHidlTest, GetSupportedConfigsForFeature) { + description("Verify that GetSupportedConfigsForFeature does not crash"); + Return<void> ret = effect->getSupportedConfigsForFeature( + 0, 0, 0, [&](Result, uint32_t, const hidl_vec<uint8_t>&) {}); + EXPECT_TRUE(ret.isOk()); +} + +TEST_F(AudioEffectHidlTest, GetCurrentConfigForFeature) { + description("Verify that GetCurrentConfigForFeature does not crash"); + Return<void> ret = + effect->getCurrentConfigForFeature(0, 0, [&](Result, const hidl_vec<uint8_t>&) {}); + EXPECT_TRUE(ret.isOk()); +} + +TEST_F(AudioEffectHidlTest, SetCurrentConfigForFeature) { + description("Verify that SetCurrentConfigForFeature does not crash"); + Return<Result> ret = effect->setCurrentConfigForFeature(0, hidl_vec<uint8_t>()); + EXPECT_TRUE(ret.isOk()); +} + +// The main test class for Equalizer Audio Effect HIDL HAL. +class EqualizerAudioEffectHidlTest : public AudioEffectHidlTest { + public: + void SetUp() override { + AudioEffectHidlTest::SetUp(); + equalizer = IEqualizerEffect::castFrom(effect); + ASSERT_NE(nullptr, equalizer.get()); + } + + protected: + Uuid getEffectType() override { return EQUALIZER_EFFECT_TYPE; } + void getNumBands(uint16_t* numBands); + void getLevelRange(int16_t* minLevel, int16_t* maxLevel); + void getBandFrequencyRange(uint16_t band, uint32_t* minFreq, uint32_t* centerFreq, + uint32_t* maxFreq); + void getPresetCount(size_t* count); + + sp<IEqualizerEffect> equalizer; +}; + +void EqualizerAudioEffectHidlTest::getNumBands(uint16_t* numBands) { + Result retval = Result::NOT_INITIALIZED; + Return<void> ret = equalizer->getNumBands([&](Result r, uint16_t b) { + retval = r; + if (retval == Result::OK) { + *numBands = b; + } + }); + ASSERT_TRUE(ret.isOk()); + ASSERT_EQ(Result::OK, retval); +} + +void EqualizerAudioEffectHidlTest::getLevelRange(int16_t* minLevel, int16_t* maxLevel) { + Result retval = Result::NOT_INITIALIZED; + Return<void> ret = equalizer->getLevelRange([&](Result r, int16_t min, int16_t max) { + retval = r; + if (retval == Result::OK) { + *minLevel = min; + *maxLevel = max; + } + }); + ASSERT_TRUE(ret.isOk()); + ASSERT_EQ(Result::OK, retval); +} + +void EqualizerAudioEffectHidlTest::getBandFrequencyRange(uint16_t band, uint32_t* minFreq, + uint32_t* centerFreq, uint32_t* maxFreq) { + Result retval = Result::NOT_INITIALIZED; + Return<void> ret = + equalizer->getBandFrequencyRange(band, [&](Result r, uint32_t min, uint32_t max) { + retval = r; + if (retval == Result::OK) { + *minFreq = min; + *maxFreq = max; + } + }); + ASSERT_TRUE(ret.isOk()); + ASSERT_EQ(Result::OK, retval); + ret = equalizer->getBandCenterFrequency(band, [&](Result r, uint32_t center) { + retval = r; + if (retval == Result::OK) { + *centerFreq = center; + } + }); + ASSERT_TRUE(ret.isOk()); + ASSERT_EQ(Result::OK, retval); +} + +void EqualizerAudioEffectHidlTest::getPresetCount(size_t* count) { + Result retval = Result::NOT_INITIALIZED; + Return<void> ret = equalizer->getPresetNames([&](Result r, const hidl_vec<hidl_string>& names) { + retval = r; + if (retval == Result::OK) { + *count = names.size(); + } + }); + ASSERT_TRUE(ret.isOk()); + ASSERT_EQ(Result::OK, retval); +} + +TEST_F(EqualizerAudioEffectHidlTest, GetNumBands) { + description("Verify that Equalizer effect reports at least one band"); + uint16_t numBands = 0; + getNumBands(&numBands); + EXPECT_GT(numBands, 0); +} + +TEST_F(EqualizerAudioEffectHidlTest, GetLevelRange) { + description("Verify that Equalizer effect reports adequate band level range"); + int16_t minLevel = 0x7fff, maxLevel = 0; + getLevelRange(&minLevel, &maxLevel); + EXPECT_GT(maxLevel, minLevel); +} + +TEST_F(EqualizerAudioEffectHidlTest, GetSetBandLevel) { + description("Verify that manipulating band levels works for Equalizer effect"); + uint16_t numBands = 0; + getNumBands(&numBands); + ASSERT_GT(numBands, 0); + int16_t levels[3]{0x7fff, 0, 0}; + getLevelRange(&levels[0], &levels[2]); + ASSERT_GT(levels[2], levels[0]); + levels[1] = (levels[2] + levels[0]) / 2; + for (uint16_t i = 0; i < numBands; ++i) { + for (size_t j = 0; j < ARRAY_SIZE(levels); ++j) { + Return<Result> ret = equalizer->setBandLevel(i, levels[j]); + EXPECT_TRUE(ret.isOk()); + EXPECT_EQ(Result::OK, ret); + Result retval = Result::NOT_INITIALIZED; + int16_t actualLevel; + Return<void> ret2 = equalizer->getBandLevel(i, [&](Result r, int16_t l) { + retval = r; + if (retval == Result::OK) { + actualLevel = l; + } + }); + EXPECT_TRUE(ret2.isOk()); + EXPECT_EQ(Result::OK, retval); + EXPECT_EQ(levels[j], actualLevel); + } + } +} + +TEST_F(EqualizerAudioEffectHidlTest, GetBandCenterFrequencyAndRange) { + description("Verify that Equalizer effect reports adequate band frequency range"); + uint16_t numBands = 0; + getNumBands(&numBands); + ASSERT_GT(numBands, 0); + for (uint16_t i = 0; i < numBands; ++i) { + uint32_t minFreq = 0xffffffff, centerFreq = 0xffffffff, maxFreq = 0xffffffff; + getBandFrequencyRange(i, &minFreq, ¢erFreq, &maxFreq); + // Note: NXP legacy implementation reports "1" as upper bound for last band, + // so this check fails. + EXPECT_GE(maxFreq, centerFreq); + EXPECT_GE(centerFreq, minFreq); + } +} + +TEST_F(EqualizerAudioEffectHidlTest, GetBandForFrequency) { + description("Verify that Equalizer effect supports GetBandForFrequency correctly"); + uint16_t numBands = 0; + getNumBands(&numBands); + ASSERT_GT(numBands, 0); + for (uint16_t i = 0; i < numBands; ++i) { + uint32_t freqs[3]{0, 0, 0}; + getBandFrequencyRange(i, &freqs[0], &freqs[1], &freqs[2]); + // NXP legacy implementation reports "1" as upper bound for last band, some + // of the checks fail. + for (size_t j = 0; j < ARRAY_SIZE(freqs); ++j) { + if (j == 0) { + freqs[j]++; + } // Min frequency is an open interval. + Result retval = Result::NOT_INITIALIZED; + uint16_t actualBand = numBands + 1; + Return<void> ret = equalizer->getBandForFrequency(freqs[j], [&](Result r, uint16_t b) { + retval = r; + if (retval == Result::OK) { + actualBand = b; + } + }); + EXPECT_TRUE(ret.isOk()); + EXPECT_EQ(Result::OK, retval); + EXPECT_EQ(i, actualBand) << "Frequency: " << freqs[j]; + } + } +} + +TEST_F(EqualizerAudioEffectHidlTest, GetPresetNames) { + description("Verify that Equalizer effect reports at least one preset"); + size_t presetCount; + getPresetCount(&presetCount); + EXPECT_GT(presetCount, 0u); +} + +TEST_F(EqualizerAudioEffectHidlTest, GetSetCurrentPreset) { + description("Verify that manipulating the current preset for Equalizer effect"); + size_t presetCount; + getPresetCount(&presetCount); + ASSERT_GT(presetCount, 0u); + for (uint16_t i = 0; i < presetCount; ++i) { + Return<Result> ret = equalizer->setCurrentPreset(i); + EXPECT_TRUE(ret.isOk()); + EXPECT_EQ(Result::OK, ret); + Result retval = Result::NOT_INITIALIZED; + uint16_t actualPreset = 0xffff; + Return<void> ret2 = equalizer->getCurrentPreset([&](Result r, uint16_t p) { + retval = r; + if (retval == Result::OK) { + actualPreset = p; + } + }); + EXPECT_TRUE(ret2.isOk()); + EXPECT_EQ(Result::OK, retval); + EXPECT_EQ(i, actualPreset); + } +} + +TEST_F(EqualizerAudioEffectHidlTest, GetSetAllProperties) { + description( + "Verify that setting band levels and presets works via Get / " + "SetAllProperties for Equalizer effect"); + using AllProperties = + android::hardware::audio::effect::CPP_VERSION::IEqualizerEffect::AllProperties; + uint16_t numBands = 0; + getNumBands(&numBands); + ASSERT_GT(numBands, 0); + AllProperties props; + props.bandLevels.resize(numBands); + for (size_t i = 0; i < numBands; ++i) { + props.bandLevels[i] = 0; + } + + AllProperties actualProps; + Result retval = Result::NOT_INITIALIZED; + + // Verify setting of the band levels via properties. + props.curPreset = -1; + Return<Result> ret = equalizer->setAllProperties(props); + EXPECT_TRUE(ret.isOk()); + EXPECT_EQ(Result::OK, ret); + Return<void> ret2 = equalizer->getAllProperties([&](Result r, AllProperties p) { + retval = r; + if (retval == Result::OK) { + actualProps = p; + } + }); + EXPECT_TRUE(ret2.isOk()); + EXPECT_EQ(Result::OK, retval); + EXPECT_EQ(props.bandLevels, actualProps.bandLevels); + + // Verify setting of the current preset via properties. + props.curPreset = 0; // Assuming there is at least one preset. + ret = equalizer->setAllProperties(props); + EXPECT_TRUE(ret.isOk()); + EXPECT_EQ(Result::OK, ret); + ret2 = equalizer->getAllProperties([&](Result r, AllProperties p) { + retval = r; + if (retval == Result::OK) { + actualProps = p; + } + }); + EXPECT_TRUE(ret2.isOk()); + EXPECT_EQ(Result::OK, retval); + EXPECT_EQ(props.curPreset, actualProps.curPreset); +} + +// The main test class for Equalizer Audio Effect HIDL HAL. +class LoudnessEnhancerAudioEffectHidlTest : public AudioEffectHidlTest { + public: + void SetUp() override { + AudioEffectHidlTest::SetUp(); + enhancer = ILoudnessEnhancerEffect::castFrom(effect); + ASSERT_NE(nullptr, enhancer.get()); + } + + protected: + Uuid getEffectType() override { return LOUDNESS_ENHANCER_EFFECT_TYPE; } + + sp<ILoudnessEnhancerEffect> enhancer; +}; + +TEST_F(LoudnessEnhancerAudioEffectHidlTest, GetSetTargetGain) { + description( + "Verify that manipulating the target gain works for Loudness Enhancer " + "effect"); + const int32_t gain = 100; + Return<Result> ret = enhancer->setTargetGain(gain); + EXPECT_TRUE(ret.isOk()); + EXPECT_EQ(Result::OK, ret); + int32_t actualGain = 0; + Result retval; + Return<void> ret2 = enhancer->getTargetGain([&](Result r, int32_t g) { + retval = r; + if (retval == Result::OK) { + actualGain = g; + } + }); + EXPECT_TRUE(ret2.isOk()); + EXPECT_EQ(Result::OK, retval); + EXPECT_EQ(gain, actualGain); +} + +int main(int argc, char** argv) { + ::testing::AddGlobalTestEnvironment(AudioEffectsFactoryHidlEnvironment::Instance()); + ::testing::InitGoogleTest(&argc, argv); + AudioEffectsFactoryHidlEnvironment::Instance()->init(&argc, argv); + int status = RUN_ALL_TESTS(); + LOG(INFO) << "Test result = " << status; + return status; +} |