Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4cff8923 authored by jinyao.yu's avatar jinyao.yu Committed by Tim Tsai
Browse files

Add A2DP src and sink co-exist feature btif layer (2/5)

[Description]
Add A2DP src and sink co-exist feature, that we can connect
both sink and src remote device at the same time while only
keep 1 streaming.

Bug: 256938279
Test: A2DP src/sink connect, streaming successully,
net_test_btif_rc unit test pass

Change-Id: I89ee8391f53daffaa992a5e7fafba36635419641
parent 8474c598
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -397,6 +397,9 @@ cc_test {
    include_dirs: btifCommonIncludes,
    srcs: [
        ":TestCommonLogMsg",
        ":TestCommonMockFunctions",
        ":TestMockCommon",
        ":TestMockOsi",
        "test/btif_rc_test.cc",
    ],
    header_libs: ["libbluetooth_headers"],
@@ -411,7 +414,6 @@ cc_test {
        "libbt-protos-lite",
        "libchrome",
        "libevent",
        "libosi",
        "libosi-AllocationTestHarness",
    ],
    target: {
+9 −1
Original line number Diff line number Diff line
@@ -109,7 +109,7 @@ class AvrcpInterfaceImpl : public AvrcpInterface {

  uint16_t MsgReq(uint8_t handle, uint8_t label, uint8_t ctype,
                  BT_HDR* p_pkt) override {
    return AVRC_MsgReq(handle, label, ctype, p_pkt);
    return AVRC_MsgReq(handle, label, ctype, p_pkt, true);
  }

  void SaveControllerVersion(const RawAddress& bdaddr,
@@ -684,5 +684,13 @@ void AvrcpService::DebugDump(int fd) {
  dprintf(fd, "%s", stream.str().c_str());
}

/** when a2dp connected, btif will start register vol changed, so we need a
 * interface for it. */
void AvrcpService::RegisterVolChanged(const RawAddress& bdaddr) {
  LOG(INFO) << ": address=" << ADDRESS_TO_LOGGABLE_STR(bdaddr);

  connection_handler_->RegisterVolChanged(bdaddr);
}

}  // namespace avrcp
}  // namespace bluetooth
+4 −0
Original line number Diff line number Diff line
@@ -76,6 +76,10 @@ class AvrcpService : public MediaCallbacks {
  void SendPlayerSettingsChanged(std::vector<PlayerAttribute> attributes,
                                 std::vector<uint8_t> values) override;

  /** when a2dp connected, btif will start register vol changed, so we need a
   * interface for it. */
  void RegisterVolChanged(const RawAddress& bdaddr);

  class ServiceInterfaceImpl : public ServiceInterface {
   public:
    void Init(MediaInterface* media_interface,
+1 −1
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@
#include "types/raw_address.h"

// Process 'idle' request from the BTIF state machine during initialization.
void btif_a2dp_on_idle(void);
void btif_a2dp_on_idle(const RawAddress& peer_addr);

// Process 'start' request from the BTIF state machine to prepare for A2DP
// streaming.
+25 −0
Original line number Diff line number Diff line
@@ -46,6 +46,11 @@ RawAddress btif_av_sink_active_peer(void);
 */
bool btif_av_is_sink_enabled(void);

/**
 * Check whether A2DP Source is enabled.
 */
bool btif_av_is_source_enabled(void);

/**
 * Start streaming.
 */
@@ -226,6 +231,14 @@ bool btif_av_is_a2dp_offload_running(void);
 */
bool btif_av_is_peer_silenced(const RawAddress& peer_address);

/**
 * check the a2dp connect status
 *
 * @param address : checked device address
 *
 */
bool btif_av_is_connected_addr(const RawAddress& peer_address);

/**
 * Set the dynamic audio buffer size
 *
@@ -240,4 +253,16 @@ void btif_av_set_dynamic_audio_buffer_size(uint8_t dynamic_audio_buffer_size);
 */
void btif_av_set_low_latency(bool is_low_latency);

/**
 * Check whether A2DP Source is enabled.
 */
extern bool btif_av_is_source_enabled(void);
extern bool btif_av_both_enable(void);
extern bool btif_av_src_sink_coexist_enabled(void);
extern bool btif_av_is_sink_enabled(void);
extern bool btif_av_is_connected_addr(const RawAddress& peer_address);
extern bool btif_av_peer_is_connected_sink(const RawAddress& peer_address);
extern bool btif_av_peer_is_connected_source(const RawAddress& peer_address);
extern bool btif_av_peer_is_sink(const RawAddress& peer_address);
extern bool btif_av_peer_is_source(const RawAddress& peer_address);
#endif /* BTIF_AV_H */
Loading