component/bt: Avoid A2DP demo to use unallocated memory
This commit is contained in:
parent
d1f774bc0a
commit
2d1d747cbb
|
@ -26,7 +26,7 @@ static void bt_app_work_dispatched(bt_app_msg_t *msg);
|
||||||
static xQueueHandle s_bt_app_task_queue = NULL;
|
static xQueueHandle s_bt_app_task_queue = NULL;
|
||||||
static xTaskHandle s_bt_app_task_handle = NULL;
|
static xTaskHandle s_bt_app_task_handle = NULL;
|
||||||
static xTaskHandle s_bt_i2s_task_handle = NULL;
|
static xTaskHandle s_bt_i2s_task_handle = NULL;
|
||||||
static RingbufHandle_t ringbuf_i2s = NULL;;
|
static RingbufHandle_t s_ringbuf_i2s = NULL;;
|
||||||
|
|
||||||
bool bt_app_work_dispatch(bt_app_cb_t p_cback, uint16_t event, void *p_params, int param_len, bt_app_copy_cb_t p_copy_cback)
|
bool bt_app_work_dispatch(bt_app_cb_t p_cback, uint16_t event, void *p_params, int param_len, bt_app_copy_cb_t p_copy_cback)
|
||||||
{
|
{
|
||||||
|
@ -123,18 +123,18 @@ static void bt_i2s_task_handler(void *arg)
|
||||||
size_t bytes_written = 0;
|
size_t bytes_written = 0;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
data = (uint8_t *)xRingbufferReceive(ringbuf_i2s, &item_size, (portTickType)portMAX_DELAY);
|
data = (uint8_t *)xRingbufferReceive(s_ringbuf_i2s, &item_size, (portTickType)portMAX_DELAY);
|
||||||
if (item_size != 0){
|
if (item_size != 0){
|
||||||
i2s_write(0, data, item_size, &bytes_written, portMAX_DELAY);
|
i2s_write(0, data, item_size, &bytes_written, portMAX_DELAY);
|
||||||
vRingbufferReturnItem(ringbuf_i2s,(void *)data);
|
vRingbufferReturnItem(s_ringbuf_i2s,(void *)data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void bt_i2s_task_start_up(void)
|
void bt_i2s_task_start_up(void)
|
||||||
{
|
{
|
||||||
ringbuf_i2s = xRingbufferCreate(8 * 1024, RINGBUF_TYPE_BYTEBUF);
|
s_ringbuf_i2s = xRingbufferCreate(8 * 1024, RINGBUF_TYPE_BYTEBUF);
|
||||||
if(ringbuf_i2s == NULL){
|
if(s_ringbuf_i2s == NULL){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,13 +149,15 @@ void bt_i2s_task_shut_down(void)
|
||||||
s_bt_i2s_task_handle = NULL;
|
s_bt_i2s_task_handle = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
vRingbufferDelete(ringbuf_i2s);
|
if (s_ringbuf_i2s) {
|
||||||
ringbuf_i2s = NULL;
|
vRingbufferDelete(s_ringbuf_i2s);
|
||||||
|
s_ringbuf_i2s = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t write_ringbuf(const uint8_t *data, size_t size)
|
size_t write_ringbuf(const uint8_t *data, size_t size)
|
||||||
{
|
{
|
||||||
BaseType_t done = xRingbufferSend(ringbuf_i2s, (void *)data, size, (portTickType)portMAX_DELAY);
|
BaseType_t done = xRingbufferSend(s_ringbuf_i2s, (void *)data, size, (portTickType)portMAX_DELAY);
|
||||||
if(done){
|
if(done){
|
||||||
return size;
|
return size;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -26,7 +26,7 @@ static void bt_app_work_dispatched(bt_app_msg_t *msg);
|
||||||
static xQueueHandle s_bt_app_task_queue = NULL;
|
static xQueueHandle s_bt_app_task_queue = NULL;
|
||||||
static xTaskHandle s_bt_app_task_handle = NULL;
|
static xTaskHandle s_bt_app_task_handle = NULL;
|
||||||
static xTaskHandle s_bt_i2s_task_handle = NULL;
|
static xTaskHandle s_bt_i2s_task_handle = NULL;
|
||||||
static RingbufHandle_t ringbuf_i2s = NULL;;
|
static RingbufHandle_t s_ringbuf_i2s = NULL;;
|
||||||
|
|
||||||
bool bt_app_work_dispatch(bt_app_cb_t p_cback, uint16_t event, void *p_params, int param_len, bt_app_copy_cb_t p_copy_cback)
|
bool bt_app_work_dispatch(bt_app_cb_t p_cback, uint16_t event, void *p_params, int param_len, bt_app_copy_cb_t p_copy_cback)
|
||||||
{
|
{
|
||||||
|
@ -123,18 +123,18 @@ static void bt_i2s_task_handler(void *arg)
|
||||||
size_t bytes_written = 0;
|
size_t bytes_written = 0;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
data = (uint8_t *)xRingbufferReceive(ringbuf_i2s, &item_size, (portTickType)portMAX_DELAY);
|
data = (uint8_t *)xRingbufferReceive(s_ringbuf_i2s, &item_size, (portTickType)portMAX_DELAY);
|
||||||
if (item_size != 0){
|
if (item_size != 0){
|
||||||
i2s_write(0, data, item_size, &bytes_written, portMAX_DELAY);
|
i2s_write(0, data, item_size, &bytes_written, portMAX_DELAY);
|
||||||
vRingbufferReturnItem(ringbuf_i2s,(void *)data);
|
vRingbufferReturnItem(s_ringbuf_i2s,(void *)data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void bt_i2s_task_start_up(void)
|
void bt_i2s_task_start_up(void)
|
||||||
{
|
{
|
||||||
ringbuf_i2s = xRingbufferCreate(8 * 1024, RINGBUF_TYPE_BYTEBUF);
|
s_ringbuf_i2s = xRingbufferCreate(8 * 1024, RINGBUF_TYPE_BYTEBUF);
|
||||||
if(ringbuf_i2s == NULL){
|
if(s_ringbuf_i2s == NULL){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,13 +149,15 @@ void bt_i2s_task_shut_down(void)
|
||||||
s_bt_i2s_task_handle = NULL;
|
s_bt_i2s_task_handle = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
vRingbufferDelete(ringbuf_i2s);
|
if (s_ringbuf_i2s) {
|
||||||
ringbuf_i2s = NULL;
|
vRingbufferDelete(s_ringbuf_i2s);
|
||||||
|
s_ringbuf_i2s = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t write_ringbuf(const uint8_t *data, size_t size)
|
size_t write_ringbuf(const uint8_t *data, size_t size)
|
||||||
{
|
{
|
||||||
BaseType_t done = xRingbufferSend(ringbuf_i2s, (void *)data, size, (portTickType)portMAX_DELAY);
|
BaseType_t done = xRingbufferSend(s_ringbuf_i2s, (void *)data, size, (portTickType)portMAX_DELAY);
|
||||||
if(done){
|
if(done){
|
||||||
return size;
|
return size;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue