OSDN Git Service

Initialize btif_max_hf_clients with proper value
authorMallikarjuna GB <gbmalli@codeaurora.org>
Thu, 21 May 2015 08:54:05 +0000 (14:24 +0530)
committerAndre Eisenbach <eisenbach@google.com>
Wed, 10 Jun 2015 21:24:22 +0000 (21:24 +0000)
btif_max_hf_clients which is an unsigned 16bit integer is
initialized with -1(0xFFFF) in btif_hf.c. Later on, when
application calls init with max_hf_clients as 1, btif_max_hf_clients
will be set to 1. But, before this happens, context switch happened
from application context to btif context with btif_max_hf_clients as -1.
In the btif context, BTA_AgRegister gets called in for loop for 0xFFFF
times. We are running out of scbs due to this.
Initialize btif_max_hf_clients with 1. Assign it to max_hf_clients
before context switch happens.

Change-Id: Ibde1bebbab2eb64442027164236f1d82e4269d23

btif/src/btif_hf.c

index 3e0122c..f3fd983 100644 (file)
@@ -95,7 +95,7 @@
 #define BTIF_HF_NUM_CB       2
 
 /* Max HF clients supported from App */
-UINT16 btif_max_hf_clients = -1;
+UINT16 btif_max_hf_clients = 1;
 
 /* HF app ids for service registration */
 typedef enum {
@@ -704,6 +704,10 @@ static bt_status_t init( bthf_callbacks_t* callbacks, int max_hf_clients)
     bt_hf_callbacks = callbacks;
     memset(&btif_hf_cb, 0, sizeof(btif_hf_cb));
 
+    memset(&btif_hf_cb, 0, sizeof(btif_hf_cb));
+    btif_max_hf_clients = max_hf_clients;
+    BTIF_TRACE_DEBUG("btif_max_hf_clients = %d", btif_max_hf_clients);
+
     /* Invoke the enable service API to the core to set the appropriate service_id
      * Internally, the HSP_SERVICE_ID shall also be enabled if HFP is enabled (phone)
      * othwerwise only HSP is enabled (tablet)