@@ -38,9 +38,9 @@ USB_STREAM::~USB_STREAM()
38
38
{}
39
39
40
40
// Method to register a user-defined callback function
41
- void USB_STREAM::uvcCamRegisterCb (uvc_frame_callback_t * newFunction, void *cb_arg)
41
+ void USB_STREAM::uvcCamRegisterCb (uvc_frame_callback_t newFunction, void *cb_arg)
42
42
{
43
- if (newFunction == NULL ) {
43
+ if (newFunction == nullptr ) {
44
44
ESP_LOGE (TAG, " registerCallBack function error\n " );
45
45
return ;
46
46
} else {
@@ -53,15 +53,15 @@ void USB_STREAM::uvcCamRegisterCb(uvc_frame_callback_t *newFunction, void *cb_ar
53
53
static void _camera_frame_cb (uvc_frame_t *frame, void *ptr)
54
54
{
55
55
USB_STREAM *my_instance = (USB_STREAM *)ptr;
56
- if (my_instance->_user_frame_cb != NULL ) {
56
+ if (my_instance->_user_frame_cb != nullptr ) {
57
57
my_instance->_user_frame_cb (frame, my_instance->_user_frame_cb_arg );
58
58
}
59
59
}
60
60
61
61
// Method to register a user-defined callback function
62
- void USB_STREAM::uacMicRegisterCb (mic_callback_t * newFunction, void *cb_arg)
62
+ void USB_STREAM::uacMicRegisterCb (mic_callback_t newFunction, void *cb_arg)
63
63
{
64
- if (newFunction == NULL ) {
64
+ if (newFunction == nullptr ) {
65
65
ESP_LOGE (TAG, " registerCallBack function error\n " );
66
66
return ;
67
67
} else {
@@ -74,7 +74,7 @@ void USB_STREAM::uacMicRegisterCb(mic_callback_t *newFunction, void *cb_arg)
74
74
static void _mic_frame_cb (mic_frame_t *frame, void *ptr)
75
75
{
76
76
USB_STREAM *my_instance = (USB_STREAM *)ptr;
77
- if (my_instance->_user_mic_frame_cb != NULL ) {
77
+ if (my_instance->_user_mic_frame_cb != nullptr ) {
78
78
my_instance->_user_mic_frame_cb (frame, my_instance->_user_frame_cb_arg );
79
79
}
80
80
}
@@ -91,18 +91,18 @@ void USB_STREAM::uvcConfiguration(uint16_t width, uint16_t height, uint32_t fram
91
91
_frame_height = height;
92
92
_frame_interval = frameInterval;
93
93
94
- uvc_config_t uvc_config = {
95
- . frame_width = _frame_width,
96
- . frame_height = _frame_height,
97
- . frame_interval = _frame_interval,
98
- . xfer_buffer_size = transferBufferSize,
99
- . xfer_buffer_a = transferBufferA,
100
- . xfer_buffer_b = transferBufferB,
101
- . frame_buffer_size = frameBufferSize,
102
- . frame_buffer = frameBuffer,
103
- . frame_cb = &_camera_frame_cb,
104
- . frame_cb_arg = this ,
105
- } ;
94
+ uvc_config_t uvc_config;
95
+ memset (&uvc_config, 0 , sizeof (uvc_config));
96
+ uvc_config. frame_width = _frame_width;
97
+ uvc_config. frame_height = _frame_height;
98
+ uvc_config. frame_interval = _frame_interval;
99
+ uvc_config. xfer_buffer_size = transferBufferSize;
100
+ uvc_config. xfer_buffer_a = transferBufferA;
101
+ uvc_config. xfer_buffer_b = transferBufferB;
102
+ uvc_config. frame_buffer_size = frameBufferSize;
103
+ uvc_config. frame_buffer = frameBuffer;
104
+ uvc_config. frame_cb = &_camera_frame_cb;
105
+ uvc_config. frame_cb_arg = this ;
106
106
// Configure the UVC streaming with the provided configuration
107
107
CHECK_ESP_ERROR (uvc_streaming_config (&uvc_config), " UVC streaming config fail" );
108
108
}
@@ -121,18 +121,18 @@ void USB_STREAM::uacConfiguration(uint8_t mic_ch_num, uint16_t mic_bit_resolutio
121
121
_spk_samples_frequency = spk_samples_frequency;
122
122
_spk_buf_size = spk_buf_size;
123
123
124
- uac_config_t uac_config = {
125
- . spk_ch_num = _spk_ch_num,
126
- . mic_ch_num = _mic_ch_num,
127
- . mic_bit_resolution = _mic_bit_resolution,
128
- . mic_samples_frequence = _mic_samples_frequency,
129
- . spk_bit_resolution = _spk_bit_resolution,
130
- . spk_samples_frequence = _spk_samples_frequency,
131
- . spk_buf_size = _spk_buf_size,
132
- . mic_buf_size = _mic_buf_size,
133
- . mic_cb = &_mic_frame_cb,
134
- . mic_cb_arg = this ,
135
- } ;
124
+ uac_config_t uac_config;
125
+ memset (&uac_config, 0 , sizeof (uac_config));
126
+ uac_config. spk_ch_num = _spk_ch_num;
127
+ uac_config. mic_ch_num = _mic_ch_num;
128
+ uac_config. mic_bit_resolution = _mic_bit_resolution;
129
+ uac_config. mic_samples_frequence = _mic_samples_frequency;
130
+ uac_config. spk_bit_resolution = _spk_bit_resolution;
131
+ uac_config. spk_samples_frequence = _spk_samples_frequency;
132
+ uac_config. spk_buf_size = _spk_buf_size;
133
+ uac_config. mic_buf_size = _mic_buf_size;
134
+ uac_config. mic_cb = &_mic_frame_cb;
135
+ uac_config. mic_cb_arg = this ;
136
136
CHECK_ESP_ERROR (uac_streaming_config (&uac_config), " UAC streaming config fail" );
137
137
}
138
138
@@ -229,9 +229,9 @@ void USB_STREAM::uacSpkVolume(void *ctrl_value)
229
229
uvc_frame_size_t *USB_STREAM::uvcCamGetFrameSize (uvc_frame_size_t *uvc_frame_list)
230
230
{
231
231
if (uvc_frame_list == nullptr ) {
232
- return NULL ;
232
+ return nullptr ;
233
233
}
234
- CHECK_ESP_ERROR (uvc_frame_size_list_get (uvc_frame_list, NULL , NULL ), " uvc cam get frame size fail" );
234
+ CHECK_ESP_ERROR (uvc_frame_size_list_get (uvc_frame_list, nullptr , nullptr ), " uvc cam get frame size fail" );
235
235
return uvc_frame_list;
236
236
}
237
237
@@ -249,8 +249,8 @@ void USB_STREAM::uvcCamGetFrameListSize(size_t *frame_size, size_t *frame_index)
249
249
void USB_STREAM::uvcCamFrameReset (uint16_t frame_width, uint16_t frame_height, uint32_t frame_interval)
250
250
{
251
251
252
- if (frame_width == NULL || frame_height == NULL || frame_interval == NULL ) {
253
- ESP_LOGE (TAG, " arguments cannot be null " );
252
+ if (frame_width == 0 || frame_height == 0 || frame_interval == 0 ) {
253
+ ESP_LOGE (TAG, " arguments cannot be zero " );
254
254
return ;
255
255
}
256
256
CHECK_ESP_ERROR (uvc_frame_size_reset (frame_width, frame_height, frame_interval), " reset camera frame size fail" );
@@ -270,19 +270,19 @@ void USB_STREAM::uacReadMic(uint8_t *buffer, size_t buf_size, size_t *data_bytes
270
270
uac_frame_size_t *USB_STREAM::uacSpkGetFrameSize (uac_frame_size_t *uac_frame_list)
271
271
{
272
272
if (uac_frame_list == nullptr ) {
273
- return NULL ;
273
+ return nullptr ;
274
274
}
275
- CHECK_ESP_ERROR (uac_frame_size_list_get (STREAM_UAC_SPK, uac_frame_list, NULL , NULL ), " uac spk get frame size fail" );
275
+ CHECK_ESP_ERROR (uac_frame_size_list_get (STREAM_UAC_SPK, uac_frame_list, nullptr , nullptr ), " uac spk get frame size fail" );
276
276
return uac_frame_list;
277
277
}
278
278
279
279
// Method to get uac mic frame size
280
280
uac_frame_size_t *USB_STREAM::uacMicGetFrameSize (uac_frame_size_t *uac_frame_list)
281
281
{
282
282
if (uac_frame_list == nullptr ) {
283
- return NULL ;
283
+ return nullptr ;
284
284
}
285
- CHECK_ESP_ERROR (uac_frame_size_list_get (STREAM_UAC_MIC, uac_frame_list, NULL , NULL ), " uac mic get frame size fail" );
285
+ CHECK_ESP_ERROR (uac_frame_size_list_get (STREAM_UAC_MIC, uac_frame_list, nullptr , nullptr ), " uac mic get frame size fail" );
286
286
return uac_frame_list;
287
287
}
288
288
@@ -309,8 +309,8 @@ void USB_STREAM::uacSpkGetFrameListSize(size_t *frame_size, size_t *frame_index)
309
309
// Method to reset uac mic frame
310
310
void USB_STREAM::uacMicFrameReset (uint8_t ch_num, uint16_t bit_resolution, uint32_t samples_frequency)
311
311
{
312
- if (ch_num == NULL || bit_resolution == NULL || samples_frequency == NULL ) {
313
- ESP_LOGE (TAG, " arguments cannot be null " );
312
+ if (ch_num == 0 || bit_resolution == 0 || samples_frequency == 0 ) {
313
+ ESP_LOGE (TAG, " arguments cannot be zero " );
314
314
return ;
315
315
}
316
316
CHECK_ESP_ERROR (uac_frame_size_reset (STREAM_UAC_MIC, ch_num, bit_resolution, samples_frequency), " reset Mic frame size fail" );
@@ -319,8 +319,8 @@ void USB_STREAM::uacMicFrameReset(uint8_t ch_num, uint16_t bit_resolution, uint3
319
319
// Method to reset uac spk frame
320
320
void USB_STREAM::uacSpkFrameReset (uint8_t ch_num, uint16_t bit_resolution, uint32_t samples_frequency)
321
321
{
322
- if (ch_num == NULL || bit_resolution == NULL || samples_frequency == NULL ) {
323
- ESP_LOGE (TAG, " arguments cannot be null " );
322
+ if (ch_num == 0 || bit_resolution == 0 || samples_frequency == 0 ) {
323
+ ESP_LOGE (TAG, " arguments cannot be zero " );
324
324
return ;
325
325
}
326
326
CHECK_ESP_ERROR (uac_frame_size_reset (STREAM_UAC_SPK, ch_num, bit_resolution, samples_frequency), " reset Spk frame size fail" );
@@ -329,7 +329,7 @@ void USB_STREAM::uacSpkFrameReset(uint8_t ch_num, uint16_t bit_resolution, uint3
329
329
// Method to write uac frame
330
330
void USB_STREAM::uacWriteSpk (uint16_t *buffer, size_t data_bytes, size_t timeout_ms)
331
331
{
332
- if (buffer == nullptr || data_bytes == NULL ) {
332
+ if (buffer == nullptr || data_bytes == 0 ) {
333
333
ESP_LOGE (TAG, " Invalid parameters for uacWriteSpk" );
334
334
return ;
335
335
}
0 commit comments