diff --git a/distributedaudio.gni b/distributedaudio.gni index 9ce5fe6aa41415232518b3eabe86bd709aaedd11..ceb4f789895190974c1ab666753fe2193c888e10 100644 --- a/distributedaudio.gni +++ b/distributedaudio.gni @@ -32,9 +32,8 @@ audio_processor_path = "${services_path}/audioprocessor" audio_transport_path = "${services_path}/audiotransport" softbusadapter_path = "${services_path}/softbusadapter" interfaces_path = "${distributedaudio_path}/interfaces" -hdf_interfaces_path = - "${distributedaudio_path}/hdf_interfaces/distributed_audio" -hdf_service_path = "${distributedaudio_path}/hdf_service/distributed_audio" +hdf_interfaces_path = "//drivers/interface/distributed_audio" +hdf_service_path = "//drivers/peripheral/distributed_audio" hdf_ser_aud_path = "${hdf_service_path}/hdi_service/audio/v1_0" hdf_ser_aud_ext_path = "${hdf_service_path}/hdi_service/audio_ext/v1_0" diff --git a/hdf_interfaces/distributed_audio/audio/v1_0/AudioTypes.idl b/hdf_interfaces/distributed_audio/audio/v1_0/AudioTypes.idl deleted file mode 100644 index 38cb481b6baae59cb90084a6a053d28251cea6ce..0000000000000000000000000000000000000000 --- a/hdf_interfaces/distributed_audio/audio/v1_0/AudioTypes.idl +++ /dev/null @@ -1,285 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 ohos.hdi.distributed_audio.audio.v1_0; - -enum AudioPortDirection { - PORT_OUT = 1, /**< Output port */ - PORT_IN = 2, /**< Input port */ - PORT_OUT_IN = 3, /**< Input/output port, supporting both audio input and output */ -}; -enum AudioPortPin { - PIN_NONE = 0, /**< Invalid pin */ - PIN_OUT_SPEAKER = 1 << 0, /**< Speaker output pin */ - PIN_OUT_HEADSET = 1 << 1, /**< Wired headset pin for output */ - PIN_OUT_LINEOUT = 1 << 2, /**< Line-out pin */ - PIN_OUT_HDMI = 1 << 3, /**< HDMI output pin */ - PIN_OUT_USB = 1 << 4, /**< USB output pin */ - PIN_OUT_USB_EXT = 1 << 5, /**< Extended USB output pin*/ - PIN_OUT_EARPIECE = 1 << 5 | 1 << 4, /**< Earpiece output pin */ - PIN_OUT_BLUETOOTH_SCO = 1 << 6, /**< Bluetooth SCO output pin */ - PIN_OUT_DAUDIO_DEFAULT = 1 << 7, - PIN_IN_MIC = 1 << 27 | 1 << 0, /**< Microphone input pin */ - PIN_IN_HS_MIC = 1 << 27 | 1 << 1, /**< Wired headset microphone pin for input */ - PIN_IN_LINEIN = 1 << 27 | 1 << 2, /**< Line-in pin */ - PIN_IN_USB_EXT = 1 << 27 | 1 << 3, /**< Extended USB input pin*/ - PIN_IN_BLUETOOTH_SCO_HEADSET = 1 << 27 | 1 << 4, /**< Bluetooth SCO headset input pin */ - PIN_IN_DAUDIO_DEFAULT = 1 << 27 | 1 << 5, -}; -enum AudioCategory { - AUDIO_IN_MEDIA = 0, - AUDIO_IN_COMMUNICATION = 1, - AUDIO_IN_RINGTONE = 2, - AUDIO_IN_CALL = 3, - AUDIO_MMAP_NOIRQ = 4, -}; -enum AudioFormat { - AUDIO_FORMAT_TYPE_PCM_8_BIT = 1 << 0, /**< 8-bit PCM */ - AUDIO_FORMAT_TYPE_PCM_16_BIT = 1 << 1, /**< 16-bit PCM */ - AUDIO_FORMAT_TYPE_PCM_24_BIT = 1 << 1 | 1 << 0, /**< 24-bit PCM */ - AUDIO_FORMAT_TYPE_PCM_32_BIT = 1 << 2, /**< 32-bit PCM */ - AUDIO_FORMAT_TYPE_AAC_MAIN = 1 << 24 | 1 << 0, /**< AAC main */ - AUDIO_FORMAT_TYPE_AAC_LC = 1 << 24 | 1 << 1, /**< AAC LC */ - AUDIO_FORMAT_TYPE_AAC_LD = 1 << 24 | 1 << 1 | 1 << 0, /**< AAC LD */ - AUDIO_FORMAT_TYPE_AAC_ELD = 1 << 24 | 1 << 2, /**< AAC ELD */ - AUDIO_FORMAT_TYPE_AAC_HE_V1 = 1 << 24 | 1 << 2 | 1 << 0, /**< AAC HE_V1 */ - AUDIO_FORMAT_TYPE_AAC_HE_V2 = 1 << 24 | 1 << 2 | 1 << 1, /**< AAC HE_V2 */ - AUDIO_FORMAT_TYPE_G711A = 1 << 25 | 1 << 0, /**< G711A */ - AUDIO_FORMAT_TYPE_G711U = 1 << 25 | 1 << 1, /**< G711u */ - AUDIO_FORMAT_TYPE_G726 = 1 << 25 | 1 << 1 | 1 << 0, /**< G726 */ -}; -enum AudioChannelMask { - AUDIO_CHANNEL_FRONT_LEFT = 1, /**< Front left channel */ - AUDIO_CHANNEL_FRONT_RIGHT = 2, /**< Front right channel */ - AUDIO_CHANNEL_MONO = 1, /**< Mono channel */ - AUDIO_CHANNEL_STEREO = 3, /**< Stereo channel, consisting of front left and front right channels */ -}; -enum AudioSampleRatesMask { - AUDIO_SAMPLE_RATE_MASK_8000 = 1 << 0, /**< 8 kHz */ - AUDIO_SAMPLE_RATE_MASK_12000 = 1 << 1, /**< 12 kHz */ - AUDIO_SAMPLE_RATE_MASK_11025 = 1 << 2, /**< 11.025 kHz */ - AUDIO_SAMPLE_RATE_MASK_16000 = 1 << 3, /**< 16 kHz */ - AUDIO_SAMPLE_RATE_MASK_22050 = 1 << 4, /**< 22.050 kHz */ - AUDIO_SAMPLE_RATE_MASK_24000 = 1 << 5, /**< 24 kHz */ - AUDIO_SAMPLE_RATE_MASK_32000 = 1 << 6, /**< 32 kHz */ - AUDIO_SAMPLE_RATE_MASK_44100 = 1 << 7, /**< 44.1 kHz */ - AUDIO_SAMPLE_RATE_MASK_48000 = 1 << 8, /**< 48 kHz */ - AUDIO_SAMPLE_RATE_MASK_64000 = 1 << 9, /**< 64 kHz */ - AUDIO_SAMPLE_RATE_MASK_96000 = 1 << 10, /**< 96 kHz */ - AUDIO_SAMPLE_RATE_MASK_INVALID = 4294967295, /**< Invalid sampling rate */ -}; -enum AudioPortPassthroughMode { - PORT_PASSTHROUGH_LPCM = 1, - PORT_PASSTHROUGH_RAW = 2, - PORT_PASSTHROUGH_HBR2LBR = 4, - PORT_PASSTHROUGH_AUTO = 8, -}; -enum AudioSampleFormat { - AUDIO_SAMPLE_FORMAT_S8 = 0, - AUDIO_SAMPLE_FORMAT_S8P = 1, - AUDIO_SAMPLE_FORMAT_U8 = 2, - AUDIO_SAMPLE_FORMAT_U8P = 3, - AUDIO_SAMPLE_FORMAT_S16 = 4, - AUDIO_SAMPLE_FORMAT_S16P = 5, - AUDIO_SAMPLE_FORMAT_U16 = 6, - AUDIO_SAMPLE_FORMAT_U16P = 7, - AUDIO_SAMPLE_FORMAT_S24 = 8, - AUDIO_SAMPLE_FORMAT_S24P = 9, - AUDIO_SAMPLE_FORMAT_U24 = 10, - AUDIO_SAMPLE_FORMAT_U24P = 11, - AUDIO_SAMPLE_FORMAT_S32 = 12, - AUDIO_SAMPLE_FORMAT_S32P = 13, - AUDIO_SAMPLE_FORMAT_U32 = 14, - AUDIO_SAMPLE_FORMAT_U32P = 15, - AUDIO_SAMPLE_FORMAT_S64 = 16, - AUDIO_SAMPLE_FORMAT_S64P = 17, - AUDIO_SAMPLE_FORMAT_U64 = 18, - AUDIO_SAMPLE_FORMAT_U64P = 19, - AUDIO_SAMPLE_FORMAT_F32 = 20, - AUDIO_SAMPLE_FORMAT_F32P = 21, - AUDIO_SAMPLE_FORMAT_F64 = 22, - AUDIO_SAMPLE_FORMAT_F64P = 23, -}; -enum AudioChannelMode { - AUDIO_CHANNEL_NORMAL = 0, - AUDIO_CHANNEL_BOTH_LEFT = 1, - AUDIO_CHANNEL_BOTH_RIGHT = 2, - AUDIO_CHANNEL_EXCHANGE = 3, - AUDIO_CHANNEL_MIX = 4, - AUDIO_CHANNEL_LEFT_MUTE = 5, - AUDIO_CHANNEL_RIGHT_MUTE = 6, - AUDIO_CHANNEL_BOTH_MUTE = 7, -}; -enum AudioDrainNotifyType { - AUDIO_DRAIN_NORMAL_MODE = 0, - AUDIO_DRAIN_EARLY_MODE = 1, -}; -enum AudioCallbackType { - AUDIO_NONBLOCK_WRITE_COMPELETED = 0, - AUDIO_DRAIN_COMPELETED = 1, - AUDIO_FLUSH_COMPLETED = 2, - AUDIO_RENDER_FULL = 3, - AUDIO_ERROR_OCCUR = 4, -}; -enum AudioPortRole { - AUDIO_PORT_UNASSIGNED_ROLE = 0, - AUDIO_PORT_SOURCE_ROLE = 1, - AUDIO_PORT_SINK_ROLE = 2, -}; -enum AudioPortType { - AUDIO_PORT_UNASSIGNED_TYPE = 0, - AUDIO_PORT_DEVICE_TYPE = 1, - AUDIO_PORT_MIX_TYPE = 2, - AUDIO_PORT_SESSION_TYPE = 3, -}; -enum AudioSessionType { - AUDIO_OUTPUT_STAGE_SESSION = 0, - AUDIO_OUTPUT_MIX_SESSION = 1, - AUDIO_ALLOCATE_SESSION = 2, - AUDIO_INVALID_SESSION = 3, -}; -enum AudioDeviceType { - AUDIO_LINEOUT = 1 << 0, - AUDIO_HEADPHONE = 1 << 1, - AUDIO_HEADSET = 1 << 2, - AUDIO_USB_HEADSET = 1 << 3, - AUDIO_USB_HEADPHONE = 1 << 4, - AUDIO_USBA_HEADSET = 1 << 5, - AUDIO_USBA_HEADPHONE = 1 << 6, - AUDIO_PRIMARY_DEVICE = 1 << 7, - AUDIO_USB_DEVICE = 1 << 8, - AUDIO_A2DP_DEVICE = 1 << 9, - AUDIO_DEVICE_UNKNOWN, -}; -enum AudioEventType { - AUDIO_DEVICE_ADD = 1, - AUDIO_DEVICE_REMOVE = 2, - AUDIO_LOAD_SUCCESS = 3, - AUDIO_LOAD_FAILURE = 4, - AUDIO_UNLOAD = 5, - AUDIO_SERVICE_VALID = 7, - AUDIO_SERVICE_INVALID = 8, - AUDIO_CAPTURE_THRESHOLD = 9, - AUDIO_EVENT_UNKNOWN = 10, -}; -enum AudioExtParamKey { - AUDIO_EXT_PARAM_KEY_NONE = 0, /**< Distributed audio extra param key none */ - AUDIO_EXT_PARAM_KEY_VOLUME = 1, /**< Distributed audio extra param key volume event */ - AUDIO_EXT_PARAM_KEY_FOCUS = 2, /**< Distributed audio extra param key focus event */ - AUDIO_EXT_PARAM_KEY_BUTTON = 3, /**< Distributed audio extra param key media button event */ - AUDIO_EXT_PARAM_KEY_EFFECT = 4, /**< Distributed audio extra param key audio effect event */ - AUDIO_EXT_PARAM_KEY_STATUS = 5, /**< Distributed audio extra param key device status event */ - AUDIO_EXT_PARAM_KEY_LOWPOWER = 1000, /**< Low power event type */ -}; -struct AudioDeviceStatus { - unsigned int pnpStatus; -}; -union SceneDesc { - unsigned int id; -}; -struct AudioPort { - enum AudioPortDirection dir; - unsigned int portId; - String portName; -}; -struct AudioAdapterDescriptor { - String adapterName; - struct AudioPort[] ports; -}; -struct AudioDeviceDescriptor { - unsigned int portId; - enum AudioPortPin pins; - String desc; -}; -struct AudioSceneDescriptor { - union SceneDesc scene; - struct AudioDeviceDescriptor desc; -}; -struct AudioSampleAttributes { - enum AudioCategory type; - boolean interleaved; - enum AudioFormat format; - unsigned int sampleRate; - unsigned int channelCount; - unsigned int period; - unsigned int frameSize; - boolean isBigEndian; - boolean isSignedData; - unsigned int startThreshold; - unsigned int stopThreshold; - unsigned int silenceThreshold; - int streamId; -}; -struct AudioTimeStamp { - long tvSec; - long tvNSec; -}; -struct AudioSubPortCapability { - unsigned int portId; - String desc; - enum AudioPortPassthroughMode mask; -}; -struct AudioPortCapability { - unsigned int deviceType; - unsigned int deviceId; - boolean hardwareMode; - unsigned int formatNum; - enum AudioFormat[] formats; - unsigned int sampleRateMasks; - enum AudioChannelMask channelMasks; - unsigned int channelCount; - struct AudioSubPortCapability[] subPorts; - enum AudioSampleFormat[] supportSampleFormats; -}; -struct AudioMmapBufferDescriptor { - byte[] memoryAddress; - FileDescriptor memoryFd; - int totalBufferFrames; - int transferFrameSize; - int isShareable; - unsigned int offset; - String filePath; -}; -struct AudioDevExtInfo { - int moduleId; - enum AudioPortPin type; - String desc; -}; -struct AudioMixExtInfo { - int moduleId; - int streamId; -}; -struct AudioSessionExtInfo { - enum AudioSessionType sessionType; -}; -struct AudioInfo { - struct AudioDevExtInfo device; - struct AudioMixExtInfo mix; - struct AudioSessionExtInfo session; -}; -struct AudioRouteNode { - int portId; - enum AudioPortRole role; - enum AudioPortType type; - struct AudioInfo ext; -}; -struct AudioRoute { - struct AudioRouteNode[] sources; - struct AudioRouteNode[] sinks; -}; -struct AudioEvent { - unsigned int eventType; /**< @link enum AudioEventType */ - unsigned int deviceType; /**< @link enum AudioDeviceType */ -}; diff --git a/hdf_interfaces/distributed_audio/audio/v1_0/BUILD.gn b/hdf_interfaces/distributed_audio/audio/v1_0/BUILD.gn deleted file mode 100644 index 333eb2161c47519c655cc4698aeb70904a4ba81b..0000000000000000000000000000000000000000 --- a/hdf_interfaces/distributed_audio/audio/v1_0/BUILD.gn +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# 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. - -import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") -hdi("daudio") { - module_name = "daudio" - sources = [ - "AudioTypes.idl", - "IAudioAdapter.idl", - "IAudioCallback.idl", - "IAudioCapture.idl", - "IAudioManager.idl", - "IAudioRender.idl", - ] - language = "cpp" - root = "ohos.hdi://foundation/distributedhardware/distributed_audio/hdf_interfaces/" - subsystem_name = "hdf" - part_name = "drivers_interface_distributed_audio" -} diff --git a/hdf_interfaces/distributed_audio/audio/v1_0/IAudioAdapter.idl b/hdf_interfaces/distributed_audio/audio/v1_0/IAudioAdapter.idl deleted file mode 100644 index 39f5ff59c1e0cc76a76aa1da8596006f282eb880..0000000000000000000000000000000000000000 --- a/hdf_interfaces/distributed_audio/audio/v1_0/IAudioAdapter.idl +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 ohos.hdi.distributed_audio.audio.v1_0; - -import ohos.hdi.distributed_audio.audio.v1_0.AudioTypes; -import ohos.hdi.distributed_audio.audio.v1_0.IAudioCapture; -import ohos.hdi.distributed_audio.audio.v1_0.IAudioRender; -import ohos.hdi.distributed_audio.audio.v1_0.IAudioCallback; - -interface IAudioAdapter { - InitAllPorts(); - CreateRender([in] struct AudioDeviceDescriptor desc, [in] struct AudioSampleAttributes attrs, [out] IAudioRender render); - DestroyRender([in] struct AudioDeviceDescriptor desc); - CreateCapture([in] struct AudioDeviceDescriptor desc, [in] struct AudioSampleAttributes attrs, [out] IAudioCapture capture); - DestroyCapture([in] struct AudioDeviceDescriptor desc); - GetPortCapability([in] struct AudioPort port, [out] struct AudioPortCapability capability); - SetPassthroughMode([in] struct AudioPort port, [in] enum AudioPortPassthroughMode mode); - GetPassthroughMode([in] struct AudioPort port, [out] enum AudioPortPassthroughMode mode); - GetDeviceStatus([out] struct AudioDeviceStatus status); - UpdateAudioRoute([in] struct AudioRoute route, [out] int routeHandle); - ReleaseAudioRoute([in] int routeHandle); - SetMicMute([in] boolean mute); - GetMicMute([out] boolean mute); - SetVoiceVolume([in] float volume); - SetExtraParams([in] enum AudioExtParamKey key, [in] String condition, [in] String value); - GetExtraParams([in] enum AudioExtParamKey key, [in] String condition, [out] String value); - RegExtraParamObserver([in] IAudioCallback audioCallback, [in] byte cookie); -} diff --git a/hdf_interfaces/distributed_audio/audio/v1_0/IAudioCallback.idl b/hdf_interfaces/distributed_audio/audio/v1_0/IAudioCallback.idl deleted file mode 100644 index f73ff31b06421ee75bd55528ce8bcf8a4be5726d..0000000000000000000000000000000000000000 --- a/hdf_interfaces/distributed_audio/audio/v1_0/IAudioCallback.idl +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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. - */ - -/** - * @addtogroup HdiAudio - * @{ - * - * @brief Provides unified APIs for audio services to access audio drivers. - * - * An audio service can obtain an audio driver object or agent and then call APIs provided by this object or agent to - * access different types of audio devices based on the audio IDs, thereby obtaining audio information, - * subscribing to or unsubscribing from audio data, enabling or disabling an audio, - * setting the audio data reporting mode, and setting audio options such as the accuracy and measurement range. - * - * @version 1.0 - */ - -package ohos.hdi.distributed_audio.audio.v1_0; - -import ohos.hdi.distributed_audio.audio.v1_0.AudioTypes; - -/** - * @brief Called when an event defined in {@link AudioCallbackType} occurs. - * - * @param AudioCallbackType Indicates the occurred event that triggers this callback. - * @param reserved Indicates the pointer to a reserved field. - * @param cookie Indicates the pointer to the cookie for data transmission. - * @return Returns 0 if the callback is successfully executed; returns a negative value otherwise. - * @see RegCallback - */ -[callback] interface IAudioCallback { - RenderCallback([in] enum AudioCallbackType type, [out] byte reserved, [out] byte cookie); - ParamCallback([in] enum AudioExtParamKey key, [in] String condition, [in] String value, [out] byte reserved, [out] byte cookie); -} diff --git a/hdf_interfaces/distributed_audio/audio/v1_0/IAudioCapture.idl b/hdf_interfaces/distributed_audio/audio/v1_0/IAudioCapture.idl deleted file mode 100644 index c93ae0115a449c2c19b632379a1cfacc5455b33b..0000000000000000000000000000000000000000 --- a/hdf_interfaces/distributed_audio/audio/v1_0/IAudioCapture.idl +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 ohos.hdi.distributed_audio.audio.v1_0; - -import ohos.hdi.distributed_audio.audio.v1_0.AudioTypes; - -interface IAudioCapture { - CaptureFrame([out] byte[] frame, [in] unsigned long requestBytes); - GetCapturePosition([out] unsigned long frames, [out] struct AudioTimeStamp time); - CheckSceneCapability([in] struct AudioSceneDescriptor scene, [out] boolean supported); - SelectScene([in] struct AudioSceneDescriptor scene); - SetMute([in] boolean mute); - GetMute([out] boolean mute); - SetVolume([in] float volume); - GetVolume([out] float volume); - GetGainThreshold([out] float min, [out] float max); - GetGain([out] float gain); - SetGain([in] float gain); - GetFrameSize([out] unsigned long size); - GetFrameCount([out] unsigned long count); - SetSampleAttributes([in] struct AudioSampleAttributes attrs); - GetSampleAttributes([out] struct AudioSampleAttributes attrs); - GetCurrentChannelId([out] unsigned int channelId); - SetExtraParams([in] String keyValueList); - GetExtraParams([out] String keyValueList); - ReqMmapBuffer([in] int reqSize, [out] struct AudioMmapBufferDescriptor desc); - GetMmapPosition([out] unsigned long frames, [out] struct AudioTimeStamp time); - AddAudioEffect([in] unsigned long effectid); - RemoveAudioEffect([in] unsigned long effectid); - GetFrameBufferSize([out] unsigned long bufferSize); - Start(); - Stop(); - Pause(); - Resume(); - Flush(); - TurnStandbyMode(); - AudioDevDump([in] int range, [in] int fd); - IsSupportsPauseAndResume([out] boolean supportPause, [out] boolean supportResume); -} \ No newline at end of file diff --git a/hdf_interfaces/distributed_audio/audio/v1_0/IAudioManager.idl b/hdf_interfaces/distributed_audio/audio/v1_0/IAudioManager.idl deleted file mode 100644 index beef5cafae6a062b16dc6f77e7bb602f8393f531..0000000000000000000000000000000000000000 --- a/hdf_interfaces/distributed_audio/audio/v1_0/IAudioManager.idl +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 ohos.hdi.distributed_audio.audio.v1_0; - -import ohos.hdi.distributed_audio.audio.v1_0.AudioTypes; -import ohos.hdi.distributed_audio.audio.v1_0.IAudioAdapter; - -interface IAudioManager { - GetAllAdapters([out] struct AudioAdapterDescriptor[] descs); - LoadAdapter([in] struct AudioAdapterDescriptor desc, [out] IAudioAdapter adapter); - UnloadAdapter([in] String adapterName); - ReleaseAudioManagerObject(); -} diff --git a/hdf_interfaces/distributed_audio/audio/v1_0/IAudioRender.idl b/hdf_interfaces/distributed_audio/audio/v1_0/IAudioRender.idl deleted file mode 100644 index 4e24e431d9284cfc0c2b9b3495441ece618db2fc..0000000000000000000000000000000000000000 --- a/hdf_interfaces/distributed_audio/audio/v1_0/IAudioRender.idl +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 ohos.hdi.distributed_audio.audio.v1_0; - -import ohos.hdi.distributed_audio.audio.v1_0.AudioTypes; -import ohos.hdi.distributed_audio.audio.v1_0.IAudioCallback; - -interface IAudioRender { - GetLatency([out] unsigned int ms); - RenderFrame([in] byte[] frame, [out] unsigned long replyBytes); - GetRenderPosition([out] unsigned long frames, [out] struct AudioTimeStamp time); - SetRenderSpeed([in] float speed); - GetRenderSpeed([out] float speed); - SetChannelMode([in] enum AudioChannelMode mode); - GetChannelMode([out] enum AudioChannelMode mode); - RegCallback([in] IAudioCallback audioCallback, [in] byte cookie); - DrainBuffer([out] enum AudioDrainNotifyType type); - IsSupportsDrain([out] boolean support); - CheckSceneCapability([in] struct AudioSceneDescriptor scene, [out] boolean supported); - SelectScene([in] struct AudioSceneDescriptor scene); - SetMute([in] boolean mute); - GetMute([out] boolean mute); - SetVolume([in] float volume); - GetVolume([out] float volume); - GetGainThreshold([out] float min, [out] float max); - GetGain([out] float gain); - SetGain([in] float gain); - GetFrameSize([out] unsigned long size); - GetFrameCount([out] unsigned long count); - SetSampleAttributes([in] struct AudioSampleAttributes attrs); - GetSampleAttributes([out] struct AudioSampleAttributes attrs); - GetCurrentChannelId([out] unsigned int channelId); - SetExtraParams([in] String keyValueList); - GetExtraParams([out] String keyValueList); - ReqMmapBuffer([in] int reqSize, [out] struct AudioMmapBufferDescriptor desc); - GetMmapPosition([out] unsigned long frames, [out] struct AudioTimeStamp time); - AddAudioEffect([in] unsigned long effectid); - RemoveAudioEffect([in] unsigned long effectid); - GetFrameBufferSize([out] unsigned long bufferSize); - Start(); - Stop(); - Pause(); - Resume(); - Flush(); - TurnStandbyMode(); - AudioDevDump([in] int range, [in] int fd); - IsSupportsPauseAndResume([out] boolean supportPause, [out] boolean supportResume); -} \ No newline at end of file diff --git a/hdf_interfaces/distributed_audio/audioext/v1_0/BUILD.gn b/hdf_interfaces/distributed_audio/audioext/v1_0/BUILD.gn deleted file mode 100644 index 22a30fba844e41d93103da71e304a69cd99b38c4..0000000000000000000000000000000000000000 --- a/hdf_interfaces/distributed_audio/audioext/v1_0/BUILD.gn +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# 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. - -import("//drivers/hdf_core/adapter/uhdf2/hdi.gni") -hdi("daudioext") { - module_name = "daudioext" - sources = [ - "IDAudioCallback.idl", - "IDAudioManager.idl", - "Types.idl", - ] - language = "cpp" - root = "ohos.hdi://foundation/distributedhardware/distributed_audio/hdf_interfaces/" - subsystem_name = "hdf" - part_name = "drivers_interface_distributed_audio" -} diff --git a/hdf_interfaces/distributed_audio/audioext/v1_0/IDAudioCallback.idl b/hdf_interfaces/distributed_audio/audioext/v1_0/IDAudioCallback.idl deleted file mode 100644 index b4f787c74dc56948a30b3986be291b3317fcfe76..0000000000000000000000000000000000000000 --- a/hdf_interfaces/distributed_audio/audioext/v1_0/IDAudioCallback.idl +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 ohos.hdi.distributed_audio.audioext.v1_0; - -import ohos.hdi.distributed_audio.audioext.v1_0.Types; - -[callback] interface IDAudioCallback { - OpenDevice([in] String adpName, [in] int devId); - CloseDevice([in] String adpName, [in] int devId); - SetParameters([in] String adpName, [in] int devId, [in] struct AudioParameter param); - NotifyEvent([in] String adpName, [in] int devId, [in] struct DAudioEvent event); - WriteStreamData([in] String adpName, [in] int devId, [in] struct AudioData data); - ReadStreamData([in] String adpName, [in] int devId, [out] struct AudioData data); - ReadMmapPosition([in] String adpName, [in] int devId, [out] unsigned long frames, [out] struct CurrentTime time); - RefreshAshmemInfo([in] String adpName, [in] int devId, [in] FileDescriptor fd, [in] int ashmemLength, [in] int lengthPerTrans); -} \ No newline at end of file diff --git a/hdf_interfaces/distributed_audio/audioext/v1_0/IDAudioManager.idl b/hdf_interfaces/distributed_audio/audioext/v1_0/IDAudioManager.idl deleted file mode 100644 index 9ea0f8bacd6c1b37b7bb6c80eabcbf43eebfdd42..0000000000000000000000000000000000000000 --- a/hdf_interfaces/distributed_audio/audioext/v1_0/IDAudioManager.idl +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 ohos.hdi.distributed_audio.audioext.v1_0; - -import ohos.hdi.distributed_audio.audioext.v1_0.IDAudioCallback; -import ohos.hdi.distributed_audio.audioext.v1_0.Types; - -interface IDAudioManager { - RegisterAudioDevice([in] String adpName, [in] int devId, [in] String capability, [in] IDAudioCallback callbackObj); - UnRegisterAudioDevice([in] String adpName, [in] int devId); - NotifyEvent([in] String adpName, [in] int devId, [in] struct DAudioEvent event); -} \ No newline at end of file diff --git a/hdf_interfaces/distributed_audio/audioext/v1_0/Types.idl b/hdf_interfaces/distributed_audio/audioext/v1_0/Types.idl deleted file mode 100644 index 35b5c1fb6b8f382d42205c50922046c8b7f77681..0000000000000000000000000000000000000000 --- a/hdf_interfaces/distributed_audio/audioext/v1_0/Types.idl +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 ohos.hdi.distributed_audio.audioext.v1_0; -enum PortOperationMode { - NORMAL_MODE = 0, - MMAP_MODE = 1, -}; -struct AudioParameter { - unsigned int format; - unsigned int channelCount; - unsigned int sampleRate; - unsigned int period; - unsigned int frameSize; - unsigned int streamUsage; - enum PortOperationMode renderFlags; - enum PortOperationMode capturerFlags; - String ext; -}; -struct AudioData { - struct AudioParameter param; - byte[] data; -}; -struct DAudioEvent { - int type; - String content; -}; -struct CurrentTime { - long tvSec; - long tvNSec; -}; \ No newline at end of file diff --git a/hdf_interfaces/distributed_audio/bundle.json b/hdf_interfaces/distributed_audio/bundle.json deleted file mode 100644 index a339e95ed5cde8f60b3229a1c038611708b26026..0000000000000000000000000000000000000000 --- a/hdf_interfaces/distributed_audio/bundle.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "name": "@ohos/drivers_interface_distributed_audio", - "description": "distributed audio device driver interface", - "version": "4.0", - "license": "Apache License 2.0", - "segment":{ - "destPath":"foundation/distributedhardware/distributed_audio/hdf_interfaces/" - }, - "component": { - "name": "drivers_interface_distributed_audio", - "subsystem": "distributedhardware", - "adapted_system_type":[ - "standard" - ], - "rom": "675KB", - "ram": "1024KB", - "deps": { - "components": [ - "ipc", - "hdf_core", - "hiviewdfx_hilog_native", - "c_utils" - ], - "third_party": [] - }, - "build": { - "sub_component": [ - "//foundation/distributedhardware/distributed_audio/hdf_interfaces/distributed_audio/audio/v1_0:daudio_idl_target", - "//foundation/distributedhardware/distributed_audio/hdf_interfaces/distributed_audio/audioext/v1_0:daudioext_idl_target" - ], - "test": [ - - ], - "inner_kits": [ - { - "name":"//foundation/distributedhardware/distributed_audio/hdf_interfaces/distributed_audio/audio/v1_0:libdaudio_proxy_1.0", - "header": { - "header_files": [ - - ], - "header_base": "//foundation/distributedhardware/distributed_audio/hdf_interfaces/distributed_audio/audio" - } - }, - { - "name":"//foundation/distributedhardware/distributed_audio/hdf_interfaces/distributed_audio/audioext/v1_0:libdaudioext_proxy_1.0", - "header": { - "header_files": [ - - ], - "header_base": "//foundation/distributedhardware/distributed_audio/hdf_interfaces/distributed_audio/audioext" - } - } - ] - } - } -} \ No newline at end of file diff --git a/hdf_service/distributed_audio/BUILD.gn b/hdf_service/distributed_audio/BUILD.gn deleted file mode 100644 index 3e332e5e6576eec60d69ee50bc3d3a63192b624e..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/BUILD.gn +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# 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. - -if (defined(ohos_lite)) { - group("distributed_audio_entry") { - deps = [] - } -} else { - group("distributed_audio_entry") { - deps = [ - "./../../hdf_interfaces/distributed_audio/audio/v1_0:daudio_idl_target", - "./../../hdf_interfaces/distributed_audio/audioext/v1_0:daudioext_idl_target", - "./hdi_service/audio/v1_0:hdf_daudio_primary_service", - "./hdi_service/audio_ext/v1_0:hdf_daudio_ext_service", - ] - } -} diff --git a/hdf_service/distributed_audio/bundle.json b/hdf_service/distributed_audio/bundle.json deleted file mode 100644 index 37f64fc0e8dc973e2f275cfe6fa4acbe58d18229..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/bundle.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "name": "@ohos/drivers_peripheral_distributed_audio", - "description": "distributed audo device driver", - "version": "4.0", - "license": "Apache License 2.0", - "segment":{ - "destPath":"foundation/distributedhardware/distributed_audio/hdf_service/" - }, - "component": { - "name": "drivers_peripheral_distributed_audio", - "subsystem": "distributedhardware", - "adapted_system_type":[ - "standard" - ], - "rom": "1000KB", - "ram": "8000KB", - "deps": { - "components": [ - "ipc", - "hdf_core", - "hiviewdfx_hilog_native", - "c_utils" - ], - "third_party": [ - "bounds_checking_function" - ] - }, - "build": { - "sub_component": [ - "//foundation/distributedhardware/distributed_audio/hdf_service/distributed_audio:distributed_audio_entry", - "//foundation/distributedhardware/distributed_audio/hdf_service/distributed_audio/hdi_service/common:libdaudio_hdf_utils" - ], - "test": [ - "//foundation/distributedhardware/distributed_audio/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest:hdi_service_audio_test", - "//foundation/distributedhardware/distributed_audio/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/unittest:hdi_service_audio_ext_test" - ], - "inner_kits": [ - { - "name": "//foundation/distributedhardware/distributed_audio/hdf_interfaces/distributed_audio/audio/v1_0:libdaudio_proxy_1.0", - "header": { - "header_files": [ - ], - "header_base": "//foundation/distributedhardware/distributed_audio/hdf_interfaces/distributed_audio/audio" - } - }, - { - "name": "//foundation/distributedhardware/distributed_audio/hdf_interfaces/distributed_audio/audioext/v1_0:libdaudioext_proxy_1.0", - "header": { - "header_files": [ - ], - "header_base": "//foundation/distributedhardware/distributed_audio/hdf_interfaces/distributed_audio/audioext" - } - } - ] - } - } -} diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio/v1_0/BUILD.gn deleted file mode 100644 index 6fbd906bb9006b8514f907243f898e5f6687d860..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/BUILD.gn +++ /dev/null @@ -1,101 +0,0 @@ -# Copyright (c) 2023 Huawei Device Co., Ltd. -# 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. - -import("//build/ohos.gni") -import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni") -import("../../../../../distributedaudio.gni") - -ohos_shared_library("libaudio_manager_daudio_primary_service_1.0") { - include_dirs = [ - "${hdf_ser_aud_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] - - if (distributed_audio_extension) { - include_dirs += - [ "${distributedaudio_ext_path}/hdf_service_extension/include/" ] - } - - sources = [ - "./src/audio_adapter_interface_impl.cpp", - "./src/audio_capture_interface_impl.cpp", - "./src/audio_manager_interface_impl.cpp", - "./src/audio_render_interface_impl.cpp", - ] - - if (distributed_audio_extension) { - sources += [ - "${distributedaudio_ext_path}/hdf_service_extension/src/audio_capture_ext_impl.cpp", - "${distributedaudio_ext_path}/hdf_service_extension/src/audio_render_ext_impl.cpp", - ] - } - - public_deps = [ - "${hdf_interfaces_path}/audio/v1_0:libdaudio_stub_1.0", - "${hdf_interfaces_path}/audioext/v1_0:libdaudioext_stub_1.0", - "${hdf_service_path}/hdi_service/common:libdaudio_hdf_utils", - ] - - external_deps = [ - "c_utils:utils", - "hdf_core:libhdf_host", - "hdf_core:libhdf_utils", - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_single", - ] - - if (distributed_audio_extension) { - cflags = [ "-DDAUDIO_SUPPORT_EXTENSION" ] - } - - defines = [ - "HI_LOG_ENABLE", - "LOG_DOMAIN=0xD004100", - ] - - install_images = [ chipset_base_dir ] - subsystem_name = "hdf" - part_name = "drivers_peripheral_distributed_audio" -} - -ohos_shared_library("libdaudio_primary_driver") { - include_dirs = [ "${hdf_ser_aud_path}/include" ] - - sources = [ "./src/audio_driver.cpp" ] - - deps = [ "${hdf_ser_aud_path}:libaudio_manager_daudio_primary_service_1.0" ] - - external_deps = [ - "c_utils:utils", - "hdf_core:libhdf_host", - "hdf_core:libhdf_ipc_adapter", - "hdf_core:libhdf_utils", - "hdf_core:libhdi", - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_single", - ] - - shlib_type = "hdi" - install_images = [ chipset_base_dir ] - subsystem_name = "hdf" - part_name = "drivers_peripheral_distributed_audio" -} - -group("hdf_daudio_primary_service") { - deps = [ - ":libaudio_manager_daudio_primary_service_1.0", - ":libdaudio_primary_driver", - ] -} diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_adapter_interface_impl.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_adapter_interface_impl.h deleted file mode 100644 index cee31f40caa666312a3b1f7d05a3bc906aa18865..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_adapter_interface_impl.h +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * 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 OHOS_AUDIO_ADAPTER_INTERFACE_IMPL_H -#define OHOS_AUDIO_ADAPTER_INTERFACE_IMPL_H - -#include -#include -#include - -#include -#include -#include - -#include "audio_capture_interface_impl.h" -#include "audio_capture_interface_impl_base.h" -#include "audio_render_interface_impl.h" -#include "audio_render_interface_impl_base.h" -#ifdef DAUDIO_SUPPORT_EXTENSION -#include "audio_capture_ext_impl.h" -#include "audio_render_ext_impl.h" -#endif - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -using OHOS::HDI::DistributedAudio::Audioext::V1_0::DAudioEvent; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::PortOperationMode; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioParameter; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::IDAudioCallback; - -typedef enum { - STATUS_ONLINE = 0, - STATUS_OFFLINE, - STATUS_LOAD, - STATUS_UNLOAD, - STATUS_CREATE_RENDER, -} AudioAdapterStatus; - -typedef enum { - EVENT_DEV_CLOSED = 0, - EVENT_OPEN_SPK, - EVENT_CLOSE_SPK, - EVENT_OPEN_MIC, - EVENT_CLOSE_MIC, -} AudioDeviceEvent; - -typedef enum { - EVENT_GET_VOLUME = 1, - EVENT_GET_MIN_VOLUME = 2, - EVENT_GET_MAX_VOLUME = 3, - EVENT_IS_STREAM_MUTE = 4, -} VolumeEventType; - -class AudioAdapterInterfaceImpl : public IAudioAdapter { -public: - explicit AudioAdapterInterfaceImpl(const AudioAdapterDescriptor &desc); - ~AudioAdapterInterfaceImpl() override; - - int32_t InitAllPorts() override; - int32_t CreateRender(const AudioDeviceDescriptor &desc, const AudioSampleAttributes &attrs, - sptr &render) override; - int32_t DestroyRender(const AudioDeviceDescriptor &desc) override; - int32_t CreateCapture(const AudioDeviceDescriptor &desc, const AudioSampleAttributes &attrs, - sptr &capture) override; - int32_t DestroyCapture(const AudioDeviceDescriptor &desc) override; - int32_t GetPortCapability(const AudioPort &port, AudioPortCapability &capability) override; - int32_t SetPassthroughMode(const AudioPort &port, AudioPortPassthroughMode mode) override; - int32_t GetPassthroughMode(const AudioPort &port, AudioPortPassthroughMode &mode) override; - int32_t GetDeviceStatus(AudioDeviceStatus& status) override; - int32_t UpdateAudioRoute(const AudioRoute &route, int32_t &routeHandle) override; - int32_t ReleaseAudioRoute(int32_t routeHandle) override; - int32_t SetMicMute(bool mute) override; - int32_t GetMicMute(bool& mute) override; - int32_t SetVoiceVolume(float volume) override; - int32_t SetExtraParams(AudioExtParamKey key, const std::string &condition, const std::string &value) override; - int32_t GetExtraParams(AudioExtParamKey key, const std::string &condition, std::string &value) override; - int32_t RegExtraParamObserver(const sptr &audioCallback, int8_t cookie) override; - -public: - void SetSpeakerCallback(const sptr &speakerCallback); - void SetMicCallback(const sptr &micCallback); - AudioAdapterDescriptor GetAdapterDesc(); - std::string GetDeviceCapabilitys(const uint32_t devId); - int32_t AdapterLoad(); - int32_t AdapterUnload(); - int32_t Notify(const uint32_t devId, const DAudioEvent &event); - int32_t AddAudioDevice(const uint32_t devId, const std::string &caps); - int32_t RemoveAudioDevice(const uint32_t devId); - int32_t OpenRenderDevice(const AudioDeviceDescriptor &desc, const AudioSampleAttributes &attrs); - int32_t CloseRenderDevice(const AudioDeviceDescriptor &desc); - int32_t OpenCaptureDevice(const AudioDeviceDescriptor &desc, const AudioSampleAttributes &attrs); - int32_t CloseCaptureDevice(const AudioDeviceDescriptor &desc); - uint32_t GetVolumeGroup(const uint32_t devId); - uint32_t GetInterruptGroup(const uint32_t devId); - bool IsPortsNoReg(); - -private: - int32_t SetAudioVolume(const std::string& condition, const std::string ¶m); - int32_t GetAudioVolume(const std::string& condition, std::string ¶m); - int32_t HandleFocusChangeEvent(const DAudioEvent &event); - int32_t HandleRenderStateChangeEvent(const DAudioEvent &event); - int32_t HandleVolumeChangeEvent(const DAudioEvent &event); - int32_t HandleSANotifyEvent(const DAudioEvent &event); - int32_t WaitForSANotify(const AudioDeviceEvent &event); - int32_t HandleDeviceClosed(const DAudioEvent &event); - int32_t getEventTypeFromCondition(const std::string& condition); - -private: - static constexpr uint8_t WAIT_SECONDS = 10; - static constexpr int32_t TYPE_CONDITION = 11; - AudioAdapterDescriptor adpDescriptor_; - AudioAdapterStatus status_ = STATUS_OFFLINE; - - sptr extSpkCallback_ = nullptr; - sptr extMicCallback_ = nullptr; - sptr paramCallback_ = nullptr; - sptr audioRender_ = nullptr; - AudioParameter renderParam_; - sptr audioCapture_ = nullptr; - AudioParameter captureParam_; - - std::mutex devMapMtx_; - std::mutex captureOptMtx_; - std::mutex renderOptMtx_; - std::map mapAudioDevice_; - std::mutex spkWaitMutex_; - std::condition_variable spkWaitCond_; - std::mutex micWaitMutex_; - std::condition_variable micWaitCond_; - - bool isSpkOpened_ = false; - bool isMicOpened_ = false; - bool spkNotifyFlag_ = false; - bool micNotifyFlag_ = false; - - uint32_t spkPinInUse_ = 0; - uint32_t micPinInUse_ = 0; - uint32_t streamMuteStatus_ = 0; - uint32_t timeInterval_ = 5; - - // mmap param - PortOperationMode renderFlags_ = Audioext::V1_0::NORMAL_MODE; - PortOperationMode capturerFlags_ = Audioext::V1_0::NORMAL_MODE; - - const std::string NOT_MUTE_STATUS = "0"; - const std::string IS_MUTE_STATUS = "1"; -}; -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS -#endif // OHOS_AUDIO_ADAPTER_INTERFACE_IMPL_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_capture_interface_impl.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_capture_interface_impl.h deleted file mode 100644 index e11c2a8ace8176e95054cced19c189214632b3e5..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_capture_interface_impl.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. - * 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 OHOS_AUDIO_CAPTURE_INTERFACE_IMPL_H -#define OHOS_AUDIO_CAPTURE_INTERFACE_IMPL_H - -#include -#include - -#include "audio_capture_interface_impl_base.h" - -#include -#include -#include - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -using OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioData; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioParameter; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::DAudioEvent; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::IDAudioCallback; - -class AudioCaptureInterfaceImpl : public AudioCaptureInterfaceImplBase { -public: - AudioCaptureInterfaceImpl(const std::string &adpName, const AudioDeviceDescriptor &desc, - const AudioSampleAttributes &attrs, const sptr &callback); - ~AudioCaptureInterfaceImpl() override; - - int32_t CaptureFrame(std::vector &frame, uint64_t requestBytes) override; - int32_t GetCapturePosition(uint64_t &frames, AudioTimeStamp &time) override; - int32_t CheckSceneCapability(const AudioSceneDescriptor &scene, bool &supported) override; - int32_t SelectScene(const AudioSceneDescriptor &scene) override; - int32_t SetMute(bool mute) override; - int32_t GetMute(bool &mute) override; - int32_t SetVolume(float volume) override; - int32_t GetVolume(float &volume) override; - int32_t GetGainThreshold(float &min, float &max) override; - int32_t GetGain(float &gain) override; - int32_t SetGain(float gain) override; - int32_t GetFrameSize(uint64_t &size) override; - int32_t GetFrameCount(uint64_t &count) override; - int32_t SetSampleAttributes(const AudioSampleAttributes &attrs) override; - int32_t GetSampleAttributes(AudioSampleAttributes &attrs) override; - int32_t GetCurrentChannelId(uint32_t &channelId) override; - int32_t SetExtraParams(const std::string &keyValueList) override; - int32_t GetExtraParams(std::string &keyValueList) override; - int32_t ReqMmapBuffer(int32_t reqSize, AudioMmapBufferDescriptor &desc) override; - int32_t GetMmapPosition(uint64_t &frames, AudioTimeStamp &time) override; - int32_t AddAudioEffect(uint64_t effectid) override; - int32_t RemoveAudioEffect(uint64_t effectid) override; - int32_t GetFrameBufferSize(uint64_t &bufferSize) override; - int32_t Start() override; - int32_t Stop() override; - int32_t Pause() override; - int32_t Resume() override; - int32_t Flush() override; - int32_t TurnStandbyMode() override; - int32_t AudioDevDump(int32_t range, int32_t fd) override; - int32_t IsSupportsPauseAndResume(bool &supportPause, bool &supportResume) override; - const AudioDeviceDescriptor &GetCaptureDesc() override; - void SetAttrs(const std::string &adpName, const AudioDeviceDescriptor &desc, - const AudioSampleAttributes &attrs, const sptr &callback) override; - -private: - static constexpr int64_t AUDIO_OFFSET_FRAME_NUM = 10; - std::string adapterName_; - AudioDeviceDescriptor devDesc_; - AudioSampleAttributes devAttrs_; - uint32_t timeInterval_ = 5; - int64_t frameIndex_ = 0; - int64_t framePeriodNs_ = 0; - int64_t startTime_ = 0; - - std::mutex captureMtx_; - AudioCaptureStatus captureStatus_ = CAPTURE_STATUS_CLOSE; - sptr audioExtCallback_ = nullptr; -}; -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS -#endif // OHOS_AUDIO_CAPTURE_INTERFACE_IMPL_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_capture_interface_impl_base.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_capture_interface_impl_base.h deleted file mode 100644 index 4e3c4912fca9871b713a1e4fb5b01f7b61db36e7..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_capture_interface_impl_base.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * 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 OHOS_AUDIO_CAPTURE_INTERFACE_IMPL_BASE_H -#define OHOS_AUDIO_CAPTURE_INTERFACE_IMPL_BASE_H - -#include - -#include -#include - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -using OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioData; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioParameter; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::IDAudioCallback; -typedef enum { - CAPTURE_STATUS_OPEN = 0, - CAPTURE_STATUS_CLOSE, - CAPTURE_STATUS_START, - CAPTURE_STATUS_STOP, - CAPTURE_STATUS_PAUSE, -} AudioCaptureStatus; - -class AudioCaptureInterfaceImplBase : public IAudioCapture { -public: - AudioCaptureInterfaceImplBase() = default; - virtual ~AudioCaptureInterfaceImplBase() = default; - - virtual const AudioDeviceDescriptor &GetCaptureDesc() = 0; - virtual void SetAttrs(const std::string &adpName, const AudioDeviceDescriptor &desc, - const AudioSampleAttributes &attrs, const sptr &callback) = 0; -}; -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS -#endif // OHOS_AUDIO_CAPTURE_INTERFACE_IMPL_BASE_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_manager_interface_impl.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_manager_interface_impl.h deleted file mode 100644 index 6ba9cd55bcc53f68d602a0eaac0b4cd03ab005ac..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_manager_interface_impl.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 OHOS_AUDIO_MANAGER_INTERFACE_IMPL_H -#define OHOS_AUDIO_MANAGER_INTERFACE_IMPL_H - -#include -#include -#include - -#include "hdf_device_desc.h" -#include -#include - -#include "audio_adapter_interface_impl.h" - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -using OHOS::HDI::DistributedAudio::Audioext::V1_0::DAudioEvent; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::IDAudioCallback; - -typedef struct { - std::string adapterName; - uint32_t devId; - uint32_t eventType; - uint32_t deviceType; - uint32_t volGroupId; - uint32_t iptGroupId; -} DAudioDevEvent; - -class AudioManagerInterfaceImpl : public IAudioManager { -public: - static AudioManagerInterfaceImpl *GetAudioManager() - { - if (audioManager_ == nullptr) { - std::unique_lock mgr_mutex(audioManagerMtx_); - if (audioManager_ == nullptr) { - audioManager_ = new AudioManagerInterfaceImpl(); - } - } - return audioManager_; - } - - ~AudioManagerInterfaceImpl() override; - int32_t GetAllAdapters(std::vector &descs) override; - int32_t LoadAdapter(const AudioAdapterDescriptor &desc, sptr &adapter) override; - int32_t UnloadAdapter(const std::string &adapterName) override; - int32_t ReleaseAudioManagerObject() override; - - int32_t AddAudioDevice(const std::string &adpName, const uint32_t devId, const std::string &caps, - const sptr &callback); - int32_t RemoveAudioDevice(const std::string &adpName, const uint32_t devId); - int32_t Notify(const std::string &adpName, const uint32_t devId, const DAudioEvent &event); - void SetDeviceObject(struct HdfDeviceObject *deviceObject); - -private: - AudioManagerInterfaceImpl(); - int32_t NotifyFwk(const DAudioDevEvent &event); - int32_t CreateAdapter(const std::string &adpName, const uint32_t devId, const sptr &callback); - -private: - class Deletor { - public: - ~Deletor() - { - if (AudioManagerInterfaceImpl::audioManager_ != nullptr) { - delete AudioManagerInterfaceImpl::audioManager_; - } - }; - }; - static Deletor deletor; - -private: - static AudioManagerInterfaceImpl *audioManager_; - static std::mutex audioManagerMtx_; - struct HdfDeviceObject *deviceObject_ = nullptr; - std::mutex adapterMapMtx_; - std::map> mapAudioAdapter_; -}; -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS -#endif // OHOS_AUDIO_MANAGER_INTERFACE_IMPL_H diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_render_interface_impl.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_render_interface_impl.h deleted file mode 100644 index 221eb9469d3bce0a6487073a1f957ac39f299290..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_render_interface_impl.h +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 OHOS_AUDIO_RENDER_INTERFACE_IMPL_H -#define OHOS_AUDIO_RENDER_INTERFACE_IMPL_H - -#include -#include -#include - -#include "audio_render_interface_impl_base.h" - -#include -#include -#include - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -using OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioData; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioParameter; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::DAudioEvent; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::IDAudioCallback; - -constexpr uint32_t DURATION_FRAMES = 100; -constexpr uint32_t CUR_FRAME_INIT_VALUE = 0; - -class AudioRenderInterfaceImpl : public AudioRenderInterfaceImplBase { -public: - AudioRenderInterfaceImpl(const std::string &adpName, const AudioDeviceDescriptor &desc, - const AudioSampleAttributes &attrs, const sptr &callback); - ~AudioRenderInterfaceImpl() override; - - int32_t GetLatency(uint32_t &ms) override; - int32_t RenderFrame(const std::vector &frame, uint64_t &replyBytes) override; - int32_t GetRenderPosition(uint64_t &frames, AudioTimeStamp &time) override; - int32_t SetRenderSpeed(float speed) override; - int32_t GetRenderSpeed(float &speed) override; - int32_t SetChannelMode(AudioChannelMode mode) override; - int32_t GetChannelMode(AudioChannelMode &mode) override; - int32_t RegCallback(const sptr &audioCallback, int8_t cookie) override; - int32_t DrainBuffer(AudioDrainNotifyType &type) override; - int32_t IsSupportsDrain(bool &support) override; - int32_t CheckSceneCapability(const AudioSceneDescriptor &scene, bool &supported) override; - int32_t SelectScene(const AudioSceneDescriptor &scene) override; - int32_t SetMute(bool mute) override; - int32_t GetMute(bool &mute) override; - int32_t SetVolume(float volume) override; - int32_t GetVolume(float &volume) override; - int32_t GetGainThreshold(float &min, float &max) override; - int32_t SetGain(float gain) override; - int32_t GetGain(float &gain) override; - int32_t GetFrameSize(uint64_t &size) override; - int32_t GetFrameCount(uint64_t &count) override; - int32_t SetSampleAttributes(const AudioSampleAttributes &attrs) override; - int32_t GetSampleAttributes(AudioSampleAttributes &attrs) override; - int32_t GetCurrentChannelId(uint32_t &channelId) override; - int32_t SetExtraParams(const std::string &keyValueList) override; - int32_t GetExtraParams(std::string &keyValueList) override; - int32_t ReqMmapBuffer(int32_t reqSize, AudioMmapBufferDescriptor &desc) override; - int32_t GetMmapPosition(uint64_t &frames, AudioTimeStamp &time) override; - int32_t AddAudioEffect(uint64_t effectid) override; - int32_t RemoveAudioEffect(uint64_t effectid) override; - int32_t GetFrameBufferSize(uint64_t &bufferSize) override; - int32_t Start() override; - int32_t Stop() override; - int32_t Pause() override; - int32_t Resume() override; - int32_t Flush() override; - int32_t TurnStandbyMode() override; - int32_t AudioDevDump(int32_t range, int32_t fd) override; - int32_t IsSupportsPauseAndResume(bool &supportPause, bool &supportResume) override; - - const AudioDeviceDescriptor &GetRenderDesc() override; - void SetVolumeInner(const uint32_t vol) override; - void SetVolumeRangeInner(const uint32_t volMax, const uint32_t volMin) override; - uint32_t GetVolumeInner() override; - uint32_t GetMaxVolumeInner() override; - uint32_t GetMinVolumeInner() override; - void SetAttrs(const std::string &adpName, const AudioDeviceDescriptor &desc, - const AudioSampleAttributes &attrs, const sptr &callback) override; - -private: - float GetFadeRate(uint32_t currentIndex, const uint32_t durationIndex); - int32_t FadeInProcess(const uint32_t durationFrame, int8_t* frameData, const size_t frameLength); - -private: - static constexpr int64_t AUDIO_OFFSET_FRAME_NUM = 10; - - std::string adapterName_; - AudioDeviceDescriptor devDesc_; - AudioSampleAttributes devAttrs_; - - uint32_t timeInterval_ = 5; - float renderSpeed_ = 0; - uint32_t currentFrame_ = 0; - std::mutex renderMtx_; - AudioChannelMode channelMode_ = AUDIO_CHANNEL_NORMAL; - AudioRenderStatus renderStatus_ = RENDER_STATUS_CLOSE; - sptr audioExtCallback_ = nullptr; - sptr renderCallback_ = nullptr; - bool firstOpenFlag_ = true; - - int64_t frameIndex_ = 0; - int64_t framePeriodNs_ = 0; - int64_t startTime_ = 0; - - std::mutex volMtx_; - uint32_t vol_ = 0; - uint32_t volMax_ = 0; - uint32_t volMin_ = 0; -}; -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS -#endif // OHOS_AUDIO_RENDER_INTERFACE_IMPL_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_render_interface_impl_base.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_render_interface_impl_base.h deleted file mode 100644 index 5929d137f2c6e9c169fbdb2c9e0f160530d6845a..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/include/audio_render_interface_impl_base.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 OHOS_AUDIO_RENDER_INTERFACE_IMPL_BASE_H -#define OHOS_AUDIO_RENDER_INTERFACE_IMPL_BASE_H - -#include -#include -#include - -#include -#include -#include - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -using OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioData; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioParameter; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::IDAudioCallback; -typedef enum { - RENDER_STATUS_OPEN = 0, - RENDER_STATUS_CLOSE, - RENDER_STATUS_START, - RENDER_STATUS_STOP, - RENDER_STATUS_PAUSE, -} AudioRenderStatus; - -class AudioRenderInterfaceImplBase : public IAudioRender { -public: - AudioRenderInterfaceImplBase() = default; - virtual ~AudioRenderInterfaceImplBase() = default; - - virtual const AudioDeviceDescriptor &GetRenderDesc() = 0; - virtual void SetVolumeInner(const uint32_t vol) = 0; - virtual void SetVolumeRangeInner(const uint32_t volMax, const uint32_t volMin) = 0; - virtual uint32_t GetVolumeInner() = 0; - virtual uint32_t GetMaxVolumeInner() = 0; - virtual uint32_t GetMinVolumeInner() = 0; - virtual void SetAttrs(const std::string &adpName, const AudioDeviceDescriptor &desc, - const AudioSampleAttributes &attrs, const sptr &callback) = 0; -}; -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS -#endif // OHOS_AUDIO_RENDER_INTERFACE_IMPL_BASE_H diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_adapter_interface_impl.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_adapter_interface_impl.cpp deleted file mode 100644 index 57ec5fc02095a5cf1f1fcbca1fe1095b1abc0077..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_adapter_interface_impl.cpp +++ /dev/null @@ -1,857 +0,0 @@ -/* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. - * 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 "audio_adapter_interface_impl.h" - -#include -#include -#include - -#include "daudio_constants.h" -#include "daudio_errcode.h" -#include "daudio_events.h" -#include "daudio_log.h" -#include "daudio_utils.h" - -#undef DH_LOG_TAG -#define DH_LOG_TAG "AudioAdapterInterfaceImpl" - -using namespace OHOS::DistributedHardware; -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -AudioAdapterInterfaceImpl::AudioAdapterInterfaceImpl(const AudioAdapterDescriptor &desc) - : adpDescriptor_(desc) -{ - renderParam_ = { 0, 0, 0, 0, 0, 0 }; - captureParam_ = { 0, 0, 0, 0, 0, 0 }; - DHLOGD("Distributed audio adapter constructed, name(%s).", GetAnonyString(desc.adapterName).c_str()); -} - -AudioAdapterInterfaceImpl::~AudioAdapterInterfaceImpl() -{ - DHLOGD("Distributed audio adapter destructed, name(%s).", GetAnonyString(adpDescriptor_.adapterName).c_str()); -} - - -void AudioAdapterInterfaceImpl::SetSpeakerCallback(const sptr &spkCallback) -{ - if (spkCallback == nullptr) { - DHLOGE("Callback is nullptr."); - return; - } - extSpkCallback_ = spkCallback; -} - -void AudioAdapterInterfaceImpl::SetMicCallback(const sptr &micCallback) -{ - if (micCallback == nullptr) { - DHLOGE("Callback is nullptr."); - return; - } - extMicCallback_ = micCallback; -} - -int32_t AudioAdapterInterfaceImpl::InitAllPorts() -{ - DHLOGI("Init (%zu) distributed audio ports.", mapAudioDevice_.size()); - return HDF_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::CreateRender(const AudioDeviceDescriptor &desc, - const AudioSampleAttributes &attrs, sptr &render) -{ - DHLOGI("Create distributed audio render, {pin: %zu, sampleRate: %zu, channel: %zu, formats: %zu, type: %d}.", - desc.pins, attrs.sampleRate, attrs.channelCount, attrs.format, static_cast(attrs.type)); - render = nullptr; - { - std::lock_guard devLck(devMapMtx_); - if (mapAudioDevice_.find(desc.pins) == mapAudioDevice_.end()) { - DHLOGE("Can not find device, create render failed."); - return HDF_FAILURE; - } - } -#ifdef DAUDIO_SUPPORT_EXTENSION - if (attrs.type == AUDIO_MMAP_NOIRQ) { - DHLOGI("Try to mmap mode."); - renderFlags_ = Audioext::V1_0::MMAP_MODE; - audioRender_ = new AudioRenderExtImpl(); - audioRender_->SetAttrs(adpDescriptor_.adapterName, desc, attrs, extSpkCallback_); - } else { - DHLOGI("Try to normal mode."); - renderFlags_ = Audioext::V1_0::NORMAL_MODE; - audioRender_ = new AudioRenderInterfaceImpl(adpDescriptor_.adapterName, desc, attrs, extSpkCallback_); - } -#else - renderFlags_ = Audioext::V1_0::NORMAL_MODE; - audioRender_ = new AudioRenderInterfaceImpl(adpDescriptor_.adapterName, desc, attrs, extSpkCallback_); -#endif - if (audioRender_ == nullptr) { - DHLOGE("Create render failed."); - return HDF_FAILURE; - } - - int32_t ret = OpenRenderDevice(desc, attrs); - if (ret != DH_SUCCESS) { - DHLOGE("Open render device failed."); - audioRender_ = nullptr; - return HDF_FAILURE; - } - render = audioRender_; - DHLOGI("Create render success."); - return HDF_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::DestroyRender(const AudioDeviceDescriptor &desc) -{ - DHLOGI("Destroy distributed audio render, {pin: %zu}.", desc.pins); - if (audioRender_ == nullptr) { - DHLOGD("Render has not been created, do not need destroy."); - return HDF_SUCCESS; - } - if (desc.pins != audioRender_->GetRenderDesc().pins) { - DHLOGE("Render pin is wrong, destroy render failed."); - return HDF_FAILURE; - } - - int32_t ret = CloseRenderDevice(desc); - if (ret != DH_SUCCESS) { - DHLOGE("Close render device failed."); - return HDF_FAILURE; - } - audioRender_ = nullptr; - return HDF_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::CreateCapture(const AudioDeviceDescriptor &desc, - const AudioSampleAttributes &attrs, sptr &capture) -{ - DHLOGI("Create distributed audio capture, {pin: %zu, sampleRate: %zu, channel: %zu, formats: %zu}.", - desc.pins, attrs.sampleRate, attrs.channelCount, attrs.format); - capture = nullptr; - { - std::lock_guard devLck(devMapMtx_); - if (mapAudioDevice_.find(desc.pins) == mapAudioDevice_.end()) { - DHLOGE("Can not find device, create capture failed."); - return HDF_FAILURE; - } - } -#ifdef DAUDIO_SUPPORT_EXTENSION - if (attrs.type == AUDIO_MMAP_NOIRQ) { - DHLOGI("Try to mmap mode."); - capturerFlags_ = Audioext::V1_0::MMAP_MODE; - audioCapture_ = new AudioCaptureExtImpl(); - audioCapture_->SetAttrs(adpDescriptor_.adapterName, desc, attrs, extMicCallback_); - } else { - DHLOGI("Try to normal mode."); - capturerFlags_ = Audioext::V1_0::NORMAL_MODE; - audioCapture_ = new AudioCaptureInterfaceImpl(adpDescriptor_.adapterName, desc, attrs, extMicCallback_); - } -#else - capturerFlags_ = Audioext::V1_0::NORMAL_MODE; - audioCapture_ = new AudioCaptureInterfaceImpl(adpDescriptor_.adapterName, desc, attrs, extMicCallback_); -#endif - if (audioCapture_ == nullptr) { - DHLOGE("Create capture failed."); - return HDF_FAILURE; - } - - int32_t ret = OpenCaptureDevice(desc, attrs); - if (ret != DH_SUCCESS) { - DHLOGE("Open capture device failed."); - audioCapture_ = nullptr; - return HDF_FAILURE; - } - capture = audioCapture_; - DHLOGI("Create capture success."); - return HDF_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::DestroyCapture(const AudioDeviceDescriptor &desc) -{ - DHLOGI("Destroy distributed audio capture, {pin: %zu}.", desc.pins); - if (audioCapture_ == nullptr) { - DHLOGD("Capture has not been created, do not need destroy."); - return HDF_SUCCESS; - } - if (desc.pins != audioCapture_->GetCaptureDesc().pins) { - DHLOGE("Capture pin is wrong, destroy capture failed."); - return HDF_FAILURE; - } - - int32_t ret = CloseCaptureDevice(desc); - if (ret != DH_SUCCESS) { - DHLOGE("Close capture device failed."); - return HDF_FAILURE; - } - audioCapture_ = nullptr; - return HDF_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::GetPortCapability(const AudioPort &port, AudioPortCapability &capability) -{ - DHLOGD("Get audio port capability."); - (void)port; - capability.sampleRateMasks = AUDIO_SAMPLE_RATE_DEFAULT; - capability.channelCount = AUDIO_CHANNEL_COUNT_DEFAULT; - - return HDF_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::SetPassthroughMode(const AudioPort &port, AudioPortPassthroughMode mode) -{ - (void)port; - (void)mode; - return HDF_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::GetPassthroughMode(const AudioPort &port, AudioPortPassthroughMode &mode) -{ - (void)port; - (void)mode; - return HDF_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::GetDeviceStatus(AudioDeviceStatus& status) -{ - (void) status; - return HDF_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::UpdateAudioRoute(const AudioRoute &route, int32_t &routeHandle) -{ - (void) route; - (void) routeHandle; - return HDF_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::ReleaseAudioRoute(int32_t routeHandle) -{ - (void) routeHandle; - return HDF_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::SetMicMute(bool mute) -{ - (void) mute; - return HDF_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::GetMicMute(bool& mute) -{ - (void) mute; - return HDF_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::SetVoiceVolume(float volume) -{ - (void) volume; - return HDF_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::SetExtraParams(AudioExtParamKey key, const std::string &condition, - const std::string &value) -{ - DHLOGD("Set audio parameters, key = %d, condition: %s value: %s.", key, condition.c_str(), value.c_str()); - int32_t ret = ERR_DH_AUDIO_HDF_FAIL; - switch (key) { - case AudioExtParamKey::AUDIO_EXT_PARAM_KEY_VOLUME: - ret = SetAudioVolume(condition, value); - if (ret != DH_SUCCESS) { - DHLOGE("Set audio parameters failed."); - return HDF_FAILURE; - } - break; - case AudioExtParamKey::AUDIO_EXT_PARAM_KEY_NONE: - DHLOGE("Parameter is unknown."); - break; - default: - DHLOGE("Parameter is invalid."); - return HDF_ERR_INVALID_PARAM; - } - DHLOGI("Set audio parameters success."); - return HDF_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::GetExtraParams(AudioExtParamKey key, const std::string &condition, - std::string &value) -{ - DHLOGD("Get audio parameters, key: %d, condition: %s.", key, condition.c_str()); - int32_t ret = ERR_DH_AUDIO_HDF_FAIL; - switch (key) { - case AudioExtParamKey::AUDIO_EXT_PARAM_KEY_VOLUME: - ret = GetAudioVolume(condition, value); - if (ret != DH_SUCCESS) { - DHLOGE("Get audio parameters failed."); - return HDF_FAILURE; - } - break; - case AudioExtParamKey::AUDIO_EXT_PARAM_KEY_NONE: - DHLOGE("Parameter is unknown."); - break; - default: - DHLOGE("Parameter is invalid."); - return HDF_ERR_INVALID_PARAM; - } - DHLOGI("Get audio parameters success."); - return HDF_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::RegExtraParamObserver(const sptr &audioCallback, int8_t cookie) -{ - DHLOGD("Register audio param observer."); - paramCallback_ = audioCallback; - (void) cookie; - return HDF_SUCCESS; -} - -AudioAdapterDescriptor AudioAdapterInterfaceImpl::GetAdapterDesc() -{ - adpDescriptor_.ports.clear(); - std::lock_guard devLck(devMapMtx_); - for (auto pin = mapAudioDevice_.begin(); pin != mapAudioDevice_.end(); pin++) { - AudioPort port = {PORT_OUT_IN, pin->first, ""}; - adpDescriptor_.ports.emplace_back(port); - } - return adpDescriptor_; -} - -std::string AudioAdapterInterfaceImpl::GetDeviceCapabilitys(const uint32_t devId) -{ - std::lock_guard devLck(devMapMtx_); - auto dev = mapAudioDevice_.find(devId); - if (dev == mapAudioDevice_.end()) { - DHLOGE("Device not found."); - return ""; - } - return dev->second; -} - -int32_t AudioAdapterInterfaceImpl::AdapterLoad() -{ - status_ = AudioAdapterStatus::STATUS_LOAD; - return HDF_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::AdapterUnload() -{ - status_ = AudioAdapterStatus::STATUS_UNLOAD; - return HDF_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::Notify(const uint32_t devId, const DAudioEvent &event) -{ - switch (static_cast(event.type)) { - case HDF_AUDIO_EVENT_VOLUME_CHANGE: - DHLOGI("Notify event: VOLUME_CHANGE, event content: %s.", event.content.c_str()); - return HandleVolumeChangeEvent(event); - case HDF_AUDIO_EVENT_FOCUS_CHANGE: - DHLOGI("Notify event: FOCUS_CHANGE, event content: %s.", event.content.c_str()); - return HandleFocusChangeEvent(event); - case HDF_AUDIO_EVENT_RENDER_STATE_CHANGE: - DHLOGI("Notify event: RENDER_STATE_CHANGE, event content: %s.", event.content.c_str()); - return HandleRenderStateChangeEvent(event); - case HDF_AUDIO_EVENT_OPEN_SPK_RESULT: - case HDF_AUDIO_EVENT_CLOSE_SPK_RESULT: - case HDF_AUDIO_EVENT_OPEN_MIC_RESULT: - case HDF_AUDIO_EVENT_CLOSE_MIC_RESULT: - return HandleSANotifyEvent(event); - case HDF_AUDIO_EVENT_SPK_CLOSED: - case HDF_AUDIO_EVENT_MIC_CLOSED: - return HandleDeviceClosed(event); - default: - DHLOGE("Audio event: %d is undefined.", event.type); - return ERR_DH_AUDIO_HDF_INVALID_OPERATION; - } -} - -int32_t AudioAdapterInterfaceImpl::AddAudioDevice(const uint32_t devId, const std::string &caps) -{ - DHLOGI("Add distributed audio device %d.", devId); - std::lock_guard devLck(devMapMtx_); - auto dev = mapAudioDevice_.find(devId); - if (dev != mapAudioDevice_.end()) { - DHLOGI("Device has been add, do not repeat add."); - return DH_SUCCESS; - } - mapAudioDevice_.insert(std::make_pair(devId, caps)); - - DHLOGI("Add audio device success."); - return DH_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::RemoveAudioDevice(const uint32_t devId) -{ - DHLOGI("Remove distributed audio device %d.", devId); - { - std::lock_guard devLck(devMapMtx_); - if (mapAudioDevice_.find(devId) == mapAudioDevice_.end()) { - DHLOGE("Device has not been add, remove device failed."); - return ERR_DH_AUDIO_HDF_INVALID_OPERATION; - } - mapAudioDevice_.erase(devId); - } - AudioDeviceDescriptor dec; - if (devId == spkPinInUse_) { - dec.pins = static_cast(spkPinInUse_); - DestroyRender(dec); - } - if (devId == micPinInUse_) { - dec.pins = static_cast(micPinInUse_); - DestroyCapture(dec); - } - - DHLOGI("Remove audio device success."); - return DH_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::OpenRenderDevice(const AudioDeviceDescriptor &desc, - const AudioSampleAttributes &attrs) -{ - DHLOGI("Open render device, pin: %d.", desc.pins); - if (isSpkOpened_) { - DHLOGI("Render already opened."); - return DH_SUCCESS; - } - std::lock_guard devLck(renderOptMtx_); - spkPinInUse_ = desc.pins; - renderParam_.format = attrs.format; - renderParam_.channelCount = attrs.channelCount; - renderParam_.sampleRate = attrs.sampleRate; - renderParam_.streamUsage = attrs.type; - renderParam_.frameSize = CalculateFrameSize(attrs.sampleRate, attrs.channelCount, attrs.format, - timeInterval_, renderFlags_ == Audioext::V1_0::MMAP_MODE); - renderParam_.renderFlags = renderFlags_; - - int32_t ret = extSpkCallback_->SetParameters(adpDescriptor_.adapterName, desc.pins, renderParam_); - if (ret != HDF_SUCCESS) { - DHLOGE("Set render parameters failed."); - return ERR_DH_AUDIO_HDF_SET_PARAM_FAIL; - } - ret = extSpkCallback_->OpenDevice(adpDescriptor_.adapterName, desc.pins); - if (ret != HDF_SUCCESS) { - DHLOGE("Open render device failed."); - return ERR_DH_AUDIO_HDF_OPEN_DEVICE_FAIL; - } - - ret = WaitForSANotify(EVENT_OPEN_SPK); - if (ret != DH_SUCCESS) { - DHLOGE("Wait SA notify failed."); - return ret; - } - DHLOGI("Open render device success."); - return DH_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::CloseRenderDevice(const AudioDeviceDescriptor &desc) -{ - DHLOGI("Close render device, pin: %d.", desc.pins); - std::lock_guard devLck(renderOptMtx_); - if (spkPinInUse_ == 0) { - DHLOGI("No need close render device."); - return DH_SUCCESS; - } - renderParam_ = {}; - int32_t ret = extSpkCallback_->CloseDevice(adpDescriptor_.adapterName, desc.pins); - if (ret != HDF_SUCCESS) { - DHLOGE("Close audio device failed."); - return ERR_DH_AUDIO_HDF_CLOSE_DEVICE_FAIL; - } - - ret = WaitForSANotify(EVENT_CLOSE_SPK); - if (ret != DH_SUCCESS) { - DHLOGE("Wait SA notify failed."); - return ret; - } - spkPinInUse_ = 0; - DHLOGI("Close render device success."); - return DH_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::OpenCaptureDevice(const AudioDeviceDescriptor &desc, - const AudioSampleAttributes &attrs) -{ - DHLOGI("Open capture device, pin: %d.", desc.pins); - if (isMicOpened_) { - DHLOGI("Capture already opened."); - return DH_SUCCESS; - } - std::lock_guard devLck(captureOptMtx_); - micPinInUse_ = desc.pins; - captureParam_.format = attrs.format; - captureParam_.channelCount = attrs.channelCount; - captureParam_.sampleRate = attrs.sampleRate; - captureParam_.streamUsage = attrs.type; - captureParam_.frameSize = CalculateFrameSize(attrs.sampleRate, attrs.channelCount, - attrs.format, timeInterval_, capturerFlags_ == Audioext::V1_0::MMAP_MODE); - captureParam_.capturerFlags = capturerFlags_; - - int32_t ret = extMicCallback_->SetParameters(adpDescriptor_.adapterName, desc.pins, captureParam_); - if (ret != HDF_SUCCESS) { - DHLOGE("Set audio parameters failed."); - return ERR_DH_AUDIO_HDF_SET_PARAM_FAIL; - } - ret = extMicCallback_->OpenDevice(adpDescriptor_.adapterName, desc.pins); - if (ret != HDF_SUCCESS) { - DHLOGE("Open audio device failed."); - return ERR_DH_AUDIO_HDF_OPEN_DEVICE_FAIL; - } - - ret = WaitForSANotify(EVENT_OPEN_MIC); - if (ret != DH_SUCCESS) { - DHLOGE("Wait SA notify failed."); - return ret; - } - DHLOGI("Open capture device success."); - return DH_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::CloseCaptureDevice(const AudioDeviceDescriptor &desc) -{ - DHLOGI("Close capture device, pin: %d.", desc.pins); - std::lock_guard devLck(captureOptMtx_); - if (micPinInUse_ == 0) { - DHLOGI("No need close capture device."); - return DH_SUCCESS; - } - captureParam_ = {}; - int32_t ret = extMicCallback_->CloseDevice(adpDescriptor_.adapterName, desc.pins); - if (ret != HDF_SUCCESS) { - DHLOGE("Close audio device failed."); - return ERR_DH_AUDIO_HDF_CLOSE_DEVICE_FAIL; - } - - ret = WaitForSANotify(EVENT_CLOSE_MIC); - if (ret != DH_SUCCESS) { - DHLOGE("Wait SA notify failed."); - return ret; - } - micPinInUse_ = 0; - DHLOGI("Close capture device success."); - return DH_SUCCESS; -} - -uint32_t AudioAdapterInterfaceImpl::GetVolumeGroup(const uint32_t devId) -{ - uint32_t volGroup = VOLUME_GROUP_ID_DEFAULT; - std::lock_guard devLck(devMapMtx_); - auto caps = mapAudioDevice_.find(devId); - if (caps == mapAudioDevice_.end()) { - DHLOGE("Can not find caps of dev:%u.", devId); - return volGroup; - } - - int32_t ret = GetAudioParamUInt(caps->second, VOLUME_GROUP_ID, volGroup); - if (ret != DH_SUCCESS) { - DHLOGE("Get volume group param failed, use default value, ret = %d.", ret); - } - return volGroup; -} - -uint32_t AudioAdapterInterfaceImpl::GetInterruptGroup(const uint32_t devId) -{ - uint32_t iptGroup = INTERRUPT_GROUP_ID_DEFAULT; - std::lock_guard devLck(devMapMtx_); - auto caps = mapAudioDevice_.find(devId); - if (caps == mapAudioDevice_.end()) { - DHLOGE("Can not find caps of dev:%u.", devId); - return iptGroup; - } - - int32_t ret = GetAudioParamUInt(caps->second, INTERRUPT_GROUP_ID, iptGroup); - if (ret != DH_SUCCESS) { - DHLOGE("Get interrupt group param failed, use default value, ret = %d.", ret); - } - return iptGroup; -} - -int32_t AudioAdapterInterfaceImpl::SetAudioVolume(const std::string& condition, const std::string ¶m) -{ - if (extSpkCallback_ == nullptr) { - DHLOGE("Callback is nullptr."); - return ERR_DH_AUDIO_HDF_NULLPTR; - } - if (audioRender_ == nullptr) { - DHLOGE("Render has not been created."); - return ERR_DH_AUDIO_HDF_NULLPTR; - } - std::string content = condition; - int32_t type = getEventTypeFromCondition(content); - EXT_PARAM_EVENT eventType; - - if (type == VolumeEventType::EVENT_IS_STREAM_MUTE) { - if (param == IS_MUTE_STATUS) { - streamMuteStatus_ = 1; - } else if (param == NOT_MUTE_STATUS) { - streamMuteStatus_ = 0; - } else { - DHLOGE("Mute param is error."); - return ERR_DH_AUDIO_HDF_FAIL; - } - eventType = HDF_AUDIO_EVNET_MUTE_SET; - SetAudioParamStr(content, STREAM_MUTE_STATUS, param); - } else { - eventType = HDF_AUDIO_EVENT_VOLUME_SET; - streamMuteStatus_ = 0; - SetAudioParamStr(content, VOLUME_LEVEL, param); - } - DAudioEvent event = { eventType, content }; - int32_t ret = - extSpkCallback_->NotifyEvent(adpDescriptor_.adapterName, audioRender_->GetRenderDesc().pins, event); - if (ret != HDF_SUCCESS) { - DHLOGE("NotifyEvent failed."); - return ERR_DH_AUDIO_HDF_FAIL; - } - return DH_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::GetAudioVolume(const std::string& condition, std::string ¶m) -{ - if (audioRender_ == nullptr) { - DHLOGE("Render has not been created."); - return ERR_DH_AUDIO_HDF_NULLPTR; - } - int32_t type = getEventTypeFromCondition(condition); - uint32_t vol; - switch (type) { - case VolumeEventType::EVENT_GET_VOLUME: - vol = audioRender_->GetVolumeInner(); - break; - case VolumeEventType::EVENT_GET_MAX_VOLUME: - vol = audioRender_->GetMaxVolumeInner(); - break; - case VolumeEventType::EVENT_GET_MIN_VOLUME: - vol = audioRender_->GetMinVolumeInner(); - break; - case VolumeEventType::EVENT_IS_STREAM_MUTE: - vol = streamMuteStatus_; - break; - default: - vol = 0; - DHLOGE("Get volume failed."); - } - param = std::to_string(vol); - return DH_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::getEventTypeFromCondition(const std::string &condition) -{ - std::string::size_type position = condition.find_first_of(";"); - int32_t type = std::stoi(condition.substr(TYPE_CONDITION, position - TYPE_CONDITION)); - return static_cast(type); -} - -int32_t AudioAdapterInterfaceImpl::HandleVolumeChangeEvent(const DAudioEvent &event) -{ - DHLOGI("Vol change (%s).", event.content.c_str()); - if (audioRender_ == nullptr) { - DHLOGE("Render has not been created."); - return ERR_DH_AUDIO_HDF_NULLPTR; - } - int32_t vol = AUDIO_DEFAULT_MIN_VOLUME_LEVEL; - int32_t ret = GetAudioParamInt(event.content, VOLUME_LEVEL, vol); - if (ret != DH_SUCCESS) { - DHLOGE("Get volume value failed."); - return ERR_DH_AUDIO_HDF_FAIL; - } - - if (event.content.rfind("FIRST_VOLUME_CHANAGE", 0) == 0) { - int32_t maxVol = AUDIO_DEFAULT_MAX_VOLUME_LEVEL; - ret = GetAudioParamInt(event.content, MAX_VOLUME_LEVEL, maxVol); - if (ret != DH_SUCCESS) { - DHLOGE("Get max volume value failed, use defult max volume."); - } - int32_t minVol = AUDIO_DEFAULT_MIN_VOLUME_LEVEL; - ret = GetAudioParamInt(event.content, MIN_VOLUME_LEVEL, minVol); - if (ret != DH_SUCCESS) { - DHLOGE("Get min volume value failed, use defult min volume."); - } - audioRender_->SetVolumeInner(vol); - audioRender_->SetVolumeRangeInner(maxVol, minVol); - return DH_SUCCESS; - } - - audioRender_->SetVolumeInner(vol); - if (paramCallback_ == nullptr) { - DHLOGE("Audio param observer is null."); - return ERR_DH_AUDIO_HDF_NULLPTR; - } - int8_t reserved; - int8_t cookie; - ret = paramCallback_->ParamCallback(AUDIO_EXT_PARAM_KEY_VOLUME, event.content, std::to_string(vol), - reserved, cookie); - if (ret != DH_SUCCESS) { - DHLOGE("Notify vol failed."); - return ERR_DH_AUDIO_HDF_FAIL; - } - return DH_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::HandleFocusChangeEvent(const DAudioEvent &event) -{ - DHLOGI("Focus change (%s).", event.content.c_str()); - if (paramCallback_ == nullptr) { - DHLOGE("Audio param observer is null."); - return ERR_DH_AUDIO_HDF_NULLPTR; - } - int8_t reserved; - int8_t cookie; - int32_t ret = paramCallback_->ParamCallback(AUDIO_EXT_PARAM_KEY_FOCUS, event.content, "", reserved, cookie); - if (ret != DH_SUCCESS) { - DHLOGE("Notify Focus failed."); - return ERR_DH_AUDIO_HDF_FAIL; - } - return DH_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::HandleRenderStateChangeEvent(const DAudioEvent &event) -{ - DHLOGI("Render state change (%s).", event.content.c_str()); - if (paramCallback_ == nullptr) { - DHLOGE("Audio param observer is null."); - return ERR_DH_AUDIO_HDF_NULLPTR; - } - int8_t reserved; - int8_t cookie; - int32_t ret = paramCallback_->ParamCallback(AUDIO_EXT_PARAM_KEY_STATUS, event.content, "", reserved, cookie); - if (ret != DH_SUCCESS) { - DHLOGE("Notify render state failed."); - return ERR_DH_AUDIO_HDF_FAIL; - } - return DH_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::HandleSANotifyEvent(const DAudioEvent &event) -{ - if (event.type == HDF_AUDIO_EVENT_OPEN_SPK_RESULT) { - DHLOGD("Notify event: OPEN_SPK_RESULT, event content: %s.", event.content.c_str()); - if (event.content == HDF_EVENT_RESULT_SUCCESS) { - isSpkOpened_ = true; - } - spkNotifyFlag_ = true; - spkWaitCond_.notify_all(); - return DH_SUCCESS; - } else if (event.type == HDF_AUDIO_EVENT_CLOSE_SPK_RESULT) { - DHLOGD("Notify event: CLOSE_SPK_RESULT, event content: %s.", event.content.c_str()); - if (event.content == HDF_EVENT_RESULT_SUCCESS) { - isSpkOpened_ = false; - } - spkNotifyFlag_ = true; - spkWaitCond_.notify_all(); - return DH_SUCCESS; - } else if (event.type == HDF_AUDIO_EVENT_OPEN_MIC_RESULT) { - DHLOGD("Notify event: OPEN_MIC_RESULT, event content: %s.", event.content.c_str()); - if (event.content == HDF_EVENT_RESULT_SUCCESS) { - isMicOpened_ = true; - } - micNotifyFlag_ = true; - micWaitCond_.notify_all(); - return DH_SUCCESS; - } else if (event.type == HDF_AUDIO_EVENT_CLOSE_MIC_RESULT) { - DHLOGD("Notify event: CLOSE_MIC_RESULT, event content: %s.", event.content.c_str()); - if (event.content == HDF_EVENT_RESULT_SUCCESS) { - isMicOpened_ = false; - } - micNotifyFlag_ = true; - micWaitCond_.notify_all(); - return DH_SUCCESS; - } - return ERR_DH_AUDIO_HDF_FAIL; -} - -int32_t AudioAdapterInterfaceImpl::WaitForSANotify(const AudioDeviceEvent &event) -{ - if (event == EVENT_OPEN_SPK || event == EVENT_CLOSE_SPK) { - spkNotifyFlag_ = false; - std::unique_lock lck(spkWaitMutex_); - auto status = - spkWaitCond_.wait_for(lck, std::chrono::seconds(WAIT_SECONDS), [this]() { return spkNotifyFlag_; }); - if (!status) { - DHLOGE("Wait spk event: %d timeout(%d)s.", event, WAIT_SECONDS); - return ERR_DH_AUDIO_HDF_FAIL; - } - if (event == EVENT_OPEN_SPK && isSpkOpened_ != true) { - DHLOGE("Wait open render device failed."); - return ERR_DH_AUDIO_HDF_OPEN_DEVICE_FAIL; - } else if (event == EVENT_CLOSE_SPK && isSpkOpened_ != false) { - DHLOGE("Wait close render device failed."); - return ERR_DH_AUDIO_HDF_CLOSE_DEVICE_FAIL; - } - return DH_SUCCESS; - } - - if (event == EVENT_OPEN_MIC || event == EVENT_CLOSE_MIC) { - micNotifyFlag_ = false; - std::unique_lock lck(micWaitMutex_); - auto status = - micWaitCond_.wait_for(lck, std::chrono::seconds(WAIT_SECONDS), [this]() { return micNotifyFlag_; }); - if (!status) { - DHLOGE("Wait mic event: %d timeout(%d)s.", event, WAIT_SECONDS); - return ERR_DH_AUDIO_HDF_FAIL; - } - if (event == EVENT_OPEN_MIC && isMicOpened_ != true) { - DHLOGE("Wait open capture device failed."); - return ERR_DH_AUDIO_HDF_OPEN_DEVICE_FAIL; - } else if (event == EVENT_CLOSE_MIC && isMicOpened_ != false) { - DHLOGE("Wait close capture device failed."); - return ERR_DH_AUDIO_HDF_CLOSE_DEVICE_FAIL; - } - return DH_SUCCESS; - } - return DH_SUCCESS; -} - -int32_t AudioAdapterInterfaceImpl::HandleDeviceClosed(const DAudioEvent &event) -{ - DHLOGI("Handle device closed, event type: %d.", event.type); - if (paramCallback_ != nullptr) { - std::stringstream ss; - ss << "ERR_EVENT;DEVICE_TYPE=" << - (event.type == HDF_AUDIO_EVENT_SPK_CLOSED ? AUDIO_DEVICE_TYPE_SPEAKER : AUDIO_DEVICE_TYPE_MIC) << ";"; - int8_t reserved; - int8_t cookie; - int32_t ret = paramCallback_->ParamCallback(AUDIO_EXT_PARAM_KEY_STATUS, ss.str(), - std::to_string(EVENT_DEV_CLOSED), reserved, cookie); - if (ret != DH_SUCCESS) { - DHLOGE("Notify fwk failed."); - } - } - - AudioDeviceDescriptor dec; - if (isSpkOpened_ == true && event.type == HDF_AUDIO_EVENT_SPK_CLOSED) { - DHLOGE("Render device status error, close render."); - dec.pins = static_cast(spkPinInUse_); - return DestroyRender(dec); - } else if (isMicOpened_ == true && event.type == HDF_AUDIO_EVENT_MIC_CLOSED) { - DHLOGE("Capture device status error, close capture."); - dec.pins = static_cast(micPinInUse_); - return DestroyCapture(dec); - } - DHLOGI("Handle device closed success."); - return DH_SUCCESS; -} - -bool AudioAdapterInterfaceImpl::IsPortsNoReg() -{ - std::lock_guard devLck(devMapMtx_); - return mapAudioDevice_.empty(); -} -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_capture_interface_impl.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_capture_interface_impl.cpp deleted file mode 100644 index 39b830a374e8b96e374e71782abf16778102ba4e..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_capture_interface_impl.cpp +++ /dev/null @@ -1,338 +0,0 @@ -/* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. - * 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 "audio_capture_interface_impl.h" - -#include -#include -#include "sys/time.h" -#include - -#include "daudio_constants.h" -#include "daudio_events.h" -#include "daudio_log.h" -#include "daudio_utils.h" - -#undef DH_LOG_TAG -#define DH_LOG_TAG "AudioCaptureInterfaceImpl" - -using namespace OHOS::DistributedHardware; -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -AudioCaptureInterfaceImpl::AudioCaptureInterfaceImpl(const std::string &adpName, const AudioDeviceDescriptor &desc, - const AudioSampleAttributes &attrs, const sptr &callback) - : adapterName_(adpName), devDesc_(desc), - devAttrs_(attrs), audioExtCallback_(callback) -{ - devAttrs_.frameSize = CalculateFrameSize(attrs.sampleRate, attrs.channelCount, attrs.format, timeInterval_, false); - const int32_t sizePerSec = static_cast(attrs.sampleRate * attrs.channelCount) *attrs.format; - framePeriodNs_ = (static_cast(devAttrs_.frameSize) * AUDIO_NS_PER_SECOND) / sizePerSec; - DHLOGD("Distributed audio capture constructed, period(%d),frameSize(%d), framePeriodNs_(%d).", - attrs.period, devAttrs_.frameSize, framePeriodNs_); - DHLOGD("Distributed audio capture constructed, id(%d).", desc.pins); -} - -AudioCaptureInterfaceImpl::~AudioCaptureInterfaceImpl() -{ - DHLOGD("Distributed audio capture destructed, id(%d).", devDesc_.pins); -} - -int32_t AudioCaptureInterfaceImpl::GetCapturePosition(uint64_t &frames, AudioTimeStamp &time) -{ - DHLOGI("Get capture position, not support yet."); - (void)frames; - (void)time; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::CaptureFrame(std::vector &frame, uint64_t requestBytes) -{ - DHLOGD("Capture frame[sampleRate: %d, channelCount: %d, format: %d, frameSize: %d].", devAttrs_.sampleRate, - devAttrs_.channelCount, devAttrs_.format, devAttrs_.frameSize); - int64_t timeOffset = UpdateTimeOffset(frameIndex_, framePeriodNs_, startTime_); - DHLOGD("Capture framIndex: %lld, timeOffset: %lld.", frameIndex_, timeOffset); - - std::lock_guard captureLck(captureMtx_); - if (captureStatus_ != CAPTURE_STATUS_START) { - DHLOGE("Capture status wrong, return false."); - return HDF_FAILURE; - } - if (audioExtCallback_ == nullptr) { - DHLOGE("Callback is nullptr."); - return HDF_FAILURE; - } - - AudioData audioData; - int32_t ret = audioExtCallback_->ReadStreamData(adapterName_, devDesc_.pins, audioData); - if (ret != HDF_SUCCESS) { - DHLOGE("Read stream data failed."); - return HDF_FAILURE; - } - - frame.resize(devAttrs_.frameSize); - ret = memcpy_s(frame.data(), frame.size(), audioData.data.data(), audioData.data.size()); - if (ret != EOK) { - DHLOGE("Copy capture frame failed, error code %d.", ret); - return HDF_FAILURE; - } - ++frameIndex_; - AbsoluteSleep(startTime_ + frameIndex_ * framePeriodNs_ - timeOffset); - DHLOGD("Capture audio frame success."); - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::Start() -{ - DHLOGI("Start capture."); - DAudioEvent event = { HDF_AUDIO_EVENT_START, "" }; - if (audioExtCallback_ == nullptr) { - DHLOGE("Callback is nullptr."); - return HDF_FAILURE; - } - if (audioExtCallback_->NotifyEvent(adapterName_, devDesc_.pins, event) != HDF_SUCCESS) { - DHLOGE("Notify start event failed."); - return HDF_FAILURE; - } - std::lock_guard captureLck(captureMtx_); - captureStatus_ = CAPTURE_STATUS_START; - frameIndex_ = 0; - startTime_ = 0; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::Stop() -{ - DHLOGI("Stop capture."); - DAudioEvent event = { HDF_AUDIO_EVENT_STOP, "" }; - if (audioExtCallback_ == nullptr) { - DHLOGE("Callback is nullptr."); - return HDF_FAILURE; - } - if (audioExtCallback_->NotifyEvent(adapterName_, devDesc_.pins, event) != HDF_SUCCESS) { - DHLOGE("Notify stop event failed."); - return HDF_FAILURE; - } - std::lock_guard captureLck(captureMtx_); - captureStatus_ = CAPTURE_STATUS_STOP; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::Pause() -{ - DHLOGI("Pause capture."); - std::lock_guard captureLck(captureMtx_); - captureStatus_ = CAPTURE_STATUS_PAUSE; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::Resume() -{ - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::Flush() -{ - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::TurnStandbyMode() -{ - DHLOGI("Turn stand by mode, not support yet."); - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::AudioDevDump(int32_t range, int32_t fd) -{ - DHLOGI("Dump audio info, not support yet."); - (void)range; - (void)fd; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::IsSupportsPauseAndResume(bool &supportPause, bool &supportResume) -{ - DHLOGI("Check whether pause and resume is supported, not support yet."); - (void)supportPause; - (void)supportResume; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::CheckSceneCapability(const AudioSceneDescriptor &scene, bool &supported) -{ - DHLOGI("Check scene capability."); - (void)scene; - supported = false; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::SelectScene(const AudioSceneDescriptor &scene) -{ - DHLOGI("Select audio scene, not support yet."); - (void)scene; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::SetMute(bool mute) -{ - DHLOGI("Set mute, not support yet."); - (void)mute; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::GetMute(bool &mute) -{ - DHLOGI("Get mute, not support yet."); - (void)mute; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::SetVolume(float volume) -{ - DHLOGI("Can not set vol not by this interface."); - (void)volume; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::GetVolume(float &volume) -{ - DHLOGI("Can not get vol not by this interface."); - (void)volume; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::GetGainThreshold(float &min, float &max) -{ - DHLOGI("Get gain threshold, not support yet."); - min = 0; - max = 0; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::SetGain(float gain) -{ - DHLOGI("Set gain, not support yet."); - (void)gain; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::GetGain(float &gain) -{ - DHLOGI("Get gain, not support yet."); - gain = 1.0; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::GetFrameSize(uint64_t &size) -{ - (void)size; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::GetFrameCount(uint64_t &count) -{ - (void)count; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::SetSampleAttributes(const AudioSampleAttributes &attrs) -{ - DHLOGI("Set sample attributes."); - devAttrs_ = attrs; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::GetSampleAttributes(AudioSampleAttributes &attrs) -{ - DHLOGI("Get sample attributes."); - attrs = devAttrs_; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::GetCurrentChannelId(uint32_t &channelId) -{ - DHLOGI("Get current channel id, not support yet."); - (void)channelId; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::SetExtraParams(const std::string &keyValueList) -{ - DHLOGI("Set extra parameters, not support yet."); - (void)keyValueList; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::GetExtraParams(std::string &keyValueList) -{ - DHLOGI("Get extra parameters, not support yet."); - (void)keyValueList; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::ReqMmapBuffer(int32_t reqSize, AudioMmapBufferDescriptor &desc) -{ - DHLOGI("Request mmap buffer, not support yet."); - (void)reqSize; - (void)desc; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::GetMmapPosition(uint64_t &frames, AudioTimeStamp &time) -{ - DHLOGI("Get mmap position, not support yet."); - (void)frames; - (void)time; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::AddAudioEffect(uint64_t effectid) -{ - DHLOGI("Add audio effect, not support yet."); - (void)effectid; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::RemoveAudioEffect(uint64_t effectid) -{ - DHLOGI("Remove audio effect, not support yet."); - (void)effectid; - return HDF_SUCCESS; -} - -int32_t AudioCaptureInterfaceImpl::GetFrameBufferSize(uint64_t &bufferSize) -{ - DHLOGI("Get frame buffer size, not support yet."); - (void)bufferSize; - return HDF_SUCCESS; -} - -void AudioCaptureInterfaceImpl::SetAttrs(const std::string &adpName, const AudioDeviceDescriptor &desc, - const AudioSampleAttributes &attrs, const sptr &callback) -{ - DHLOGI("Set attrs, not support yet."); -} - -const AudioDeviceDescriptor &AudioCaptureInterfaceImpl::GetCaptureDesc() -{ - return devDesc_; -} -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_driver.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_driver.cpp deleted file mode 100644 index 5aed2588b59b88ff7d82ed4c52ed31c1b56f462e..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_driver.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 -#include -#include -#include -#include - -#include "audio_manager_interface_impl.h" - -using namespace OHOS::HDI::DistributedAudio::Audio::V1_0; - -struct HdfAudioManagerHost { - struct IDeviceIoService ioService; - OHOS::sptr stub; -}; - -static int32_t AudioManagerDriverDispatch(struct HdfDeviceIoClient *client, int cmdId, struct HdfSBuf *data, - struct HdfSBuf *reply) -{ - auto *hdfAudioManagerHost = CONTAINER_OF(client->device->service, struct HdfAudioManagerHost, ioService); - - OHOS::MessageParcel *dataParcel = nullptr; - OHOS::MessageParcel *replyParcel = nullptr; - OHOS::MessageOption option; - - if (SbufToParcel(data, &dataParcel) != HDF_SUCCESS) { - HDF_LOGE("%{public}s:invalid data sbuf object to dispatch", __func__); - return HDF_ERR_INVALID_PARAM; - } - if (SbufToParcel(reply, &replyParcel) != HDF_SUCCESS) { - HDF_LOGE("%{public}s:invalid reply sbuf object to dispatch", __func__); - return HDF_ERR_INVALID_PARAM; - } - - return hdfAudioManagerHost->stub->SendRequest(cmdId, *dataParcel, *replyParcel, option); -} - -int HdfAudioManagerDriverInit(struct HdfDeviceObject *deviceObject) -{ - HDF_LOGI("Hdf audio manager driver init."); - AudioManagerInterfaceImpl::GetAudioManager()->SetDeviceObject(deviceObject); - HdfDeviceSetClass(deviceObject, DEVICE_CLASS_AUDIO); - return HDF_SUCCESS; -} - -int HdfAudioManagerDriverBind(struct HdfDeviceObject *deviceObject) -{ - HDF_LOGI("Hdf audio manager driver bind."); - - auto *hdfAudioManagerHost = new (std::nothrow) HdfAudioManagerHost; - if (hdfAudioManagerHost == nullptr) { - HDF_LOGE("%{public}s: failed to create create HdfAudioManagerHost object", __func__); - return HDF_FAILURE; - } - - hdfAudioManagerHost->ioService.Dispatch = AudioManagerDriverDispatch; - hdfAudioManagerHost->ioService.Open = NULL; - hdfAudioManagerHost->ioService.Release = NULL; - - auto serviceImpl = IAudioManager::Get("daudio_primary_service", true); - if (serviceImpl == nullptr) { - HDF_LOGE("%{public}s: failed to get of implement service", __func__); - delete hdfAudioManagerHost; - return HDF_FAILURE; - } - - hdfAudioManagerHost->stub = OHOS::HDI::ObjectCollector::GetInstance().GetOrNewObject(serviceImpl, - IAudioManager::GetDescriptor()); - if (hdfAudioManagerHost->stub == nullptr) { - HDF_LOGE("%{public}s: failed to get stub object", __func__); - delete hdfAudioManagerHost; - return HDF_FAILURE; - } - - deviceObject->service = &hdfAudioManagerHost->ioService; - return HDF_SUCCESS; -} - -void HdfAudioManagerDriverRelease(struct HdfDeviceObject *deviceObject) -{ - HDF_LOGI("Hdf audio manager driver release."); - auto *hdfAudioManagerHost = CONTAINER_OF(deviceObject->service, struct HdfAudioManagerHost, ioService); - delete hdfAudioManagerHost; -} - -struct HdfDriverEntry g_audiomanagerDriverEntry = { - .moduleVersion = 1, - .moduleName = "daudio", - .Bind = HdfAudioManagerDriverBind, - .Init = HdfAudioManagerDriverInit, - .Release = HdfAudioManagerDriverRelease, -}; - -#ifndef __cplusplus -extern "C" { -#endif -HDF_INIT(g_audiomanagerDriverEntry); -#ifndef __cplusplus -} -#endif diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_manager_interface_impl.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_manager_interface_impl.cpp deleted file mode 100644 index 2a13a42b619f386e2b2175d0cacc22b1e699bc8f..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_manager_interface_impl.cpp +++ /dev/null @@ -1,264 +0,0 @@ -/* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. - * 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 "audio_manager_interface_impl.h" - -#include -#include "hdf_device_object.h" -#include - -#include "daudio_constants.h" -#include "daudio_errcode.h" -#include "daudio_events.h" -#include "daudio_log.h" -#include "daudio_utils.h" - -#undef DH_LOG_TAG -#define DH_LOG_TAG "AudioManagerInterfaceImpl" - -using namespace OHOS::DistributedHardware; -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -AudioManagerInterfaceImpl *AudioManagerInterfaceImpl::audioManager_ = nullptr; -std::mutex AudioManagerInterfaceImpl::audioManagerMtx_; -extern "C" IAudioManager *AudioManagerImplGetInstance(void) -{ - return AudioManagerInterfaceImpl::GetAudioManager(); -} - -AudioManagerInterfaceImpl::AudioManagerInterfaceImpl() -{ - DHLOGD("Distributed audio manager constructed."); -} - -AudioManagerInterfaceImpl::~AudioManagerInterfaceImpl() -{ - DHLOGD("Distributed audio manager destructed."); -} - -int32_t AudioManagerInterfaceImpl::GetAllAdapters(std::vector &descs) -{ - DHLOGI("Get all distributed audio adapters."); - std::lock_guard adpLck(adapterMapMtx_); - - std::transform(mapAudioAdapter_.begin(), mapAudioAdapter_.end(), std::back_inserter(descs), - [](auto& adp) { return adp.second->GetAdapterDesc(); }); - - DHLOGI("Get adapters success, total is (%zu). ", mapAudioAdapter_.size()); - return HDF_SUCCESS; -} - -int32_t AudioManagerInterfaceImpl::LoadAdapter(const AudioAdapterDescriptor &desc, sptr &adapter) -{ - DHLOGI("Load distributed audio adapter: %s.", GetAnonyString(desc.adapterName).c_str()); - std::lock_guard adpLck(adapterMapMtx_); - auto adp = mapAudioAdapter_.find(desc.adapterName); - if (adp == mapAudioAdapter_.end()) { - DHLOGE("Load audio adapter failed, can not find adapter."); - adapter = nullptr; - return HDF_FAILURE; - } - - int32_t ret = adp->second->AdapterLoad(); - if (ret != DH_SUCCESS) { - DHLOGE("Load audio adapter failed, adapter return: %d.", ret); - adapter = nullptr; - return HDF_FAILURE; - } - - adapter = adp->second; - DHLOGI("Load adapter success."); - return HDF_SUCCESS; -} - -int32_t AudioManagerInterfaceImpl::UnloadAdapter(const std::string &adapterName) -{ - DHLOGI("Unload distributed audio adapter: %s.", GetAnonyString(adapterName).c_str()); - std::lock_guard adpLck(adapterMapMtx_); - auto adp = mapAudioAdapter_.find(adapterName); - if (adp == mapAudioAdapter_.end()) { - DHLOGE("Unload audio adapter failed, can not find adapter."); - return HDF_SUCCESS; - } - - int32_t ret = adp->second->AdapterUnload(); - if (ret != DH_SUCCESS) { - DHLOGE("Unload audio adapter failed, adapter return: %d.", ret); - return HDF_SUCCESS; - } - DHLOGI("Unload adapter success."); - return HDF_SUCCESS; -} - -int32_t AudioManagerInterfaceImpl::ReleaseAudioManagerObject() -{ - DHLOGD("Release distributed audio manager object."); - return HDF_SUCCESS; -} - -int32_t AudioManagerInterfaceImpl::AddAudioDevice(const std::string &adpName, const uint32_t devId, - const std::string &caps, const sptr &callback) -{ - DHLOGI("Add audio device name: %s, device: %d.", GetAnonyString(adpName).c_str(), devId); - std::lock_guard adpLck(adapterMapMtx_); - auto adp = mapAudioAdapter_.find(adpName); - if (adp == mapAudioAdapter_.end()) { - int32_t ret = CreateAdapter(adpName, devId, callback); - if (ret != DH_SUCCESS) { - DHLOGE("Create audio adapter failed."); - return ERR_DH_AUDIO_HDF_FAIL; - } - } - adp = mapAudioAdapter_.find(adpName); - if (adp == mapAudioAdapter_.end() || adp->second == nullptr) { - DHLOGE("Audio device has not been created or is null ptr."); - return ERR_DH_AUDIO_HDF_INVALID_OPERATION; - } - switch (GetDevTypeByDHId(devId)) { - case AUDIO_DEVICE_TYPE_SPEAKER: - adp->second->SetSpeakerCallback(callback); - break; - case AUDIO_DEVICE_TYPE_MIC: - adp->second->SetMicCallback(callback); - break; - case AUDIO_DEVICE_TYPE_UNKNOWN: - default: - DHLOGE("DhId is illegal, devType is unknow."); - return ERR_DH_AUDIO_HDF_FAIL; - } - int32_t ret = adp->second->AddAudioDevice(devId, caps); - if (ret != DH_SUCCESS) { - DHLOGE("Add audio device failed, adapter return: %d.", ret); - return ERR_DH_AUDIO_HDF_FAIL; - } - - DAudioDevEvent event = { adpName, - devId, - HDF_AUDIO_DEVICE_ADD, - 0, - adp->second->GetVolumeGroup(devId), - adp->second->GetInterruptGroup(devId) }; - ret = NotifyFwk(event); - if (ret != DH_SUCCESS) { - DHLOGE("Notify audio fwk failed, ret = %d.", ret); - return ret; - } - DHLOGI("Add audio device success."); - return DH_SUCCESS; -} - -int32_t AudioManagerInterfaceImpl::RemoveAudioDevice(const std::string &adpName, const uint32_t devId) -{ - DHLOGI("Remove audio device name: %s, device: %d.", GetAnonyString(adpName).c_str(), devId); - std::lock_guard adpLck(adapterMapMtx_); - auto adp = mapAudioAdapter_.find(adpName); - if (adp == mapAudioAdapter_.end() || adp->second == nullptr) { - DHLOGE("Audio device has not been created or is null ptr."); - return ERR_DH_AUDIO_HDF_INVALID_OPERATION; - } - - int32_t ret = adp->second->RemoveAudioDevice(devId); - if (ret != DH_SUCCESS) { - DHLOGE("Remove audio device failed, adapter return: %d.", ret); - return ret; - } - - DAudioDevEvent event = { adpName, devId, HDF_AUDIO_DEVICE_REMOVE, 0, 0, 0 }; - ret = NotifyFwk(event); - if (ret != DH_SUCCESS) { - DHLOGE("Notify audio fwk failed, ret = %d.", ret); - } - if (adp->second->IsPortsNoReg()) { - mapAudioAdapter_.erase(adpName); - } - DHLOGI("Remove audio device success, mapAudioAdapter size() is : %d .", mapAudioAdapter_.size()); - return DH_SUCCESS; -} - -int32_t AudioManagerInterfaceImpl::Notify(const std::string &adpName, const uint32_t devId, const DAudioEvent &event) -{ - DHLOGI("Notify event, adapter name: %s. event type: %d", GetAnonyString(adpName).c_str(), - event.type); - auto adp = mapAudioAdapter_.find(adpName); - if (adp == mapAudioAdapter_.end()) { - DHLOGE("Notify failed, can not find adapter."); - return ERR_DH_AUDIO_HDF_INVALID_OPERATION; - } - - int32_t ret = adp->second->Notify(devId, event); - if (ret != DH_SUCCESS) { - DHLOGE("Notify failed, adapter return: %d.", ret); - return ERR_DH_AUDIO_HDF_FAIL; - } - return DH_SUCCESS; -} - -int32_t AudioManagerInterfaceImpl::NotifyFwk(const DAudioDevEvent &event) -{ - DHLOGD("Notify audio fwk event(type:%d, adapter:%s, pin:%d).", event.eventType, - GetAnonyString(event.adapterName).c_str(), event.devId); - std::stringstream ss; - ss << "EVENT_TYPE=" << event.eventType << ";NID=" << event.adapterName << ";PIN=" << event.devId << ";VID=" << - event.volGroupId << ";IID=" << event.iptGroupId; - std::string eventInfo = ss.str(); - int ret = HdfDeviceObjectSetServInfo(deviceObject_, eventInfo.c_str()); - if (ret != HDF_SUCCESS) { - DHLOGE("Set service info failed, ret = %d.", ret); - return ERR_DH_AUDIO_HDF_FAIL; - } - ret = HdfDeviceObjectUpdate(deviceObject_); - if (ret != HDF_SUCCESS) { - DHLOGE("Update service info failed, ret = %d.", ret); - return ERR_DH_AUDIO_HDF_FAIL; - } - - DHLOGI("Notify audio fwk success."); - return DH_SUCCESS; -} - -int32_t AudioManagerInterfaceImpl::CreateAdapter(const std::string &adpName, const uint32_t devId, - const sptr &callback) -{ - if (callback == nullptr) { - DHLOGE("Adapter callback is null."); - return ERR_DH_AUDIO_HDF_NULLPTR; - } - if (devId != PIN_OUT_DAUDIO_DEFAULT && devId != PIN_IN_DAUDIO_DEFAULT) { - DHLOGE("Pin is not default, can not create audio adapter."); - return ERR_DH_AUDIO_HDF_FAIL; - } - - AudioAdapterDescriptor desc = { adpName }; - sptr adapter(new AudioAdapterInterfaceImpl(desc)); - if (adapter == nullptr) { - DHLOGE("Create new audio adapter failed."); - return ERR_DH_AUDIO_HDF_NULLPTR; - } - mapAudioAdapter_.insert(std::make_pair(adpName, adapter)); - return DH_SUCCESS; -} - -void AudioManagerInterfaceImpl::SetDeviceObject(struct HdfDeviceObject *deviceObject) -{ - deviceObject_ = deviceObject; -} -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOSf diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_render_interface_impl.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_render_interface_impl.cpp deleted file mode 100644 index cf7bd3cd02bd84083954afe4877d816a3ca44f5d..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/src/audio_render_interface_impl.cpp +++ /dev/null @@ -1,448 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 "audio_render_interface_impl.h" - -#include -#include -#include "sys/time.h" - -#include "daudio_constants.h" -#include "daudio_events.h" -#include "daudio_log.h" -#include "daudio_utils.h" - -#undef DH_LOG_TAG -#define DH_LOG_TAG "AudioRenderInterfaceImpl" - -using namespace OHOS::DistributedHardware; -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -AudioRenderInterfaceImpl::AudioRenderInterfaceImpl(const std::string &adpName, const AudioDeviceDescriptor &desc, - const AudioSampleAttributes &attrs, const sptr &callback) - : adapterName_(adpName), devDesc_(desc), - devAttrs_(attrs), audioExtCallback_(callback) -{ - devAttrs_.frameSize = CalculateFrameSize(attrs.sampleRate, attrs.channelCount, attrs.format, timeInterval_, false); - const int32_t sizePerSec = static_cast(attrs.sampleRate * attrs.channelCount) *attrs.format; - framePeriodNs_ = (static_cast(devAttrs_.frameSize) * AUDIO_NS_PER_SECOND) /sizePerSec; - DHLOGD("Distributed audio render constructed, period(%d), frameSize(%d), framePeriodNs_(%d).", - attrs.period, devAttrs_.frameSize, framePeriodNs_); -} - -AudioRenderInterfaceImpl::~AudioRenderInterfaceImpl() -{ - DHLOGD("Distributed audio render destructed, id(%d).", devDesc_.pins); -} - -int32_t AudioRenderInterfaceImpl::GetLatency(uint32_t &ms) -{ - DHLOGI("Get render device latency, not support yet."); - ms = 0; - return HDF_SUCCESS; -} - -float AudioRenderInterfaceImpl::GetFadeRate(uint32_t currentIndex, const uint32_t durationIndex) -{ - if (currentIndex > durationIndex) { - return 1.0f; - } - - float fadeRate = static_cast(currentIndex) / durationIndex * DAUDIO_FADE_NORMALIZATION_FACTOR; - if (fadeRate < 1) { - return pow(fadeRate, DAUDIO_FADE_POWER_NUM) / DAUDIO_FADE_NORMALIZATION_FACTOR; - } - return -pow(fadeRate - DAUDIO_FADE_MAXIMUM_VALUE, DAUDIO_FADE_POWER_NUM) / - DAUDIO_FADE_NORMALIZATION_FACTOR + 1; -} - -int32_t AudioRenderInterfaceImpl::FadeInProcess(const uint32_t durationFrame, - int8_t* frameData, const size_t frameLength) -{ - int16_t* frame = reinterpret_cast(frameData); - const size_t newFrameLength = frameLength / 2; - - for (size_t k = 0; k < newFrameLength; ++k) { - float rate = GetFadeRate(currentFrame_ * newFrameLength + k, durationFrame * newFrameLength); - frame[k] = currentFrame_ == durationFrame - 1 ? frame[k] : static_cast(rate * frame[k]); - } - DHLOGI("Fade-in frame[currentFrame: %d].", currentFrame_); - ++currentFrame_; - currentFrame_ = currentFrame_ >= durationFrame ? durationFrame - 1 : currentFrame_; - - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::RenderFrame(const std::vector &frame, uint64_t &replyBytes) -{ - DHLOGD("Render frame[sampleRate: %d, channelCount: %d, format: %d, frameSize: %d].", devAttrs_.sampleRate, - devAttrs_.channelCount, devAttrs_.format, devAttrs_.frameSize); - int64_t timeOffset = UpdateTimeOffset(frameIndex_, framePeriodNs_, startTime_); - DHLOGD("Render frameIndex: %lld, timeOffset: %lld.", frameIndex_, timeOffset); - - std::lock_guard renderLck(renderMtx_); - if (renderStatus_ != RENDER_STATUS_START) { - DHLOGE("Render status wrong, return false."); - return HDF_FAILURE; - } - - AudioParameter param = { devAttrs_.format, devAttrs_.channelCount, devAttrs_.sampleRate, 0, devAttrs_.frameSize}; - AudioData data = { param, frame }; - FadeInProcess(DURATION_FRAMES, data.data.data(), frame.size()); - if (audioExtCallback_ == nullptr) { - DHLOGE("Callback is nullptr."); - return HDF_FAILURE; - } - int32_t ret = audioExtCallback_->WriteStreamData(adapterName_, devDesc_.pins, data); - if (ret != HDF_SUCCESS) { - DHLOGE("Write stream data failed."); - return HDF_FAILURE; - } - - ++frameIndex_; - AbsoluteSleep(startTime_ + frameIndex_ * framePeriodNs_ - timeOffset); - DHLOGD("Render audio frame success."); - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::GetRenderPosition(uint64_t &frames, AudioTimeStamp &time) -{ - DHLOGI("Get render position, not support yet."); - (void)frames; - (void)time; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::SetRenderSpeed(float speed) -{ - DHLOGI("Set render speed, control render speed is not support yet."); - renderSpeed_ = speed; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::GetRenderSpeed(float &speed) -{ - DHLOGI("Get render speed, control render speed is not support yet."); - speed = renderSpeed_; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::SetChannelMode(AudioChannelMode mode) -{ - DHLOGI("Set channel mode, control channel mode is not support yet."); - channelMode_ = mode; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::GetChannelMode(AudioChannelMode &mode) -{ - DHLOGI("Get channel mode, control channel mode is not support yet."); - mode = channelMode_; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::RegCallback(const sptr &audioCallback, int8_t cookie) -{ - DHLOGI("Register render callback."); - (void)cookie; - renderCallback_ = audioCallback; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::DrainBuffer(AudioDrainNotifyType &type) -{ - DHLOGI("Drain audio buffer, not support yet."); - (void)type; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::IsSupportsDrain(bool &support) -{ - DHLOGI("Check whether drain is supported, not support yet."); - (void)support; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::Start() -{ - DHLOGI("Start render."); - if (firstOpenFlag_) { - firstOpenFlag_ = false; - } else { - DAudioEvent event = { HDF_AUDIO_EVENT_CHANGE_PLAY_STATUS, HDF_EVENT_RESTART }; - int32_t ret = audioExtCallback_->NotifyEvent(adapterName_, devDesc_.pins, event); - if (ret != HDF_SUCCESS) { - DHLOGE("Restart failed."); - } - } - std::lock_guard renderLck(renderMtx_); - renderStatus_ = RENDER_STATUS_START; - currentFrame_ = CUR_FRAME_INIT_VALUE; - frameIndex_ = 0; - startTime_ = 0; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::Stop() -{ - DHLOGI("Stop render."); - DAudioEvent event = { HDF_AUDIO_EVENT_CHANGE_PLAY_STATUS, HDF_EVENT_PAUSE }; - int32_t ret = audioExtCallback_->NotifyEvent(adapterName_, devDesc_.pins, event); - if (ret != HDF_SUCCESS) { - DHLOGE("Pause and clear cache streams failed."); - } - std::lock_guard renderLck(renderMtx_); - renderStatus_ = RENDER_STATUS_STOP; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::Pause() -{ - DHLOGI("Pause render."); - std::lock_guard renderLck(renderMtx_); - renderStatus_ = RENDER_STATUS_PAUSE; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::Resume() -{ - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::Flush() -{ - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::TurnStandbyMode() -{ - DHLOGI("Turn stand by mode, not support yet."); - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::AudioDevDump(int32_t range, int32_t fd) -{ - DHLOGI("Dump audio info, not support yet."); - (void)range; - (void)fd; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::IsSupportsPauseAndResume(bool &supportPause, bool &supportResume) -{ - DHLOGI("Check whether pause and resume is supported, not support yet."); - (void)supportPause; - (void)supportResume; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::CheckSceneCapability(const AudioSceneDescriptor &scene, bool &supported) -{ - DHLOGI("Check scene capability."); - (void)scene; - (void)supported; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::SelectScene(const AudioSceneDescriptor &scene) -{ - DHLOGI("Select audio scene, not support yet."); - (void)scene; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::SetMute(bool mute) -{ - DHLOGI("Set mute, not support yet."); - (void)mute; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::GetMute(bool &mute) -{ - DHLOGI("Get mute, not support yet."); - (void)mute; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::SetVolume(float volume) -{ - DHLOGI("Can not set vol not by this interface."); - (void)volume; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::GetVolume(float &volume) -{ - DHLOGI("Can not get vol not by this interface."); - (void)volume; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::GetGainThreshold(float &min, float &max) -{ - DHLOGI("Get gain threshold, not support yet."); - min = 0; - max = 0; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::SetGain(float gain) -{ - DHLOGI("Set gain, not support yet."); - (void)gain; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::GetGain(float &gain) -{ - DHLOGI("Get gain, not support yet."); - gain = 1.0; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::GetFrameSize(uint64_t &size) -{ - (void)size; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::GetFrameCount(uint64_t &count) -{ - (void)count; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::SetSampleAttributes(const AudioSampleAttributes &attrs) -{ - DHLOGI("Set sample attributes."); - devAttrs_ = attrs; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::GetSampleAttributes(AudioSampleAttributes &attrs) -{ - DHLOGI("Get sample attributes."); - attrs = devAttrs_; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::GetCurrentChannelId(uint32_t &channelId) -{ - DHLOGI("Get current channel id, not support yet."); - (void)channelId; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::SetExtraParams(const std::string &keyValueList) -{ - DHLOGI("Set extra parameters, not support yet."); - (void)keyValueList; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::GetExtraParams(std::string &keyValueList) -{ - DHLOGI("Get extra parameters, not support yet."); - (void)keyValueList; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::ReqMmapBuffer(int32_t reqSize, AudioMmapBufferDescriptor &desc) -{ - DHLOGI("Request mmap buffer, not support yet."); - (void)reqSize; - (void)desc; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::GetMmapPosition(uint64_t &frames, AudioTimeStamp &time) -{ - DHLOGI("Get mmap position, not support yet."); - (void)frames; - (void)time; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::AddAudioEffect(uint64_t effectid) -{ - DHLOGI("Add audio effect, not support yet."); - (void)effectid; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::RemoveAudioEffect(uint64_t effectid) -{ - DHLOGI("Remove audio effect, not support yet."); - (void)effectid; - return HDF_SUCCESS; -} - -int32_t AudioRenderInterfaceImpl::GetFrameBufferSize(uint64_t &bufferSize) -{ - DHLOGI("Get frame buffer size, not support yet."); - (void)bufferSize; - return HDF_SUCCESS; -} - -const AudioDeviceDescriptor &AudioRenderInterfaceImpl::GetRenderDesc() -{ - return devDesc_; -} - -void AudioRenderInterfaceImpl::SetVolumeInner(const uint32_t vol) -{ - std::lock_guard volLck(volMtx_); - vol_ = vol; -} - -void AudioRenderInterfaceImpl::SetVolumeRangeInner(const uint32_t volMax, const uint32_t volMin) -{ - std::lock_guard volLck(volMtx_); - volMin_ = volMin; - volMax_ = volMax; -} - -uint32_t AudioRenderInterfaceImpl::GetVolumeInner() -{ - std::lock_guard volLck(volMtx_); - return vol_; -} - -uint32_t AudioRenderInterfaceImpl::GetMaxVolumeInner() -{ - std::lock_guard volLck(volMtx_); - return volMax_; -} - -uint32_t AudioRenderInterfaceImpl::GetMinVolumeInner() -{ - std::lock_guard volLck(volMtx_); - return volMin_; -} - -void AudioRenderInterfaceImpl::SetAttrs(const std::string &adpName, const AudioDeviceDescriptor &desc, - const AudioSampleAttributes &attrs, const sptr &callback) -{ - DHLOGI("Set attrs, not support yet."); -} -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/captureframe_fuzzer/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/captureframe_fuzzer/BUILD.gn deleted file mode 100644 index 2355d3244567cd099fa75332f6840feed4eeccd7..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/captureframe_fuzzer/BUILD.gn +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# 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. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import("../../../../../../../../distributedaudio.gni") - -##############################fuzztest########################################## -ohos_fuzztest("CaptureFrameFuzzTest") { - module_out_path = "distributed_audio/captureframe_fuzzer" - fuzz_config_file = "${hdf_ser_aud_path}/test/fuzztest/captureframe_fuzzer" - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "captureframe_fuzzer.cpp" ] - - include_dirs = [ - "${hdf_ser_aud_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] - - include_dirs += [ - "include", - "${common_path}/include", - ] - - deps = [ "${hdf_ser_aud_path}:libaudio_manager_daudio_primary_service_1.0" ] - - external_deps = [ - "c_utils:utils", - "ipc:ipc_core", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"CaptureFrameFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":CaptureFrameFuzzTest" ] -} -############################################################################### diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/captureframe_fuzzer/captureframe_fuzzer.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/captureframe_fuzzer/captureframe_fuzzer.cpp deleted file mode 100644 index e15c3fe225b2c63b54b2cd7701e87c24fa515f64..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/captureframe_fuzzer/captureframe_fuzzer.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 "captureframe_fuzzer.h" - -#include -#include - -#include "audio_capture_interface_impl.h" -#include "if_system_ability_manager.h" -#include "iservice_registry.h" - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -void CaptureFrameFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < (sizeof(uint64_t)))) { - return; - } - - std::string adpName(reinterpret_cast(data), size); - AudioDeviceDescriptor desc; - AudioSampleAttributes attrs; - sptr callback = nullptr; - auto audioCapture = std::make_shared(adpName, desc, attrs, callback); - std::vector frame; - uint64_t requestBytes = *(reinterpret_cast(data)); - - audioCapture->CaptureFrame(frame, requestBytes); -} -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::HDI::DistributedAudio::Audio::V1_0::CaptureFrameFuzzTest(data, size); - return 0; -} - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/captureframe_fuzzer/captureframe_fuzzer.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/captureframe_fuzzer/captureframe_fuzzer.h deleted file mode 100644 index ba15a80b77ee397ff5d05d5cba9eaeaa60104d04..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/captureframe_fuzzer/captureframe_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 CAPTUREFRAME_FUZZER_H -#define CAPTUREFRAME_FUZZER_H - -#define FUZZ_PROJECT_NAME "captureframe_fuzzer" - -#endif diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/captureframe_fuzzer/corpus/init b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/captureframe_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6eb6b7d71f0c70c244e5768d62bee6ac5..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/captureframe_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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. - */ - -FUZZ \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/captureframe_fuzzer/project.xml b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/captureframe_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/captureframe_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createcapture_fuzzer/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createcapture_fuzzer/BUILD.gn deleted file mode 100644 index ff0e6053984303f4cdbac796f6b75430b52c1388..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createcapture_fuzzer/BUILD.gn +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# 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. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import("../../../../../../../../distributedaudio.gni") - -##############################fuzztest########################################## -ohos_fuzztest("CreateCaptureFuzzTest") { - module_out_path = "distributed_audio/createcapture_fuzzer" - fuzz_config_file = "${hdf_ser_aud_path}/test/fuzztest/createcapture_fuzzer" - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "createcapture_fuzzer.cpp" ] - - include_dirs = [ - "${hdf_ser_aud_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] - - include_dirs += [ - "include", - "${common_path}/include", - ] - - deps = [ "${hdf_ser_aud_path}:libaudio_manager_daudio_primary_service_1.0" ] - - external_deps = [ - "c_utils:utils", - "ipc:ipc_core", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"CreateCaptureFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":CreateCaptureFuzzTest" ] -} -############################################################################### diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createcapture_fuzzer/corpus/init b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createcapture_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6eb6b7d71f0c70c244e5768d62bee6ac5..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createcapture_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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. - */ - -FUZZ \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createcapture_fuzzer/createcapture_fuzzer.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createcapture_fuzzer/createcapture_fuzzer.cpp deleted file mode 100644 index 87f0fe8a9adac6ff10574b5b23906f10b46a2aac..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createcapture_fuzzer/createcapture_fuzzer.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 "createcapture_fuzzer.h" - -#include -#include - -#include "audio_adapter_interface_impl.h" -#include "if_system_ability_manager.h" -#include "iservice_registry.h" - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -void CreateCaptureFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < (sizeof(int32_t)))) { - return; - } - - AudioAdapterDescriptor desc; - auto audioAdapter = std::make_shared(desc); - - AudioDeviceDescriptor deviceDes = { - .portId = *(reinterpret_cast(data)), - .pins = *(reinterpret_cast(data)), - .desc = std::string(reinterpret_cast(data), size), - }; - - AudioSampleAttributes sampleAttr = { - .type = *(reinterpret_cast(data)), - .interleaved = *(reinterpret_cast(data)), - .format = *(reinterpret_cast(data)), - .sampleRate = *(reinterpret_cast(data)), - .channelCount = *(reinterpret_cast(data)), - .period = *(reinterpret_cast(data)), - .frameSize = *(reinterpret_cast(data)), - .isBigEndian = *(reinterpret_cast(data)), - .isSignedData = *(reinterpret_cast(data)), - .startThreshold = *(reinterpret_cast(data)), - .stopThreshold = *(reinterpret_cast(data)), - .silenceThreshold = *(reinterpret_cast(data)), - .streamId = *(reinterpret_cast(data)), - }; - - sptr capture; - audioAdapter->CreateCapture(deviceDes, sampleAttr, capture); -} -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::HDI::DistributedAudio::Audio::V1_0::CreateCaptureFuzzTest(data, size); - return 0; -} - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createcapture_fuzzer/createcapture_fuzzer.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createcapture_fuzzer/createcapture_fuzzer.h deleted file mode 100644 index 46d8462958a59798058c78ac6c9318dfb3a2edab..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createcapture_fuzzer/createcapture_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 CREATECAPTURE_FUZZER_H -#define CREATECAPTURE_FUZZER_H - -#define FUZZ_PROJECT_NAME "createrender_fuzzer" - -#endif diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createcapture_fuzzer/project.xml b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createcapture_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createcapture_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createrender_fuzzer/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createrender_fuzzer/BUILD.gn deleted file mode 100644 index 7d35e8f64457808ad478750ed0efc7f06b85c84d..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createrender_fuzzer/BUILD.gn +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# 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. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import("../../../../../../../../distributedaudio.gni") - -##############################fuzztest########################################## -ohos_fuzztest("CreateRenderFuzzTest") { - module_out_path = "distributed_audio/createrender_fuzzer" - fuzz_config_file = "${hdf_ser_aud_path}/test/fuzztest/createrender_fuzzer" - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "createrender_fuzzer.cpp" ] - - include_dirs = [ - "${hdf_ser_aud_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] - - include_dirs += [ - "include", - "${common_path}/include", - ] - - deps = [ "${hdf_ser_aud_path}:libaudio_manager_daudio_primary_service_1.0" ] - - external_deps = [ - "c_utils:utils", - "ipc:ipc_core", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"CreateRenderFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":CreateRenderFuzzTest" ] -} -############################################################################### diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createrender_fuzzer/corpus/init b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createrender_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6eb6b7d71f0c70c244e5768d62bee6ac5..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createrender_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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. - */ - -FUZZ \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createrender_fuzzer/createrender_fuzzer.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createrender_fuzzer/createrender_fuzzer.cpp deleted file mode 100644 index d3ba28c74ba45be0af3cf7200faf408e1142c8c1..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createrender_fuzzer/createrender_fuzzer.cpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 "createrender_fuzzer.h" - -#include -#include - -#include "audio_adapter_interface_impl.h" -#include "if_system_ability_manager.h" -#include "iservice_registry.h" - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -void CreateRenderFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < (sizeof(int32_t)))) { - return; - } - - AudioAdapterDescriptor desc; - auto audioAdapter = std::make_shared(desc); - - AudioDeviceDescriptor deviceDes = { - .portId = *(reinterpret_cast(data)), - .pins = *(reinterpret_cast(data)), - .desc = std::string(reinterpret_cast(data), size), - }; - - AudioSampleAttributes sampleAttr = { - .type = *(reinterpret_cast(data)), - .interleaved = *(reinterpret_cast(data)), - .format = *(reinterpret_cast(data)), - .sampleRate = *(reinterpret_cast(data)), - .channelCount = *(reinterpret_cast(data)), - .period = *(reinterpret_cast(data)), - .frameSize = *(reinterpret_cast(data)), - .isBigEndian = *(reinterpret_cast(data)), - .isSignedData = *(reinterpret_cast(data)), - .startThreshold = *(reinterpret_cast(data)), - .stopThreshold = *(reinterpret_cast(data)), - .silenceThreshold = *(reinterpret_cast(data)), - .streamId = *(reinterpret_cast(data)), - }; - - sptr render; - audioAdapter->CreateRender(deviceDes, sampleAttr, render); -} -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::HDI::DistributedAudio::Audio::V1_0::CreateRenderFuzzTest(data, size); - return 0; -} - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createrender_fuzzer/createrender_fuzzer.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createrender_fuzzer/createrender_fuzzer.h deleted file mode 100644 index 56001ad0c5582a575077682e7c0849da9c491e22..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createrender_fuzzer/createrender_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 CREATERENDER_FUZZER_H -#define CREATERENDER_FUZZER_H - -#define FUZZ_PROJECT_NAME "createrender_fuzzer" - -#endif diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createrender_fuzzer/project.xml b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createrender_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/createrender_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroycapture_fuzzer/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroycapture_fuzzer/BUILD.gn deleted file mode 100644 index 6d0edba66065368780a9e82772fafc5b10836e6e..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroycapture_fuzzer/BUILD.gn +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# 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. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import("../../../../../../../../distributedaudio.gni") - -##############################fuzztest########################################## -ohos_fuzztest("DestroyCaptureFuzzTest") { - module_out_path = "distributed_audio/destroycapture_fuzzer" - fuzz_config_file = "${hdf_ser_aud_path}/test/fuzztest/destroycapture_fuzzer" - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "destroycapture_fuzzer.cpp" ] - - include_dirs = [ - "${hdf_ser_aud_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] - - include_dirs += [ - "include", - "${common_path}/include", - ] - - deps = [ "${hdf_ser_aud_path}:libaudio_manager_daudio_primary_service_1.0" ] - - external_deps = [ "ipc:ipc_core" ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"DestroyCaptureFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":DestroyCaptureFuzzTest" ] -} -############################################################################### diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroycapture_fuzzer/corpus/init b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroycapture_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6eb6b7d71f0c70c244e5768d62bee6ac5..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroycapture_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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. - */ - -FUZZ \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroycapture_fuzzer/destroycapture_fuzzer.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroycapture_fuzzer/destroycapture_fuzzer.cpp deleted file mode 100644 index fcf2144be81af0423c939d64af96e0d1de577aee..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroycapture_fuzzer/destroycapture_fuzzer.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 "destroycapture_fuzzer.h" - -#include -#include - -#include "audio_adapter_interface_impl.h" -#include "if_system_ability_manager.h" -#include "iservice_registry.h" - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -void DestroyCaptureFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < (sizeof(int32_t)))) { - return; - } - - AudioAdapterDescriptor desc; - auto audioAdapter = std::make_shared(desc); - - AudioDeviceDescriptor deviceDes = { - .portId = *(reinterpret_cast(data)), - .pins = *(reinterpret_cast(data)), - .desc = std::string(reinterpret_cast(data), size), - }; - - audioAdapter->DestroyCapture(deviceDes); -} -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::HDI::DistributedAudio::Audio::V1_0::DestroyCaptureFuzzTest(data, size); - return 0; -} - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroycapture_fuzzer/destroycapture_fuzzer.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroycapture_fuzzer/destroycapture_fuzzer.h deleted file mode 100644 index eaac4aaa471a046a9bdfaeb22720f9c1c5f3ac27..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroycapture_fuzzer/destroycapture_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 DESTROYCAPTURE_FUZZER_H -#define DESTROYCAPTURE_FUZZER_H - -#define FUZZ_PROJECT_NAME "destroycapture_fuzzer" - -#endif diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroycapture_fuzzer/project.xml b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroycapture_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroycapture_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroyrender_fuzzer/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroyrender_fuzzer/BUILD.gn deleted file mode 100644 index ef2baedef945c72fd3a306e93e1bda33dffe297f..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroyrender_fuzzer/BUILD.gn +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# 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. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import("../../../../../../../../distributedaudio.gni") - -##############################fuzztest########################################## -ohos_fuzztest("DestroyRenderFuzzTest") { - module_out_path = "distributed_audio/destroyrender_fuzzer" - fuzz_config_file = "${hdf_ser_aud_path}/test/fuzztest/destroyrender_fuzzer" - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "destroyrender_fuzzer.cpp" ] - - include_dirs = [ - "${hdf_ser_aud_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] - - include_dirs += [ - "include", - "${common_path}/include", - ] - - deps = [ "${hdf_ser_aud_path}:libaudio_manager_daudio_primary_service_1.0" ] - - external_deps = [ "ipc:ipc_core" ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"DestroyRenderFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":DestroyRenderFuzzTest" ] -} -############################################################################### diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroyrender_fuzzer/corpus/init b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroyrender_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6eb6b7d71f0c70c244e5768d62bee6ac5..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroyrender_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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. - */ - -FUZZ \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroyrender_fuzzer/destroyrender_fuzzer.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroyrender_fuzzer/destroyrender_fuzzer.cpp deleted file mode 100644 index c4c39172a78a4bf379f9fa19d22b64c3bc14539d..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroyrender_fuzzer/destroyrender_fuzzer.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 "destroyrender_fuzzer.h" - -#include -#include - -#include "audio_adapter_interface_impl.h" -#include "if_system_ability_manager.h" -#include "iservice_registry.h" - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -void DestroyRenderFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < (sizeof(int32_t)))) { - return; - } - - AudioAdapterDescriptor desc; - auto audioAdapter = std::make_shared(desc); - - AudioDeviceDescriptor deviceDes = { - .portId = *(reinterpret_cast(data)), - .pins = *(reinterpret_cast(data)), - .desc = std::string(reinterpret_cast(data), size), - }; - - audioAdapter->DestroyRender(deviceDes); -} -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::HDI::DistributedAudio::Audio::V1_0::DestroyRenderFuzzTest(data, size); - return 0; -} - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroyrender_fuzzer/destroyrender_fuzzer.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroyrender_fuzzer/destroyrender_fuzzer.h deleted file mode 100644 index 7e1f6e106ac7d494eb3468c51617bb649884ccec..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroyrender_fuzzer/destroyrender_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 DESTROYRENDER_FUZZER_H -#define DESTROYRENDER_FUZZER_H - -#define FUZZ_PROJECT_NAME "destroyrender_fuzzer" - -#endif diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroyrender_fuzzer/project.xml b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroyrender_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/destroyrender_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getalladapters_fuzzer/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getalladapters_fuzzer/BUILD.gn deleted file mode 100644 index 5b24b91b5b8fb48898092b9d2ac43bb9a40bf1d1..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getalladapters_fuzzer/BUILD.gn +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# 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. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import("../../../../../../../../distributedaudio.gni") - -##############################fuzztest########################################## -ohos_fuzztest("GetAllAdaptersFuzzTest") { - module_out_path = "distributed_audio/getalladapters_fuzzer" - fuzz_config_file = "${hdf_ser_aud_path}/test/fuzztest/getalladapters_fuzzer" - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "getalladapters_fuzzer.cpp" ] - - include_dirs = [ - "${hdf_ser_aud_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] - - include_dirs += [ - "include", - "${common_path}/include", - ] - - deps = [ "${hdf_ser_aud_path}:libaudio_manager_daudio_primary_service_1.0" ] - - external_deps = [ - "hdf_core:libhdf_host", - "ipc:ipc_core", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"GetAllAdaptersFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":GetAllAdaptersFuzzTest" ] -} -############################################################################### diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getalladapters_fuzzer/corpus/init b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getalladapters_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6eb6b7d71f0c70c244e5768d62bee6ac5..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getalladapters_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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. - */ - -FUZZ \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getalladapters_fuzzer/getalladapters_fuzzer.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getalladapters_fuzzer/getalladapters_fuzzer.cpp deleted file mode 100644 index d3b5db040c206f3539d51dcb3a7ebcc0156b6a3a..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getalladapters_fuzzer/getalladapters_fuzzer.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 "getalladapters_fuzzer.h" - -#include -#include - -#include "audio_manager_interface_impl.h" -#include "if_system_ability_manager.h" -#include "iservice_registry.h" - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -void GetAllAdaptersFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < (sizeof(int32_t)))) { - return; - } - - std::vector descriptors; - AudioManagerInterfaceImpl::GetAudioManager()->GetAllAdapters(descriptors); -} -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::HDI::DistributedAudio::Audio::V1_0::GetAllAdaptersFuzzTest(data, size); - return 0; -} - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getalladapters_fuzzer/getalladapters_fuzzer.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getalladapters_fuzzer/getalladapters_fuzzer.h deleted file mode 100644 index e6e66c0a9dcfccc5afde8dff0b4491de301a567b..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getalladapters_fuzzer/getalladapters_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 GETALLADAPTERS_FUZZER_H -#define GETALLADAPTERS_FUZZER_H - -#define FUZZ_PROJECT_NAME "getalladapters_fuzzer" - -#endif diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getalladapters_fuzzer/project.xml b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getalladapters_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getalladapters_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getextraparams_fuzzer/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getextraparams_fuzzer/BUILD.gn deleted file mode 100644 index d02deb800e9095ef8122c96b39021a58342d8474..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getextraparams_fuzzer/BUILD.gn +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# 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. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import("../../../../../../../../distributedaudio.gni") - -##############################fuzztest########################################## -ohos_fuzztest("GetExtraParamsFuzzTest") { - module_out_path = "distributed_audio/getextraparams_fuzzer" - fuzz_config_file = "${hdf_ser_aud_path}/test/fuzztest/getextraparams_fuzzer" - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "getextraparams_fuzzer.cpp" ] - - include_dirs = [ - "${hdf_ser_aud_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] - - include_dirs += [ - "include", - "${common_path}/include", - ] - - deps = [ "${hdf_ser_aud_path}:libaudio_manager_daudio_primary_service_1.0" ] - - external_deps = [ "ipc:ipc_core" ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"GetExtraParamsFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":GetExtraParamsFuzzTest" ] -} -############################################################################### diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getextraparams_fuzzer/corpus/init b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getextraparams_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6eb6b7d71f0c70c244e5768d62bee6ac5..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getextraparams_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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. - */ - -FUZZ \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getextraparams_fuzzer/getextraparams_fuzzer.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getextraparams_fuzzer/getextraparams_fuzzer.cpp deleted file mode 100644 index e422c0404b806075a780efe7567443fc1a40230f..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getextraparams_fuzzer/getextraparams_fuzzer.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 "getextraparams_fuzzer.h" - -#include -#include - -#include "audio_adapter_interface_impl.h" -#include "if_system_ability_manager.h" -#include "iservice_registry.h" - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -void GetExtraParamsFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < (sizeof(int32_t)))) { - return; - } - - AudioAdapterDescriptor desc; - auto audioAdapter = std::make_shared(desc); - AudioExtParamKey key = *(reinterpret_cast(data)); - std::string condition(reinterpret_cast(data), size); - std::string value(reinterpret_cast(data), size); - - audioAdapter->GetExtraParams(key, condition, value); -} -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::HDI::DistributedAudio::Audio::V1_0::GetExtraParamsFuzzTest(data, size); - return 0; -} - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getextraparams_fuzzer/getextraparams_fuzzer.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getextraparams_fuzzer/getextraparams_fuzzer.h deleted file mode 100644 index 4b6bfd094497ac3fba5271cca6b12fdc03c75690..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getextraparams_fuzzer/getextraparams_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 GETEXTRAPARAMS_FUZZER_H -#define GETEXTRAPARAMS_FUZZER_H - -#define FUZZ_PROJECT_NAME "getextraparams_fuzzer" - -#endif diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getextraparams_fuzzer/project.xml b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getextraparams_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/getextraparams_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/loadadapter_fuzzer/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/loadadapter_fuzzer/BUILD.gn deleted file mode 100644 index 1b978b2ed053e7966fd02b1f7bef0a533892f84e..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/loadadapter_fuzzer/BUILD.gn +++ /dev/null @@ -1,64 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# 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. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import("../../../../../../../../distributedaudio.gni") - -##############################fuzztest########################################## -ohos_fuzztest("LoadAdapterFuzzTest") { - module_out_path = "distributed_audio/loadadapter_fuzzer" - fuzz_config_file = "${hdf_ser_aud_path}/test/fuzztest/loadadapter_fuzzer" - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "loadadapter_fuzzer.cpp" ] - - include_dirs = [ - "${hdf_ser_aud_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] - - include_dirs += [ - "include", - "${common_path}/include", - ] - - deps = [ "${hdf_ser_aud_path}:libaudio_manager_daudio_primary_service_1.0" ] - - external_deps = [ - "c_utils:utils", - "hdf_core:libhdf_host", - "ipc:ipc_core", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"LoadAdapterFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":LoadAdapterFuzzTest" ] -} -############################################################################### diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/loadadapter_fuzzer/corpus/init b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/loadadapter_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6eb6b7d71f0c70c244e5768d62bee6ac5..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/loadadapter_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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. - */ - -FUZZ \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/loadadapter_fuzzer/loadadapter_fuzzer.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/loadadapter_fuzzer/loadadapter_fuzzer.cpp deleted file mode 100644 index 0501f9b83f796d01746a6dc59dc473e66532d8b7..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/loadadapter_fuzzer/loadadapter_fuzzer.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 "loadadapter_fuzzer.h" - -#include -#include - -#include "audio_manager_interface_impl.h" -#include "if_system_ability_manager.h" -#include "iservice_registry.h" - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -void LoadAdapterFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < (sizeof(int32_t)))) { - return; - } - - AudioAdapterDescriptor descriptor; - sptr adapter = nullptr; - AudioManagerInterfaceImpl::GetAudioManager()->LoadAdapter(descriptor, adapter); -} -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::HDI::DistributedAudio::Audio::V1_0::LoadAdapterFuzzTest(data, size); - return 0; -} - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/loadadapter_fuzzer/loadadapter_fuzzer.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/loadadapter_fuzzer/loadadapter_fuzzer.h deleted file mode 100644 index 47123aea3309a2e5ce62f8addd53d2f8c18c36e7..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/loadadapter_fuzzer/loadadapter_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 LOADADAPTER_FUZZER_H -#define LOADADAPTER_FUZZER_H - -#define FUZZ_PROJECT_NAME "getalladapters_fuzzer" - -#endif diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/loadadapter_fuzzer/project.xml b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/loadadapter_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/loadadapter_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/renderframe_fuzzer/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/renderframe_fuzzer/BUILD.gn deleted file mode 100644 index b1e2ff88bd39b0b655686882595cfa36eb10f593..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/renderframe_fuzzer/BUILD.gn +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# 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. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import("../../../../../../../../distributedaudio.gni") - -##############################fuzztest########################################## -ohos_fuzztest("RenderFrameFuzzTest") { - module_out_path = "distributed_audio/renderframe_fuzzer" - fuzz_config_file = "${hdf_ser_aud_path}/test/fuzztest/renderframe_fuzzer" - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "renderframe_fuzzer.cpp" ] - - include_dirs = [ - "${hdf_ser_aud_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] - - include_dirs += [ - "include", - "${common_path}/include", - ] - - deps = [ "${hdf_ser_aud_path}:libaudio_manager_daudio_primary_service_1.0" ] - - external_deps = [ - "c_utils:utils", - "ipc:ipc_core", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"RenderFrameFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":RenderFrameFuzzTest" ] -} -############################################################################### diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/renderframe_fuzzer/corpus/init b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/renderframe_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6eb6b7d71f0c70c244e5768d62bee6ac5..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/renderframe_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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. - */ - -FUZZ \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/renderframe_fuzzer/project.xml b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/renderframe_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/renderframe_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/renderframe_fuzzer/renderframe_fuzzer.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/renderframe_fuzzer/renderframe_fuzzer.cpp deleted file mode 100644 index 4174b196071b9168cd0de5ba843170398f4843d9..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/renderframe_fuzzer/renderframe_fuzzer.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 "renderframe_fuzzer.h" - -#include -#include - -#include "audio_render_interface_impl.h" -#include "if_system_ability_manager.h" -#include "iservice_registry.h" - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -void RenderFrameFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < (sizeof(uint64_t)))) { - return; - } - - std::string adpName(reinterpret_cast(data), size); - AudioDeviceDescriptor desc; - AudioSampleAttributes attrs; - sptr callback = nullptr; - auto audioRender = std::make_shared(adpName, desc, attrs, callback); - - std::vector frame; - uint64_t replyBytes = *(reinterpret_cast(data)); - audioRender->RenderFrame(frame, replyBytes); -} -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::HDI::DistributedAudio::Audio::V1_0::RenderFrameFuzzTest(data, size); - return 0; -} - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/renderframe_fuzzer/renderframe_fuzzer.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/renderframe_fuzzer/renderframe_fuzzer.h deleted file mode 100644 index c50605544451d8726ce481450daa85be7ea3ad65..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/renderframe_fuzzer/renderframe_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 RENDERFRAME_FUZZER_H -#define RENDERFRAME_FUZZER_H - -#define FUZZ_PROJECT_NAME "renderframe_fuzzer" - -#endif diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/setextraparams_fuzzer/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/setextraparams_fuzzer/BUILD.gn deleted file mode 100644 index 413c9be2b503129ec4fefd48a8c51e1f1a6832bc..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/setextraparams_fuzzer/BUILD.gn +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# 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. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import("../../../../../../../../distributedaudio.gni") - -##############################fuzztest########################################## -ohos_fuzztest("SetExtraParamsFuzzTest") { - module_out_path = "distributed_audio/setextraparams_fuzzer" - fuzz_config_file = "${hdf_ser_aud_path}/test/fuzztest/setextraparams_fuzzer" - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "setextraparams_fuzzer.cpp" ] - - include_dirs = [ - "${hdf_ser_aud_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] - - include_dirs += [ - "include", - "${common_path}/include", - ] - - deps = [ "${hdf_ser_aud_path}:libaudio_manager_daudio_primary_service_1.0" ] - - external_deps = [ "ipc:ipc_core" ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"SetExtraParamsFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":SetExtraParamsFuzzTest" ] -} -############################################################################### diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/setextraparams_fuzzer/corpus/init b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/setextraparams_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6eb6b7d71f0c70c244e5768d62bee6ac5..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/setextraparams_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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. - */ - -FUZZ \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/setextraparams_fuzzer/project.xml b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/setextraparams_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/setextraparams_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/setextraparams_fuzzer/setextraparams_fuzzer.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/setextraparams_fuzzer/setextraparams_fuzzer.cpp deleted file mode 100644 index c6da6a795465b5a3c3b8f85fb31ea99a7a375594..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/setextraparams_fuzzer/setextraparams_fuzzer.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 "setextraparams_fuzzer.h" - -#include -#include - -#include "audio_adapter_interface_impl.h" -#include "if_system_ability_manager.h" -#include "iservice_registry.h" - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -void SetExtraParamsFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < (sizeof(int32_t)))) { - return; - } - - AudioAdapterDescriptor desc; - auto audioAdapter = std::make_shared(desc); - AudioExtParamKey key = *(reinterpret_cast(data)); - std::string condition(reinterpret_cast(data), size); - std::string value(reinterpret_cast(data), size); - - audioAdapter->SetExtraParams(key, condition, value); -} -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::HDI::DistributedAudio::Audio::V1_0::SetExtraParamsFuzzTest(data, size); - return 0; -} - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/setextraparams_fuzzer/setextraparams_fuzzer.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/setextraparams_fuzzer/setextraparams_fuzzer.h deleted file mode 100644 index c6420264bb5ab69dc9ca54f78e00c732f50a5b03..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/setextraparams_fuzzer/setextraparams_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 SETEXTRAPARAMS_FUZZER_H -#define SETEXTRAPARAMS_FUZZER_H - -#define FUZZ_PROJECT_NAME "setextraparams_fuzzer" - -#endif diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/unloadadapter_fuzzer/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/unloadadapter_fuzzer/BUILD.gn deleted file mode 100644 index 49c4d108fc64457e8cc48713739f57bbec1292f3..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/unloadadapter_fuzzer/BUILD.gn +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# 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. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import("../../../../../../../../distributedaudio.gni") - -##############################fuzztest########################################## -ohos_fuzztest("UnloadAdapterFuzzTest") { - module_out_path = "distributed_audio/unloadadapter_fuzzer" - fuzz_config_file = "${hdf_ser_aud_path}/test/fuzztest/unloadadapter_fuzzer" - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "unloadadapter_fuzzer.cpp" ] - - include_dirs = [ - "${hdf_ser_aud_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] - - include_dirs += [ - "include", - "${common_path}/include", - ] - - deps = [ "${hdf_ser_aud_path}:libaudio_manager_daudio_primary_service_1.0" ] - - external_deps = [ - "hdf_core:libhdf_host", - "ipc:ipc_core", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"UnloadAdapterFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":UnloadAdapterFuzzTest" ] -} -############################################################################### diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/unloadadapter_fuzzer/corpus/init b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/unloadadapter_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6eb6b7d71f0c70c244e5768d62bee6ac5..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/unloadadapter_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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. - */ - -FUZZ \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/unloadadapter_fuzzer/project.xml b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/unloadadapter_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/unloadadapter_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/unloadadapter_fuzzer/unloadadapter_fuzzer.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/unloadadapter_fuzzer/unloadadapter_fuzzer.cpp deleted file mode 100644 index 2de0fe95761f04d7d5dd547b96d445770afca827..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/unloadadapter_fuzzer/unloadadapter_fuzzer.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 "unloadadapter_fuzzer.h" - -#include -#include - -#include "audio_manager_interface_impl.h" -#include "if_system_ability_manager.h" -#include "iservice_registry.h" - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -void UnloadAdapterFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < (sizeof(int32_t)))) { - return; - } - - std::string adpName(reinterpret_cast(data), size); - AudioManagerInterfaceImpl::GetAudioManager()->UnloadAdapter(adpName); -} -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::HDI::DistributedAudio::Audio::V1_0::UnloadAdapterFuzzTest(data, size); - return 0; -} - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/unloadadapter_fuzzer/unloadadapter_fuzzer.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/unloadadapter_fuzzer/unloadadapter_fuzzer.h deleted file mode 100644 index 00d51d772333b9840f871efbaf4070760e800a32..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/fuzztest/unloadadapter_fuzzer/unloadadapter_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 UNLOADADAPTER_FUZZER_H -#define UNLOADADAPTER_FUZZER_H - -#define FUZZ_PROJECT_NAME "unloadadapter_fuzzer" - -#endif diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/BUILD.gn deleted file mode 100644 index 72d69d8c9794e8857d2e0e6911b4e473cc116279..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/BUILD.gn +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright (c) 2023 Huawei Device Co., Ltd. -# 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. - -import("//build/ohos.gni") -import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni") -import("../../../../../../../distributedaudio.gni") - -group("hdi_service_audio_test") { - testonly = true - deps = [ - "${hdf_ser_aud_path}/test/unittest/audio_adapter_interface:hdi_service_audio_adapter_test", - "${hdf_ser_aud_path}/test/unittest/audio_capture_interface:hdi_service_audio_capture_test", - "${hdf_ser_aud_path}/test/unittest/audio_manager_interface:hdi_service_audio_manager_test", - "${hdf_ser_aud_path}/test/unittest/audio_render_interface:hdi_service_audio_render_test", - ] -} diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_adapter_interface/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_adapter_interface/BUILD.gn deleted file mode 100644 index 47a93d83562865f11c36a65c08ee94414660ac17..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_adapter_interface/BUILD.gn +++ /dev/null @@ -1,58 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# 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. - -import("//build/ohos.gni") -import("//build/test.gni") -import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni") -import("../../../../../../../../distributedaudio.gni") - -module_out_path = "distributed_audio/hdf_service/hdi_service/audio" - -config("module_private_config") { - visibility = [ ":*" ] - - include_dirs = [ - "${hdf_ser_aud_path}/include", - "${hdf_ser_aud_path}/test/unittest/audio_adapter_interface/include", - "${hdf_ser_aud_path}/test/unittest/audio_test_utils", - "${hdf_ser_aud_ext_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] -} - -## UnitTest hdi_service_adapter_test -ohos_unittest("HDIServiceAudioAdapterTest") { - module_out_path = module_out_path - - sources = [ "${hdf_ser_aud_path}/test/unittest/audio_adapter_interface/src/audio_adapter_interface_impl_test.cpp" ] - - configs = [ ":module_private_config" ] - - public_deps = [ - "${hdf_ser_aud_path}:libaudio_manager_daudio_primary_service_1.0", - "//third_party/googletest:gmock", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "c_utils:utils", - "ipc:ipc_core", - ] -} - -group("hdi_service_audio_adapter_test") { - testonly = true - deps = [ ":HDIServiceAudioAdapterTest" ] -} diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_adapter_interface/include/audio_adapter_interface_impl_test.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_adapter_interface/include/audio_adapter_interface_impl_test.h deleted file mode 100644 index 312e23c2ea766b553e2f16944e71391b005187c4..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_adapter_interface/include/audio_adapter_interface_impl_test.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 OHOS_AUDIO_ADAPTER_INTERFACE_IMPL_TEST_H -#define OHOS_AUDIO_ADAPTER_INTERFACE_IMPL_TEST_H - -#include -#include - -#include - -#include "audio_render_interface_impl.h" -#include "audio_test_utils.h" - -#define private public -#include "audio_adapter_interface_impl.h" -#undef private - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -using OHOS::HDI::DistributedAudio::Audioext::V1_0::DAudioEvent; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioParameter; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::IDAudioCallback; - -class AudioAdapterInterfaceImpTest : public testing::Test { -public: - static void SetUpTestCase(void); - static void TearDownTestCase(void); - void SetUp(); - void TearDown(); - - sptr callback_ = nullptr; - std::shared_ptr AdapterTest_ = nullptr; -}; -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS -#endif // OHOS_AUDIO_ADAPTER_INTERFACE_IMPL_TEST_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_adapter_interface/src/audio_adapter_interface_impl_test.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_adapter_interface/src/audio_adapter_interface_impl_test.cpp deleted file mode 100644 index c2c586a33c4e76e4404da95c4f7df715bd9dbf30..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_adapter_interface/src/audio_adapter_interface_impl_test.cpp +++ /dev/null @@ -1,1183 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 -#include - -#include "audio_adapter_interface_impl_test.h" -#include "daudio_constants.h" - -using namespace testing::ext; -using namespace OHOS::DistributedHardware; -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -void AudioAdapterInterfaceImpTest::SetUpTestCase(void) {} - -void AudioAdapterInterfaceImpTest::TearDownTestCase(void) {} - -void AudioAdapterInterfaceImpTest::SetUp(void) -{ - AudioAdapterDescriptor adaDesc; - AdapterTest_ = std::make_shared(adaDesc); -} - -void AudioAdapterInterfaceImpTest::TearDown(void) -{ - AdapterTest_ = nullptr; -} - -/** - * @tc.name: InitAllPorts_001 - * @tc.desc: Verify the InitAllPorts function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, InitAllPorts_001, TestSize.Level1) -{ - sptr speakerCallback = nullptr; - AdapterTest_->SetSpeakerCallback(speakerCallback); - speakerCallback = new MockIDAudioCallback(); - AdapterTest_->SetSpeakerCallback(speakerCallback); - - sptr micCallback = nullptr; - AdapterTest_->SetMicCallback(micCallback); - micCallback = new MockIDAudioCallback(); - AdapterTest_->SetMicCallback(micCallback); - - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->InitAllPorts()); -} - -/** - * @tc.name: CreateRender_001 - * @tc.desc: Verify the CreateRender function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, CreateRender_001, TestSize.Level1) -{ - AudioDeviceDescriptor devDesc; - AudioSampleAttributes attrs; - sptr render = nullptr; - AdapterTest_->extSpkCallback_ = new MockIDAudioCallback(); - EXPECT_NE(HDF_SUCCESS, AdapterTest_->CreateRender(devDesc, attrs, render)); - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->DestroyRender(devDesc)); - - AdapterTest_->mapAudioDevice_.insert(std::make_pair(PIN_OUT_DAUDIO_DEFAULT, "hello")); - devDesc.pins = PIN_OUT_DAUDIO_DEFAULT; - EXPECT_NE(HDF_SUCCESS, AdapterTest_->CreateRender(devDesc, attrs, render)); - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->DestroyRender(devDesc)); -} - -/** - * @tc.name: DestroyRender_001 - * @tc.desc: Verify the DestroyRender function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, DestroyRender_001, TestSize.Level1) -{ - AudioDeviceDescriptor devDesc; - AudioSampleAttributes attrs; - std::string adpterName = "adbcef"; - sptr callback = new MockIDAudioCallback(); - AdapterTest_->extSpkCallback_ = new MockRevertIDAudioCallback(); - - devDesc.pins = PIN_OUT_DAUDIO_DEFAULT; - AdapterTest_->audioRender_ = new AudioRenderInterfaceImpl(adpterName, devDesc, attrs, callback); - AdapterTest_->spkPinInUse_ = 0; - - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->DestroyRender(devDesc)); - AdapterTest_->spkPinInUse_ = 1; - EXPECT_NE(HDF_FAILURE, AdapterTest_->DestroyRender(devDesc)); -} - -/** - * @tc.name: CreateCapture_001 - * @tc.desc: Verify the CreateCapture function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, CreateCapture_001, TestSize.Level1) -{ - AudioDeviceDescriptor devDesc; - AudioSampleAttributes attrs; - sptr capture = nullptr; - AdapterTest_->extMicCallback_ = new MockIDAudioCallback(); - EXPECT_NE(HDF_SUCCESS, AdapterTest_->CreateCapture(devDesc, attrs, capture)); - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->DestroyCapture(devDesc)); - - AdapterTest_->mapAudioDevice_.insert(std::make_pair(PIN_OUT_DAUDIO_DEFAULT, "hello")); - devDesc.pins = PIN_OUT_DAUDIO_DEFAULT; - EXPECT_NE(HDF_SUCCESS, AdapterTest_->CreateCapture(devDesc, attrs, capture)); - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->DestroyCapture(devDesc)); -} - -/** - * @tc.name: CreateRender_001 - * @tc.desc: Verify the DestroyCapture function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, DestroyCapture_001, TestSize.Level1) -{ - AudioDeviceDescriptor devDesc; - AudioSampleAttributes attrs; - std::string adpterName = "adbcef"; - sptr callback = new MockIDAudioCallback(); - AdapterTest_->extMicCallback_ = new MockRevertIDAudioCallback(); - - devDesc.pins = PIN_OUT_DAUDIO_DEFAULT; - AdapterTest_->audioCapture_ = new AudioCaptureInterfaceImpl(adpterName, devDesc, attrs, callback); - - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->DestroyCapture(devDesc)); - AdapterTest_->micPinInUse_ = 1; - EXPECT_NE(HDF_FAILURE, AdapterTest_->DestroyCapture(devDesc)); -} - -/** - * @tc.name: GetPortCapability_001 - * @tc.desc: Verify the GetPortCapability function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, GetPortCapability_001, TestSize.Level1) -{ - AudioPort port; - AudioPortCapability capability; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->GetPortCapability(port, capability)); -} - -/** - * @tc.name: SetPassthroughMode_001 - * @tc.desc: Verify the SetPassthroughMode function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, SetPassthroughMode_001, TestSize.Level1) -{ - AudioPort port; - AudioPortPassthroughMode mode = AudioPortPassthroughMode::PORT_PASSTHROUGH_LPCM; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->SetPassthroughMode(port, mode)); -} - -/** - * @tc.name: GetPassthroughMode_001 - * @tc.desc: Verify the GetPassthroughMode function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, GetPassthroughMode_001, TestSize.Level1) -{ - AudioPort port; - AudioPortPassthroughMode mode = AudioPortPassthroughMode::PORT_PASSTHROUGH_LPCM; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->GetPassthroughMode(port, mode)); -} - -/** - * @tc.name: GetDeviceStatus_001 - * @tc.desc: Verify the GetDeviceStatus function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, GetDeviceStatus_001, TestSize.Level1) -{ - AudioDeviceStatus sta; - - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->GetDeviceStatus(sta)); -} - -/** - * @tc.name: SetMicMute_001 - * @tc.desc: Verify the SetMicMute function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, SetMicMute_001, TestSize.Level1) -{ - bool muteTmp = true; - bool muteGetted; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->SetMicMute(muteTmp)); - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->GetMicMute(muteGetted)); -} - -/** - * @tc.name: SetVoiceVolume_001 - * @tc.desc: Verify the SetVoiceVolume function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, SetVoiceVolume_001, TestSize.Level1) -{ - float vol = 1.0f; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->SetVoiceVolume(vol)); -} - -/** - * @tc.name: UpdateAudioRoute_001 - * @tc.desc: Verify the UpdateAudioRoute function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, UpdateAudioRoute_001, TestSize.Level1) -{ - AudioRoute route; - int32_t handle = 0; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->UpdateAudioRoute(route, handle)); -} - -/** - * @tc.name: ReleaseAudioRoute_001 - * @tc.desc: Verify the ReleaseAudioRoute function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, ReleaseAudioRoute_001, TestSize.Level1) -{ - int32_t handle = 0; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->ReleaseAudioRoute(handle)); -} - -/** - * @tc.name: SetExtraParams_001 - * @tc.desc: Verify the SetExtraParams function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, SetExtraParams_001, TestSize.Level1) -{ - AudioExtParamKey key = AudioExtParamKey::AUDIO_EXT_PARAM_KEY_NONE; - std::string condition = "hello"; - std::string value = "world"; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->SetExtraParams(key, condition, value)); - key = AudioExtParamKey::AUDIO_EXT_PARAM_KEY_VOLUME; - EXPECT_NE(HDF_SUCCESS, AdapterTest_->SetExtraParams(key, condition, value)); - key = AudioExtParamKey::AUDIO_EXT_PARAM_KEY_LOWPOWER; - EXPECT_NE(HDF_SUCCESS, AdapterTest_->SetExtraParams(key, condition, value)); -} - -/** - * @tc.name: GetExtraParams_001 - * @tc.desc: Verify the GetExtraParams function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, GetExtraParams_001, TestSize.Level1) -{ - AudioExtParamKey key = AudioExtParamKey::AUDIO_EXT_PARAM_KEY_NONE; - std::string condition = "hello"; - std::string value = "world"; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->GetExtraParams(key, condition, value)); -} - -/** - * @tc.name: GetExtraParams_002 - * @tc.desc: Verify the GetExtraParams function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, GetExtraParams_002, TestSize.Level1) -{ - AudioExtParamKey key = AudioExtParamKey::AUDIO_EXT_PARAM_KEY_VOLUME; - std::string condition = "hello"; - std::string value = "1"; - EXPECT_NE(HDF_SUCCESS, AdapterTest_->GetExtraParams(key, condition, value)); -} - -/** - * @tc.name: GetExtraParams_003 - * @tc.desc: Verify the GetExtraParams function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, GetExtraParams_003, TestSize.Level1) -{ - AudioExtParamKey key = AudioExtParamKey::AUDIO_EXT_PARAM_KEY_VOLUME; - std::string condition = "EVENT_TYPE=1;VOLUME_GROUP_ID=2;AUDIO_VOLUME_TYPE=1;"; - std::string value = "1"; - EXPECT_EQ(HDF_FAILURE, AdapterTest_->GetExtraParams(key, condition, value)); -} - -/** - * @tc.name: GetExtraParams_004 - * @tc.desc: Verify the GetExtraParams function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, GetExtraParams_004, TestSize.Level1) -{ - AudioExtParamKey key = AudioExtParamKey::AUDIO_EXT_PARAM_KEY_STATUS; - std::string condition = "hello"; - std::string value = "world"; - EXPECT_EQ(HDF_ERR_INVALID_PARAM, AdapterTest_->GetExtraParams(key, condition, value)); -} - -/** - * @tc.name: RegExtraParamObserver_001 - * @tc.desc: Verify the RegExtraParamObserver function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, RegExtraParamObserver_001, TestSize.Level1) -{ - sptr cbObj = nullptr; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->RegExtraParamObserver(cbObj, 0)); -} - -/** - * @tc.name: RegExtraParamObserver_002 - * @tc.desc: Verify the RegExtraParamObserver function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, RegExtraParamObserver_002, TestSize.Level1) -{ - AdapterTest_->paramCallback_ = new MockIAudioParamCallback(); - sptr cbObj = new MockIAudioParamCallback(); - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->RegExtraParamObserver(cbObj, 0)); -} - -/** - * @tc.name: GetAdapterDesc_002 - * @tc.desc: Verify the GetAdapterDesc function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, GetAdapterDesc_002, TestSize.Level1) -{ - AdapterTest_->mapAudioDevice_.insert(std::make_pair(64, "hello")); - AudioPort port; - port.dir = PORT_OUT_IN; - port.portId = 64; - port.portName = ""; - AdapterTest_->GetAdapterDesc(); - EXPECT_EQ(PORT_OUT_IN, AdapterTest_->adpDescriptor_.ports[0].dir); -} - -/** - * @tc.name: GetDeviceCapabilitys_001 - * @tc.desc: Verify the GetDeviceCapabilitys function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, GetDeviceCapabilitys_001, TestSize.Level1) -{ - uint32_t devId = 88; - std::string caps = "worldcup"; - AdapterTest_->AddAudioDevice(devId, caps); - - EXPECT_EQ(caps, AdapterTest_->GetDeviceCapabilitys(devId)); -} - -/** - * @tc.name: GetDeviceCapabilitys_002 - * @tc.desc: Verify the GetDeviceCapabilitys function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, GetDeviceCapabilitys_002, TestSize.Level1) -{ - uint32_t devId = 88; - std::string caps = "worldcup"; - AdapterTest_->RemoveAudioDevice(devId); - - EXPECT_EQ("", AdapterTest_->GetDeviceCapabilitys(devId)); -} - -/** - * @tc.name: AdapterLoad_001 - * @tc.desc: Verify the AdapterLoad function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, AdapterLoad_001, TestSize.Level1) -{ - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->AdapterLoad()); -} - -/** - * @tc.name: AdapterUnload_001 - * @tc.desc: Verify the AdapterUnload function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, AdapterUnload_001, TestSize.Level1) -{ - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->AdapterUnload()); -} - -/** - * @tc.name: Notify_001 - * @tc.desc: Verify the Notify function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, Notify_001, TestSize.Level1) -{ - DAudioEvent event; - event.type = 3; - event.content = "VOLUME_LEVEL"; - uint32_t devId = 64; - EXPECT_NE(HDF_SUCCESS, AdapterTest_->Notify(devId, event)); -} - -/** - * @tc.name: Notify_002 - * @tc.desc: Verify the Notify function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, Notify_002, TestSize.Level1) -{ - DAudioEvent event; - event.type = 10; - event.content = "FOCUS_CHANGE"; - uint32_t devId = 64; - EXPECT_NE(HDF_SUCCESS, AdapterTest_->Notify(devId, event)); - event.type = 11; - event.content = "RENDER_STATE_CHANG"; - EXPECT_NE(HDF_SUCCESS, AdapterTest_->Notify(devId, event)); - event.type = 7; - event.content = "CLOSE_MIC_RESULT"; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->Notify(devId, event)); - event.type = 9; - event.content = "MIC_CLOSED_STATE"; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->Notify(devId, event)); -} - -/** - * @tc.name: Notify_003 - * @tc.desc: Verify the Notify function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, Notify_003, TestSize.Level1) -{ - DAudioEvent event; - event.type = 4; - event.content = "OPEN_SPK_RESULT"; - uint32_t devId = 64; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->Notify(devId, event)); - event.type = 5; - event.content = "CLOSE_SPK_RESULT"; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->Notify(devId, event)); - event.type = 6; - event.content = "OPEN_MIC_RESULT"; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->Notify(devId, event)); - event.type = 8; - event.content = "SPK_CLOSED"; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->Notify(devId, event)); -} - -/** - * @tc.name: AddAudioDevice_001 - * @tc.desc: Verify the AddAudioDevice function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, AddAudioDevice_001, TestSize.Level1) -{ - uint32_t devId = 64; - std::string caps; - AdapterTest_->mapAudioDevice_.insert(std::make_pair(64, "hello")); - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->AddAudioDevice(devId, caps)); - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->RemoveAudioDevice(devId)); -} - -/** - * @tc.name: AddAudioDevice_002 - * @tc.desc: Verify the AddAudioDevice function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, AddAudioDevice_002, TestSize.Level1) -{ - uint32_t devId = 64; - std::string caps = "hello"; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->AddAudioDevice(devId, caps)); - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->RemoveAudioDevice(devId)); -} - -/** - * @tc.name: RemoveAudioDevice_001 - * @tc.desc: Verify the RemoveAudioDevice function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, RemoveAudioDevice_001, TestSize.Level1) -{ - uint32_t devId = 64; - std::string caps; - AdapterTest_->mapAudioDevice_.insert(std::make_pair(64, "hello")); - AdapterTest_->spkPinInUse_ = 64; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->RemoveAudioDevice(devId)); - AdapterTest_->mapAudioDevice_.insert(std::make_pair(64, "hello")); - AdapterTest_->spkPinInUse_ = 0; - AdapterTest_->micPinInUse_ = 64; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->RemoveAudioDevice(devId)); -} - -/** - * @tc.name: OpenRenderDevice_001 - * @tc.desc: Verify the OpenRenderDevice function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, OpenRenderDevice_001, TestSize.Level1) -{ - AudioDeviceDescriptor devDesc; - AudioSampleAttributes attrs; - AdapterTest_->extSpkCallback_ = new MockIDAudioCallback(); - EXPECT_NE(HDF_SUCCESS, AdapterTest_->OpenRenderDevice(devDesc, attrs)); - AdapterTest_->isSpkOpened_ = true; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->OpenRenderDevice(devDesc, attrs)); -} -/** - * @tc.name: OpenRenderDevice_002 - * @tc.desc: Verify the OpenRenderDevice function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, OpenRenderDevice_002, TestSize.Level1) -{ - AudioDeviceDescriptor devDesc; - AudioSampleAttributes attrs; - AdapterTest_->extSpkCallback_ = new MockRevertIDAudioCallback(); - AdapterTest_->isSpkOpened_ = false; - EXPECT_NE(HDF_SUCCESS, AdapterTest_->OpenRenderDevice(devDesc, attrs)); -} - -/** - * @tc.name: CloseRenderDevice_001 - * @tc.desc: Verify the CloseRenderDevice function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, CloseRenderDevice_001, TestSize.Level1) -{ - AudioDeviceDescriptor devDesc; - AdapterTest_->spkPinInUse_ = 0; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->CloseRenderDevice(devDesc)); - AdapterTest_->spkPinInUse_ = 1; - AdapterTest_->extSpkCallback_ = new MockIDAudioCallback(); - EXPECT_NE(HDF_SUCCESS, AdapterTest_->CloseRenderDevice(devDesc)); - AdapterTest_->extSpkCallback_ = new MockRevertIDAudioCallback(); - EXPECT_NE(HDF_SUCCESS, AdapterTest_->CloseRenderDevice(devDesc)); -} - -/** - * @tc.name: OpenCaptureDevice_001 - * @tc.desc: Verify the OpenCaptureDevice function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, OpenCaptureDevice_001, TestSize.Level1) -{ - AudioDeviceDescriptor devDesc; - AudioSampleAttributes attrs; - AdapterTest_->extMicCallback_ = new MockIDAudioCallback(); - EXPECT_NE(HDF_SUCCESS, AdapterTest_->OpenCaptureDevice(devDesc, attrs)); - AdapterTest_->isMicOpened_ = true; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->OpenCaptureDevice(devDesc, attrs)); -} - -/** - * @tc.name: CloseCaptureDevice_001 - * @tc.desc: Verify the CloseCaptureDevice function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, CloseCaptureDevice_001, TestSize.Level1) -{ - AudioDeviceDescriptor devDesc; - AdapterTest_->extMicCallback_ = new MockIDAudioCallback(); - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->CloseCaptureDevice(devDesc)); - AdapterTest_->micPinInUse_ = 1; - EXPECT_NE(HDF_SUCCESS, AdapterTest_->CloseCaptureDevice(devDesc)); -} - -/** - * @tc.name: GetVolumeGroup_001 - * @tc.desc: Verify the GetVolumeGroup function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, GetVolumeGroup_001, TestSize.Level1) -{ - uint32_t devId = 88; - - AdapterTest_->extMicCallback_ = new MockIDAudioCallback(); - EXPECT_EQ(0, AdapterTest_->GetVolumeGroup(devId)); -} - -/** - * @tc.name: GetInterruptGroup_001 - * @tc.desc: Verify the GetInterruptGroup function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, GetInterruptGroup_001, TestSize.Level1) -{ - uint32_t devId = 88; - - AdapterTest_->extMicCallback_ = new MockIDAudioCallback(); - EXPECT_EQ(0, AdapterTest_->GetInterruptGroup(devId)); -} - -/** - * @tc.name: SetAudioVolume_001 - * @tc.desc: Verify the SetAudioVolume function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, SetAudioVolume_001, TestSize.Level1) -{ - std::string condition = "EVENT_TYPE=4;VOLUME_GROUP_ID=2;AUDIO_VOLUME_TYPE=1;"; - std::string param = "1"; - EXPECT_NE(HDF_SUCCESS, AdapterTest_->SetAudioVolume(condition, param)); - AdapterTest_->extSpkCallback_ = new MockIDAudioCallback(); - EXPECT_NE(HDF_SUCCESS, AdapterTest_->SetAudioVolume(condition, param)); - std::string adpterName = "adbcef"; - AudioDeviceDescriptor desc; - AudioSampleAttributes attrs; - sptr callback = new MockIDAudioCallback(); - - AdapterTest_->audioRender_ = new AudioRenderInterfaceImpl(adpterName, desc, attrs, callback); - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->SetAudioVolume(condition, param)); - param = "0"; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->SetAudioVolume(condition, param)); - param = "-66"; - EXPECT_NE(HDF_SUCCESS, AdapterTest_->SetAudioVolume(condition, param)); - condition = "EVENT_TYPE=1;VOLUME_GROUP_ID=2;AUDIO_VOLUME_TYPE=1;"; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->SetAudioVolume(condition, param)); -} - -/** - * @tc.name: GetAudioVolume_001 - * @tc.desc: Verify the GetAudioVolume function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, GetAudioVolume_001, TestSize.Level1) -{ - std::string adpterName = "adbcef"; - AudioDeviceDescriptor desc; - AudioSampleAttributes attrs; - sptr callback = new MockIDAudioCallback(); - - AdapterTest_->audioRender_ = new AudioRenderInterfaceImpl(adpterName, desc, attrs, callback); - - std::string condition = "EVENT_TYPE=1;VOLUME_GROUP_ID=2;AUDIO_VOLUME_TYPE=1;"; - std::string param = "1"; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->GetAudioVolume(condition, param)); -} - -/** - * @tc.name: GetAudioVolume_002 - * @tc.desc: Verify the GetAudioVolume function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, GetAudioVolume_002, TestSize.Level1) -{ - std::string adpterName = "adbcef"; - AudioDeviceDescriptor desc; - AudioSampleAttributes attrs; - sptr callback = new MockIDAudioCallback(); - - AdapterTest_->audioRender_ = new AudioRenderInterfaceImpl(adpterName, desc, attrs, callback); - - std::string condition = "EVENT_TYPE=3;VOLUME_GROUP_ID=2;AUDIO_VOLUME_TYPE=1;"; - std::string param = "1"; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->GetAudioVolume(condition, param)); -} - -/** - * @tc.name: GetAudioVolume_003 - * @tc.desc: Verify the GetAudioVolume function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, GetAudioVolume_003, TestSize.Level1) -{ - std::string adpterName = "adbcef"; - AudioDeviceDescriptor desc; - AudioSampleAttributes attrs; - sptr callback = new MockIDAudioCallback(); - - AdapterTest_->audioRender_ = new AudioRenderInterfaceImpl(adpterName, desc, attrs, callback); - - std::string condition = "EVENT_TYPE=2;VOLUME_GROUP_ID=2;AUDIO_VOLUME_TYPE=1;"; - std::string param = "1"; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->GetAudioVolume(condition, param)); -} - -/** - * @tc.name: GetAudioVolume_004 - * @tc.desc: Verify the GetAudioVolume function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, GetAudioVolume_004, TestSize.Level1) -{ - std::string adpterName = "adbcef"; - AudioDeviceDescriptor desc; - AudioSampleAttributes attrs; - sptr callback = new MockIDAudioCallback(); - - AdapterTest_->audioRender_ = new AudioRenderInterfaceImpl(adpterName, desc, attrs, callback); - - std::string condition = "EVENT_TYPE=4;VOLUME_GROUP_ID=2;AUDIO_VOLUME_TYPE=1;"; - std::string param = "1"; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->GetAudioVolume(condition, param)); -} - - -/** - * @tc.name: GetAudioVolume_005 - * @tc.desc: Verify the GetAudioVolume function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, GetAudioVolume_005, TestSize.Level1) -{ - std::string adpterName = "adbcef"; - AudioDeviceDescriptor desc; - AudioSampleAttributes attrs; - sptr callback = new MockIDAudioCallback(); - - AdapterTest_->audioRender_ = new AudioRenderInterfaceImpl(adpterName, desc, attrs, callback); - - std::string condition = "EVENT_TYPE=66;VOLUME_GROUP_ID=2;AUDIO_VOLUME_TYPE=1;"; - std::string param = "1"; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->GetAudioVolume(condition, param)); - EXPECT_EQ("0", param); -} - -/** - * @tc.name: GetAudioVolume_006 - * @tc.desc: Verify the GetAudioVolume function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, GetAudioVolume_006, TestSize.Level1) -{ - AdapterTest_->audioRender_ = nullptr; - - std::string condition = "EVENT_TYPE=1;VOLUME_GROUP_ID=2;AUDIO_VOLUME_TYPE=1;"; - std::string param = "1"; - EXPECT_NE(HDF_SUCCESS, AdapterTest_->GetAudioVolume(condition, param)); - EXPECT_EQ("1", param); -} - -/** - * @tc.name: getEventTypeFromCondition_001 - * @tc.desc: Verify the getEventTypeFromCondition function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, getEventTypeFromCondition_001, TestSize.Level1) -{ - std::string condition = "EVENT_TYPE=1;VOLUME_GROUP_ID=2;AUDIO_VOLUME_TYPE=1;"; - auto actualValue = AdapterTest_->getEventTypeFromCondition(condition); - EXPECT_EQ(1, actualValue); -} - -/** - * @tc.name: getEventTypeFromCondition_002 - * @tc.desc: Verify the getEventTypeFromCondition function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, getEventTypeFromCondition_002, TestSize.Level1) -{ - std::string condition = "EVENT_TYPE=12;VOLUME_GROUP_ID=2;AUDIO_VOLUME_TYPE=1;"; - auto actualValue = AdapterTest_->getEventTypeFromCondition(condition); - EXPECT_EQ(12, actualValue); -} - -/** - * @tc.name: HandleVolumeChangeEvent_001 - * @tc.desc: Verify the HandleVolumeChangeEvent function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, HandleVolumeChangeEvent_001, TestSize.Level1) -{ - DAudioEvent event = {HDF_AUDIO_EVENT_VOLUME_CHANGE, - "VOLUME_CHANAGE;AUDIO_STREAM_TYPE=1;VOLUME_LEVEL=1;IS_UPDATEUI=1;VOLUME_GROUP_ID=1;"}; - std::string adpterName = "adbcef"; - AudioDeviceDescriptor desc; - AudioSampleAttributes attrs; - sptr callback = new MockIDAudioCallback(); - - AdapterTest_->audioRender_ = nullptr; - EXPECT_NE(HDF_SUCCESS, AdapterTest_->HandleVolumeChangeEvent(event)); - - AdapterTest_->audioRender_ = new AudioRenderInterfaceImpl(adpterName, desc, attrs, callback); - EXPECT_NE(HDF_SUCCESS, AdapterTest_->HandleVolumeChangeEvent(event)); - AdapterTest_->paramCallback_ = new MockIAudioParamCallback(); - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->HandleVolumeChangeEvent(event)); -} - -/** - * @tc.name: HandleVolumeChangeEvent_002 - * @tc.desc: Verify the HandleVolumeChangeEvent function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, HandleVolumeChangeEvent_002, TestSize.Level1) -{ - DAudioEvent event = {HDF_AUDIO_EVENT_VOLUME_CHANGE, "V"}; - std::string adpterName = "adbcef"; - AudioDeviceDescriptor desc; - AudioSampleAttributes attrs; - sptr callback = new MockIDAudioCallback(); - - AdapterTest_->audioRender_ = new AudioRenderInterfaceImpl(adpterName, desc, attrs, callback); - EXPECT_NE(HDF_SUCCESS, AdapterTest_->HandleVolumeChangeEvent(event)); -} - -/** - * @tc.name: HandleVolumeChangeEvent_003 - * @tc.desc: Verify the HandleVolumeChangeEvent function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, HandleVolumeChangeEvent_003, TestSize.Level1) -{ - DAudioEvent event = {HDF_AUDIO_EVENT_VOLUME_CHANGE, "V"}; - std::string adpterName = "adbcef"; - AudioDeviceDescriptor desc; - AudioSampleAttributes attrs; - sptr callback = new MockIDAudioCallback(); - - AdapterTest_->audioRender_ = new AudioRenderInterfaceImpl(adpterName, desc, attrs, callback); - EXPECT_NE(HDF_SUCCESS, AdapterTest_->HandleVolumeChangeEvent(event)); -} - -/** - * @tc.name: HandleFocusChangeEvent_001 - * @tc.desc: Verify the HandleFocusChangeEvent function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, HandleFocusChangeEvent_001, TestSize.Level1) -{ - DAudioEvent event = {HDF_AUDIO_EVENT_FOCUS_CHANGE, - "INTERRUPT_EVENT;EVENT_TYPE=1;VOLUME_LEVEL=1;FORCE_TYPE=1;HINT_TYPE=1;"}; - - EXPECT_NE(HDF_SUCCESS, AdapterTest_->HandleFocusChangeEvent(event)); - AdapterTest_->paramCallback_ = new MockIAudioParamCallback(); - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->HandleFocusChangeEvent(event)); -} - -/** - * @tc.name: HandleFocusChangeEvent_002 - * @tc.desc: Verify the HandleFocusChangeEvent function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, HandleFocusChangeEvent_002, TestSize.Level1) -{ - DAudioEvent event = {HDF_AUDIO_EVENT_FOCUS_CHANGE, - "INTERRUPT_EVENT;EVENT_TYPE=1;VOLUME_LEVEL=1;FORCE_TYPE=1;HINT_TYPE=1;"}; - - AdapterTest_->paramCallback_ = new MockRevertIAudioParamCallback(); - EXPECT_NE(HDF_SUCCESS, AdapterTest_->HandleFocusChangeEvent(event)); -} - -/** - * @tc.name: HandleRenderStateChangeEvent_001 - * @tc.desc: Verify the HandleRenderStateChangeEvent function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, HandleRenderStateChangeEvent_001, TestSize.Level1) -{ - DAudioEvent event = {HDF_AUDIO_EVENT_RENDER_STATE_CHANGE, - "RENDER_STATE_CHANGE_EVENT;STATE=0;"}; - - EXPECT_NE(HDF_SUCCESS, AdapterTest_->HandleRenderStateChangeEvent(event)); - AdapterTest_->paramCallback_ = new MockIAudioParamCallback(); - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->HandleRenderStateChangeEvent(event)); -} - -/** - * @tc.name: HandleRenderStateChangeEvent_002 - * @tc.desc: Verify the HandleRenderStateChangeEvent function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, HandleRenderStateChangeEvent_002, TestSize.Level1) -{ - DAudioEvent event = {HDF_AUDIO_EVENT_RENDER_STATE_CHANGE, - "RENDER_STATE_CHANGE_EVENT;STATE=0;"}; - - AdapterTest_->paramCallback_ = new MockRevertIAudioParamCallback(); - EXPECT_NE(HDF_SUCCESS, AdapterTest_->HandleRenderStateChangeEvent(event)); -} - -/** - * @tc.name: HandleSANotifyEvent_001 - * @tc.desc: Verify the HandleSANotifyEvent function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, HandleSANotifyEvent_001, TestSize.Level1) -{ - DAudioEvent event = {HDF_AUDIO_EVENT_OPEN_SPK_RESULT, "RENDER_STATE_CHANGE_EVENT"}; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->HandleSANotifyEvent(event)); -} - -/** - * @tc.name: HandleSANotifyEvent_002 - * @tc.desc: Verify the HandleSANotifyEvent function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, HandleSANotifyEvent_002, TestSize.Level1) -{ - DAudioEvent event = {HDF_AUDIO_EVENT_OPEN_SPK_RESULT, HDF_EVENT_RESULT_SUCCESS}; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->HandleSANotifyEvent(event)); -} - -/** - * @tc.name: HandleSANotifyEvent_003 - * @tc.desc: Verify the HandleSANotifyEvent function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, HandleSANotifyEvent_003, TestSize.Level1) -{ - DAudioEvent event = {HDF_AUDIO_EVENT_CLOSE_SPK_RESULT, - HDF_EVENT_RESULT_SUCCESS}; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->HandleSANotifyEvent(event)); - DAudioEvent event1 = {HDF_AUDIO_EVENT_CLOSE_SPK_RESULT, "RENDER_STATE_CHANGE"}; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->HandleSANotifyEvent(event1)); -} - -/** - * @tc.name: HandleSANotifyEvent_004 - * @tc.desc: Verify the HandleSANotifyEvent function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, HandleSANotifyEvent_004, TestSize.Level1) -{ - DAudioEvent event = {HDF_AUDIO_EVENT_OPEN_MIC_RESULT, - HDF_EVENT_RESULT_SUCCESS}; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->HandleSANotifyEvent(event)); - DAudioEvent event1 = {HDF_AUDIO_EVENT_OPEN_MIC_RESULT, "RENDER_STATE_CHANGE"}; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->HandleSANotifyEvent(event1)); -} - -/** - * @tc.name: HandleSANotifyEvent_005 - * @tc.desc: Verify the HandleSANotifyEvent function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, HandleSANotifyEvent_005, TestSize.Level1) -{ - DAudioEvent event = {HDF_AUDIO_EVENT_CLOSE_MIC_RESULT, HDF_EVENT_RESULT_SUCCESS}; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->HandleSANotifyEvent(event)); - DAudioEvent event1 = {HDF_AUDIO_EVENT_CLOSE_MIC_RESULT, "RENDER_STATE_CHANGE"}; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->HandleSANotifyEvent(event1)); -} - -/** - * @tc.name: HandleSANotifyEvent_006 - * @tc.desc: Verify the HandleSANotifyEvent function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, HandleSANotifyEvent_006, TestSize.Level1) -{ - using namespace DistributedHardware; - DAudioEvent event = {-1, "ddd"}; - EXPECT_NE(HDF_SUCCESS, AdapterTest_->HandleSANotifyEvent(event)); -} - -/** - * @tc.name: WaitForSANotify_001 - * @tc.desc: Verify the WaitForSANotify function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, WaitForSANotify_001, TestSize.Level1) -{ - int flag = 1; - std::thread th([&]() { - while (flag) { - std::this_thread::sleep_for(std::chrono::seconds(2)); - AdapterTest_->spkNotifyFlag_ = true; - AdapterTest_->spkWaitCond_.notify_one(); - }}); - AudioDeviceEvent event = EVENT_OPEN_SPK; - AdapterTest_->isSpkOpened_ = false; - EXPECT_EQ(ERR_DH_AUDIO_HDF_OPEN_DEVICE_FAIL, AdapterTest_->WaitForSANotify(event)); - AudioDeviceEvent event1 = EVENT_CLOSE_SPK ; - AdapterTest_->isSpkOpened_ = true; - EXPECT_EQ(ERR_DH_AUDIO_HDF_CLOSE_DEVICE_FAIL, AdapterTest_->WaitForSANotify(event1)); - flag = 0; - if (th.joinable()) { - th.join(); - } -} - -/** - * @tc.name: WaitForSANotify_002 - * @tc.desc: Verify the WaitForSANotify function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, WaitForSANotify_002, TestSize.Level1) -{ - int flag = 1; - std::thread th([&]() { - while (flag) { - std::this_thread::sleep_for(std::chrono::seconds(2)); - AdapterTest_->spkNotifyFlag_ = true; - AdapterTest_->spkWaitCond_.notify_one(); - }}); - AudioDeviceEvent event = EVENT_OPEN_SPK; - AdapterTest_->isSpkOpened_ = true; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->WaitForSANotify(event)); - flag = 0; - if (th.joinable()) { - th.join(); - } -} - -/** - * @tc.name: WaitForSANotify_003 - * @tc.desc: Verify the WaitForSANotify function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, WaitForSANotify_003, TestSize.Level1) -{ - int flag = 1; - std::thread th([&]() { - while (flag) { - std::this_thread::sleep_for(std::chrono::seconds(2)); - AdapterTest_->micNotifyFlag_ = true; - AdapterTest_->micWaitCond_.notify_one(); - }}); - AudioDeviceEvent event = EVENT_OPEN_MIC; - EXPECT_EQ(ERR_DH_AUDIO_HDF_OPEN_DEVICE_FAIL, AdapterTest_->WaitForSANotify(event)); - - AudioDeviceEvent event1 = EVENT_CLOSE_MIC; - AdapterTest_->isMicOpened_ = true; - EXPECT_EQ(ERR_DH_AUDIO_HDF_CLOSE_DEVICE_FAIL, AdapterTest_->WaitForSANotify(event1)); - flag = 0; - if (th.joinable()) { - th.join(); - } -} - -/** - * @tc.name: WaitForSANotify_004 - * @tc.desc: Verify the WaitForSANotify function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, WaitForSANotify_004, TestSize.Level1) -{ - int flag = 1; - std::thread th([&]() { - while (flag) { - std::this_thread::sleep_for(std::chrono::seconds(2)); - AdapterTest_->micNotifyFlag_ = true; - AdapterTest_->micWaitCond_.notify_one(); - }}); - AudioDeviceEvent event = EVENT_OPEN_MIC; - AdapterTest_->isMicOpened_ = true;; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->WaitForSANotify(event)); - flag = 0; - if (th.joinable()) { - th.join(); - } -} - -/** - * @tc.name: WaitForSANotify_005 - * @tc.desc: Verify the WaitForSANotify function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, WaitForSANotify_005, TestSize.Level1) -{ - AudioDeviceEvent event = EVENT_DEV_CLOSED; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->WaitForSANotify(event)); -} - -/** - * @tc.name: HandleDeviceClosed_001 - * @tc.desc: Verify the HandleDeviceClosed function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, HandleDeviceClosed_001, TestSize.Level1) -{ - DAudioEvent event = {HDF_AUDIO_EVENT_SPK_CLOSED, "gtest"}; - - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->HandleDeviceClosed(event)); - AdapterTest_->paramCallback_ = new MockIAudioParamCallback(); - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->HandleDeviceClosed(event)); -} - -/** - * @tc.name: HandleDeviceClosed_002 - * @tc.desc: Verify the HandleDeviceClosed function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, HandleDeviceClosed_002, TestSize.Level1) -{ - DAudioEvent event = {HDF_AUDIO_EVENT_SPK_CLOSED, "gtest"}; - DAudioEvent event1 = {HDF_AUDIO_EVENT_MIC_CLOSED, "gmock"}; - AdapterTest_->paramCallback_ = nullptr; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->HandleDeviceClosed(event)); - - AdapterTest_->isSpkOpened_ = true; - AdapterTest_->isMicOpened_ = true; - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->HandleDeviceClosed(event)); - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->HandleDeviceClosed(event1)); -} - -/** - * @tc.name: HandleDeviceClosed_001 - * @tc.desc: Verify the HandleDeviceClosed function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioAdapterInterfaceImpTest, HandleDeviceClosed_003, TestSize.Level1) -{ - DAudioEvent event = {HDF_AUDIO_EVENT_SPK_CLOSED, "gtest"}; - - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->HandleDeviceClosed(event)); - AdapterTest_->paramCallback_ = new MockRevertIAudioParamCallback(); - EXPECT_EQ(HDF_SUCCESS, AdapterTest_->HandleDeviceClosed(event)); -} - -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_capture_interface/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_capture_interface/BUILD.gn deleted file mode 100644 index cd59d35c8ee205b978f81c61de4145cb76565e99..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_capture_interface/BUILD.gn +++ /dev/null @@ -1,57 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# 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. - -import("//build/ohos.gni") -import("//build/test.gni") -import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni") -import("../../../../../../../../distributedaudio.gni") - -module_out_path = "distributed_audio/hdf_service/hdi_service/audio" - -config("module_private_config") { - visibility = [ ":*" ] - - include_dirs = [ - "include", - "${hdf_ser_aud_path}/include", - "${hdf_ser_aud_path}/test/unittest/audio_test_utils", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] -} - -## UnitTest hdi_service_audio_v1_0_test -ohos_unittest("HDIServiceCaptureTest") { - module_out_path = module_out_path - - sources = [ "${hdf_ser_aud_path}/test/unittest/audio_capture_interface/src/audio_capture_interface_impl_test.cpp" ] - - configs = [ ":module_private_config" ] - - public_deps = [ - "${hdf_ser_aud_path}:libaudio_manager_daudio_primary_service_1.0", - "//third_party/googletest:gmock", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "c_utils:utils", - "ipc:ipc_core", - ] -} - -group("hdi_service_audio_capture_test") { - testonly = true - deps = [ ":HDIServiceCaptureTest" ] -} diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_capture_interface/include/audio_capture_interface_impl_test.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_capture_interface/include/audio_capture_interface_impl_test.h deleted file mode 100644 index 8a2d56253bd824759d6310960340c1367e4f296d..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_capture_interface/include/audio_capture_interface_impl_test.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 OHOS_AUDIO_CAPTURE_INTERFACE_IMPL_TEST_H -#define OHOS_AUDIO_CAPTURE_INTERFACE_IMPL_TEST_H - -#include - -#include -#include - -#include "audio_test_utils.h" -#define private public -#include "audio_capture_interface_impl.h" -#undef private - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -using OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioData; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioParameter; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::IDAudioCallback; - -class AudioCaptureInterfaceImplTest : public testing::Test { -public: - static void SetUpTestCase(void); - static void TearDownTestCase(void); - void SetUp(); - void TearDown(); - - std::string adpName_; - AudioDeviceDescriptor desc_; - AudioSampleAttributes attrs_; - sptr callback_; - std::shared_ptr audioCaptureInterfaceImpl_ = nullptr; -}; -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS -#endif // OHOS_AUDIO_CAPTURE_INTERFACE_IMPL_TEST_H - diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_capture_interface/src/audio_capture_interface_impl_test.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_capture_interface/src/audio_capture_interface_impl_test.cpp deleted file mode 100644 index d23237d34f5c37ea955eecaa4c9c5b9a173a444a..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_capture_interface/src/audio_capture_interface_impl_test.cpp +++ /dev/null @@ -1,482 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 "audio_capture_interface_impl_test.h" - -#include -#include -#include "sys/time.h" - -#include "daudio_constants.h" -#include "daudio_log.h" - -using namespace testing::ext; - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -void AudioCaptureInterfaceImplTest::SetUpTestCase(void) {} - -void AudioCaptureInterfaceImplTest::TearDownTestCase(void) {} - -void AudioCaptureInterfaceImplTest::SetUp(void) -{ - std::string adpName; - AudioDeviceDescriptor desc; - AudioSampleAttributes attrs; - sptr callback; - audioCaptureInterfaceImpl_ = std::make_shared(adpName, desc, attrs, callback); -} - -void AudioCaptureInterfaceImplTest::TearDown(void) -{ - audioCaptureInterfaceImpl_ = nullptr; -} - -/** - * @tc.name: GetCapturePosition_001 - * @tc.desc: Verify the GetCapturePosition function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, GetCapturePosition_001, TestSize.Level1) -{ - uint64_t frames = 0; - AudioTimeStamp time; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->GetCapturePosition(frames, time)); -} - -/** - * @tc.name: CaptureFrame_001 - * @tc.desc: Verify the CaptureFrame function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, CaptureFrame_001, TestSize.Level1) -{ - vector frame; - uint64_t requestBytes = 0; - EXPECT_EQ(HDF_FAILURE, audioCaptureInterfaceImpl_->CaptureFrame(frame, requestBytes)); -} - -/** - * @tc.name: CaptureFrame_002 - * @tc.desc: Verify the CaptureFrame function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, CaptureFrame_002, TestSize.Level1) -{ - vector frame{1, 1, 1, 1, 1}; - uint64_t requestBytes = 0; - audioCaptureInterfaceImpl_->captureStatus_ = CAPTURE_STATUS_START; - audioCaptureInterfaceImpl_->audioExtCallback_ = nullptr; - EXPECT_EQ(HDF_FAILURE, audioCaptureInterfaceImpl_->CaptureFrame(frame, requestBytes)); - audioCaptureInterfaceImpl_->audioExtCallback_ = new MockIDAudioCallback(); - EXPECT_NE(HDF_SUCCESS, audioCaptureInterfaceImpl_->CaptureFrame(frame, requestBytes)); -} - -/** - * @tc.name: CaptureFrame_003 - * @tc.desc: Verify the CaptureFrame function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, CaptureFrame_003, TestSize.Level1) -{ - vector frame; - uint64_t requestBytes = 0; - audioCaptureInterfaceImpl_->captureStatus_ = CAPTURE_STATUS_START; - audioCaptureInterfaceImpl_->audioExtCallback_ = new MockRevertIDAudioCallback(); - EXPECT_EQ(HDF_FAILURE, audioCaptureInterfaceImpl_->CaptureFrame(frame, requestBytes)); -} - -/** - * @tc.name: Start_001 - * @tc.desc: Verify the Start function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, Start_001, TestSize.Level1) -{ - EXPECT_EQ(HDF_FAILURE, audioCaptureInterfaceImpl_->Start()); -} - -/** - * @tc.name: Stop_001 - * @tc.desc: Verify the Stop function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, Stop_001, TestSize.Level1) -{ - EXPECT_EQ(HDF_FAILURE, audioCaptureInterfaceImpl_->Stop()); -} - -/** - * @tc.name: Pause_001 - * @tc.desc: Verify the Pause function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, Pause_001, TestSize.Level1) -{ - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->Pause()); -} - -/** - * @tc.name: Resume_001 - * @tc.desc: Verify the Resume function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, Resume_001, TestSize.Level1) -{ - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->Resume()); -} - -/** - * @tc.name: Flush_001 - * @tc.desc: Verify the Flush function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, Flush_001, TestSize.Level1) -{ - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->Flush()); -} - -/** - * @tc.name: TurnStandbyMode_001 - * @tc.desc: Verify the TurnStandbyMode function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, TurnStandbyMode_001, TestSize.Level1) -{ - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->TurnStandbyMode()); -} - -/** - * @tc.name: AudioDevDump_001 - * @tc.desc: Verify the AudioDevDump function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, AudioDevDump_001, TestSize.Level1) -{ - int32_t range = 0; - int32_t fd = 0; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->AudioDevDump(range, fd)); -} - -/** - * @tc.name: IsSupportsPauseAndResume_001 - * @tc.desc: Verify the IsSupportsPauseAndResume function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, IsSupportsPauseAndResume_001, TestSize.Level1) -{ - bool supportPause = true; - bool supportResume = true; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_-> - IsSupportsPauseAndResume(supportPause, supportResume)); -} - -/** - * @tc.name: CheckSceneCapability_001 - * @tc.desc: Verify the CheckSceneCapability function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, CheckSceneCapability_001, TestSize.Level1) -{ - AudioSceneDescriptor scene; - bool support = false; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->CheckSceneCapability(scene, support)); -} - -/** - * @tc.name: SelectScene_001 - * @tc.desc: Verify the SelectScene function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, SelectScene_001, TestSize.Level1) -{ - AudioSceneDescriptor scene; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->SelectScene(scene)); -} - -/** - * @tc.name: SetMute_001 - * @tc.desc: Verify the SetMute function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, SetMute_001, TestSize.Level1) -{ - bool mute = true; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->SetMute(mute)); -} - -/** - * @tc.name: GetMute_001 - * @tc.desc: Verify the GetMute function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, GetMute_001, TestSize.Level1) -{ - bool mute = true; - - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->GetMute(mute)); -} - -/** - * @tc.name: SetVolume_001 - * @tc.desc: Verify the SetVolume function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, SetVolume_001, TestSize.Level1) -{ - float volume = 0; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->SetVolume(volume)); -} - -/** - * @tc.name: GetVolume_001 - * @tc.desc: Verify the GetVolume function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, GetVolume_001, TestSize.Level1) -{ - float volume = 0; - - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->GetVolume(volume)); -} - -/** - * @tc.name: GetGainThreshold_001 - * @tc.desc: Verify the GetGainThreshold function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, GetGainThreshold_001, TestSize.Level1) -{ - float min = 0; - float max = 0; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->GetGainThreshold(min, max)); -} - -/** - * @tc.name: SetGain_001 - * @tc.desc: Verify the SetGain function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, SetGain_001, TestSize.Level1) -{ - float gain = 0; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->SetGain(gain)); -} - -/** - * @tc.name: GetGain_001 - * @tc.desc: Verify the GetGain function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, GetGain_001, TestSize.Level1) -{ - float gain = 0; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->GetGain(gain)); -} - - -/** - * @tc.name: GetFrameSize_001 - * @tc.desc: Verify the GetFrameSize function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, GetFrameSize_001, TestSize.Level1) -{ - uint64_t size = 0; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->GetFrameSize(size)); -} - -/** - * @tc.name: GetFrameCount_001 - * @tc.desc: Verify the GetFrameCount function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, GetFrameCount_001, TestSize.Level1) -{ - uint64_t count = 0; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->GetFrameCount(count)); -} - -/** - * @tc.name: SetSampleAttributes_001 - * @tc.desc: Verify the SetSampleAttributes function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, SetSampleAttributes_001, TestSize.Level1) -{ - AudioSampleAttributes attrs; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->SetSampleAttributes(attrs)); -} - -/** - * @tc.name: GetSampleAttributes_001 - * @tc.desc: Verify the GetSampleAttributes function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, GetSampleAttributes_001, TestSize.Level1) -{ - AudioSampleAttributes attrs; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->GetSampleAttributes(attrs)); -} - -/** - * @tc.name: GetCurrentChannelId_001 - * @tc.desc: Verify the GetCurrentChannelId function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, GetCurrentChannelId_001, TestSize.Level1) -{ - uint32_t channelId = 0; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->GetCurrentChannelId(channelId)); -} - -/** - * @tc.name: SetExtraParams_001 - * @tc.desc: Verify the SetExtraParams function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, SetExtraParams_001, TestSize.Level1) -{ - std::string keyValueList; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->SetExtraParams(keyValueList)); -} - -/** - * @tc.name: GetExtraParams_001 - * @tc.desc: Verify the GetExtraParams function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, GetExtraParams_001, TestSize.Level1) -{ - std::string keyValueList; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->GetExtraParams(keyValueList)); -} - -/** - * @tc.name: ReqMmapBuffer_001 - * @tc.desc: Verify the ReqMmapBuffer function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, ReqMmapBuffer_001, TestSize.Level1) -{ - int32_t reqSize = 0; - AudioMmapBufferDescriptor desc; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->ReqMmapBuffer(reqSize, desc)); -} - -/** - * @tc.name: GetMmapPosition_001 - * @tc.desc: Verify the GetMmapPosition function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, GetMmapPosition_001, TestSize.Level1) -{ - uint64_t frames = 0; - AudioTimeStamp time; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->GetMmapPosition(frames, time)); -} - -/** - * @tc.name: AddAudioEffect_001 - * @tc.desc: Verify the AddAudioEffect function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, AddAudioEffect_001, TestSize.Level1) -{ - uint64_t effectid = 0; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->AddAudioEffect(effectid)); -} - -/** - * @tc.name: RemoveAudioEffect_001 - * @tc.desc: Verify the RemoveAudioEffect function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, RemoveAudioEffect_001, TestSize.Level1) -{ - uint64_t effectid = 0; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->RemoveAudioEffect(effectid)); -} - -/** - * @tc.name: GetFrameBufferSize_001 - * @tc.desc: Verify the GetFrameBufferSize function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, GetFrameBufferSize_001, TestSize.Level1) -{ - uint64_t bufferSize = 6; - EXPECT_EQ(HDF_SUCCESS, audioCaptureInterfaceImpl_->GetFrameBufferSize(bufferSize)); -} - -/** - * @tc.name: GetCaptureDesc_001 - * @tc.desc: Verify the GetCaptureDesc function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioCaptureInterfaceImplTest, GetCaptureDesc_001, TestSize.Level1) -{ - desc_.portId = 0; - desc_.pins = PIN_NONE; - desc_.desc = "mic"; - auto audioCaptureInterfaceImplTmp = std::make_shared(adpName_, desc_, attrs_, callback_); - AudioDeviceDescriptor descriptorTmp = audioCaptureInterfaceImplTmp->GetCaptureDesc(); - - EXPECT_EQ(desc_.portId, descriptorTmp.portId); - EXPECT_EQ(desc_.pins, descriptorTmp.pins); - EXPECT_EQ(desc_.desc, descriptorTmp.desc); -} -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_manager_interface/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_manager_interface/BUILD.gn deleted file mode 100644 index 138e852eea2a166ee90413be124666d7d9788367..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_manager_interface/BUILD.gn +++ /dev/null @@ -1,58 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# 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. - -import("//build/ohos.gni") -import("//build/test.gni") -import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni") -import("../../../../../../../../distributedaudio.gni") - -module_out_path = "distributed_audio/hdf_service/hdi_service/audio" - -config("module_private_config") { - visibility = [ ":*" ] - - include_dirs = [ - "include", - "${hdf_ser_aud_path}/test/unittest/audio_test_utils", - "${hdf_ser_aud_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] -} - -## UnitTest hdi_service_audio_v1_0_test -ohos_unittest("HDIServiceManagerTest") { - module_out_path = module_out_path - - sources = [ "${hdf_ser_aud_path}/test/unittest/audio_manager_interface/src/audio_manager_interface_impl_test.cpp" ] - - configs = [ ":module_private_config" ] - - public_deps = [ - "${hdf_ser_aud_path}:libaudio_manager_daudio_primary_service_1.0", - "//third_party/googletest:gmock", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "c_utils:utils", - "hdf_core:libhdf_host", - "ipc:ipc_core", - ] -} - -group("hdi_service_audio_manager_test") { - testonly = true - deps = [ ":HDIServiceManagerTest" ] -} diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_manager_interface/include/audio_manager_interface_impl_test.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_manager_interface/include/audio_manager_interface_impl_test.h deleted file mode 100644 index 2e56f26b0c4537a0e256552a2bbe46879b912d63..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_manager_interface/include/audio_manager_interface_impl_test.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 OHOS_AUDIO_MANAGER_INTERFACE_IMPL_TEST_H -#define OHOS_AUDIO_MANAGER_INTERFACE_IMPL_TEST_H - -#include - -#include "hdf_device_desc.h" -#include -#include - -#include "audio_adapter_interface_impl.h" -#include "audio_test_utils.h" - -#define private public -#include "audio_manager_interface_impl.h" -#undef private - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -using OHOS::HDI::DistributedAudio::Audioext::V1_0::DAudioEvent; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::IDAudioCallback; - -class AudioManagerInterfaceImplTest : public testing::Test { -public: - static void SetUpTestCase(void); - static void TearDownTestCase(void); - void SetUp(); - void TearDown(); - - std::shared_ptr audioManagerInterfaceImpl_; -}; -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS -#endif // OHOS_AUDIO_MANAGER_INTERFACE_IMPL_TEST_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_manager_interface/src/audio_manager_interface_impl_test.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_manager_interface/src/audio_manager_interface_impl_test.cpp deleted file mode 100644 index 2a8396ae26c4747446f555257e03cdec8071841e..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_manager_interface/src/audio_manager_interface_impl_test.cpp +++ /dev/null @@ -1,243 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 "audio_manager_interface_impl_test.h" - -#include -#include "hdf_device_object.h" -#include - -#include "daudio_constants.h" -#include "daudio_errcode.h" -#include "daudio_events.h" -#include "daudio_log.h" -#include "daudio_utils.h" - -using namespace testing::ext; -using namespace OHOS::DistributedHardware; - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -void AudioManagerInterfaceImplTest::SetUpTestCase(void) {} - -void AudioManagerInterfaceImplTest::TearDownTestCase(void) {} - -void AudioManagerInterfaceImplTest::SetUp(void) -{ - audioManagerInterfaceImpl_ = std::make_shared(); -} - -void AudioManagerInterfaceImplTest::TearDown(void) -{ - audioManagerInterfaceImpl_ = nullptr; -} - -/** - * @tc.name: GetAllAdapters_001 - * @tc.desc: Verify the GetAllAdapters function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioManagerInterfaceImplTest, GetAllAdapters_001, TestSize.Level1) -{ - std::vector descriptors; - EXPECT_EQ(HDF_SUCCESS, audioManagerInterfaceImpl_->GetAllAdapters(descriptors)); -} - -/** - * @tc.name: LoadAdapter_001 - * @tc.desc: Verify the LoadAdapter and UnloadAdapter function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioManagerInterfaceImplTest, LoadAdapter_001, TestSize.Level1) -{ - std::string adpName = "adpName"; - AudioAdapterDescriptor descriptor; - descriptor.adapterName = adpName; - AudioPort audioPort = { - .dir = PORT_OUT_IN, - .portId = 0, - .portName = "world", - }; - descriptor.ports.push_back(audioPort); - sptr adapter = nullptr; - EXPECT_EQ(HDF_FAILURE, audioManagerInterfaceImpl_->LoadAdapter(descriptor, adapter)); - EXPECT_EQ(HDF_SUCCESS, audioManagerInterfaceImpl_->UnloadAdapter(adpName)); -} - -/** - * @tc.name: ReleaseAudioManagerObject_001 - * @tc.desc: Verify the ReleaseAudioManagerObject function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioManagerInterfaceImplTest, ReleaseAudioManagerObject_001, TestSize.Level1) -{ - EXPECT_EQ(HDF_SUCCESS, audioManagerInterfaceImpl_->ReleaseAudioManagerObject()); -} - -/** - * @tc.name: LoadAdapter_002 - * @tc.desc: Verify the LoadAdapter and UnloadAdapter function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioManagerInterfaceImplTest, LoadAdapter_002, TestSize.Level1) -{ - std::string adpName = "adpName"; - AudioAdapterDescriptor descriptor; - descriptor.adapterName = adpName; - AudioPort audioPort = { - .dir = PORT_OUT_IN, - .portId = 0, - .portName = "world", - }; - descriptor.ports.push_back(audioPort); - sptr adapter = nullptr; - AudioAdapterDescriptor desc; - sptr AudioAdapter = new AudioAdapterInterfaceImpl(desc); - audioManagerInterfaceImpl_->mapAudioAdapter_.insert(std::make_pair(adpName, AudioAdapter)); - EXPECT_EQ(HDF_SUCCESS, audioManagerInterfaceImpl_->LoadAdapter(descriptor, adapter)); - EXPECT_EQ(HDF_SUCCESS, audioManagerInterfaceImpl_->UnloadAdapter(adpName)); -} - -/** - * @tc.name: AddAudioDevice_001 - * @tc.desc: Verify the AddAudioDevice and RemoveAudioDevice function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioManagerInterfaceImplTest, AddAudioDevice_001, TestSize.Level1) -{ - std::string adpName; - uint32_t devId = 0; - std::string caps; - sptr callback = nullptr; - EXPECT_EQ(ERR_DH_AUDIO_HDF_FAIL, audioManagerInterfaceImpl_->AddAudioDevice(adpName, devId, caps, callback)); - EXPECT_EQ(ERR_DH_AUDIO_HDF_INVALID_OPERATION, audioManagerInterfaceImpl_->RemoveAudioDevice(adpName, devId)); -} - -/** - * @tc.name: AddAudioDevice_002 - * @tc.desc: Verify the AddAudioDevice and RemoveAudioDevice function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioManagerInterfaceImplTest, AddAudioDevice_002, TestSize.Level1) -{ - std::string adpName = "adpName"; - uint32_t devId = 1; - std::string caps = "world"; - sptr callback = new MockIDAudioCallback(); - AudioAdapterDescriptor desc; - sptr AudioAdapter = new AudioAdapterInterfaceImpl(desc); - audioManagerInterfaceImpl_->mapAudioAdapter_.insert(std::make_pair(adpName, AudioAdapter)); - EXPECT_EQ(ERR_DH_AUDIO_HDF_FAIL, audioManagerInterfaceImpl_->AddAudioDevice(adpName, devId, caps, callback)); - EXPECT_EQ(DH_SUCCESS, audioManagerInterfaceImpl_->RemoveAudioDevice(adpName, devId)); -} - -/** - * @tc.name: Notify_001 - * @tc.desc: Verify the Notify function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioManagerInterfaceImplTest, Notify_001, TestSize.Level1) -{ - std::string adpName; - uint32_t devId = 0; - DAudioEvent event; - EXPECT_EQ(ERR_DH_AUDIO_HDF_INVALID_OPERATION, audioManagerInterfaceImpl_->Notify(adpName, devId, event)); -} - -/** - * @tc.name: Notify_002 - * @tc.desc: Verify the Notify function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioManagerInterfaceImplTest, Notify_002, TestSize.Level1) -{ - std::string adpName = "adpName"; - uint32_t devId = 0; - DAudioEvent event; - AudioAdapterDescriptor desc; - sptr AudioAdapter = new AudioAdapterInterfaceImpl(desc); - audioManagerInterfaceImpl_->mapAudioAdapter_.insert(std::make_pair(adpName, AudioAdapter)); - EXPECT_EQ(ERR_DH_AUDIO_HDF_FAIL, audioManagerInterfaceImpl_->Notify(adpName, devId, event)); -} - -/** - * @tc.name: NotifyFwk_001 - * @tc.desc: Verify the NotifyFwk function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioManagerInterfaceImplTest, NotifyFwk_001, TestSize.Level1) -{ - DAudioDevEvent event; - EXPECT_EQ(ERR_DH_AUDIO_HDF_FAIL, audioManagerInterfaceImpl_->NotifyFwk(event)); -} - -/** - * @tc.name: CreateAdapter_001 - * @tc.desc: Verify the CreateAdapter function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioManagerInterfaceImplTest, CreateAdapter_001, TestSize.Level1) -{ - std::string adpName; - uint32_t devId = 0; - sptr callback = nullptr; - EXPECT_EQ(ERR_DH_AUDIO_HDF_NULLPTR, audioManagerInterfaceImpl_->CreateAdapter(adpName, devId, callback)); -} - -/** - * @tc.name: CreateAdapter_002 - * @tc.desc: Verify the CreateAdapter function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioManagerInterfaceImplTest, CreateAdapter_002, TestSize.Level1) -{ - std::string adpName = "adpName"; - uint32_t devId = static_cast(PIN_OUT_DAUDIO_DEFAULT); - sptr callback = new MockIDAudioCallback(); - EXPECT_EQ(DH_SUCCESS, audioManagerInterfaceImpl_->CreateAdapter(adpName, devId, callback)); -} - -/** - * @tc.name: SetDeviceObject_002 - * @tc.desc: Verify the SetDeviceObject function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioManagerInterfaceImplTest, SetDeviceObject_002, TestSize.Level1) -{ - struct HdfDeviceObject deviceObject; - audioManagerInterfaceImpl_->SetDeviceObject(&deviceObject); - DAudioDevEvent event; - EXPECT_EQ(ERR_DH_AUDIO_HDF_FAIL, audioManagerInterfaceImpl_->NotifyFwk(event)); -} -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_render_interface/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_render_interface/BUILD.gn deleted file mode 100644 index 5b6e36a8b536a78ae030fae01413741921811a2a..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_render_interface/BUILD.gn +++ /dev/null @@ -1,58 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# 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. - -import("//build/ohos.gni") -import("//build/test.gni") -import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni") -import("../../../../../../../../distributedaudio.gni") - -module_out_path = "distributed_audio/hdf_service/hdi_service/audio" - -config("module_private_config") { - visibility = [ ":*" ] - - include_dirs = [ - "include", - "${hdf_ser_aud_path}/include", - "${hdf_service_path}/hdi_service/audio/v1_0/test/unittest/audio_test_utils", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] -} - -## UnitTest hdi_service_audio_v1_0_test -ohos_unittest("HDIServiceRenderTest") { - module_out_path = module_out_path - - sources = [ "${hdf_ser_aud_path}/test/unittest/audio_render_interface/src/audio_render_interface_impl_test.cpp" ] - - configs = [ ":module_private_config" ] - - public_deps = [ - "${hdf_ser_aud_path}:libaudio_manager_daudio_primary_service_1.0", - "${hdf_service_path}/hdi_service/common:libdaudio_hdf_utils", - "//third_party/googletest:gmock", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "c_utils:utils", - "ipc:ipc_core", - ] -} - -group("hdi_service_audio_render_test") { - testonly = true - deps = [ ":HDIServiceRenderTest" ] -} diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_render_interface/include/audio_render_interface_impl_test.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_render_interface/include/audio_render_interface_impl_test.h deleted file mode 100644 index 5045b0a76753416bf808d19b96575dc21ac70424..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_render_interface/include/audio_render_interface_impl_test.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 OHOS_AUDIO_RENDER_INTERFACE_IMPL_TEST_H -#define OHOS_AUDIO_RENDER_INTERFACE_IMPL_TEST_H - -#include -#include -#include - -#include -#include -#include - -#define private public -#include "audio_render_interface_impl.h" -#undef private - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -using OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioData; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioParameter; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::IDAudioCallback; - -class AudioRenderInterfaceImplTest : public testing::Test { -public: - static void SetUpTestCase(void); - static void TearDownTestCase(void); - void SetUp(); - void TearDown(); - - std::string adpName_; - AudioDeviceDescriptor desc_; - AudioSampleAttributes attrs_; - sptr callback_ = new MockIDAudioCallback(); - std::shared_ptr audioRenderInterfaceImpl_ = nullptr; -}; -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS -#endif // OHOS_AUDIO_RENDER_INTERFACE_IMPL_TEST_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_render_interface/src/audio_render_interface_impl_test.cpp b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_render_interface/src/audio_render_interface_impl_test.cpp deleted file mode 100644 index 03962b7a2f89882fded94ba373395a3b71b82ac0..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_render_interface/src/audio_render_interface_impl_test.cpp +++ /dev/null @@ -1,723 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 "audio_render_interface_impl_test.h" - -#include -#include -#include "sys/time.h" - -#include "daudio_constants.h" -#include "daudio_log.h" - -using namespace testing::ext; - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -void AudioRenderInterfaceImplTest::SetUpTestCase(void) {} - -void AudioRenderInterfaceImplTest::TearDownTestCase(void) {} - -void AudioRenderInterfaceImplTest::SetUp(void) -{ - desc_.portId = 0; - desc_.pins = PIN_NONE; - desc_.desc = "mic"; - audioRenderInterfaceImpl_ = std::make_shared(adpName_, desc_, attrs_, callback_); -} - -void AudioRenderInterfaceImplTest::TearDown(void) -{ - audioRenderInterfaceImpl_ = nullptr; -} - -/** - * @tc.name: GetLatency_001 - * @tc.desc: Verify the GetLatency function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetLatency_001, TestSize.Level1) -{ - uint32_t ms = 12; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->GetLatency(ms)); -} - -/** - * @tc.name: RenderFrame_001 - * @tc.desc: Verify the RenderFrame function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, RenderFrame_001, TestSize.Level1) -{ - std::vector frame; - uint64_t replyBytes = 0; - EXPECT_EQ(HDF_FAILURE, audioRenderInterfaceImpl_->RenderFrame(frame, replyBytes)); -} - -/** - * @tc.name: RenderFrame_002 - * @tc.desc: Verify the RenderFrame function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, RenderFrame_002, TestSize.Level1) -{ - std::vector frame; - uint64_t replyBytes = 0; - audioRenderInterfaceImpl_->renderStatus_ = RENDER_STATUS_START; - audioRenderInterfaceImpl_->audioExtCallback_ = nullptr; - EXPECT_EQ(HDF_FAILURE, audioRenderInterfaceImpl_->RenderFrame(frame, replyBytes)); -} - -/** - * @tc.name: RenderFrame_003 - * @tc.desc: Verify the RenderFrame function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, RenderFrame_003, TestSize.Level1) -{ - std::vector frame; - uint64_t replyBytes = 0; - audioRenderInterfaceImpl_->renderStatus_ = RENDER_STATUS_START; - audioRenderInterfaceImpl_->audioExtCallback_ = new MockRevertIDAudioCallback(); - EXPECT_EQ(HDF_FAILURE, audioRenderInterfaceImpl_->RenderFrame(frame, replyBytes)); -} - -/** - * @tc.name: GetRenderPosition_001 - * @tc.desc: Verify the GetRenderPosition function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetRenderPosition_001, TestSize.Level1) -{ - uint64_t frames = 0; - AudioTimeStamp time; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->GetRenderPosition(frames, time)); -} - -/** - * @tc.name: SetRenderSpeedr_001 - * @tc.desc: Verify the SetRenderSpeed function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, SetRenderSpeed_001, TestSize.Level1) -{ - float speed = 0; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->SetRenderSpeed(speed)); -} - -/** - * @tc.name: GetRenderSpeed_001 - * @tc.desc: Verify the GetRenderSpeed function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetRenderSpeed_001, TestSize.Level1) -{ - float speed; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->GetRenderSpeed(speed)); -} - -/** - * @tc.name: SetChannelMode_001 - * @tc.desc: Verify the SetChannelMode function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, SetChannelMode_001, TestSize.Level1) -{ - AudioChannelMode mode = AudioChannelMode::AUDIO_CHANNEL_NORMAL; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->SetChannelMode(mode)); -} - -/** - * @tc.name: GetChannelMode_001 - * @tc.desc: Verify the GetChannelMode function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetChannelMode_001, TestSize.Level1) -{ - AudioChannelMode mode = AudioChannelMode::AUDIO_CHANNEL_MIX; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->GetChannelMode(mode)); -} - -/** - * @tc.name: RegCallback_001 - * @tc.desc: Verify the RegCallback function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, RegCallback_001, TestSize.Level1) -{ - sptr cbObj = nullptr; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->RegCallback(cbObj, 0)); -} - -/** - * @tc.name: DrainBuffer_001 - * @tc.desc: Verify the DrainBuffer function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, DrainBuffer_001, TestSize.Level1) -{ - AudioDrainNotifyType type = AudioDrainNotifyType::AUDIO_DRAIN_EARLY_MODE; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->DrainBuffer(type)); -} - -/** - * @tc.name: IsSupportsDrain_001 - * @tc.desc: Verify the IsSupportsDrain function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, IsSupportsDrain_001, TestSize.Level1) -{ - bool support = true; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->IsSupportsDrain(support)); -} - -/** - * @tc.name: Start_001 - * @tc.desc: Verify the Start function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, Start_001, TestSize.Level1) -{ - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->Start()); -} - -/** - * @tc.name: Start_002 - * @tc.desc: Verify the Start function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, Start_002, TestSize.Level1) -{ - audioRenderInterfaceImpl_->firstOpenFlag_ = false; - audioRenderInterfaceImpl_->audioExtCallback_ = new MockIDAudioCallback(); - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->Start()); -} - -/** - * @tc.name: Start_003 - * @tc.desc: Verify the Start function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, Start_003, TestSize.Level1) -{ - audioRenderInterfaceImpl_->firstOpenFlag_ = false; - audioRenderInterfaceImpl_->audioExtCallback_ = new MockRevertIDAudioCallback(); - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->Start()); -} - -/** - * @tc.name: Stop_001 - * @tc.desc: Verify the Stop function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, Stop_001, TestSize.Level1) -{ - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->Stop()); - audioRenderInterfaceImpl_->audioExtCallback_ = new MockRevertIDAudioCallback(); - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->Stop()); -} - -/** - * @tc.name: Pause_001 - * @tc.desc: Verify the Pause function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, Pause_001, TestSize.Level1) -{ - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->Pause()); -} - -/** - * @tc.name: Resume_001 - * @tc.desc: Verify the Resume function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, Resume_001, TestSize.Level1) -{ - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->Resume()); -} - -/** - * @tc.name: Flush_001 - * @tc.desc: Verify the Flush function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, Flush_001, TestSize.Level1) -{ - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->Flush()); -} - -/** - * @tc.name: TurnStandbyMode_001 - * @tc.desc: Verify the TurnStandbyMode function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, TurnStandbyMode_001, TestSize.Level1) -{ - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->TurnStandbyMode()); -} - -/** - * @tc.name: AudioDevDump_001 - * @tc.desc: Verify the AudioDevDump function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, AudioDevDump_001, TestSize.Level1) -{ - int32_t range = 0; - int32_t fd = 0; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->AudioDevDump(range, fd)); -} - -/** - * @tc.name: IsSupportsPauseAndResume_001 - * @tc.desc: Verify the IsSupportsPauseAndResume function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, IsSupportsPauseAndResume_001, TestSize.Level1) -{ - bool supportPause = true; - bool supportResume = true; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->IsSupportsPauseAndResume(supportPause, supportResume)); -} - -/** - * @tc.name: CheckSceneCapability_001 - * @tc.desc: Verify the CheckSceneCapability function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, CheckSceneCapability_001, TestSize.Level1) -{ - AudioSceneDescriptor scene; - bool support = true; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->CheckSceneCapability(scene, support)); -} - -/** - * @tc.name: SelectScene_001 - * @tc.desc: Verify the SelectScene function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, SelectScene_001, TestSize.Level1) -{ - AudioSceneDescriptor scene; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->SelectScene(scene)); -} - -/** - * @tc.name: SetMute_001 - * @tc.desc: Verify the SetMute function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, SetMute_001, TestSize.Level1) -{ - bool mute = true; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->SetMute(mute)); -} - -/** - * @tc.name: GetMute_001 - * @tc.desc: Verify the GetMute function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetMute_001, TestSize.Level1) -{ - bool mute = true; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->GetMute(mute)); -} - -/** - * @tc.name: SetVolume_001 - * @tc.desc: Verify the SetVolume function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, SetVolume_001, TestSize.Level1) -{ - float volume = 0; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->SetVolume(volume)); -} - -/** - * @tc.name: GetVolume_001 - * @tc.desc: Verify the GetVolume function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetVolume_001, TestSize.Level1) -{ - float volume = 0; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->GetVolume(volume)); -} - -/** - * @tc.name: GetGainThreshold_001 - * @tc.desc: Verify the GetGainThreshold function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetGainThreshold_001, TestSize.Level1) -{ - float min = 0; - float max = 0; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->GetGainThreshold(min, max)); -} - -/** - * @tc.name: SetGain_001 - * @tc.desc: Verify the SetGain function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, SetGain_001, TestSize.Level1) -{ - float gain = 0; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->SetGain(gain)); -} - -/** - * @tc.name: GetGain_001 - * @tc.desc: Verify the GetGain function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetGain_001, TestSize.Level1) -{ - float gain = 0; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->GetGain(gain)); -} - -/** - * @tc.name: GetFrameSize_001 - * @tc.desc: Verify the GetFrameSize function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetFrameSize_001, TestSize.Level1) -{ - uint64_t size = 0; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->GetFrameSize(size)); -} - -/** - * @tc.name: GetFrameCount_001 - * @tc.desc: Verify the GetFrameCount function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetFrameCount_001, TestSize.Level1) -{ - uint64_t count = 0; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->GetFrameCount(count)); -} - -/** - * @tc.name: SetSampleAttributes_001 - * @tc.desc: Verify the SetSampleAttributes function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, SetSampleAttributes_001, TestSize.Level1) -{ - AudioSampleAttributes attrs = { - .type = AUDIO_IN_MEDIA, - .interleaved = true, - .format = AUDIO_FORMAT_TYPE_PCM_16_BIT, - .sampleRate = 44100, - .channelCount = 2, - .period = 1, - .frameSize = 1, - .isBigEndian = true, - .isSignedData = true, - .startThreshold = 1, - .stopThreshold = 1, - .silenceThreshold = 1, - .streamId = 1, - }; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->SetSampleAttributes(attrs)); -} - -/** - * @tc.name: GetSampleAttributes_001 - * @tc.desc: Verify the GetSampleAttributes function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetSampleAttributes_001, TestSize.Level1) -{ - AudioSampleAttributes attrs; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->GetSampleAttributes(attrs)); -} - -/** - * @tc.name: GetCurrentChannelId_001 - * @tc.desc: Verify the GetCurrentChannelId function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetCurrentChannelId_001, TestSize.Level1) -{ - uint32_t channelId = 0; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->GetCurrentChannelId(channelId)); -} - -/** - * @tc.name: SetExtraParams_001 - * @tc.desc: Verify the SetExtraParams function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, SetExtraParams_001, TestSize.Level1) -{ - std::string keyValueList = "hello"; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->SetExtraParams(keyValueList)); -} - -/** - * @tc.name: GetExtraParams_001 - * @tc.desc: Verify the GetExtraParams function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetExtraParams_001, TestSize.Level1) -{ - std::string keyValueList; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->GetExtraParams(keyValueList)); -} - -/** - * @tc.name: ReqMmapBuffer_001 - * @tc.desc: Verify the ReqMmapBuffer function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, ReqMmapBuffer_001, TestSize.Level1) -{ - int32_t reqSize = 1; - AudioMmapBufferDescriptor desc; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->ReqMmapBuffer(reqSize, desc)); -} - -/** - * @tc.name: GetMmapPosition_001 - * @tc.desc: Verify the GetMmapPosition function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetMmapPosition_001, TestSize.Level1) -{ - uint64_t frame = 0; - AudioTimeStamp time = {1, 1}; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->GetMmapPosition(frame, time)); -} - -/** - * @tc.name: GetFrameBufferSize_001 - * @tc.desc: Verify the GetFrameBufferSize function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetFrameBufferSize_001, TestSize.Level1) -{ - uint64_t bufferSize = 6; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->GetFrameBufferSize(bufferSize)); -} - -/** - * @tc.name: RemoveAudioEffect_001 - * @tc.desc: Verify the RemoveAudioEffect function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, RemoveAudioEffect_001, TestSize.Level1) -{ - uint64_t effectid = 0; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->RemoveAudioEffect(effectid)); -} - - -/** - * @tc.name: AddAudioEffect_001 - * @tc.desc: Verify the AddAudioEffect function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, AddAudioEffect_001, TestSize.Level1) -{ - uint64_t id = 0; - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->AddAudioEffect(id)); -} - -/** - * @tc.name: GetRenderDesc_001 - * @tc.desc: Verify the GetRenderDesc function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetRenderDesc_001, TestSize.Level1) -{ - desc_.portId = 0; - desc_.pins = PIN_NONE; - desc_.desc = "mic"; - auto audioRenderInterfaceImplTmp = std::make_shared(adpName_, desc_, attrs_, callback_); - AudioDeviceDescriptor descriptorTmp = audioRenderInterfaceImplTmp->GetRenderDesc(); - - EXPECT_EQ(desc_.portId, descriptorTmp.portId); - EXPECT_EQ(desc_.pins, descriptorTmp.pins); - EXPECT_EQ(desc_.desc, descriptorTmp.desc); -} - -/** - * @tc.name: GetVolumeInner_001 - * @tc.desc: Verify the GetVolumeInner function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetVolumeInner_001, TestSize.Level1) -{ - uint32_t volTmp = 2; - uint32_t volTmpMin = 2; - uint32_t volTmpMax = 10; - - audioRenderInterfaceImpl_->SetVolumeInner(volTmp); - audioRenderInterfaceImpl_->SetVolumeRangeInner(volTmpMax, volTmpMin); - EXPECT_EQ(audioRenderInterfaceImpl_->vol_, audioRenderInterfaceImpl_->GetVolumeInner()); -} - -/** - * @tc.name: GetMaxVolumeInner_001 - * @tc.desc: Verify the GetMaxVolumeInner function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetMaxVolumeInner_001, TestSize.Level1) -{ - uint32_t volTmpMin = 2; - uint32_t volTmpMax = 10; - - audioRenderInterfaceImpl_->SetVolumeRangeInner(volTmpMax, volTmpMin); - EXPECT_EQ(audioRenderInterfaceImpl_->volMax_, audioRenderInterfaceImpl_->GetMaxVolumeInner()); -} - -/** - * @tc.name: GetMinVolumeInner_001 - * @tc.desc: Verify the GetMinVolumeInner function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetMinVolumeInner_001, TestSize.Level1) -{ - uint32_t volTmpMin = 2; - uint32_t volTmpMax = 10; - - audioRenderInterfaceImpl_->SetVolumeRangeInner(volTmpMax, volTmpMin); - EXPECT_EQ(audioRenderInterfaceImpl_->volMin_, audioRenderInterfaceImpl_->GetMinVolumeInner()); -} - -/** - * @tc.name: GetFadeRate_001 - * @tc.desc: Verify the GetFadeRate function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetFadeRate_001, TestSize.Level1) -{ - uint32_t currentIndex = 2; - const uint32_t durationIndex = 5; - - float fadeRate = audioRenderInterfaceImpl_->GetFadeRate(currentIndex, durationIndex); - EXPECT_LE(0, fadeRate); - EXPECT_GE(0.5f, fadeRate); -} - -/** - * @tc.name: GetFadeRate_002 - * @tc.desc: Verify the GetFadeRate function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetFadeRate_002, TestSize.Level1) -{ - uint32_t currentIndex = 3; - const uint32_t durationIndex = 5; - - float fadeRate = audioRenderInterfaceImpl_->GetFadeRate(currentIndex, durationIndex); - EXPECT_LE(0.5f, fadeRate); - EXPECT_GE(1.0f, fadeRate); -} - -/** - * @tc.name: GetFadeRate_002 - * @tc.desc: Verify the GetFadeRate function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, GetFadeRate_003, TestSize.Level1) -{ - uint32_t currentIndex = 6; - const uint32_t durationIndex = 5; - - float fadeRate = audioRenderInterfaceImpl_->GetFadeRate(currentIndex, durationIndex); - EXPECT_EQ(1.0f, fadeRate); -} - -/** - * @tc.name: FadeInProcess_001 - * @tc.desc: Verify the FadeInProcess function. - * @tc.type: FUNC - * @tc.require: AR000H0E6H - */ -HWTEST_F(AudioRenderInterfaceImplTest, FadeInProcess_001, TestSize.Level1) -{ - const uint32_t durationFrame = 10; - const size_t frameLength = 4096; - int8_t* frameData = new int8_t[frameLength]; - - EXPECT_EQ(HDF_SUCCESS, audioRenderInterfaceImpl_->FadeInProcess(durationFrame, frameData, frameLength)); -} -} // V1_0 -} // Audio -} // Distributedaudio -} // HDI -} // OHOS diff --git a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_test_utils/audio_test_utils.h b/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_test_utils/audio_test_utils.h deleted file mode 100644 index bc57b7db4ad093b47b48c2df829f84cc46974f3d..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio/v1_0/test/unittest/audio_test_utils/audio_test_utils.h +++ /dev/null @@ -1,536 +0,0 @@ -/* - * Copyright (c) 2023 Huawei Device Co., Ltd. - * 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 OHOS_DAUDIO_TEST_UTILS_H -#define OHOS_DAUDIO_TEST_UTILS_H - -#include -#include - -#include -#include -#include -#include - -#include "daudio_errcode.h" - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audio { -namespace V1_0 { -using OHOS::HDI::DistributedAudio::Audioext::V1_0::DAudioEvent; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioData; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::AudioParameter; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::CurrentTime; -using OHOS::HDI::DistributedAudio::Audioext::V1_0::IDAudioCallback; -using OHOS::HDI::DistributedAudio::Audio::V1_0::IAudioCallback; -class MockIDAudioCallback : public IDAudioCallback { -public: - MockIDAudioCallback() {} - ~MockIDAudioCallback() {} - - int32_t OpenDevice(const std::string &adpName, int32_t devId) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t CloseDevice(const std::string &adpName, int32_t devId) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t SetParameters(const std::string &adpName, int32_t devId, const AudioParameter ¶m) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t NotifyEvent(const std::string &adpName, int32_t devId, const DAudioEvent &event) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t WriteStreamData(const std::string &adpName, int32_t devId, const AudioData &data) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t ReadStreamData(const std::string &adpName, int32_t devId, AudioData &data) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t ReadMmapPosition(const std::string &adpName, int32_t devId, uint64_t &frames, - CurrentTime &time) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t RefreshAshmemInfo(const std::string &adpName, int32_t devId, int fd, - int32_t ashmemLength, int32_t lengthPerTrans) override - { - return DistributedHardware::DH_SUCCESS; - } -}; - -class MockIAudioRender : public IAudioRender { -public: - MockIAudioRender() {} - ~MockIAudioRender() {} - - int32_t GetLatency(uint32_t &ms) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t RenderFrame(const std::vector &frame, uint64_t &replyBytes) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetRenderPosition(uint64_t &frames, AudioTimeStamp &time) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t SetRenderSpeed(float speed) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetRenderSpeed(float &speed) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t SetChannelMode(AudioChannelMode mode) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetChannelMode(AudioChannelMode &mode) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t RegCallback(const sptr &audioCallback, int8_t cookie) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t DrainBuffer(AudioDrainNotifyType &type) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t IsSupportsDrain(bool &support) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t CheckSceneCapability(const AudioSceneDescriptor &scene, bool &supported) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t SelectScene(const AudioSceneDescriptor &scene) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t SetMute(bool mute) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetMute(bool &mute) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t SetVolume(float volume) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetVolume(float &volume) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetGainThreshold(float &min, float &max) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t SetGain(float gain) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetGain(float &gain) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetFrameSize(uint64_t &size) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetFrameCount(uint64_t &count) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t SetSampleAttributes(const AudioSampleAttributes &attrs) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetSampleAttributes(AudioSampleAttributes &attrs) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetCurrentChannelId(uint32_t &channelId) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t SetExtraParams(const std::string &keyValueList) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetExtraParams(std::string &keyValueList) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t ReqMmapBuffer(int32_t reqSize, AudioMmapBufferDescriptor &desc) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetMmapPosition(uint64_t &frames, AudioTimeStamp &time) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t AddAudioEffect(uint64_t effectid) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t RemoveAudioEffect(uint64_t effectid) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetFrameBufferSize(uint64_t &bufferSize) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t Start() override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t Stop() override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t Pause() override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t Resume() override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t Flush() override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t TurnStandbyMode() override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t AudioDevDump(int32_t range, int32_t fd) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t IsSupportsPauseAndResume(bool &supportPause, bool &supportResume) override - { - return DistributedHardware::DH_SUCCESS; - } -}; - -class MockIAudioCapture : public IAudioCapture { -public: - MockIAudioCapture() {} - ~MockIAudioCapture() {} - - int32_t CaptureFrame(std::vector &frame, uint64_t requestBytes) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetCapturePosition(uint64_t &frames, AudioTimeStamp &time) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t CheckSceneCapability(const AudioSceneDescriptor &scene, bool &supported) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t SelectScene(const AudioSceneDescriptor &scene) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t SetMute(bool mute) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetMute(bool &mute) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t SetVolume(float volume) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetVolume(float &volume) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetGainThreshold(float &min, float &max) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetGain(float &gain) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t SetGain(float gain) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetFrameSize(uint64_t &size) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetFrameCount(uint64_t &count) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t SetSampleAttributes(const AudioSampleAttributes &attrs) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetSampleAttributes(AudioSampleAttributes &attrs) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetCurrentChannelId(uint32_t &channelId) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t SetExtraParams(const std::string &keyValueList) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetExtraParams(std::string &keyValueList) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t ReqMmapBuffer(int32_t reqSize, AudioMmapBufferDescriptor &desc) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetMmapPosition(uint64_t &frames, AudioTimeStamp &time) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t AddAudioEffect(uint64_t effectid) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t RemoveAudioEffect(uint64_t effectid) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t GetFrameBufferSize(uint64_t &bufferSize) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t Start() override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t Stop() override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t Pause() override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t Resume() override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t Flush() override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t TurnStandbyMode() override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t AudioDevDump(int32_t range, int32_t fd) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t IsSupportsPauseAndResume(bool &supportPause, bool &supportResume) override - { - return DistributedHardware::DH_SUCCESS; - } -}; - -class MockIAudioParamCallback : public IAudioCallback { -public: - MockIAudioParamCallback() {} - ~MockIAudioParamCallback() {} - - int32_t RenderCallback(AudioCallbackType type, int8_t &reserved, int8_t &cookie) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t ParamCallback(AudioExtParamKey key, const std::string& condition, const std::string& value, - int8_t &reserved, int8_t &cookie) override - { - return DistributedHardware::DH_SUCCESS; - } -}; - -class MockRevertIAudioParamCallback : public IAudioCallback { -public: - MockRevertIAudioParamCallback() {} - ~MockRevertIAudioParamCallback() {} - - int32_t RenderCallback(AudioCallbackType type, int8_t &reserved, int8_t &cookie) override - { - return DistributedHardware::ERR_DH_AUDIO_HDF_FAIL; - } - - int32_t ParamCallback(AudioExtParamKey key, const std::string& condition, const std::string& value, - int8_t &reserved, int8_t &cookie) override - { - return DistributedHardware::ERR_DH_AUDIO_HDF_FAIL; - } -}; - -class MockRevertIDAudioCallback : public IDAudioCallback { -public: - MockRevertIDAudioCallback() {} - ~MockRevertIDAudioCallback() {} - - int32_t OpenDevice(const std::string &adpName, int32_t devId) override - { - return DistributedHardware::ERR_DH_AUDIO_HDF_FAIL; - } - - int32_t CloseDevice(const std::string &adpName, int32_t devId) override - { - return DistributedHardware::ERR_DH_AUDIO_HDF_FAIL; - } - - int32_t SetParameters(const std::string &adpName, int32_t devId, const AudioParameter ¶m) override - { - return DistributedHardware::ERR_DH_AUDIO_HDF_FAIL; - } - - int32_t NotifyEvent(const std::string &adpName, int32_t devId, const DAudioEvent &event) override - { - return DistributedHardware::ERR_DH_AUDIO_HDF_FAIL; - } - - int32_t WriteStreamData(const std::string &adpName, int32_t devId, const AudioData &data) override - { - return DistributedHardware::ERR_DH_AUDIO_HDF_FAIL; - } - - int32_t ReadStreamData(const std::string &adpName, int32_t devId, AudioData &data) override - { - return DistributedHardware::ERR_DH_AUDIO_HDF_FAIL; - } - - int32_t ReadMmapPosition(const std::string &adpName, int32_t devId, uint64_t &frames, - CurrentTime &time) override - { - return DistributedHardware::DH_SUCCESS; - } - - int32_t RefreshAshmemInfo(const std::string &adpName, int32_t devId, int fd, - int32_t ashmemLength, int32_t lengthPerTrans) override - { - return DistributedHardware::DH_SUCCESS; - } -}; -} // V1_0 -} // AudioExt -} // Distributedaudio -} // HDI -} // OHOS -#endif // OHOS_DAUDIO_TEST_UTILS_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/BUILD.gn deleted file mode 100644 index a8c2b3b77e63095be1d10571fa76f05eec9604a3..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/BUILD.gn +++ /dev/null @@ -1,81 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# 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. - -import("//build/ohos.gni") -import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni") -import("../../../../../distributedaudio.gni") - -ohos_shared_library("libdaudio_manager_daudio_ext_service_1.0") { - include_dirs = [ - "${hdf_ser_aud_ext_path}/include", - "${hdf_ser_aud_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] - - sources = [ "./src/daudio_manager_interface_impl.cpp" ] - - public_deps = [ - "${hdf_interfaces_path}/audioext/v1_0:libdaudioext_stub_1.0", - "${hdf_ser_aud_path}:libaudio_manager_daudio_primary_service_1.0", - "${hdf_service_path}/hdi_service/common:libdaudio_hdf_utils", - ] - - external_deps = [ - "c_utils:utils", - "hdf_core:libhdf_host", - "hdf_core:libhdf_utils", - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_single", - ] - - defines = [ - "HI_LOG_ENABLE", - "LOG_DOMAIN=0xD004100", - ] - - install_images = [ chipset_base_dir ] - subsystem_name = "hdf" - part_name = "drivers_peripheral_distributed_audio" -} - -ohos_shared_library("libdaudio_ext_driver") { - include_dirs = [ "${hdf_ser_aud_ext_path}/include" ] - - sources = [ "./src/daudio_manager_driver.cpp" ] - - deps = [ "${hdf_ser_aud_ext_path}:libdaudio_manager_daudio_ext_service_1.0" ] - - external_deps = [ - "c_utils:utils", - "hdf_core:libhdf_host", - "hdf_core:libhdf_ipc_adapter", - "hdf_core:libhdf_utils", - "hdf_core:libhdi", - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_single", - ] - - shlib_type = "hdi" - install_images = [ chipset_base_dir ] - subsystem_name = "hdf" - part_name = "drivers_peripheral_distributed_audio" -} - -group("hdf_daudio_ext_service") { - deps = [ - ":libdaudio_ext_driver", - ":libdaudio_manager_daudio_ext_service_1.0", - ] -} diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/include/daudio_manager_interface_impl.h b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/include/daudio_manager_interface_impl.h deleted file mode 100644 index f2592ad5d2eaf66010c1879968ac1c86b39e8823..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/include/daudio_manager_interface_impl.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. - * 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 OHOS_DAUDIO_MANAGER_INTERDFACE_IMPL_H -#define OHOS_DAUDIO_MANAGER_INTERDFACE_IMPL_H - -#include - -#include - -#include "audio_manager_interface_impl.h" - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audioext { -namespace V1_0 { -using OHOS::HDI::DistributedAudio::Audioext::V1_0::DAudioEvent; - -class DAudioManagerInterfaceImpl : public IDAudioManager { -public: - static DAudioManagerInterfaceImpl *GetDAudioManager() - { - if (dAudioMgr_ == nullptr) { - std::unique_lock mgr_mutex(mgrMtx_); - if (dAudioMgr_ == nullptr) { - dAudioMgr_ = new DAudioManagerInterfaceImpl(); - } - } - return dAudioMgr_; - } - - ~DAudioManagerInterfaceImpl() override; - - int32_t RegisterAudioDevice(const std::string &adpName, int32_t devId, const std::string &capability, - const sptr &callbackObj) override; - - int32_t UnRegisterAudioDevice(const std::string &adpName, int32_t devId) override; - - int32_t NotifyEvent(const std::string &adpName, int32_t devId, const DAudioEvent &event) override; - -private: - DAudioManagerInterfaceImpl(); - - DAudioManagerInterfaceImpl(const DAudioManagerInterfaceImpl &); - - DAudioManagerInterfaceImpl &operator = (const DAudioManagerInterfaceImpl &); - -private: - class Deletor { - public: - ~Deletor() - { - if (DAudioManagerInterfaceImpl::dAudioMgr_ != nullptr) { - delete DAudioManagerInterfaceImpl::dAudioMgr_; - } - }; - }; - static Deletor deletor; - -private: - OHOS::HDI::DistributedAudio::Audio::V1_0::AudioManagerInterfaceImpl *audioMgr_; - static DAudioManagerInterfaceImpl *dAudioMgr_; - static std::mutex mgrMtx_; -}; -} // V1_0 -} // AudioExt -} // Distributedaudio -} // HDI -} // OHOS -#endif // OHOS_DAUDIO_MANAGER_INTERDFACE_IMPL_H diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/src/daudio_manager_driver.cpp b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/src/daudio_manager_driver.cpp deleted file mode 100644 index 0ee8fef662747c3f6f1310a7f2cf498e7f4bebf4..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/src/daudio_manager_driver.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 -#include -#include -#include -#include - -using namespace OHOS::HDI::DistributedAudio::Audioext::V1_0; - -struct HdfDAudioManagerHost { - struct IDeviceIoService ioService; - OHOS::sptr stub; -}; - -static int32_t DAudioManagerDriverDispatch(struct HdfDeviceIoClient *client, int cmdId, struct HdfSBuf *data, - struct HdfSBuf *reply) -{ - auto *hdfDAudioManagerHost = CONTAINER_OF(client->device->service, struct HdfDAudioManagerHost, ioService); - - OHOS::MessageParcel *dataParcel = nullptr; - OHOS::MessageParcel *replyParcel = nullptr; - OHOS::MessageOption option; - - if (SbufToParcel(data, &dataParcel) != HDF_SUCCESS) { - HDF_LOGE("%{public}s:invalid data sbuf object to dispatch", __func__); - return HDF_ERR_INVALID_PARAM; - } - if (SbufToParcel(reply, &replyParcel) != HDF_SUCCESS) { - HDF_LOGE("%{public}s:invalid reply sbuf object to dispatch", __func__); - return HDF_ERR_INVALID_PARAM; - } - - return hdfDAudioManagerHost->stub->SendRequest(cmdId, *dataParcel, *replyParcel, option); -} - -int HdfDAudioManagerDriverInit(struct HdfDeviceObject *deviceObject) -{ - HDF_LOGI("Hdf daudio manager driver init."); - HdfDeviceSetClass(deviceObject, DEVICE_CLASS_AUDIO); - return HDF_SUCCESS; -} - -int HdfDAudioManagerDriverBind(struct HdfDeviceObject *deviceObject) -{ - HDF_LOGI("Hdf daudio manager driver bind."); - - auto *hdfDAudioManagerHost = new (std::nothrow) HdfDAudioManagerHost; - if (hdfDAudioManagerHost == nullptr) { - HDF_LOGE("%{public}s: failed to create create HdfDAudioManagerHost object", __func__); - return HDF_FAILURE; - } - - hdfDAudioManagerHost->ioService.Dispatch = DAudioManagerDriverDispatch; - hdfDAudioManagerHost->ioService.Open = NULL; - hdfDAudioManagerHost->ioService.Release = NULL; - - auto serviceImpl = IDAudioManager::Get("daudio_ext_service", true); - if (serviceImpl == nullptr) { - HDF_LOGE("%{public}s: failed to get of implement service", __func__); - delete hdfDAudioManagerHost; - return HDF_FAILURE; - } - - hdfDAudioManagerHost->stub = OHOS::HDI::ObjectCollector::GetInstance().GetOrNewObject(serviceImpl, - IDAudioManager::GetDescriptor()); - if (hdfDAudioManagerHost->stub == nullptr) { - HDF_LOGE("%{public}s: failed to get stub object", __func__); - delete hdfDAudioManagerHost; - return HDF_FAILURE; - } - - deviceObject->service = &hdfDAudioManagerHost->ioService; - return HDF_SUCCESS; -} - -void HdfDAudioManagerDriverRelease(struct HdfDeviceObject *deviceObject) -{ - HDF_LOGI("Hdf daudio manager driver release."); - if (deviceObject->service == nullptr) { - HDF_LOGE("HdfDAudioManagerDriverRelease not initted"); - return; - } - - auto *hdfDAudioManagerHost = CONTAINER_OF(deviceObject->service, struct HdfDAudioManagerHost, ioService); - delete hdfDAudioManagerHost; -} - -struct HdfDriverEntry g_daudiomanagerDriverEntry = { - .moduleVersion = 1, - .moduleName = "daudioext", - .Bind = HdfDAudioManagerDriverBind, - .Init = HdfDAudioManagerDriverInit, - .Release = HdfDAudioManagerDriverRelease, -}; - -#ifndef __cplusplus -extern "C" { -#endif -HDF_INIT(g_daudiomanagerDriverEntry); -#ifndef __cplusplus -} -#endif diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/src/daudio_manager_interface_impl.cpp b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/src/daudio_manager_interface_impl.cpp deleted file mode 100644 index 9a492118de65d9818494d5f21d8f7c60a6f11159..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/src/daudio_manager_interface_impl.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. - * 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 "daudio_manager_interface_impl.h" - -#include - -#include "daudio_errcode.h" -#include "daudio_log.h" -#include "daudio_utils.h" - -#undef DH_LOG_TAG -#define DH_LOG_TAG "DAudioManagerInterfaceImpl" - -using namespace OHOS::DistributedHardware; -using namespace OHOS::HDI::DistributedAudio::Audio::V1_0; - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audioext { -namespace V1_0 { -DAudioManagerInterfaceImpl *DAudioManagerInterfaceImpl::dAudioMgr_ = nullptr; -std::mutex DAudioManagerInterfaceImpl::mgrMtx_; -extern "C" IDAudioManager *DAudioManagerImplGetInstance(void) -{ - return DAudioManagerInterfaceImpl::GetDAudioManager(); -} - -DAudioManagerInterfaceImpl::DAudioManagerInterfaceImpl() -{ - DHLOGD("Distributed audio ext manager constructed."); - audioMgr_ = AudioManagerInterfaceImpl::GetAudioManager(); -} - -DAudioManagerInterfaceImpl::~DAudioManagerInterfaceImpl() -{ - DHLOGD("Distributed audio ext manager destructed."); -} - -int32_t DAudioManagerInterfaceImpl::RegisterAudioDevice(const std::string &adpName, int32_t devId, - const std::string &capability, const sptr &callbackObj) -{ - DHLOGI("Register audio device, name: %s, device: %d.", GetAnonyString(adpName).c_str(), devId); - if (audioMgr_ == nullptr) { - DHLOGE("Audio manager is null."); - return HDF_FAILURE; - } - - int32_t ret = audioMgr_->AddAudioDevice(adpName, devId, capability, callbackObj); - if (ret != DH_SUCCESS) { - DHLOGE("Register audio device failed, ret = %d", ret); - return HDF_FAILURE; - } - - DHLOGI("Register audio device success."); - return HDF_SUCCESS; -} - -int32_t DAudioManagerInterfaceImpl::UnRegisterAudioDevice(const std::string &adpName, int32_t devId) -{ - DHLOGI("UnRegister audio device, name: %s, device: %d.", GetAnonyString(adpName).c_str(), devId); - if (audioMgr_ == nullptr) { - DHLOGE("Audio manager is null."); - return HDF_FAILURE; - } - - int32_t ret = audioMgr_->RemoveAudioDevice(adpName, devId); - if (ret != DH_SUCCESS) { - DHLOGE("UnRegister audio devcie failed. ret = %d", ret); - return HDF_FAILURE; - } - - DHLOGI("UnRegister audio device success."); - return HDF_SUCCESS; -} - -int32_t DAudioManagerInterfaceImpl::NotifyEvent(const std::string &adpName, int32_t devId, const DAudioEvent &event) -{ - if (audioMgr_ == nullptr) { - DHLOGE("Audio manager is null."); - return HDF_FAILURE; - } - DHLOGI("Notify event. event type = %d", event.type); - int32_t ret = audioMgr_->Notify(adpName, devId, event); - if (ret != DH_SUCCESS) { - DHLOGE("Notify audio event failed. ret = %d", ret); - return HDF_FAILURE; - } - - return HDF_SUCCESS; -} -} // V1_0 -} // AudioExt -} // Daudio -} // HDI -} // OHOS diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/notifyevent_fuzzer/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/notifyevent_fuzzer/BUILD.gn deleted file mode 100644 index 5d3043c1367657570c8b0b9921132d7876035c11..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/notifyevent_fuzzer/BUILD.gn +++ /dev/null @@ -1,68 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# 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. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import("../../../../../../../../distributedaudio.gni") - -##############################fuzztest########################################## -ohos_fuzztest("NotifyEventFuzzTest") { - module_out_path = "distributed_audio/notifyevent_fuzzer" - fuzz_config_file = "${hdf_ser_aud_ext_path}/test/fuzztest/notifyevent_fuzzer" - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "notifyevent_fuzzer.cpp" ] - - include_dirs = [ - "${hdf_ser_aud_ext_path}/include", - "${hdf_ser_aud_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] - - include_dirs += [ - "include", - "${common_path}/include", - ] - - deps = [ - "${hdf_interfaces_path}/audioext/v1_0:libdaudioext_stub_1.0", - "${hdf_ser_aud_ext_path}:libdaudio_manager_daudio_ext_service_1.0", - ] - - external_deps = [ - "c_utils:utils", - "hdf_core:libhdf_host", - "ipc:ipc_core", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"NotifyEventFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":NotifyEventFuzzTest" ] -} -############################################################################### diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/notifyevent_fuzzer/corpus/init b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/notifyevent_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6eb6b7d71f0c70c244e5768d62bee6ac5..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/notifyevent_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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. - */ - -FUZZ \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/notifyevent_fuzzer/notifyevent_fuzzer.cpp b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/notifyevent_fuzzer/notifyevent_fuzzer.cpp deleted file mode 100644 index 3dcd510b8d048636ed37d008718cd1e34e12f225..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/notifyevent_fuzzer/notifyevent_fuzzer.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 "notifyevent_fuzzer.h" - -#include -#include - -#include "daudio_manager_interface_impl.h" -#include "if_system_ability_manager.h" -#include "iservice_registry.h" - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audioext { -namespace V1_0 { -void NotifyEventFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < (sizeof(int32_t)))) { - return; - } - - std::string adpName(reinterpret_cast(data), size); - int32_t devId = *(reinterpret_cast(data)); - DAudioEvent event = { - .type = *(reinterpret_cast(data)), - .content = std::string(reinterpret_cast(data), size), - }; - - DAudioManagerInterfaceImpl::GetDAudioManager()->NotifyEvent(adpName, devId, event); -} -} // V1_0 -} // AudioExt -} // Distributedaudio -} // HDI -} // OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::HDI::DistributedAudio::Audioext::V1_0::NotifyEventFuzzTest(data, size); - return 0; -} - diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/notifyevent_fuzzer/notifyevent_fuzzer.h b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/notifyevent_fuzzer/notifyevent_fuzzer.h deleted file mode 100644 index 6bf2cbcce55e48e27e573764b13e350bd4df5314..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/notifyevent_fuzzer/notifyevent_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 NOTIFYEVENT_FUZZER_H -#define NOTIFYEVENT_FUZZER_H - -#define FUZZ_PROJECT_NAME "notifyevent_fuzzer" - -#endif diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/notifyevent_fuzzer/project.xml b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/notifyevent_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/notifyevent_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/registeraudiodevice_fuzzer/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/registeraudiodevice_fuzzer/BUILD.gn deleted file mode 100644 index e77961e3e1d82caad5fd406338231e8738e865a6..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/registeraudiodevice_fuzzer/BUILD.gn +++ /dev/null @@ -1,69 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# 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. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import("../../../../../../../../distributedaudio.gni") - -##############################fuzztest########################################## -ohos_fuzztest("RegisterAudioDeviceFuzzTest") { - module_out_path = "distributed_audio/registeraudiodevice_fuzzer" - fuzz_config_file = - "${hdf_ser_aud_ext_path}/test/fuzztest/registeraudiodevice_fuzzer" - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "registeraudiodevice_fuzzer.cpp" ] - - include_dirs = [ - "${hdf_ser_aud_ext_path}/include", - "${hdf_ser_aud_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] - - include_dirs += [ - "include", - "${common_path}/include", - ] - - deps = [ - "${hdf_interfaces_path}/audioext/v1_0:libdaudioext_stub_1.0", - "${hdf_ser_aud_ext_path}:libdaudio_manager_daudio_ext_service_1.0", - ] - - external_deps = [ - "c_utils:utils", - "hdf_core:libhdf_host", - "ipc:ipc_core", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"RegisterAudioDeviceFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":RegisterAudioDeviceFuzzTest" ] -} -############################################################################### diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/registeraudiodevice_fuzzer/corpus/init b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/registeraudiodevice_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6eb6b7d71f0c70c244e5768d62bee6ac5..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/registeraudiodevice_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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. - */ - -FUZZ \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/registeraudiodevice_fuzzer/project.xml b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/registeraudiodevice_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/registeraudiodevice_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/registeraudiodevice_fuzzer/registeraudiodevice_fuzzer.cpp b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/registeraudiodevice_fuzzer/registeraudiodevice_fuzzer.cpp deleted file mode 100644 index 5f20565b5adcc20b96bbc3702e986658fb5ca010..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/registeraudiodevice_fuzzer/registeraudiodevice_fuzzer.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 "registeraudiodevice_fuzzer.h" - -#include -#include - -#include "daudio_manager_interface_impl.h" -#include "if_system_ability_manager.h" -#include "iservice_registry.h" - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audioext { -namespace V1_0 { -void RegisterAudioDeviceFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < (sizeof(int32_t)))) { - return; - } - - std::string adpName(reinterpret_cast(data), size); - int32_t devId = *(reinterpret_cast(data)); - std::string capability(reinterpret_cast(data), size); - sptr callbackObj = nullptr; - - DAudioManagerInterfaceImpl::GetDAudioManager()->RegisterAudioDevice(adpName, devId, capability, callbackObj); -} -} // V1_0 -} // AudioExt -} // Distributedaudio -} // HDI -} // OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::HDI::DistributedAudio::Audioext::V1_0::RegisterAudioDeviceFuzzTest(data, size); - return 0; -} - diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/registeraudiodevice_fuzzer/registeraudiodevice_fuzzer.h b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/registeraudiodevice_fuzzer/registeraudiodevice_fuzzer.h deleted file mode 100644 index 4fa65886db9c37f7e7f68fb82a251a6d594da850..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/registeraudiodevice_fuzzer/registeraudiodevice_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 REGISTERAUDIODEVICE_FUZZER_H -#define REGISTERAUDIODEVICE_FUZZER_H - -#define FUZZ_PROJECT_NAME "registeraudiodevice_fuzzer" - -#endif diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/unregisteraudiodevice_fuzzer/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/unregisteraudiodevice_fuzzer/BUILD.gn deleted file mode 100644 index 2f587e4d148cd19272d0e3fd7da6dd399d842462..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/unregisteraudiodevice_fuzzer/BUILD.gn +++ /dev/null @@ -1,69 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# 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. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import("../../../../../../../../distributedaudio.gni") - -##############################fuzztest########################################## -ohos_fuzztest("UnRegisterAudioDeviceFuzzTest") { - module_out_path = "distributed_audio/unregisteraudiodevice_fuzzer" - fuzz_config_file = - "${hdf_ser_aud_ext_path}/test/fuzztest/unregisteraudiodevice_fuzzer" - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - sources = [ "unregisteraudiodevice_fuzzer.cpp" ] - - include_dirs = [ - "${hdf_ser_aud_ext_path}/include", - "${hdf_ser_aud_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] - - include_dirs += [ - "include", - "${common_path}/include", - ] - - deps = [ - "${hdf_interfaces_path}/audioext/v1_0:libdaudioext_stub_1.0", - "${hdf_ser_aud_ext_path}:libdaudio_manager_daudio_ext_service_1.0", - ] - - external_deps = [ - "c_utils:utils", - "hdf_core:libhdf_host", - "ipc:ipc_core", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"UnRegisterAudioDeviceFuzzTest\"", - "LOG_DOMAIN=0xD004100", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":UnRegisterAudioDeviceFuzzTest" ] -} -############################################################################### diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/unregisteraudiodevice_fuzzer/corpus/init b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/unregisteraudiodevice_fuzzer/corpus/init deleted file mode 100644 index 8eb5a7d6eb6b7d71f0c70c244e5768d62bee6ac5..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/unregisteraudiodevice_fuzzer/corpus/init +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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. - */ - -FUZZ \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/unregisteraudiodevice_fuzzer/project.xml b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/unregisteraudiodevice_fuzzer/project.xml deleted file mode 100644 index 6e8ad2cfde8f8bda4beb6cabbe7efd8bc3c54eec..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/unregisteraudiodevice_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/unregisteraudiodevice_fuzzer/unregisteraudiodevice_fuzzer.cpp b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/unregisteraudiodevice_fuzzer/unregisteraudiodevice_fuzzer.cpp deleted file mode 100644 index d64a5dd75950879345e111b5da5e59cf0686b6a1..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/unregisteraudiodevice_fuzzer/unregisteraudiodevice_fuzzer.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 "unregisteraudiodevice_fuzzer.h" - -#include -#include - -#include "daudio_manager_interface_impl.h" -#include "if_system_ability_manager.h" -#include "iservice_registry.h" - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audioext { -namespace V1_0 { -void UnRegisterAudioDeviceFuzzTest(const uint8_t* data, size_t size) -{ - if ((data == nullptr) || (size < (sizeof(int32_t)))) { - return; - } - - std::string adpName(reinterpret_cast(data), size); - int32_t devId = *(reinterpret_cast(data)); - DAudioManagerInterfaceImpl::GetDAudioManager()->UnRegisterAudioDevice(adpName, devId); -} -} // V1_0 -} // AudioExt -} // Distributedaudio -} // HDI -} // OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) -{ - /* Run your code on data */ - OHOS::HDI::DistributedAudio::Audioext::V1_0::UnRegisterAudioDeviceFuzzTest(data, size); - return 0; -} - diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/unregisteraudiodevice_fuzzer/unregisteraudiodevice_fuzzer.h b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/unregisteraudiodevice_fuzzer/unregisteraudiodevice_fuzzer.h deleted file mode 100644 index 03b8e4fdd3cedbfb90171640e926effc557088f6..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/fuzztest/unregisteraudiodevice_fuzzer/unregisteraudiodevice_fuzzer.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 UNREGISTERAUDIODEVICE_FUZZER_H -#define UNREGISTERAUDIODEVICE_FUZZER_H - -#define FUZZ_PROJECT_NAME "unregisteraudiodevice_fuzzer" - -#endif diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/unittest/BUILD.gn b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/unittest/BUILD.gn deleted file mode 100644 index c3b4fbe62b394ab0c294c80da4217725911c100b..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/unittest/BUILD.gn +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# 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. - -import("//build/ohos.gni") -import("//build/test.gni") -import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni") -import("../../../../../../../distributedaudio.gni") - -module_out_path = "distributed_audio/hdf_service/hdi_service/audio_ext" - -config("module_private_config") { - visibility = [ ":*" ] - - include_dirs = [ - "${hdf_ser_aud_path}/include", - "${hdf_ser_aud_ext_path}/test/unittest/include", - "${hdf_ser_aud_ext_path}/include", - "${hdf_service_path}/hdi_service/common/include", - "${hdf_service_path}/hdi_service/common/log/include", - "${hdf_service_path}/hdi_service/common/utils/include", - ] -} - -## UnitTest hdi_service_audio_ext_v1_0_test -ohos_unittest("HDIServiceDaudioExtTest") { - module_out_path = module_out_path - - sources = [ "${hdf_ser_aud_ext_path}/test/unittest/src/daudio_manager_interface_impl_test.cpp" ] - - configs = [ ":module_private_config" ] - - public_deps = [ - "${hdf_interfaces_path}/audioext/v1_0:libdaudioext_stub_1.0", - "${hdf_ser_aud_ext_path}:libdaudio_manager_daudio_ext_service_1.0", - "//third_party/googletest:gmock", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "c_utils:utils", - "hdf_core:libhdf_host", - "ipc:ipc_core", - ] -} - -group("hdi_service_audio_ext_test") { - testonly = true - deps = [ ":HDIServiceDaudioExtTest" ] -} diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/unittest/include/daudio_manager_interface_impl_test.h b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/unittest/include/daudio_manager_interface_impl_test.h deleted file mode 100644 index 3ac3bb496fa55c2cd5dbc7cbd2aa5c0e39ea1000..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/unittest/include/daudio_manager_interface_impl_test.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 OHOS_DAUDIO_MANAGER_INTERFACE_IMPL_TEST_H -#define OHOS_DAUDIO_MANAGER_INTERFACE_IMPL_TEST_H - -#include - -#include "daudio_test_utils.h" -#define private public -#include "daudio_manager_interface_impl.h" -#undef private - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audioext { -namespace V1_0 { -class DAudioManagerInterfaceImplTest : public testing::Test { -public: - static void SetUpTestCase(void); - static void TearDownTestCase(void); - void SetUp(); - void TearDown(); - - sptr callbackObj_ = nullptr; -}; -} // V1_0 -} // AudioExt -} // Distributedaudio -} // HDI -} // OHOS -#endif // OHOS_DAUDIO_MANAGER_INTERFACE_IMPL_TEST_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/unittest/include/daudio_test_utils.h b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/unittest/include/daudio_test_utils.h deleted file mode 100644 index e54fc355038c100f01d8063df9c9fc263f35b3a3..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/unittest/include/daudio_test_utils.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 OHOS_DAUDIO_TEST_UTILS_H -#define OHOS_DAUDIO_TEST_UTILS_H - -#include - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audioext { -namespace V1_0 { -class MockIDAudioCallback : public IDAudioCallback { -public: - virtual ~MockIDAudioCallback() = default; - - int32_t OpenDevice(const std::string &adpName, int32_t devId) override - { - return 0; - } - - int32_t CloseDevice(const std::string &adpName, int32_t devId) override - { - return 0; - } - - int32_t SetParameters(const std::string &adpName, int32_t devId, const AudioParameter ¶m) override - { - return 0; - } - - int32_t NotifyEvent(const std::string &adpName, int32_t devId, const DAudioEvent &event) override - { - return 0; - } - - int32_t WriteStreamData(const std::string &adpName, int32_t devId, const AudioData &data) override - { - return 0; - } - - int32_t ReadStreamData(const std::string &adpName, int32_t devId, AudioData &data) override - { - return 0; - } - - int32_t ReadMmapPosition(const std::string &adpName, int32_t devId, uint64_t &frames, - CurrentTime &time) override - { - return 0; - } - - int32_t RefreshAshmemInfo(const std::string &adpName, int32_t devId, int fd, - int32_t ashmemLength, int32_t lengthPerTrans) override - { - return 0; - } -}; -} // V1_0 -} // AudioExt -} // Distributedaudio -} // HDI -} // OHOS -#endif // OHOS_DAUDIO_TEST_UTILS_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/unittest/src/daudio_manager_interface_impl_test.cpp b/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/unittest/src/daudio_manager_interface_impl_test.cpp deleted file mode 100644 index 81516e178a1a0a46119182635b7836908fef6be7..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/audio_ext/v1_0/test/unittest/src/daudio_manager_interface_impl_test.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 "daudio_manager_interface_impl_test.h" - -using namespace testing::ext; - -namespace OHOS { -namespace HDI { -namespace DistributedAudio { -namespace Audioext { -namespace V1_0 { -void DAudioManagerInterfaceImplTest::SetUpTestCase(void) {} - -void DAudioManagerInterfaceImplTest::TearDownTestCase(void) {} - -void DAudioManagerInterfaceImplTest::SetUp(void) -{ - callbackObj_ = new MockIDAudioCallback; -} - -void DAudioManagerInterfaceImplTest::TearDown(void) {} - -/** - * @tc.name: RegisterAudioDevice_001 - * @tc.desc: Verify the RegisterAudioDevice function. - * @tc.type: FUNC - * @tc.require: AR000H0E6G - */ -HWTEST_F(DAudioManagerInterfaceImplTest, RegisterAudioDevice_001, TestSize.Level1) -{ - std::string adpName; - std::string capability; - int32_t devId = 11; - EXPECT_NE(HDF_SUCCESS, - DAudioManagerInterfaceImpl::GetDAudioManager()->RegisterAudioDevice(adpName, devId, capability, callbackObj_)); - EXPECT_NE(HDF_SUCCESS, DAudioManagerInterfaceImpl::GetDAudioManager()->UnRegisterAudioDevice(adpName, devId)); -} - -/** - * @tc.name: RegisterAudioDevice_002 - * @tc.desc: Verify the RegisterAudioDevice function. - * @tc.type: FUNC - * @tc.require: AR000H0E6G - */ -HWTEST_F(DAudioManagerInterfaceImplTest, RegisterAudioDevice_002, TestSize.Level1) -{ - std::string adpName = "hello"; - std::string capability = "world"; - int32_t devId = 64; - EXPECT_NE(HDF_SUCCESS, - DAudioManagerInterfaceImpl::GetDAudioManager()->RegisterAudioDevice(adpName, devId, capability, callbackObj_)); - EXPECT_NE(HDF_SUCCESS, DAudioManagerInterfaceImpl::GetDAudioManager()->UnRegisterAudioDevice(adpName, devId)); -} - -/** - * @tc.name: UnRegisterAudioDevice_001 - * @tc.desc: Verify the UnRegisterAudioDevice function. - * @tc.type: FUNC - * @tc.require: AR000H0E6G - */ -HWTEST_F(DAudioManagerInterfaceImplTest, UnRegisterAudioDevice_001, TestSize.Level1) -{ - std::string unadpName; - int32_t devId = 11; - EXPECT_NE(HDF_SUCCESS, DAudioManagerInterfaceImpl::GetDAudioManager()->UnRegisterAudioDevice(unadpName, devId)); -} - -/** - * @tc.name: NotifyEvent_001 - * @tc.desc: Verify the NotifyEvent function. - * @tc.type: FUNC - * @tc.require: AR000H0E6G - */ -HWTEST_F(DAudioManagerInterfaceImplTest, NotifyEvent_001, TestSize.Level1) -{ - std::string adpName = "hello"; - int32_t devId = 11; - DAudioEvent event; - EXPECT_EQ(HDF_FAILURE, DAudioManagerInterfaceImpl::GetDAudioManager()->NotifyEvent(adpName, devId, event)); -} - -/** - * @tc.name: NotifyEvent_002 - * @tc.desc: Verify the NotifyEvent function. - * @tc.type: FUNC - * @tc.require: AR000H0E6G - */ -HWTEST_F(DAudioManagerInterfaceImplTest, NotifyEvent_002, TestSize.Level1) -{ - std::string adpName = "hello"; - int32_t devId = 64; - DAudioEvent event; - event.type = 15; - event.content = "hello_world"; - EXPECT_NE(HDF_SUCCESS, DAudioManagerInterfaceImpl::GetDAudioManager()->NotifyEvent(adpName, devId, event)); -} -} // V1_0 -} // AudioExt -} // Daudio -} // HDI -} // OHOS diff --git a/hdf_service/distributed_audio/hdi_service/common/BUILD.gn b/hdf_service/distributed_audio/hdi_service/common/BUILD.gn deleted file mode 100644 index 42b4b1a739be874c74323eb61f7a9bdffaa725d3..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/common/BUILD.gn +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright (c) 2022 Huawei Device Co., Ltd. -# 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. - -import("//build/ohos.gni") -import("//drivers/hdf_core/adapter/uhdf2/uhdf.gni") - -ohos_shared_library("libdaudio_hdf_utils") { - include_dirs = [ - "include", - "log/include", - "utils/include", - ] - - sources = [ - "log/src/daudio_log.cpp", - "utils/src/daudio_utils.cpp", - ] - - external_deps = [ - "c_utils:utils", - "hdf_core:libhdf_utils", - "hiviewdfx_hilog_native:libhilog", - ] - - defines = [ - "HI_LOG_ENABLE", - "LOG_DOMAIN=0xD004100", - ] - - install_images = [ chipset_base_dir ] - subsystem_name = "hdf" - part_name = "drivers_peripheral_distributed_audio" -} diff --git a/hdf_service/distributed_audio/hdi_service/common/include/daudio_constants.h b/hdf_service/distributed_audio/hdi_service/common/include/daudio_constants.h deleted file mode 100644 index 56ef2fb665220d022343983c07033282a4374139..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/common/include/daudio_constants.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. - * 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 OHOS_DAUDIO_CONSTANTS_H -#define OHOS_DAUDIO_CONSTANTS_H - -#include - -namespace OHOS { -namespace DistributedHardware { -// Distributed Auido Parameters -const std::string KEY_AUDIOPORT_DIR = "portdir"; -const std::string KEY_AUDIOFORMAT = "format"; -const std::string KEY_AUDIOCHANNELMASK = "channel"; -const std::string KEY_AUDIOSAMPLERATE = "samplerate"; - -const std::string VALUE_AUDIOPORT_DIR_IN = "portdirin"; -const std::string VALUE_AUDIOPORT_DIR_OUT = "portdirout"; -const std::string VALUE_AUDIOPORT_DIR_INOUT = "portdirinout"; - -const std::string DEVICE_TYPE_OUTPUT_DEFAULT = "0"; -const std::string DEVICE_TYPE_INPUT_DEFAULT = "1"; - -const std::string VOLUME_GROUP_ID = "VOLUME_GROUP_ID"; -const std::string INTERRUPT_GROUP_ID = "INTERRUPT_GROUP_ID"; - -// Distributed Auido Parameters -const std::string VOLUME_LEVEL = "VOLUME_LEVEL"; -const std::string VOLUME_EVENT_TYPE = "EVENT_TYPE"; -const std::string MAX_VOLUME_LEVEL = "MAX_VOLUME_LEVEL"; -const std::string MIN_VOLUME_LEVEL = "MIN_VOLUME_LEVEL"; -const std::string STREAM_MUTE_STATUS = "STREAM_MUTE_STATUS"; - -const std::string HDF_EVENT_RESULT_SUCCESS = "DH_SUCCESS"; -const std::string HDF_EVENT_RESULT_FAILED = "DH_FAILED"; - -const std::string HDF_EVENT_RESTART = "restart"; -const std::string HDF_EVENT_PAUSE = "pause"; - -constexpr int32_t AUDIO_DEVICE_TYPE_UNKNOWN = 0; -constexpr int32_t AUDIO_DEVICE_TYPE_SPEAKER = 1; -constexpr int32_t AUDIO_DEVICE_TYPE_MIC = 2; - -constexpr uint32_t DAUDIO_FADE_NORMALIZATION_FACTOR = 2; -constexpr uint32_t DAUDIO_FADE_POWER_NUM = 2; -constexpr uint32_t DAUDIO_FADE_MAXIMUM_VALUE = 2; - -constexpr uint32_t VOLUME_GROUP_ID_DEFAULT = 0; -constexpr uint32_t INTERRUPT_GROUP_ID_DEFAULT = 0; - -constexpr uint32_t AUDIO_SAMPLE_RATE_DEFAULT = 4800; -constexpr uint32_t AUDIO_CHANNEL_COUNT_DEFAULT = 2; -constexpr uint32_t AUDIO_FORMAT_DEFAULT = 16; - -constexpr int32_t MILLISECOND_PER_SECOND = 1000; -constexpr uint32_t DEFAULT_AUDIO_DATA_SIZE = 4096; -constexpr int64_t AUDIO_OFFSET_FRAME_NUM = 10; - -constexpr uint32_t AUDIO_DEFAULT_MAX_VOLUME_LEVEL = 15; -constexpr uint32_t AUDIO_DEFAULT_MIN_VOLUME_LEVEL = 0; - -constexpr int32_t DAUDIO_MAX_ASHMEM_LEN = 100000; -constexpr int32_t DAUDIO_MIN_ASHMEM_LEN = 10; -} // DistributeHardware -} // OHOS -#endif // OHOS_DAUDIO_CONSTANTS_H diff --git a/hdf_service/distributed_audio/hdi_service/common/include/daudio_errcode.h b/hdf_service/distributed_audio/hdi_service/common/include/daudio_errcode.h deleted file mode 100644 index 02b742dad91d46238f40bf0637ed8664f03163fe..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/common/include/daudio_errcode.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 OHOS_DAUDIO_ERRCODE_H -#define OHOS_DAUDIO_ERRCODE_H - -namespace OHOS { -namespace DistributedHardware { -enum DAudioErrorCode { - DH_SUCCESS = 0, - // Distributed Audio HDF Error Code - ERR_DH_AUDIO_HDF_FAIL = -46001, - ERR_DH_AUDIO_HDF_NULLPTR = -46002, - ERR_DH_AUDIO_HDF_INVALID_PARAM = -46003, - ERR_DH_AUDIO_HDF_REPEAT_OPERATION = -46004, - ERR_DH_AUDIO_HDF_INVALID_OPERATION = -46005, - ERR_DH_AUDIO_HDF_SET_PARAM_FAIL = -46006, - ERR_DH_AUDIO_HDF_OPEN_DEVICE_FAIL = -46007, - ERR_DH_AUDIO_HDF_CLOSE_DEVICE_FAIL = -46008, - ERR_DH_AUDIO_COMMON_NOT_FOUND_KEY = -46009, - ERR_DH_AUDIO_HDF_FAILURE = -46010, -}; -} // Distributedaudio -} // OHOS -#endif diff --git a/hdf_service/distributed_audio/hdi_service/common/include/daudio_events.h b/hdf_service/distributed_audio/hdi_service/common/include/daudio_events.h deleted file mode 100644 index b8ef012143e536d084c9f68410ec07ed08906c0c..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/common/include/daudio_events.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. - * 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 OHOS_DAUDIO_EVENTS_H -#define OHOS_DAUDIO_EVENTS_H - -namespace OHOS { -namespace DistributedHardware { -typedef enum AudioEventType { - HDF_AUDIO_DEVICE_ADD = 0x1, - HDF_AUDIO_DEVICE_REMOVE = 0x2, - HDF_AUDIO_LOAD_SUCCESS = 0x3, - HDF_AUDIO_LOAD_FAILURE = 0x4, - HDF_AUDIO_UNLOAD = 0x5, - HDF_AUDIO_SERVICE_VALID = 0x7, - HDF_AUDIO_SERVICE_INVALID = 0x8, - HDF_AUDIO_CAPTURE_THRESHOLD = 0x9, - HDF_AUDIO_EVENT_TYPE_UNKNOWN, -} EVENT_TYPE; - -typedef enum AudioDeviceType { - HDF_AUDIO_LINEOUT = 0x1, - HDF_AUDIO_HEADPHONE = 0x2, - HDF_AUDIO_HEADSET = 0x4, - HDF_AUDIO_USB_HEADSET = 0x8, - HDF_AUDIO_USB_HEADPHONE = 0x10, - HDF_AUDIO_USBA_HEADSET = 0x20, - HDF_AUDIO_USBA_HEADPHONE = 0x40, - HDF_AUDIO_PRIMARY_DEVICE = 0x80, - HDF_AUDIO_USB_DEVICE = 0x100, - HDF_AUDIO_A2DP_DEVICE = 0x200, - HDF_AUDIO_DEVICE_UNKNOWN, -} DEVICE_TYPE; - -typedef enum AudioExtParamEvent { - HDF_AUDIO_EVENT_PARAM_UNKNOWN = 0, - HDF_AUDIO_EVENT_VOLUME_SET = 1, - HDF_AUDIO_EVENT_VOLUME_GET = 2, - HDF_AUDIO_EVENT_VOLUME_CHANGE = 3, - HDF_AUDIO_EVENT_OPEN_SPK_RESULT = 4, - HDF_AUDIO_EVENT_CLOSE_SPK_RESULT = 5, - HDF_AUDIO_EVENT_OPEN_MIC_RESULT = 6, - HDF_AUDIO_EVENT_CLOSE_MIC_RESULT = 7, - HDF_AUDIO_EVENT_SPK_CLOSED = 8, - HDF_AUDIO_EVENT_MIC_CLOSED = 9, - HDF_AUDIO_EVENT_FOCUS_CHANGE = 10, - HDF_AUDIO_EVENT_RENDER_STATE_CHANGE = 11, - HDF_AUDIO_EVNET_MUTE_SET = 12, - HDF_AUDIO_EVENT_CHANGE_PLAY_STATUS = 13, - HDF_AUDIO_EVENT_MMAP_START = 14, - HDF_AUDIO_EVENT_MMAP_STOP = 15, - HDF_AUDIO_EVENT_MMAP_START_MIC = 16, - HDF_AUDIO_EVENT_MMAP_STOP_MIC = 17, - HDF_AUDIO_EVENT_START = 18, - HDF_AUDIO_EVENT_STOP = 19, -} EXT_PARAM_EVENT; - -typedef enum AudioVolumeEvent { - VOLUME_EVENT_UNKNOWN = 0, - VOLUME_EVENT_BASE = 1, - VOLUME_EVENT_MIN = 2, - VOLUME_EVENT_MAX = 3, - VOLUME_EVENT_MUTE = 4, -} VOL_EVENT; -} // DistributedHardware -} // OHOS -#endif // OHOS_DAUDIO_EVENTS_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/common/log/include/daudio_log.h b/hdf_service/distributed_audio/hdi_service/common/log/include/daudio_log.h deleted file mode 100644 index 8edac1e71e1977b14eaf07dc5fc87b0bb977c718..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/common/log/include/daudio_log.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 OHOS_DAUDIO_LOG_H -#define OHOS_DAUDIO_LOG_H - -#include - -namespace OHOS { -namespace DistributedHardware { -typedef enum { - DH_LOG_DEBUG, - DH_LOG_INFO, - DH_LOG_WARN, - DH_LOG_ERROR, -} DHLogLevel; - -void DHLog(DHLogLevel logLevel, const char *fmt, ...); - -#define DHLOGD(fmt, ...) DHLog(DH_LOG_DEBUG, \ - (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) - -#define DHLOGI(fmt, ...) DHLog(DH_LOG_INFO, \ - (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) - -#define DHLOGW(fmt, ...) DHLog(DH_LOG_WARN, \ - (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) - -#define DHLOGE(fmt, ...) DHLog(DH_LOG_ERROR, \ - (std::string("[") + DH_LOG_TAG + "][" + __FUNCTION__ + "]:" + fmt).c_str(), ##__VA_ARGS__) -} // Distributedaudio -} // OHOS -#endif diff --git a/hdf_service/distributed_audio/hdi_service/common/log/src/daudio_log.cpp b/hdf_service/distributed_audio/hdi_service/common/log/src/daudio_log.cpp deleted file mode 100644 index d690b231108d376298316759231f0b416cc2abce..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/common/log/src/daudio_log.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 "daudio_log.h" - -#include -#include -#include "securec.h" - -#ifdef HI_LOG_ENABLE -#include "hilog/log.h" -#else -#endif - -namespace OHOS { -namespace DistributedHardware { -const std::string DAUDIO_LOG_TITLE_TAG = "DAUDIO"; - -static void DHLogOut(DHLogLevel logLevel, const char *logBuf) -{ -#ifdef HI_LOG_ENABLE - LogLevel hiLogLevel = LOG_INFO; - switch (logLevel) { - case DH_LOG_DEBUG: - hiLogLevel = LOG_DEBUG; - break; - case DH_LOG_INFO: - hiLogLevel = LOG_INFO; - break; - case DH_LOG_WARN: - hiLogLevel = LOG_WARN; - break; - case DH_LOG_ERROR: - hiLogLevel = LOG_ERROR; - break; - default: - break; - } - (void)HiLogPrint(LOG_CORE, hiLogLevel, LOG_DOMAIN, DAUDIO_LOG_TITLE_TAG.c_str(), "%{public}s", logBuf); -#else - switch (logLevel) { - case DH_LOG_DEBUG: - printf("[D]%s\n", logBuf); - break; - case DH_LOG_INFO: - printf("[I]%s\n", logBuf); - break; - case DH_LOG_WARN: - printf("[W]%s\n", logBuf); - break; - case DH_LOG_ERROR: - printf("[E]%s\n", logBuf); - break; - default: - break; - } -#endif -} - -void DHLog(DHLogLevel logLevel, const char *fmt, ...) -{ - constexpr int32_t logMaxLen = 4096; - char logBuf[logMaxLen] = {0}; - va_list arg; - va_start(arg, fmt); - - int32_t ret = vsprintf_s(logBuf, sizeof(logBuf), fmt, arg); - va_end(arg); - if (ret < 0) { - DHLogOut(logLevel, "DH log length error."); - return; - } - DHLogOut(logLevel, logBuf); -} -} // Distributedaudio -} // OHOS diff --git a/hdf_service/distributed_audio/hdi_service/common/utils/include/daudio_utils.h b/hdf_service/distributed_audio/hdi_service/common/utils/include/daudio_utils.h deleted file mode 100644 index 538b913040e31c18f4a286cbd6479b66d735b4e7..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/common/utils/include/daudio_utils.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. - * 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 OHOS_DAUDIO_UTILS_H -#define OHOS_DAUDIO_UTILS_H - -#include - -#define AUDIO_MS_PER_SECOND 1000 -#define AUDIO_US_PER_SECOND 1000000 -#define AUDIO_NS_PER_SECOND ((int64_t)1000000000) -namespace OHOS { -namespace DistributedHardware { -std::string GetAnonyString(const std::string &value); - -int32_t GetAudioParamStr(const std::string ¶ms, const std::string &key, std::string &value); - -int32_t GetAudioParamInt(const std::string ¶ms, const std::string &key, int32_t &value); - -int32_t GetAudioParamUInt(const std::string ¶ms, const std::string &key, uint32_t &value); - -int32_t GetAudioParamBool(const std::string ¶ms, const std::string &key, bool &value); - -int32_t SetAudioParamStr(std::string ¶ms, const std::string &key, const std::string &value); - -int32_t GetDevTypeByDHId(int32_t dhId); - -uint32_t CalculateFrameSize(uint32_t sampleRate, uint32_t channelCount, - int32_t format, uint32_t timeInterval, bool isMMAP); - -int32_t CalculateSampleNum(uint32_t sampleRate, uint32_t timems); - -int64_t GetCurNano(); - -int32_t AbsoluteSleep(int64_t nanoTime); - -int64_t CalculateOffset(const int64_t frameindex, const int64_t framePeriodNs, const int64_t startTime); - -int64_t UpdateTimeOffset(const int64_t frameIndex, const int64_t framePeriodNs, int64_t &startTime); -} // DistributedHardware -} // OHOS -#endif \ No newline at end of file diff --git a/hdf_service/distributed_audio/hdi_service/common/utils/src/daudio_utils.cpp b/hdf_service/distributed_audio/hdi_service/common/utils/src/daudio_utils.cpp deleted file mode 100644 index f9e58d4b7df5773152470f9ca3cf95d0222b6a23..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/hdi_service/common/utils/src/daudio_utils.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (c) 2022-2023 Huawei Device Co., Ltd. - * 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 "daudio_utils.h" - -#include - -#include "daudio_constants.h" -#include "daudio_errcode.h" - -namespace OHOS { -namespace DistributedHardware { -constexpr size_t INT32_SHORT_ID_LENGTH = 20; -constexpr size_t INT32_PLAINTEXT_LENGTH = 4; -constexpr size_t INT32_MIN_ID_LENGTH = 3; - -std::string GetAnonyString(const std::string &value) -{ - std::string res; - std::string tmpStr("******"); - size_t strLen = value.length(); - if (strLen < INT32_MIN_ID_LENGTH) { - return tmpStr; - } - - if (strLen <= INT32_SHORT_ID_LENGTH) { - res += value[0]; - res += tmpStr; - res += value[strLen - 1]; - } else { - res.append(value, 0, INT32_PLAINTEXT_LENGTH); - res += tmpStr; - res.append(value, strLen - INT32_PLAINTEXT_LENGTH, INT32_PLAINTEXT_LENGTH); - } - - return res; -} - -int32_t GetAudioParamStr(const std::string ¶ms, const std::string &key, std::string &value) -{ - size_t step = key.size(); - if (step >= params.size()) { - return ERR_DH_AUDIO_HDF_FAIL; - } - size_t pos = params.find(key); - if (pos == params.npos || params.at(pos + step) != '=') { - return ERR_DH_AUDIO_COMMON_NOT_FOUND_KEY; - } - size_t splitPosEnd = params.find(';', pos); - if (splitPosEnd != params.npos) { - value = params.substr(pos + step + 1, splitPosEnd - pos - step - 1); - } else { - value = params.substr(pos + step + 1); - } - return DH_SUCCESS; -} - -int32_t GetAudioParamInt(const std::string ¶ms, const std::string &key, int32_t &value) -{ - std::string val = "0"; - int32_t ret = GetAudioParamStr(params, key, val); - value = std::stoi(val); - return ret; -} - -int32_t GetAudioParamUInt(const std::string ¶ms, const std::string &key, uint32_t &value) -{ - value = 0; - return DH_SUCCESS; -} - -int32_t GetAudioParamBool(const std::string ¶ms, const std::string &key, bool &value) -{ - std::string val; - GetAudioParamStr(params, key, val); - value = (val != "0"); - return DH_SUCCESS; -} - -int32_t SetAudioParamStr(std::string ¶ms, const std::string &key, const std::string &value) -{ - params = params + key + '=' + value + ';'; - return DH_SUCCESS; -} - -int32_t GetDevTypeByDHId(int32_t dhId) -{ - if ((uint32_t)dhId & 0x8000000) { - return AUDIO_DEVICE_TYPE_MIC; - } else if ((uint32_t)dhId & 0x7ffffff) { - return AUDIO_DEVICE_TYPE_SPEAKER; - } - return AUDIO_DEVICE_TYPE_UNKNOWN; -} - -uint32_t CalculateFrameSize(uint32_t sampleRate, uint32_t channelCount, - int32_t format, uint32_t timeInterval, bool isMMAP) -{ - return isMMAP ? (sampleRate * channelCount * format * timeInterval) / AUDIO_MS_PER_SECOND : DEFAULT_AUDIO_DATA_SIZE; -} - -int32_t CalculateSampleNum(uint32_t sampleRate, uint32_t timems) -{ - return (sampleRate * timems) / AUDIO_MS_PER_SECOND; -} - -int64_t GetCurNano() -{ - int64_t result = -1; - struct timespec time; - clockid_t clockId = CLOCK_MONOTONIC; - int ret = clock_gettime(clockId, &time); - if (ret < 0) { - return result; - } - result = (time.tv_sec * AUDIO_NS_PER_SECOND) + time.tv_nsec; - return result; -} - -int32_t AbsoluteSleep(int64_t nanoTime) -{ - int32_t ret = -1; - if (nanoTime <= 0) { - return ret; - } - struct timespec time; - time.tv_sec = nanoTime / AUDIO_NS_PER_SECOND; - time.tv_nsec = nanoTime - (time.tv_sec * AUDIO_NS_PER_SECOND); - - clockid_t clockId = CLOCK_MONOTONIC; - ret = clock_nanosleep(clockId, TIMER_ABSTIME, &time, nullptr); - return ret; -} - -int64_t CalculateOffset(const int64_t frameIndex, const int64_t framePeriodNs, const int64_t startTime) -{ - int64_t totalOffset = GetCurNano() - startTime; - return totalOffset - frameIndex * framePeriodNs; -} - -int64_t UpdateTimeOffset(const int64_t frameIndex, const int64_t framePeriodNs, int64_t &startTime) -{ - int64_t timeOffset = 0; - if (frameIndex == 0) { - startTime = GetCurNano(); - } else if (frameIndex % AUDIO_OFFSET_FRAME_NUM == 0) { - timeOffset = CalculateOffset(frameIndex, framePeriodNs, startTime); - } - return timeOffset; -} -} // namespace DistributedHardware -} // namespace OHOS \ No newline at end of file diff --git a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_adapter.h b/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_adapter.h deleted file mode 100644 index dccb1f8ed4b617739309170ff512fe4f4ccda756..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_adapter.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 HDF_I_AUDIO_ADAPTER_H -#define HDF_I_AUDIO_ADAPTER_H - -#include -#include - -#include "i_audio_capture.h" -#include "i_audio_render.h" -#include "i_audio_param_callback.h" -#include "types.h" - -namespace OHOS { -namespace DistributedHardware { -using RenderHandle = uint64_t; -using CaptureHandle = uint64_t; -using RouteHandle = int32_t; - -class IAudioAdapter { -public: - virtual int32_t InitAllPorts() = 0; - - virtual int32_t CreateRender(const AudioDeviceDescriptorHAL &desc, const AudioSampleAttributesHAL &attrs, - RenderHandle &handle, IAudioRender &render) = 0; - - virtual int32_t DestoryRender(const RenderHandle handle) = 0; - - virtual int32_t CreateCapture(const AudioDeviceDescriptorHAL &desc, const AudioSampleAttributesHAL &attrs, - CaptureHandle &handle, IAudioCapture &capture) = 0; - - virtual int32_t DestoryCapture(const CaptureHandle handle) = 0; - - virtual int32_t GetPortCapability(const AudioPortHAL &port, AudioPortCapabilityHAL &capability) = 0; - - virtual int32_t SetPassthroughMode(const AudioPortHAL &port, const AudioPortPassthroughModeHAL mode) = 0; - - virtual int32_t GetPassthroughMode(const AudioPortHAL &port, AudioPortPassthroughModeHAL &mode) = 0; - - virtual int32_t UpdateAudioRoute(const AudioRouteHAL &route, RouteHandle &handle) = 0; - - virtual int32_t ReleaseAudioRoute(const RouteHandle handle) = 0; - - virtual int32_t SetAudioParameters(const std::vector ¶m) = 0; - - virtual int32_t GetAudioParameters(std::vector ¶m) = 0; - - virtual int32_t RegAudioParamObserver(IAudioParamCallback &cbObj) = 0; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // HDF_I_AUDIO_ADAPTER_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_attribute.h b/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_attribute.h deleted file mode 100644 index bdd42446dc54a6cd197d7d58b9122b09d4e4f9a2..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_attribute.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 HDF_I_AUDIO_ATTRIBUTE_H -#define HDF_I_AUDIO_ATTRIBUTE_H - -namespace OHOS { -namespace DistributedHardware { -class IAudioAttribute { - virtual int32_t GetFrameSize(uint64_t &size) = 0; - - virtual int32_t GetFrameCount(uint64_t &count) = 0; - - virtual int32_t SetSampleAttributes(const AudioSampleAttributesHAL &attrs) = 0; - - virtual int32_t GetSampleAttributes(AudioSampleAttributesHAL &attrs) = 0; - - virtual int32_t GetCurrentChannelId(uint32_t &channelId) = 0; - - virtual int32_t SetExtraParams(const std::string &keyValueList) = 0; - - virtual int32_t GetExtraParams(std::string &keyValueList) = 0; - - virtual int32_t ReqMmapBuffer(int32_t reqSize, AudioMmapBufferDescriptorHAL &desc) = 0; - - virtual int32_t GetMmapPosition(uint64_t &frames, AudioTimeStampHAL &time) = 0; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // HDF_I_AUDIO_ATTRIBUTE_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_capture.h b/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_capture.h deleted file mode 100644 index 77466e0f68235d2269d3019d064b0b42eb38ce93..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_capture.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 HDF_I_AUDIO_CAPTURE_H -#define HDF_I_AUDIO_CAPTURE_H - -#include -#include - -#include "i_audio_attribute.h" -#include "i_audio_control.h" -#include "i_audio_scene.h" -#include "i_audio_volume.h" -#include "types.h" - -namespace OHOS { -namespace DistributedHardware { -class IAudioCapture : public IAudioControl, public IAudioAttribute, public IAudioScene, public IAudioVolume { -public: - virtual int32_t GetCapturePosition(uint64_t &frames, AudioTimeStampHAL &time) = 0; - - virtual int32_t CaptureFrame(std::vector &frame, const uint64_t requestBytes, uint64_t &replyBytes) = 0; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // HDF_I_AUDIO_CAPTURE_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_control.h b/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_control.h deleted file mode 100644 index e0efb5dbf2ba5238fd1b158c976d0ee609b22e80..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_control.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 HDF_I_AUDIO_CONTROL_H -#define HDF_I_AUDIO_CONTROL_H - -namespace OHOS { -namespace DistributedHardware { -class IAudioControl { -public: - virtual int32_t Start() = 0; - - virtual int32_t Stop() = 0; - - virtual int32_t Pause() = 0; - - virtual int32_t Resume() = 0; - - virtual int32_t Flush() = 0; - - virtual int32_t TurnStandbyMode() = 0; - - virtual int32_t AudioDevDump(const int32_t range, const int32_t fd) = 0; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // HDF_I_AUDIO_CONTROL_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_manager.h b/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_manager.h deleted file mode 100644 index 6b7f9b8bae60a25e53fa2a58ea9eb31b8cdd1593..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_manager.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 HDF_I_AUDIO_MANAGER_H -#define HDF_I_AUDIO_MANAGER_H - -#include -#include - -#include "i_audio_adapter.h" -#include "types.h" - -namespace OHOS { -namespace DistributedHardware { -using AdapterHandler = uint64_t; - -class IAudioManager { -public: - virtual int32_t GetAllAdapters(std::vector &descriptors) = 0; - - virtual int32_t LoadAdapter(const AudioAdapterDescriptorHAL &descriptor, AdapterHandler &handler, - IAudioAdapter &adapter) = 0; - - virtual int32_t UnloadAdapter(const AdapterHandler &handler) = 0; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // HDF_I_AUDIO_MANAGER_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_param_callback.h b/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_param_callback.h deleted file mode 100644 index 47f761a728cc00d57669c91d872d1bd255f1d7da..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_param_callback.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 HDF_I_AUDIO_PARAM_CALLBACK_H -#define HDF_I_AUDIO_PARAM_CALLBACK_H - -#include "types.h" - -namespace OHOS { -namespace DistributedHardware { -class IAudioParamCallback { -public: - virtual int32_t OnAudioParamNotify(const AudioParameter ¶m) = 0; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // HDF_I_AUDIO_PARAM_CALLBACK_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_render.h b/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_render.h deleted file mode 100644 index 5a077e30f02b790a1040f2b321bfa615370a9386..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_render.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 HDF_I_AUDIO_RENDER_H -#define HDF_I_AUDIO_RENDER_H - -#include -#include - -#include "i_audio_attribute.h" -#include "i_audio_control.h" -#include "i_audio_scene.h" -#include "i_audio_render_callback.h" -#include "i_audio_volume.h" -#include "types.h" - -namespace OHOS { -namespace DistributedHardware { -class IAudioRender : public IAudioControl, public IAudioAttribute, public IAudioScene, public IAudioVolume { -public: - virtual int32_t GetLatency(uint32_t &ms) = 0; - - virtual int32_t RenderFrame(const std::vector &frame, const uint64_t requestBytes, - uint64_t &replyBytes) = 0; - - virtual int32_t GetRenderPosition(uint64_t &frames, AudioTimeStampHAL &time) = 0; - - virtual int32_t SetRenderSpeed(const float speed) = 0; - - virtual int32_t GetRenderSpeed(float &speed) = 0; - - virtual int32_t SetChannelMode(const AudioChannelModeHAL &mode) = 0; - - virtual int32_t GetChannelMode(AudioChannelModeHAL &mode) = 0; - - virtual int32_t RegCallback(IAudioRenderCallback &cbObj) = 0; - - virtual int32_t DrainBuffer(const AudioDrainNotifyTypeHAL &type) = 0; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // HDF_I_AUDIO_RENDER_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_render_callback.h b/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_render_callback.h deleted file mode 100644 index 8c330efde177022b97d466e08af6a47452aaaf92..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_render_callback.h +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 HDF_I_AUDIO_RENDER_CALLBACK_H -#define HDF_I_AUDIO_RENDER_CALLBACK_H - -namespace OHOS { -namespace DistributedHardware { -class IAudioRenderCallback { -public: - virtual int32_t OnAudioWriteCompleted() = 0; - - virtual int32_t OnAudioDrainCompleted() = 0; - - virtual int32_t OnAudioFlushCompleted() = 0; - - virtual int32_t OnAudioRenderFull() = 0; - - virtual int32_t OnAudioErrorOccur() = 0; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // HDF_I_AUDIO_RENDER_CALLBACK_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_scene.h b/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_scene.h deleted file mode 100644 index bc647bc93b93d6aae82f910c68e0caafb9171f5d..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_scene.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 HDF_I_AUDIO_SCENE_H -#define HDF_I_AUDIO_SCENE_H - -#include "types.h" - -namespace OHOS { -namespace DistributedHardware { -class IAudioScene { -public: - virtual int32_t CheckSceneCapability(const AudioSceneDescriptorHAL &scene, bool &support) = 0; - - virtual int32_t SelectScene(const AudioSceneDescriptorHAL &scene) = 0; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // HDF_I_AUDIO_SCENE_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_volume.h b/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_volume.h deleted file mode 100644 index 0dae40c23976435486217269693badb5a09463d1..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/interface/audio/v1_0/i_audio_volume.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 HDF_I_AUDIO_VOLUME_H -#define HDF_I_AUDIO_VOLUME_H - -namespace OHOS { -namespace DistributedHardware { -class IAudioVolume { -public: - virtual int32_t SetMute(const bool mute) = 0; - - virtual int32_t GetMute(bool &mute) = 0; - - virtual int32_t SetVolume(const float volume) = 0; - - virtual int32_t GetVolume(float &volume) = 0; - - virtual int32_t GetGainThreshold(float &min, float &max) = 0; - - virtual int32_t SetGain(const float gain) = 0; - - virtual int32_t GetGain(float &gain) = 0; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // HDF_I_AUDIO_VOLUME_H \ No newline at end of file diff --git a/hdf_service/distributed_audio/interface/audio/v1_0/types.h b/hdf_service/distributed_audio/interface/audio/v1_0/types.h deleted file mode 100644 index 8c43331f1834971fc684a5cc0eca2e03b31757cc..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/interface/audio/v1_0/types.h +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 HDF_I_AUDIO_TYPES_H -#define HDF_I_AUDIO_TYPES_H - -#include -#include - -namespace OHOS { -namespace DistributedHardware { -enum AudioChannelModeHAL { - AUDIO_CHANNEL_NORMAL = 0, - AUDIO_CHANNEL_BOTH_LEFT, - AUDIO_CHANNEL_BOTH_RIGHT, - AUDIO_CHANNEL_EXCHANGE, - - AUDIO_CHANNEL_MIX, - AUDIO_CHANNEL_LEFT_MUTE, - AUDIO_CHANNEL_RIGHT_MUTE, - AUDIO_CHANNEL_BOTH_MUTE, -}; - -enum AudioDrainNotifyTypeHAL { - AUDIO_DRAIN_NORMAL_MODE, - AUDIO_DRAIN_EARLY_MODE, -}; - -enum AudioPortPassthroughModeHAL { - PORT_PASSTHROUGH_LPCM = 0x1, - PORT_PASSTHROUGH_RAW = 0x2, - PORT_PASSTHROUGH_HBR2LBR = 0x4, - PORT_PASSTHROUGH_AUTO = 0x8, -}; - -struct AudioDeviceDescriptorHAL { - uint32_t portId; - uint32_t pins; - std::string desc; -}; - -struct AudioSceneDescriptorHAL { - uint32_t id; - AudioDeviceDescriptorHAL desc; -}; - -struct AudioPortHAL { - uint32_t dir; - uint32_t portId; - std::string portName; -}; - -struct AudioAdapterDescriptorHAL { - std::string adapterName; - std::vector ports; -}; - -struct AudioTimeStampHAL { - uint64_t tvSec; - uint64_t tvNSec; -}; - -struct AudioSampleAttributesHAL { - uint32_t type; - uint32_t interleaved; - uint32_t format; - uint32_t sampleRate; - uint32_t channelCount; - - uint32_t period; - uint32_t frameSize; - uint32_t isBigEndian; - uint32_t isSignedData; - uint32_t startThreshold; - uint32_t stopThreshold; - uint32_t silenceThreshold; - uint32_t streamId; -}; - -struct AudioSubPortCapabilityHAL { - uint32_t portId; - uint32_t mask; - std::string desc; -}; - -struct AudioPortCapabilityHAL { - uint32_t deviceType; - uint32_t deviceId; - uint32_t hardwareMode; - uint32_t formatNum; - std::vector formats; - uint32_t sampleRateMasks; - uint32_t channelMasks; - uint32_t channelCount; - uint32_t subPortsNum; - AudioSubPortCapabilityHAL subPorts; -}; - -struct AudioDevExtInfoHAL { - int32_t moduleId; - uint32_t type; - uint8_t desc[32]; -}; - -struct AudioMixExtInfoHAL { - int32_t moduleId; - int32_t streamId; -}; - -struct AudioSessionInfoHAL { - uint32_t sessionType; -}; - -struct AudioRouteNodeHAL { - int32_t portId; - uint32_t role; - uint32_t type; - struct AudioDevExtInfoHAL device; - struct AudioMixExtInfoHAL mix; - struct AudioSessionInfoHAL session; -}; - -struct AudioRouteHAL { - std::vector sources; - std::vector sinks; -}; - -struct AudioParameter { - uint32_t paramType; - uint32_t value; - std::string content; -}; - -struct AudioMmapBufferDescriptorHAL { - int32_t memoryFd; - int32_t totalBufferFrames; - int32_t transferFrameSize; - int32_t isShareable; -}; - -} // namespace DistributedHardware -} // namespace OHOS -#endif \ No newline at end of file diff --git a/hdf_service/distributed_audio/interface/audio_ext/v1_0/i_daudio_hdf_callback.h b/hdf_service/distributed_audio/interface/audio_ext/v1_0/i_daudio_hdf_callback.h deleted file mode 100644 index c5fb27a00b7593db46d339cebdd374af0ad4c7b8..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/interface/audio_ext/v1_0/i_daudio_hdf_callback.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 HDF_I_DAUDIO_HDF_CALLBACK_H -#define HDF_I_DAUDIO_HDF_CALLBACK_H - -#include -#include "types.h" - -namespace OHOS { -namespace DistributedHardware { -class IDAudioHDFCallback { -public: - virtual int32_t OpenDevice(int32_t devId, int32_t dhId) = 0; - virtual int32_t CloseDevice(int32_t devId, int32_t dhId = 0; - virtual int32_t SetParameters(int32_t devId, int32_t dhId, struct AudioParameter ¶m) = 0; - virtual int32_t NotifyEvent(int32_t devId, int32_t dhId, struct DAudioEvent &event) = 0; - virtual int32_t WriteStreamData(int32_t devId, int32_t dhId, struct AudioStreamData &data) = 0; - virtual struct AudioStreamData* ReadStreamData(int32_t devId, int32_t dhId) = 0; - virtual int32_t ReadMmapPosition(int32_t devId, int32_t dhId, - uint64_t &frames, struct CurrentTime &time) = 0; - virtual int32_t RefreshAshmemInfo(int32_t devId, int32_t dhId, - int32_t fd, int32_t ashmemLength, int32_t lengthPerTrans) = 0; -} // namespace DistributedHardware -} // namespace OHOS -} // HDF_I_DAUDIO_HDF_CALLBACK_H -#endif \ No newline at end of file diff --git a/hdf_service/distributed_audio/interface/audio_ext/v1_0/i_daudio_manager.h b/hdf_service/distributed_audio/interface/audio_ext/v1_0/i_daudio_manager.h deleted file mode 100644 index 330fe73be4ac196dd03299dcef6b01742a80ffa9..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/interface/audio_ext/v1_0/i_daudio_manager.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 HDF_I_DAUDIO_MANGER_H -#define HDF_I_DAUDIO_MANGER_H - -#include - -#include "i_daudio_hdf_callback.h" -#include "types.h" - -namespace OHOS { -namespace DistributedHardware { -class IDAudioManager { -public: - virtual int32_t RegisterAudioDevice(std::string devId, std::string dhId, struct AudioParameter ¶m, - IDAudioHDFCallback callback) = 0; - - virtual int32_t UnRegisterAudioDevice(std::string devId, std::string dhId) = 0; - - virtual int32_t NotifyEvent(std::string devId, std::string dhId, struct DAudioEvent &event) = 0; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // HDF_I_DAUDIO_MANGER_H diff --git a/hdf_service/distributed_audio/interface/audio_ext/v1_0/types.h b/hdf_service/distributed_audio/interface/audio_ext/v1_0/types.h deleted file mode 100644 index 209739307e0983c526bfce3c4c551b828ca485af..0000000000000000000000000000000000000000 --- a/hdf_service/distributed_audio/interface/audio_ext/v1_0/types.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * 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 - -struct AudioParameter { - uint32_t paramType; - uint32_t value; - std::string content; -} - -struct AudioStreamData { - std::string data; -} - -typedef struct { - int type; - std::string content; -} DAudioEvent; diff --git a/interfaces/inner_kits/native_cpp/test/fuzztest/BUILD.gn b/interfaces/inner_kits/native_cpp/test/fuzztest/BUILD.gn index 45f8f5905e070bac3e044ee1e4506100a78034f8..588e4a1a5b9d90073755bd0fc599b52929649499 100644 --- a/interfaces/inner_kits/native_cpp/test/fuzztest/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/test/fuzztest/BUILD.gn @@ -19,20 +19,6 @@ group("fuzztest") { testonly = true deps = [ - "${hdf_ser_aud_ext_path}/test/fuzztest/notifyevent_fuzzer:fuzztest", - "${hdf_ser_aud_ext_path}/test/fuzztest/registeraudiodevice_fuzzer:fuzztest", - "${hdf_ser_aud_ext_path}/test/fuzztest/unregisteraudiodevice_fuzzer:fuzztest", - "${hdf_ser_aud_path}/test/fuzztest/captureframe_fuzzer:fuzztest", - "${hdf_ser_aud_path}/test/fuzztest/createcapture_fuzzer:fuzztest", - "${hdf_ser_aud_path}/test/fuzztest/createrender_fuzzer:fuzztest", - "${hdf_ser_aud_path}/test/fuzztest/destroycapture_fuzzer:fuzztest", - "${hdf_ser_aud_path}/test/fuzztest/destroyrender_fuzzer:fuzztest", - "${hdf_ser_aud_path}/test/fuzztest/getalladapters_fuzzer:fuzztest", - "${hdf_ser_aud_path}/test/fuzztest/getextraparams_fuzzer:fuzztest", - "${hdf_ser_aud_path}/test/fuzztest/loadadapter_fuzzer:fuzztest", - "${hdf_ser_aud_path}/test/fuzztest/renderframe_fuzzer:fuzztest", - "${hdf_ser_aud_path}/test/fuzztest/setextraparams_fuzzer:fuzztest", - "${hdf_ser_aud_path}/test/fuzztest/unloadadapter_fuzzer:fuzztest", "${services_path}/audiomanager/test/fuzztest/sinkservicedaudionotify_fuzzer:fuzztest", "${services_path}/audiomanager/test/fuzztest/sinkserviceinitsink_fuzzer:fuzztest", "${services_path}/audiomanager/test/fuzztest/sinkservicereleasesink_fuzzer:fuzztest", diff --git a/interfaces/inner_kits/native_cpp/test/unittest/BUILD.gn b/interfaces/inner_kits/native_cpp/test/unittest/BUILD.gn index 583e2b94397a68efc8b3777dad0b3c3f021db6d2..32e94ae26d9ead82bb37f33b8d4eb5b99f1b8cc0 100644 --- a/interfaces/inner_kits/native_cpp/test/unittest/BUILD.gn +++ b/interfaces/inner_kits/native_cpp/test/unittest/BUILD.gn @@ -19,8 +19,6 @@ group("unittest") { testonly = true deps = [ "${distributedaudio_path}/audiohandler/test/unittest:audio_handler_test", - "${hdf_service_path}/hdi_service/audio/v1_0/test/unittest:hdi_service_audio_test", - "${hdf_service_path}/hdi_service/audio_ext/v1_0/test/unittest:hdi_service_audio_ext_test", "${interfaces_path}/inner_kits/native_cpp/test/unittest/audiosinktest:audio_sink_test", "${interfaces_path}/inner_kits/native_cpp/test/unittest/audiosourcetest:audio_source_test", "${services_path}/audioclient/test/unittest:daudio_client_test",