From 9bfb2f0cabaf725bba9d0580a0f909c1a6e6b58e Mon Sep 17 00:00:00 2001 From: wangmengyang Date: Mon, 5 Feb 2018 19:47:58 +0800 Subject: [PATCH] component/bt: make A2DP sink task size configurable through menuconfig 1. make the A2DP sink task stack size configurable through menuconfig # Conflicts: # components/bt/Kconfig # components/bt/bluedroid/api/include/esp_a2dp_api.h # components/bt/bluedroid/btc/profile/std/a2dp/btc_a2dp_sink.c # components/bt/bluedroid/btc/profile/std/a2dp/btc_a2dp_source.c # components/bt/bluedroid/osi/include/thread.h --- components/bt/Kconfig | 7 +++++++ .../bt/bluedroid/api/include/esp_a2dp_api.h | 7 ++++--- .../btc/profile/std/a2dp/btc_media_task.c | 8 ++++---- components/bt/bluedroid/osi/include/thread.h | 15 ++++++++------- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/components/bt/Kconfig b/components/bt/Kconfig index 8a4f5248f0..302064dca6 100644 --- a/components/bt/Kconfig +++ b/components/bt/Kconfig @@ -113,6 +113,13 @@ config CLASSIC_BT_ENABLED help For now this option needs "SMP_ENABLE" to be set to yes +config A2DP_SINK_TASK_STACK_SIZE + int "A2DP sink (audio stream decoding) task stack size" + depends on CLASSIC_BT_ENABLED + default 2048 + help + This affects the stack size of A2DP sink task which invokes the data callback function. + config GATTS_ENABLE bool "Include GATT server module(GATTS)" depends on BLUEDROID_ENABLED diff --git a/components/bt/bluedroid/api/include/esp_a2dp_api.h b/components/bt/bluedroid/api/include/esp_a2dp_api.h index 7f6868dde1..332bbdae06 100644 --- a/components/bt/bluedroid/api/include/esp_a2dp_api.h +++ b/components/bt/bluedroid/api/include/esp_a2dp_api.h @@ -138,9 +138,10 @@ esp_err_t esp_a2d_register_callback(esp_a2d_cb_t callback); /** * @brief Register A2DP sink data output function; For now the output is PCM data stream decoded - * from SBC format. This function should be called only after esp_bluedroid_enable() - * completes successfully - * + * from SBC format. This function should be called only after esp_bluedroid_enable() + * completes successfully, used only by A2DP sink. The callback is invoked in the context + * of A2DP sink task whose stack size is configurable through menuconfig + * * @param[in] callback: A2DP data callback function * * @return diff --git a/components/bt/bluedroid/btc/profile/std/a2dp/btc_media_task.c b/components/bt/bluedroid/btc/profile/std/a2dp/btc_media_task.c index 1b6db63c47..94e77cd717 100644 --- a/components/bt/bluedroid/btc/profile/std/a2dp/btc_media_task.c +++ b/components/bt/bluedroid/btc/profile/std/a2dp/btc_media_task.c @@ -272,13 +272,13 @@ bool btc_a2dp_start_media_task(void) APPL_TRACE_EVENT("## A2DP START MEDIA THREAD ##"); - xBtcMediaQueueSet = xQueueCreateSet(BTC_MEDIA_TASK_QUEUE_SET_LEN); + xBtcMediaQueueSet = xQueueCreateSet(BTC_A2DP_SINK_TASK_QUEUE_SET_LEN); configASSERT(xBtcMediaQueueSet); - xBtcMediaDataQueue = xQueueCreate(BTC_MEDIA_DATA_QUEUE_LEN, sizeof(void *)); + xBtcMediaDataQueue = xQueueCreate(BTC_A2DP_SINK_DATA_QUEUE_LEN, sizeof(void *)); configASSERT(xBtcMediaDataQueue); xQueueAddToSet(xBtcMediaDataQueue, xBtcMediaQueueSet); - xBtcMediaCtrlQueue = xQueueCreate(BTC_MEDIA_CTRL_QUEUE_LEN, sizeof(void *)); + xBtcMediaCtrlQueue = xQueueCreate(BTC_A2DP_SINK_CTRL_QUEUE_LEN, sizeof(void *)); configASSERT(xBtcMediaCtrlQueue); xQueueAddToSet(xBtcMediaCtrlQueue, xBtcMediaQueueSet); @@ -286,7 +286,7 @@ bool btc_a2dp_start_media_task(void) goto error_exit; } - xTaskCreatePinnedToCore(btc_media_task_handler, "BtcMediaT\n", 2048, NULL, configMAX_PRIORITIES - 3, &xBtcMediaTaskHandle, 0); + xTaskCreatePinnedToCore(btc_media_task_handler, BTC_A2DP_SINK_TASK_NAME, BTC_A2DP_SINK_TASK_STACK_SIZE, NULL, BTC_A2DP_SINK_TASK_PRIO, &xBtcMediaTaskHandle, BTC_A2DP_SINK_TASK_PINNED_TO_CORE); if (xBtcMediaTaskHandle == NULL) { goto error_exit; } diff --git a/components/bt/bluedroid/osi/include/thread.h b/components/bt/bluedroid/osi/include/thread.h index 9ac5da6bd9..f9b29dcfda 100644 --- a/components/bt/bluedroid/osi/include/thread.h +++ b/components/bt/bluedroid/osi/include/thread.h @@ -83,13 +83,14 @@ typedef enum { #define BTC_TASK_PRIO (configMAX_PRIORITIES - 6) #define BTC_TASK_QUEUE_LEN 60 -#define BTC_MEDIA_TASK_PINNED_TO_CORE (TASK_PINNED_TO_CORE) -#define BTC_MEDIA_TASK_STACK_SIZE (CONFIG_BTC_TASK_STACK_SIZE + BT_TASK_EXTRA_STACK_SIZE) -#define BTC_MEDIA_TASK_NAME "BtcMediaT" -#define BTC_MEDIA_TASK_PRIO (configMAX_PRIORITIES - 3) -#define BTC_MEDIA_DATA_QUEUE_LEN (1) -#define BTC_MEDIA_CTRL_QUEUE_LEN (5) -#define BTC_MEDIA_TASK_QUEUE_SET_LEN (BTC_MEDIA_DATA_QUEUE_LEN + BTC_MEDIA_CTRL_QUEUE_LEN) +#define BTC_A2DP_SINK_TASK_PINNED_TO_CORE (TASK_PINNED_TO_CORE) +#define BTC_A2DP_SINK_TASK_STACK_SIZE (CONFIG_A2DP_SINK_TASK_STACK_SIZE + BT_TASK_EXTRA_STACK_SIZE) // by menuconfig +#define BTC_A2DP_SINK_TASK_NAME "BtA2dSinkT" +#define BTC_A2DP_SINK_TASK_PRIO (configMAX_PRIORITIES - 3) +#define BTC_A2DP_SINK_DATA_QUEUE_LEN (1) +#define BTC_A2DP_SINK_CTRL_QUEUE_LEN (5) +#define BTC_A2DP_SINK_TASK_QUEUE_SET_LEN (BTC_A2DP_SINK_DATA_QUEUE_LEN + BTC_A2DP_SINK_CTRL_QUEUE_LEN) + #define TASK_POST_NON_BLOCKING (0) #define TASK_POST_BLOCKING (portMAX_DELAY)