diff options
author | Mattias Agren <magren@broadcom.com> | 2012-04-19 23:10:53 +0200 |
---|---|---|
committer | Matthew Xie <mattx@google.com> | 2012-07-14 11:19:17 -0700 |
commit | 0872cc31abb3990b0892898f45bf2c87da627e4c (patch) | |
tree | 27f8f72cb243ddc93ba9f2eb4f254060619057fb /btif | |
parent | e35926125a5320f5de50c22765f8ce07c588ff78 (diff) | |
download | external_bluetooth_bluedroid-0872cc31abb3990b0892898f45bf2c87da627e4c.zip external_bluetooth_bluedroid-0872cc31abb3990b0892898f45bf2c87da627e4c.tar.gz external_bluetooth_bluedroid-0872cc31abb3990b0892898f45bf2c87da627e4c.tar.bz2 |
Ensure UIPC task is fully shutdown upon termination of btif media task.
Change-Id: Ie924cd324c85ca2037e94402a145a4eeeed62511
Diffstat (limited to 'btif')
-rw-r--r--[-rwxr-xr-x] | btif/include/btif_av.h | 0 | ||||
-rw-r--r--[-rwxr-xr-x] | btif/include/btif_common.h | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | btif/src/btif_core.c | 6 | ||||
-rwxr-xr-x | btif/src/btif_media_task.c | 36 |
4 files changed, 29 insertions, 13 deletions
diff --git a/btif/include/btif_av.h b/btif/include/btif_av.h index e481459..e481459 100755..100644 --- a/btif/include/btif_av.h +++ b/btif/include/btif_av.h diff --git a/btif/include/btif_common.h b/btif/include/btif_common.h index 3ecea9f..3ecea9f 100755..100644 --- a/btif/include/btif_common.h +++ b/btif/include/btif_common.h diff --git a/btif/src/btif_core.c b/btif/src/btif_core.c index 51328a8..d3c8447 100644..100755 --- a/btif/src/btif_core.c +++ b/btif/src/btif_core.c @@ -512,10 +512,10 @@ void btif_enable_bluetooth_evt(tBTA_STATUS status, BD_ADDR local_bd) /* init rfcomm & l2cap api */ btif_sock_init(); - - /* init pan */ + + /* init pan */ btif_pan_init(); - + /* load did configuration */ bte_load_did_conf(BTE_DID_CONF_FILE); diff --git a/btif/src/btif_media_task.c b/btif/src/btif_media_task.c index b0133a9..d3c267e 100755 --- a/btif/src/btif_media_task.c +++ b/btif/src/btif_media_task.c @@ -134,6 +134,11 @@ enum BTIF_MEDIA_AUDIO_RECEIVING_INIT }; +enum { + MEDIA_TASK_STATE_OFF = 0, + MEDIA_TASK_STATE_ON = 1, + MEDIA_TASK_STATE_SHUTTING_DOWN = 2 +}; /* Macro to multiply the media task tick */ #ifndef BTIF_MEDIA_NUM_TICK @@ -275,7 +280,7 @@ typedef struct { *****************************************************************************/ static tBTIF_MEDIA_CB btif_media_cb; -static int media_task_running = 0; +static int media_task_running = MEDIA_TASK_STATE_OFF; /***************************************************************************** @@ -473,6 +478,12 @@ static void btif_recv_ctrl_data(void) { case A2DP_CTRL_CMD_CHECK_READY: + if (media_task_running == MEDIA_TASK_STATE_SHUTTING_DOWN) + { + a2dp_cmd_acknowledge(A2DP_CTRL_ACK_FAILURE); + return; + } + /* check whether avdtp is ready to start */ if (btif_av_stream_ready() == TRUE) { @@ -547,8 +558,9 @@ static void btif_a2dp_ctrl_cb(tUIPC_CH_ID ch_id, tUIPC_EVENT event) break; case UIPC_CLOSE_EVT: - /* restart ctrl server */ - UIPC_Open(UIPC_CH_ID_AV_CTRL , btif_a2dp_ctrl_cb); + /* restart ctrl server unless we are shutting down */ + if (media_task_running != MEDIA_TASK_STATE_SHUTTING_DOWN) + UIPC_Open(UIPC_CH_ID_AV_CTRL , btif_a2dp_ctrl_cb); break; case UIPC_RX_DATA_READY_EVT: @@ -573,12 +585,12 @@ static void btif_a2dp_data_cb(tUIPC_CH_ID ch_id, tUIPC_EVENT event) connection events */ UIPC_Ioctl(UIPC_CH_ID_AV_AUDIO, UIPC_REG_REMOVE_ACTIVE_READSET, NULL); - /* make sure we update any changed sbc encoder params */ - btif_a2dp_encoder_update(); - /* Start the media task to encode SBC */ btif_media_task_start_aa_req(); + /* make sure we update any changed sbc encoder params */ + btif_a2dp_encoder_update(); + /* ack back when media task is fully started */ break; @@ -700,7 +712,7 @@ int btif_a2dp_start_media_task(void) { int retval; - if (media_task_running) + if (media_task_running != MEDIA_TASK_STATE_OFF) { APPL_TRACE_ERROR0("warning : media task already running"); return GKI_FAILURE; @@ -718,7 +730,7 @@ int btif_a2dp_start_media_task(void) return retval; /* wait for task to come up to sure we are able to send messages to it */ - while (media_task_running == 0) + while (media_task_running == MEDIA_TASK_STATE_OFF) usleep(10); APPL_TRACE_EVENT0("## A2DP MEDIA TASK STARTED ##"); @@ -1183,7 +1195,7 @@ int btif_media_task(void *p) btif_media_task_init(); - media_task_running = 1; + media_task_running = MEDIA_TASK_STATE_ON; while (1) { @@ -1221,13 +1233,17 @@ int btif_media_task(void *p) /* When we get this event we exit the task - should only happen on GKI_shutdown */ if (event & BTIF_MEDIA_TASK_KILL) { + /* make sure no channels are restarted while shutting down */ + media_task_running = MEDIA_TASK_STATE_SHUTTING_DOWN; + + /* this calls blocks until uipc is fully closed */ UIPC_Close(UIPC_CH_ID_ALL); break; } } /* Clear media task flag */ - media_task_running = 0; + media_task_running = MEDIA_TASK_STATE_OFF; APPL_TRACE_DEBUG0("MEDIA TASK EXITING"); |