OSDN Git Service

am f29a2fb..e07ad10 from mirror-m-wireless-internal-release
[android-x86/system-bt.git] / btif / src / btif_av.c
index 22e33f8..5bec945 100644 (file)
@@ -30,7 +30,7 @@
 #include <string.h>
 #include "hardware/bt_av.h"
 
-#define LOG_TAG "BTIF_AV"
+#define LOG_TAG "bt_btif_av"
 
 #include "btif_av.h"
 #include "btif_util.h"
@@ -39,7 +39,6 @@
 #include "btif_media.h"
 #include "bta_av_api.h"
 #include "gki.h"
-#include "bd.h"
 #include "btu.h"
 #include "bt_utils.h"
 
@@ -122,6 +121,7 @@ else\
     case BTA_AV_VENDOR_CMD_EVT: \
     case BTA_AV_META_MSG_EVT: \
     case BTA_AV_RC_FEAT_EVT: \
+    case BTA_AV_REMOTE_RSP_EVT: \
     { \
          btif_rc_handler(e, d);\
     }break; \
@@ -334,6 +334,7 @@ static BOOLEAN btif_av_state_idle_handler(btif_sm_event_t event, void *p_data)
         case BTA_AV_VENDOR_CMD_EVT:
         case BTA_AV_META_MSG_EVT:
         case BTA_AV_RC_FEAT_EVT:
+        case BTA_AV_REMOTE_RSP_EVT:
             btif_rc_handler(event, (tBTA_AV*)p_data);
             break;
 
@@ -890,13 +891,17 @@ bt_status_t btif_av_init()
 {
     if (btif_av_cb.sm_handle == NULL)
     {
-        if (btif_a2dp_start_media_task() != GKI_SUCCESS)
+        if (!btif_a2dp_start_media_task())
             return BT_STATUS_FAIL;
 
-        btif_enable_service(BTA_A2DP_SERVICE_ID);
+        btif_enable_service(BTA_A2DP_SOURCE_SERVICE_ID);
+#if (BTA_AV_SINK_INCLUDED == TRUE)
+        btif_enable_service(BTA_A2DP_SINK_SERVICE_ID);
+#endif
 
         /* 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_av_cb.sm_handle =
+                btif_sm_init((const btif_sm_handler_t*)btif_av_state_handlers, BTIF_AV_STATE_IDLE);
 
         btif_a2dp_on_init();
 
@@ -961,7 +966,6 @@ static bt_status_t init_sink(btav_callbacks_t* callbacks)
 
     if (status == BT_STATUS_SUCCESS) {
         bt_av_sink_callbacks = callbacks;
-        BTA_AvEnable_Sink(TRUE);
     }
 
     return status;
@@ -1040,7 +1044,10 @@ static void cleanup(void)
 
     btif_a2dp_stop_media_task();
 
-    btif_disable_service(BTA_A2DP_SERVICE_ID);
+    btif_disable_service(BTA_A2DP_SOURCE_SERVICE_ID);
+#if (BTA_AV_SINK_INCLUDED == TRUE)
+    btif_disable_service(BTA_A2DP_SINK_SERVICE_ID);
+#endif
 
     /* Also shut down the AV state machine */
     btif_sm_shutdown(btif_av_cb.sm_handle);
@@ -1217,6 +1224,23 @@ bt_status_t btif_av_execute_service(BOOLEAN b_enable)
 
 /*******************************************************************************
 **
+** Function         btif_av_sink_execute_service
+**
+** Description      Initializes/Shuts down the service
+**
+** Returns          BT_STATUS_SUCCESS on success, BT_STATUS_FAIL otherwise
+**
+*******************************************************************************/
+bt_status_t btif_av_sink_execute_service(BOOLEAN b_enable)
+{
+#if (BTA_AV_SINK_INCLUDED == TRUE)
+    BTA_AvEnable_Sink(b_enable);
+#endif
+    return BT_STATUS_SUCCESS;
+}
+
+/*******************************************************************************
+**
 ** Function         btif_av_get_src_interface
 **
 ** Description      Get the AV callback interface for A2DP source profile