btif_a2dp.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright (c) 2016 Actions Semi Co., Inc.
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /**
  7. * @file
  8. * @brief bt a2dp interface
  9. */
  10. #define SYS_LOG_DOMAIN "btif_a2dp"
  11. #include "btsrv_os_common.h"
  12. #include "btsrv_inner.h"
  13. int btif_a2dp_register_processer(void)
  14. {
  15. return btsrv_register_msg_processer(MSG_BTSRV_A2DP, &btsrv_a2dp_process);
  16. }
  17. int btif_a2dp_start(struct btsrv_a2dp_start_param *param)
  18. {
  19. return btsrv_function_call_malloc(MSG_BTSRV_A2DP, MSG_BTSRV_A2DP_START, (uint8_t *)param, sizeof(struct btsrv_a2dp_start_param), 0);
  20. }
  21. int btif_a2dp_stop(void)
  22. {
  23. return btsrv_function_call(MSG_BTSRV_A2DP, MSG_BTSRV_A2DP_STOP, NULL);
  24. }
  25. int btif_a2dp_disable(void)
  26. {
  27. return btsrv_function_call(MSG_BTSRV_A2DP, MSG_BTSRV_A2DP_DISABLE, NULL);
  28. }
  29. int btif_a2dp_enable(void)
  30. {
  31. return btsrv_function_call(MSG_BTSRV_A2DP, MSG_BTSRV_A2DP_ENABLE, NULL);
  32. }
  33. int btif_a2dp_connect(bool is_src, bd_address_t *bd)
  34. {
  35. return btsrv_function_call_malloc(MSG_BTSRV_A2DP, MSG_BTSRV_A2DP_CONNECT_TO, (uint8_t *)bd, sizeof(bd_address_t), (is_src ? 1 : 0));
  36. }
  37. int btif_a2dp_disconnect(bd_address_t *bd)
  38. {
  39. return btsrv_function_call_malloc(MSG_BTSRV_A2DP, MSG_BTSRV_A2DP_DISCONNECT, (uint8_t *)bd, sizeof(bd_address_t), 0);
  40. }
  41. int btif_a2dp_check_state(void)
  42. {
  43. return btsrv_function_call(MSG_BTSRV_A2DP, MSG_BTSRV_A2DP_CHECK_STATE, NULL);
  44. }
  45. /* delay_time: 1/10 milliseconds */
  46. int btif_a2dp_send_delay_report(uint16_t delay_time)
  47. {
  48. return btsrv_function_call(MSG_BTSRV_A2DP, MSG_BTSRV_A2DP_SEND_DELAY_REPORT, (void *)((uint32_t)delay_time));
  49. }
  50. void btif_a2dp_get_active_mac(bd_address_t *addr)
  51. {
  52. int flags;
  53. flags = btsrv_set_negative_prio();
  54. btsrv_rdm_get_a2dp_acitve_mac(addr);
  55. btsrv_revert_prio(flags);
  56. }