OH_AudioCapturer_Callbacks_Struct
typedef struct OH_AudioCapturer_Callbacks_Struct {...} OH_AudioCapturer_Callbacks
Overview
The struct defines a pointer to the callback functions related to an audio capturer.
To avoid unexpected behavior, ensure that every member variable of the struct is initialized by a custom callback method or a null pointer when setting the audio callback functions. For details, see (Recommended) Using OHAudio for Audio Recording (C/C++).
Since: 10
Deprecated from: 20
Substitute
Use the following callback types for substitute:
OH_AudioCapturer_OnReadDataCallback, OH_AudioCapturer_OnDeviceChangeCallback, OH_AudioCapturer_OnInterruptCallback, and OH_AudioCapturer_OnErrorCallback
Related module: OHAudio
Header file: native_audiostream_base.h
Summary
Member Functions
| Name | Description |
|---|---|
| int32_t (*OH_AudioCapturer_OnReadData)(OH_AudioCapturer* capturer,void* userData,void* buffer,int32_t length) | Defines a function pointer to the callback function used to read audio data. |
| int32_t (*OH_AudioCapturer_OnStreamEvent)(OH_AudioCapturer* capturer,void* userData,OH_AudioStream_Event event) | Defines a function pointer to the callback function used to process audio recording stream events. |
| int32_t (*OH_AudioCapturer_OnInterruptEvent)(OH_AudioCapturer* capturer,void* userData,OH_AudioInterrupt_ForceType type,OH_AudioInterrupt_Hint hint) | Defines a function pointer to the callback function used to process audio recording interruption events. |
| int32_t (*OH_AudioCapturer_OnError)(OH_AudioCapturer* capturer, void* userData, OH_AudioStream_Result error) | Defines a function pointer to the callback function used to process audio recording errors. |
Member Function Description
NOTE
No enumerated values are defined as the return values of the following callbacks. In the current version, no processing specific to the return value is provided. To support expansion in later versions, the default value 0 is used.
OH_AudioCapturer_OnReadData()
int32_t (*OH_AudioCapturer_OnReadData)(OH_AudioCapturer* capturer,void* userData,void* buffer,int32_t length)
Description
Defines a function pointer to the callback function used to read audio data.
The callback function is used only to read audio data. Do not call AudioCapturer APIs in it.
Since: 10
Deprecated from: 20
Substitute: OH_AudioCapturer_OnReadDataCallback
Parameters
| Name | Description |
|---|---|
| OH_AudioCapturer* capturer | Pointer to an audio capturer instance, which is created by calling OH_AudioStreamBuilder_GenerateCapturer. |
| void* userData | Pointer to the data storage area customized by the application. |
| void* buffer | Pointer to the captured data storage area, which is used by the application to read captured data. |
| int32_t length | Length of the buffer. |
OH_AudioCapturer_OnStreamEvent()
int32_t (*OH_AudioCapturer_OnStreamEvent)(OH_AudioCapturer* capturer,void* userData,OH_AudioStream_Event event)
Description
Defines a function pointer to the callback function used to process audio recording stream events.
Since: 10
Deprecated from: 20
Substitute: OH_AudioCapturer_OnDeviceChangeCallback
Parameters
| Name | Description |
|---|---|
| OH_AudioCapturer* capturer | Pointer to an audio capturer instance, which is created by calling OH_AudioStreamBuilder_GenerateCapturer. |
| void* userData | Pointer to the data storage area customized by the application. |
| OH_AudioStream_Event event | Audio event. |
OH_AudioCapturer_OnInterruptEvent()
int32_t (*OH_AudioCapturer_OnInterruptEvent)(OH_AudioCapturer* capturer,void* userData,OH_AudioInterrupt_ForceType type,OH_AudioInterrupt_Hint hint)
Description
Defines a function pointer to the callback function used to process audio recording interruption events.
Since: 10
Deprecated from: 20
Substitute: OH_AudioCapturer_OnInterruptCallback
Parameters
| Name | Description |
|---|---|
| OH_AudioCapturer* capturer | Pointer to an audio capturer instance, which is created by calling OH_AudioStreamBuilder_GenerateCapturer. |
| void* userData | Pointer to the data storage area customized by the application. |
| OH_AudioInterrupt_ForceType type | Type of force that causes audio interruption. |
| OH_AudioInterrupt_Hint hint | Hint provided along with audio interruption. |
OH_AudioCapturer_OnError()
int32_t (*OH_AudioCapturer_OnError)(OH_AudioCapturer* capturer, void* userData, OH_AudioStream_Result error)
Description
Defines a function pointer to the callback function used to process audio recording errors.
Since: 10
Deprecated from: 20
Substitute: OH_AudioCapturer_OnErrorCallback
Parameters
| Name | Description |
|---|---|
| OH_AudioCapturer* capturer | Pointer to an audio capturer instance, which is created by calling OH_AudioStreamBuilder_GenerateCapturer. |
| void* userData | Pointer to the data storage area customized by the application. |
| OH_AudioStream_Result error | Audio recording error result, which may be AUDIOSTREAM_ERROR_INVALID_PARAM, AUDIOSTREAM_ERROR_ILLEGAL_STATE, or AUDIOSTREAM_ERROR_SYSTEM. |
你可能感兴趣的鸿蒙文章
openharmony 鸿蒙 capi-native-audiostreambuilder-h
openharmony 鸿蒙 capi-ohaudiosuite
openharmony 鸿蒙 js-apis-inner-multimedia-systemSoundPlayer
openharmony 鸿蒙 arkts-apis-audio-i
openharmony 鸿蒙 arkts-apis-audio-AudioManager
openharmony 鸿蒙 capi-ohaudiosuite-oh-audiosuite-spacerenderpositionparams