@@ -46,8 +46,7 @@ LOG_MODULE_REGISTER(usb, CONFIG_LOG_DEFAULT_LEVEL);
46
46
#define USB_MONO_FRAME_SIZE (USB_SAMPLE_CNT * USB_BYTES_PER_SAMPLE)
47
47
#define USB_CHANNELS 2U
48
48
#define USB_STEREO_FRAME_SIZE (USB_MONO_FRAME_SIZE * USB_CHANNELS)
49
- #define USB_OUT_RING_BUF_SIZE (CONFIG_BT_ISO_RX_BUF_COUNT * LC3_MAX_NUM_SAMPLES_STEREO)
50
- #define USB_IN_RING_BUF_SIZE (USB_MONO_FRAME_SIZE * USB_ENQUEUE_COUNT)
49
+ #define USB_IN_RING_BUF_SIZE (CONFIG_BT_ISO_RX_BUF_COUNT * LC3_MAX_NUM_SAMPLES_STEREO)
51
50
52
51
#define IN_TERMINAL_ID UAC2_ENTITY_ID(DT_NODELABEL(in_terminal))
53
52
@@ -60,8 +59,8 @@ struct decoded_sdu {
60
59
uint32_t ts ;
61
60
} decoded_sdu ;
62
61
63
- RING_BUF_DECLARE (usb_out_ring_buf , USB_OUT_RING_BUF_SIZE );
64
- K_MEM_SLAB_DEFINE_STATIC (usb_out_buf_pool , ROUND_UP (USB_STEREO_FRAME_SIZE , UDC_BUF_GRANULARITY ),
62
+ RING_BUF_DECLARE (usb_in_ring_buf , USB_IN_RING_BUF_SIZE );
63
+ K_MEM_SLAB_DEFINE_STATIC (usb_in_buf_pool , ROUND_UP (USB_STEREO_FRAME_SIZE , UDC_BUF_GRANULARITY ),
65
64
USB_ENQUEUE_COUNT , UDC_BUF_ALIGN );
66
65
static volatile bool terminal_enabled ;
67
66
@@ -74,17 +73,17 @@ static void uac2_sof_cb(const struct device *dev, void *user_data)
74
73
75
74
if (!terminal_enabled ) {
76
75
/* Simply discard the data then */
77
- (void )ring_buf_get (& usb_out_ring_buf , NULL , USB_STEREO_FRAME_SIZE );
76
+ (void )ring_buf_get (& usb_in_ring_buf , NULL , USB_STEREO_FRAME_SIZE );
78
77
return ;
79
78
}
80
79
81
- err = k_mem_slab_alloc (& usb_out_buf_pool , & pcm_buf , K_NO_WAIT );
80
+ err = k_mem_slab_alloc (& usb_in_buf_pool , & pcm_buf , K_NO_WAIT );
82
81
if (err != 0 ) {
83
82
LOG_WRN ("Could not allocate pcm_buf" );
84
83
return ;
85
84
}
86
85
87
- size = ring_buf_get (& usb_out_ring_buf , pcm_buf , USB_STEREO_FRAME_SIZE );
86
+ size = ring_buf_get (& usb_in_ring_buf , pcm_buf , USB_STEREO_FRAME_SIZE );
88
87
if (size != USB_STEREO_FRAME_SIZE ) {
89
88
/* If we could not fill the buffer, zero-fill the rest (possibly all) */
90
89
memset (((uint8_t * )pcm_buf ) + size , 0 , USB_STEREO_FRAME_SIZE - size );
@@ -116,14 +115,14 @@ static void uac2_sof_cb(const struct device *dev, void *user_data)
116
115
}
117
116
}
118
117
119
- k_mem_slab_free (& usb_out_buf_pool , pcm_buf );
118
+ k_mem_slab_free (& usb_in_buf_pool , pcm_buf );
120
119
} /* USB owns the buffer which will be released in uac2_buf_release_cb */
121
120
}
122
121
123
122
static void uac2_buf_release_cb (const struct device * dev , uint8_t terminal , void * buf ,
124
123
void * user_data )
125
124
{
126
- k_mem_slab_free (& usb_out_buf_pool , buf );
125
+ k_mem_slab_free (& usb_in_buf_pool , buf );
127
126
}
128
127
129
128
static void terminal_update_cb (const struct device * dev , uint8_t terminal , bool enabled ,
@@ -156,7 +155,7 @@ static void usb_send_frames_to_usb(void)
156
155
uint32_t rb_size ;
157
156
158
157
/* Not enough space to store data */
159
- if (ring_buf_space_get (& usb_out_ring_buf ) < sizeof (stereo_frame )) {
158
+ if (ring_buf_space_get (& usb_in_ring_buf ) < sizeof (stereo_frame )) {
160
159
if (CONFIG_INFO_REPORTING_INTERVAL > 0 &&
161
160
(fail_cnt % CONFIG_INFO_REPORTING_INTERVAL ) == 0U ) {
162
161
LOG_WRN ("[%zu] Could not send more than %zu frames to USB" ,
@@ -195,7 +194,7 @@ static void usb_send_frames_to_usb(void)
195
194
}
196
195
}
197
196
198
- rb_size = ring_buf_put (& usb_out_ring_buf , (uint8_t * )stereo_frame ,
197
+ rb_size = ring_buf_put (& usb_in_ring_buf , (uint8_t * )stereo_frame ,
199
198
sizeof (stereo_frame ));
200
199
if (rb_size != sizeof (stereo_frame )) {
201
200
LOG_WRN ("Failed to put frame on USB ring buf" );
0 commit comments