summaryrefslogtreecommitdiffstats
path: root/btif/src/btif_av.c
diff options
context:
space:
mode:
authorMattias Agren <magren@broadcom.com>2012-04-26 08:59:42 +0200
committerMatthew Xie <mattx@google.com>2012-07-14 11:19:19 -0700
commit29fa3a0e28eccd9511f530dd3e4e4a9123a33604 (patch)
tree4881769c91c365c26797eab9f2accfcb0c2cc177 /btif/src/btif_av.c
parentc02b3a558e7789dcd73bcabf5a90f24fee327364 (diff)
downloadexternal_bluetooth_bluedroid-29fa3a0e28eccd9511f530dd3e4e4a9123a33604.zip
external_bluetooth_bluedroid-29fa3a0e28eccd9511f530dd3e4e4a9123a33604.tar.gz
external_bluetooth_bluedroid-29fa3a0e28eccd9511f530dd3e4e4a9123a33604.tar.bz2
Reject an incoming a2dp start request if btif is about to disable.
Added intermediate states for DISABLING/ENABLING in btif main adapter to allow checking for this condition. Change-Id: Ifa863c12bebfaca19f50fce4847f75f479993a23
Diffstat (limited to 'btif/src/btif_av.c')
-rw-r--r--btif/src/btif_av.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/btif/src/btif_av.c b/btif/src/btif_av.c
index c716920..637387c 100644
--- a/btif/src/btif_av.c
+++ b/btif/src/btif_av.c
@@ -669,22 +669,22 @@ static void bte_av_callback(tBTA_AV_EVT event, tBTA_AV *p_data)
bt_status_t btif_av_init(void)
{
if (btif_av_cb.sm_handle == NULL)
-{
+ {
if (btif_a2dp_start_media_task() != GKI_SUCCESS)
- return BT_STATUS_FAIL;
+ return BT_STATUS_FAIL;
- btif_enable_service(BTA_A2DP_SERVICE_ID);
+ btif_enable_service(BTA_A2DP_SERVICE_ID);
- /* Initialize the AVRC CB */
- btif_rc_init();
+ /* Initialize the AVRC CB */
+ btif_rc_init();
- /* Also initialize the AV state machine */
- btif_av_cb.sm_handle = btif_sm_init((const btif_sm_handler_t*)btif_av_state_handlers, BTIF_AV_STATE_IDLE);
+ /* Also initialize the AV state machine */
+ btif_av_cb.sm_handle = btif_sm_init((const btif_sm_handler_t*)btif_av_state_handlers, BTIF_AV_STATE_IDLE);
- btif_a2dp_on_init();
+ btif_a2dp_on_init();
- return BT_STATUS_SUCCESS;
-}
+ return BT_STATUS_SUCCESS;
+ }
return BT_STATUS_DONE;
}
@@ -711,9 +711,6 @@ static bt_status_t init(btav_callbacks_t* callbacks )
bt_av_callbacks = callbacks;
btif_av_cb.sm_handle = NULL;
- /* check if stack/gki is started/enabled yet, if not defer until bluetooth
- is enabled */
-
return btif_av_init();
}
@@ -821,8 +818,16 @@ btif_sm_handle_t btif_av_get_sm_handle(void)
BOOLEAN btif_av_stream_ready(void)
{
btif_sm_state_t state = btif_sm_get_state(btif_av_cb.sm_handle);
+
BTIF_TRACE_EVENT2("btif_av_stream_ready : sm hdl %d, state %d",
btif_av_cb.sm_handle, state);
+
+ /* also make sure main adapter is enabled */
+ if (btif_is_enabled() == 0)
+ {
+ BTIF_TRACE_EVENT0("main adapter not enabled");
+ return FALSE;
+ }
return (state == BTIF_AV_STATE_OPENED);
}