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

Commit 82f6360c authored by Chris Manton's avatar Chris Manton
Browse files

Enum-ify bta/av/bta_av_int::BTA_AV_RS_

Also add BtaAvRoleSwitchText

Towards readable and loggable code

Bug: 163134718
Tag: #refactor
Test: gd/cert/run --host

Change-Id: I334e82ed2d5bb7860b4089b2f2c00158bfb7c2f3
parent 932cd5db
Loading
Loading
Loading
Loading
+19 −3
Original line number Diff line number Diff line
@@ -32,6 +32,10 @@
#include "osi/include/list.h"
#include "stack/include/a2dp_api.h"

#define CASE_RETURN_TEXT(code) \
  case code:                   \
    return #code

/*****************************************************************************
 *  Constants
 ****************************************************************************/
@@ -226,13 +230,25 @@ typedef struct {
  uint16_t service_uuid;
} tBTA_AV_API_REG;

enum {
typedef enum : uint8_t {
  BTA_AV_RS_NONE, /* straight API call */
  BTA_AV_RS_OK,   /* the role switch result - successful */
  BTA_AV_RS_FAIL, /* the role switch result - failed */
  BTA_AV_RS_DONE  /* the role switch is done - continue */
};
typedef uint8_t tBTA_AV_RS_RES;
} tBTA_AV_RS_RES;

inline std::string bta_av_role_switch_result_text(
    const tBTA_AV_RS_RES& result) {
  switch (result) {
    CASE_RETURN_TEXT(BTA_AV_RS_NONE);
    CASE_RETURN_TEXT(BTA_AV_RS_OK);
    CASE_RETURN_TEXT(BTA_AV_RS_FAIL);
    CASE_RETURN_TEXT(BTA_AV_RS_DONE);
    default:
      return std::string("UNKNOWN");
  }
}

/* data type for BTA_AV_API_OPEN_EVT */
typedef struct {
  BT_HDR hdr;