diff --git a/multimedia/audio_framework/common/native_audiostream_base.h b/multimedia/audio_framework/common/native_audiostream_base.h index aed8e102cfdfcd5ac98fd7dfc71fafaf74f7bc54..8f8d8fe1e3abe8b640edfe077fdd62ba5dea051b 100644 --- a/multimedia/audio_framework/common/native_audiostream_base.h +++ b/multimedia/audio_framework/common/native_audiostream_base.h @@ -749,6 +749,94 @@ typedef enum { AUDIOSTREAM_VOLUMEMODE_APP_INDIVIDUAL = 1 } OH_AudioStream_VolumeMode; + +/** + * @brief Callback function of interrupt event on AudioRenderer. + * + * This function is similar with OH_AudioRenderer_Callbacks_Struct.OH_AudioRenderer_OnInterruptEvent. + * + * @param renderer AudioRenderer where this callback occurs. + * @param userData User data which is passed by user. + * @param type Force type of this interrupt event. + * @param hint Hint of this interrupt event. + * @see OH_AudioRenderer_Callbacks_Struct.OH_AudioRenderer_OnInterruptEvent. + * @since 16 + */ + typedef void (*OH_AudioRenderer_OnInterruptCallback)(OH_AudioRenderer* renderer, void* userData, + OH_AudioInterrupt_ForceType type, OH_AudioInterrupt_Hint hint); + +/** + * @brief Callback function of error on AudioRenderer. + * + * This function is similar with OH_AudioRenderer_Callbacks_Struct.OH_AudioRenderer_OnError. + * + * @param renderer AudioRenderer where this callback occurs. + * @param userData User data which is passed by user. + * @param error Error while using AudioRenderer. + * @see OH_AudioRenderer_Callbacks_Struct.OH_AudioRenderer_OnError + * @since 16 + */ +typedef void (*OH_AudioRenderer_OnErrorCallback)(OH_AudioRenderer* renderer, void* userData, + OH_AudioStream_Result error); + +/** + * @brief Callback function of read data. + * + * This function is similar with OH_AudioCapturer_Callbacks_Struct.OH_AudioCapturer_OnReadData + * + * @param capturer AudioCapturer where this callback occurs. + * @param userData User data which is passed by user. + * @param audioData Audio data pointer, where user should read. + * @param audioDataSize Size of audio data that user should read. + * @see OH_AudioCapturer_Callbacks_Struct.OH_AudioCapturer_OnReadData + * @since 16 + */ +typedef void (*OH_AudioCapturer_OnReadDataCallback)(OH_AudioCapturer* capturer, void* userData, void* audioData, + int32_t audioDataSize); + +/** + * @brief Callback when input device of an AudioCapturer changes. + * + * This function is similar with OH_AudioCapturer_Callbacks_Struct.OH_AudioCapturer_OnStreamEvent + * + * @param capturer AudioCapturer where this callback occurs. + * @param userData User data which is passed by user. + * @param deviceArray Array of AudioDeviceDescriptor where the capturing data from. + * @see OH_AudioCapturer_Callbacks_Struct.OH_AudioCapturer_OnStreamEvent + * @since 16 + */ +typedef void (*OH_AudioCapturer_OnDeviceChangeCallback)(OH_AudioCapturer* capturer, void* userData, + OH_AudioStream_Event event); + +/** + * @brief Callback function of interrupt event on AudioCapturer. + * + * This function is similar with OH_AudioCapturer_Callbacks_Struct.OH_AudioCapturer_OnInterruptEvent. + * + * @param capturer AudioCapturer where this callback occurs. + * @param userData User data which is passed by user. + * @param type Force type of this interrupt event. + * @param hint Hint of this interrupt event. + * @see OH_AudioCapturer_Callbacks_Struct.OH_AudioCapturer_OnInterruptEvent. + * @since 16 + */ +typedef void (*OH_AudioCapturer_OnInterruptCallback)(OH_AudioCapturer* capturer, void* userData, + OH_AudioInterrupt_ForceType type, OH_AudioInterrupt_Hint hint); + +/** + * @brief Callback function of error on AudioCapturer. + * + * This function is similar with OH_AudioCapturer_Callbacks_Struct.OH_AudioCapturer_OnError. + * + * @param renderer AudioCapturer where this callback occurs. + * @param userData User data which is passed by user. + * @param error Error while using AudioCapturer. + * @see OH_AudioCapturer_Callbacks_Struct.OH_AudioCapturer_OnError + * @since 16 + */ +typedef void (*OH_AudioCapturer_OnErrorCallback)(OH_AudioCapturer* renderer, void* userData, + OH_AudioStream_Result error); + #ifdef __cplusplus } #endif diff --git a/multimedia/audio_framework/common/native_audiostreambuilder.h b/multimedia/audio_framework/common/native_audiostreambuilder.h index cedc25bdc7dab70ee5593d428c29cde75bef769e..172b312f049b231df25c6f91a18c551367920149 100644 --- a/multimedia/audio_framework/common/native_audiostreambuilder.h +++ b/multimedia/audio_framework/common/native_audiostreambuilder.h @@ -378,6 +378,108 @@ OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererWriteDataCallback(OH_Audi OH_AudioStream_Result OH_AudioStreamBuilder_SetVolumeMode(OH_AudioStreamBuilder* builder, OH_AudioStream_VolumeMode volumeMode); +/** + * @brief Set the callback of interrupt event on AudioRenderer. + * + * This function is similar with {@link OH_AudioStreamBuilder_SetRendererCallback}. Only the last callback set by + * OH_AudioStreamBuilder_SetRendererCallback or this function will become effective. + * + * @param builder Builder provided by OH_AudioStreamBuilder_Create() + * @param callback Callback function that will receive the interrupt event. + * @param userData Pointer to an application data structure that will be passed to the callback functions. + * @return Result code. + * {@link AUDIOSTREAM_SUCCESS} Success. + * {@link AUDIOSTREAM_ERROR_INVALID_PARAM} Parameter is invalid, e.g. builder is nullptr, e.t.c. + * @since 16 + */ + OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererInterruptCallback(OH_AudioStreamBuilder* builder, + OH_AudioRenderer_OnInterruptCallback callback, void* userData); + +/** + * @brief Set the callback of error event on AudioRenderer. + * + * This function is similar with {@link OH_AudioStreamBuilder_SetRendererCallback}. Only the last callback set by + * OH_AudioStreamBuilder_SetRendererCallback or this function will become effective. + * + * @param builder Builder provided by OH_AudioStreamBuilder_Create() + * @param callback Callback function that will recevie the error event. + * @param userData Pointer to an application data structure that will be passed to the callback functions. + * @return Result code. + * {@link AUDIOSTREAM_SUCCESS} Success. + * {@link AUDIOSTREAM_ERROR_INVALID_PARAM} Parameter is invalid, e.g. builder is nullptr, e.t.c. + * @since 16 + */ +OH_AudioStream_Result OH_AudioStreamBuilder_SetRendererErrorCallback(OH_AudioStreamBuilder* builder, + OH_AudioRenderer_OnErrorCallback callback, void* userData); + +/** + * @brief Set the callback of reading data on AudioCapturer. + * + * This function is similar with {@link OH_AudioStreamBuilder_SetCapturerCallback}. Only the last callback set by + * OH_AudioStreamBuilder_SetCapturerCallback or this function will become effective. + * + * @param builder Builder provided by OH_AudioStreamBuilder_Create() + * @param callback Callback function that will recevie the reading data event. + * @param userData Pointer to an application data structure that will be passed to the callback functions. + * @return Result code. + * {@link AUDIOSTREAM_SUCCESS} Success. + * {@link AUDIOSTREAM_ERROR_INVALID_PARAM} Parameter is invalid, e.g. builder is nullptr, e.t.c. + * @since 16 + */ +OH_AudioStream_Result OH_AudioStreamBuilder_SetCapturerReadDataCallback(OH_AudioStreamBuilder* builder, + OH_AudioCapturer_OnReadDataCallback callback, void* userData); + +/** + * @brief Set the callback of device change on AudioCapturer. + * + * This function is similar with {@link OH_AudioStreamBuilder_SetCapturerCallback}. Only the last callback set by + * OH_AudioStreamBuilder_SetCapturerCallback or this function will become effective. + * + * @param builder Builder provided by OH_AudioStreamBuilder_Create() + * @param callback Callback function that will recevie the device change event. + * @param userData Pointer to an application data structure that will be passed to the callback functions. + * @return Result code. + * {@link AUDIOSTREAM_SUCCESS} Success. + * {@link AUDIOSTREAM_ERROR_INVALID_PARAM} Parameter is invalid, e.g. builder is nullptr, e.t.c. + * @since 16 + */ +OH_AudioStream_Result OH_AudioStreamBuilder_SetCapturerDeviceChangeCallback(OH_AudioStreamBuilder* builder, + OH_AudioCapturer_OnDeviceChangeCallback callback, void* userData); + +/** + * @brief Set the callback of interrupt event on AudioCapturer. + * + * This function is similar with {@link OH_AudioStreamBuilder_SetCapturerCallback}. Only the last callback set by + * OH_AudioStreamBuilder_SetCapturerCallback or this function will become effective. + * + * @param builder Builder provided by OH_AudioStreamBuilder_Create() + * @param callback Callback function that will recevie the interrupt event. + * @param userData Pointer to an application data structure that will be passed to the callback functions. + * @return Result code. + * {@link AUDIOSTREAM_SUCCESS} Success. + * {@link AUDIOSTREAM_ERROR_INVALID_PARAM} Parameter is invalid, e.g. builder is nullptr, e.t.c. + * @since 16 + */ +OH_AudioStream_Result OH_AudioStreamBuilder_SetCapturerInterruptCallback(OH_AudioStreamBuilder* builder, + OH_AudioCapturer_OnInterruptCallback callback, void* userData); + +/** + * @brief Set the callback of error event on AudioCapturer. + * + * This function is similar with {@link OH_AudioStreamBuilder_SetCapturerCallback}. Only the last callback set by + * OH_AudioStreamBuilder_SetCapturerCallback or this function will become effective. + * + * @param builder Builder provided by OH_AudioStreamBuilder_Create() + * @param callback Callback function that will recevie the error event. + * @param userData Pointer to an application data structure that will be passed to the callback functions. + * @return Result code. + * {@link AUDIOSTREAM_SUCCESS} Success. + * {@link AUDIOSTREAM_ERROR_INVALID_PARAM} Parameter is invalid, e.g. builder is nullptr, e.t.c. + * @since 16 + */ +OH_AudioStream_Result OH_AudioStreamBuilder_SetCapturerErrorCallback(OH_AudioStreamBuilder* builder, + OH_AudioCapturer_OnErrorCallback callback, void* userData); + #ifdef __cplusplus } #endif diff --git a/multimedia/audio_framework/ohaudio.ndk.json b/multimedia/audio_framework/ohaudio.ndk.json index 2c8537d6ce6ea01760867b6ef228f3e7800434c3..da9eb76d0c83f130c70608d8e3017a81a82f690d 100644 --- a/multimedia/audio_framework/ohaudio.ndk.json +++ b/multimedia/audio_framework/ohaudio.ndk.json @@ -315,6 +315,30 @@ "first_introduced": "12", "name":"OH_AudioStreamBuilder_SetRendererWriteDataCallback" }, + { + "first_introduced": "12", + "name":"OH_AudioStreamBuilder_SetRendererInterruptCallback" + }, + { + "first_introduced": "12", + "name":"OH_AudioStreamBuilder_SetRendererErrorCallback" + }, + { + "first_introduced": "12", + "name":"OH_AudioStreamBuilder_SetCapturerReadDataCallback" + }, + { + "first_introduced": "12", + "name":"OH_AudioStreamBuilder_SetCapturerDeviceChangeCallback" + }, + { + "first_introduced": "12", + "name":"OH_AudioStreamBuilder_SetCapturerInterruptCallback" + }, + { + "first_introduced": "12", + "name":"OH_AudioStreamBuilder_SetCapturerErrorCallback" + }, { "first_introduced": "12", "name":"OH_AudioRenderer_SetSilentModeAndMixWithOthers"