OSDN Git Service

Fix A2DP source double initialization problem
authorAndre Eisenbach <eisenbach@google.com>
Tue, 21 Apr 2015 04:46:37 +0000 (21:46 -0700)
committerAndre Eisenbach <eisenbach@google.com>
Wed, 22 Apr 2015 04:25:52 +0000 (21:25 -0700)
Fixed a problem where A2DP source was initialized twice. Once before
btif was properly initialize and then a second time when the JNI
requests A2DP to be initialized, which would then fail.

Change-Id: Ia5f10a5bda344fe3bd66818a302b6b3f9db32a20

Android.mk
btif/src/btif_av.c
btif/src/btif_core.c
btif/src/btif_pan.c

index a331f19..c5d3d16 100644 (file)
@@ -19,7 +19,6 @@ endif
 
 bdroid_CFLAGS += \
   -Wall \
-#  -Werror \
   -Wno-unused-parameter \
   -Wunused-but-set-variable \
   -UNDEBUG \
index 5bec945..cbd39aa 100644 (file)
@@ -98,7 +98,7 @@ typedef struct
 ******************************************************************************/
 static btav_callbacks_t *bt_av_src_callbacks = NULL;
 static btav_callbacks_t *bt_av_sink_callbacks = NULL;
-static btif_av_cb_t btif_av_cb;
+static btif_av_cb_t btif_av_cb = {0};
 static TIMER_LIST_ENT tle_av_open_on_rc;
 
 /* both interface and media task needs to be ready to alloc incoming request */
@@ -904,11 +904,9 @@ bt_status_t btif_av_init()
                 btif_sm_init((const btif_sm_handler_t*)btif_av_state_handlers, BTIF_AV_STATE_IDLE);
 
         btif_a2dp_on_init();
-
-       return BT_STATUS_SUCCESS;
     }
 
-    return BT_STATUS_DONE;
+    return BT_STATUS_SUCCESS;
 }
 
 /*******************************************************************************
@@ -923,20 +921,11 @@ bt_status_t btif_av_init()
 
 static bt_status_t init_src(btav_callbacks_t* callbacks)
 {
-    bt_status_t status;
-
-    BTIF_TRACE_EVENT("%s", __FUNCTION__);
-
-    if (bt_av_sink_callbacks != NULL) {
-        // already did btif_av_init()
-        status = BT_STATUS_SUCCESS;
-    } else {
-        status = btif_av_init();
-    }
+    BTIF_TRACE_EVENT("%s()", __func__);
 
-    if (status == BT_STATUS_SUCCESS) {
+    bt_status_t status = btif_av_init();
+    if (status == BT_STATUS_SUCCESS)
         bt_av_src_callbacks = callbacks;
-    }
 
     return status;
 }
@@ -953,20 +942,11 @@ static bt_status_t init_src(btav_callbacks_t* callbacks)
 
 static bt_status_t init_sink(btav_callbacks_t* callbacks)
 {
-    bt_status_t status;
-
-    BTIF_TRACE_EVENT("%s", __FUNCTION__);
+    BTIF_TRACE_EVENT("%s()", __func__);
 
-    if (bt_av_src_callbacks != NULL) {
-        // already did btif_av_init()
-        status = BT_STATUS_SUCCESS;
-    } else {
-        status = btif_av_init();
-    }
-
-    if (status == BT_STATUS_SUCCESS) {
+    bt_status_t status = btif_av_init();
+    if (status == BT_STATUS_SUCCESS)
         bt_av_sink_callbacks = callbacks;
-    }
 
     return status;
 }
index 99d7ad4..62d22e1 100644 (file)
@@ -506,9 +506,6 @@ void btif_enable_bluetooth_evt(tBTA_STATUS status)
     /* callback to HAL */
     if (status == BTA_SUCCESS)
     {
-        /* initialize a2dp service */
-        btif_av_init();
-
         /* init rfcomm & l2cap api */
         btif_sock_init();
 
index 8019636..8fe03bb 100644 (file)
@@ -172,8 +172,7 @@ static btpan_callbacks_t callback;
 static bt_status_t btpan_jni_init(const btpan_callbacks_t* callbacks)
 {
     BTIF_TRACE_DEBUG("stack_initialized = %d, btpan_cb.enabled:%d", stack_initialized, btpan_cb.enabled);
-    jni_initialized = TRUE;
-    if(stack_initialized && !btpan_cb.enabled)
+    if (stack_initialized && !btpan_cb.enabled)
         btif_pan_init();
     callback = *callbacks;
     return BT_STATUS_SUCCESS;