OSDN Git Service

am f29a2fb..e07ad10 from mirror-m-wireless-internal-release
[android-x86/system-bt.git] / btif / src / btif_av.c
index ff29b19..5bec945 100644 (file)
@@ -27,6 +27,7 @@
 
 #include <hardware/bluetooth.h>
 #include <system/audio.h>
+#include <string.h>
 #include "hardware/bt_av.h"
 
 #define LOG_TAG "bt_btif_av"
@@ -894,9 +895,13 @@ bt_status_t btif_av_init()
             return BT_STATUS_FAIL;
 
         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