1# OH_AudioRenderer_Callbacks_Struct
2
3
4## Overview
5
6The **OH_AudioRenderer_Callbacks_Struct** struct defines a pointer to the callback functions related to an audio renderer.
7
8To 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 [Using OHAudio for Audio Playback](../../media/audio/using-ohaudio-for-playback.md).
9
10**System capability**: SystemCapability.Multimedia.Audio.Core
11
12**Since**: 10
13
14**Related module**: [OHAudio](_o_h_audio.md)
15
16
17## Summary
18
19
20### Member Variables
21
22| Name| Description| 
23| -------- | -------- |
24| int32_t (\*[OH_AudioRenderer_OnWriteData](#oh_audiorenderer_onwritedata))([OH_AudioRenderer](_o_h_audio.md#oh_audiorenderer) \*renderer, void \*userData, void \*buffer, int32_t length) | Defines a function pointer to the callback function used to write audio data. | 
25| int32_t (\*[OH_AudioRenderer_OnStreamEvent](#oh_audiorenderer_onstreamevent))([OH_AudioRenderer](_o_h_audio.md#oh_audiorenderer) \*renderer, void \*userData, [OH_AudioStream_Event](_o_h_audio.md#oh_audiostream_event) event) | Defines a function pointer to the callback function used to process audio playback stream events. | 
26| int32_t (\*[OH_AudioRenderer_OnInterruptEvent](#oh_audiorenderer_oninterruptevent))([OH_AudioRenderer](_o_h_audio.md#oh_audiorenderer) \*renderer, void \*userData, [OH_AudioInterrupt_ForceType](_o_h_audio.md#oh_audiointerrupt_forcetype) type, [OH_AudioInterrupt_Hint](_o_h_audio.md#oh_audiointerrupt_hint) hint) | Defines a function pointer to the callback function used to process audio playback interruption events. | 
27| int32_t (\*[OH_AudioRenderer_OnError](#oh_audiorenderer_onerror))([OH_AudioRenderer](_o_h_audio.md#oh_audiorenderer) \*renderer, void \*userData, [OH_AudioStream_Result](_o_h_audio.md#oh_audiostream_result) error) | Defines a function pointer to the callback function used to process audio playback errors. | 
28
29
30## Member Variable Description
31
32> **NOTE**
33>
34> 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.
35
36
37### OH_AudioRenderer_OnError
38
39```
40int32_t (*OH_AudioRenderer_Callbacks_Struct::OH_AudioRenderer_OnError)(OH_AudioRenderer *renderer, void *userData, OH_AudioStream_Result error)
41```
42
43**Description**
44
45Defines a function pointer to the callback function used to process audio playback errors.
46
47**Parameters**
48
49| Name| Description| 
50| -------- | -------- |
51| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](_o_h_audio.md#oh_audiostreambuilder_generaterenderer).|
52| userData | Pointer to the data storage area customized by the application.|
53| error | Audio playback error result defined by [OH_AudioStream_Result](_o_h_audio.md#oh_audiostream_result), which can be **AUDIOSTREAM_ERROR_INVALID_PARAM**, **AUDIOSTREAM_ERROR_ILLEGAL_STATE**, or **AUDIOSTREAM_ERROR_SYSTEM**.|
54
55
56### OH_AudioRenderer_OnInterruptEvent
57
58```
59int32_t (*OH_AudioRenderer_Callbacks_Struct::OH_AudioRenderer_OnInterruptEvent)(OH_AudioRenderer *renderer, void *userData, OH_AudioInterrupt_ForceType type, OH_AudioInterrupt_Hint hint)
60```
61
62**Description**
63
64Defines a function pointer to the callback function used to process audio playback interruption events.
65
66**Parameters**
67
68| Name| Description| 
69| -------- | -------- |
70| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](_o_h_audio.md#oh_audiostreambuilder_generaterenderer).|
71| userData | Pointer to the data storage area customized by the application.|
72| type | Type of force that causes audio interruption. For details about the available options, see [OH_AudioInterrupt_ForceType](_o_h_audio.md#oh_audiointerrupt_forcetype).|
73| hint | Hint provided along with audio interruption. For details about the available options, see [OH_AudioInterrupt_Hint](_o_h_audio.md#oh_audiointerrupt_hint).|
74
75### OH_AudioRenderer_OnStreamEvent
76
77```
78int32_t (*OH_AudioRenderer_Callbacks_Struct::OH_AudioRenderer_OnStreamEvent)(OH_AudioRenderer *renderer, void *userData, OH_AudioStream_Event event)
79```
80
81**Description**
82
83Defines a function pointer to the callback function used to process audio playback stream events.
84
85**Parameters**
86
87| Name| Description| 
88| -------- | -------- |
89| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](_o_h_audio.md#oh_audiostreambuilder_generaterenderer).|
90| userData | Pointer to the data storage area customized by the application.|
91| event | Audio event defined in [OH_AudioStream_Event](_o_h_audio.md#oh_audiostream_event).|
92
93
94### OH_AudioRenderer_OnWriteData
95
96```
97int32_t (*OH_AudioRenderer_Callbacks_Struct::OH_AudioRenderer_OnWriteData)(OH_AudioRenderer *renderer, void *userData, void *buffer, int32_t length)
98```
99
100**Description**
101
102Defines a function pointer to the callback function used to write audio data.
103
104**Parameters**
105
106| Name| Description| 
107| -------- | -------- |
108| renderer | Pointer to an audio renderer instance, which is created by calling [OH_AudioStreamBuilder_GenerateRenderer](_o_h_audio.md#oh_audiostreambuilder_generaterenderer).|
109| userData | Pointer to the data storage area customized by the application.|
110| buffer | Pointer to the playback data storage area, which is used by the application to fill in playback data.|
111| length | Length of the buffer.|
112