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

Commit fb1e2905 authored by Myles Watson's avatar Myles Watson
Browse files

Update macros: Add parens and do-while blocks

Test: mma -j32
Change-Id: I7a77fb3e045e29c57cbf2e9c36b8867ca263a82f
parent 6db20f6d
Loading
Loading
Loading
Loading
+134 −142
Original line number Original line Diff line number Diff line
@@ -74,54 +74,53 @@ tBTA_DM_PCM_RESAMPLE_CB bta_dm_pcm_cb;
**  Macro Definition
**  Macro Definition
*****************************************************************************/
*****************************************************************************/



#define CHECK_SATURATION16(x) \
#define CHECK_SATURATION16(x) \
            if (x > 32767)                                              \
  do {                        \
                x = 32767;                                              \
    if ((x) > 32767)          \
            else if (x < -32768)                                        \
      (x) = 32767;            \
                x = -32768;
    else if ((x) < -32768)    \
      (x) = -32768;           \
  } while (0)


////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
//
//
#define CONVERT_44100_TO_BLUETOOTH(pStart, pEnd)          \
#define CONVERT_44100_TO_BLUETOOTH(pStart, pEnd)          \
    {                                                                       \
  do {                                                    \
    int32_t out1, out2, out3, out4, out5;                 \
    int32_t out1, out2, out3, out4, out5;                 \
        SRC_TYPE    *pS = (SRC_TYPE *)pStart;                               \
    SRC_TYPE* pS = (SRC_TYPE*)(pStart);                   \
        SRC_TYPE    *pSEnd = (SRC_TYPE *)pEnd;                              \
    SRC_TYPE* pSEnd = (SRC_TYPE*)(pEnd);                  \
                                                          \
                                                          \
        while (pS < pSEnd)                                                  \
    while (pS < pSEnd) {                                  \
        {                                                                   \
      CurrentPos -= 8000;                                 \
      CurrentPos -= 8000;                                 \
                                                          \
                                                          \
            if (CurrentPos >= 0)                                            \
      if (CurrentPos >= 0) {                              \
            {                                                               \
        pS += SRC_CHANNELS;                               \
        pS += SRC_CHANNELS;                               \
        continue;                                         \
        continue;                                         \
      }                                                   \
      }                                                   \
      CurrentPos += dwSrcSps;                             \
      CurrentPos += dwSrcSps;                             \
                                                          \
                                                          \
            out1 = (SRC_SAMPLE(0) * 1587)                                   \
      out1 = (SRC_SAMPLE(0) * 1587) +                     \
                 + ((SRC_SAMPLE(1) + SRC_SAMPLE(-1)) * 1522)                \
             ((SRC_SAMPLE(1) + SRC_SAMPLE(-1)) * 1522) +  \
                 + ((SRC_SAMPLE(2) + SRC_SAMPLE(-2)) * 1337)                \
             ((SRC_SAMPLE(2) + SRC_SAMPLE(-2)) * 1337) +  \
                 + ((SRC_SAMPLE(3) + SRC_SAMPLE(-3)) * 1058);               \
             ((SRC_SAMPLE(3) + SRC_SAMPLE(-3)) * 1058);   \
                                                          \
                                                          \
      out1 = out1 / 30000;                                \
      out1 = out1 / 30000;                                \
                                                          \
                                                          \
            out2 = ((SRC_SAMPLE(4) + SRC_SAMPLE(-4)) * 725)                 \
      out2 = ((SRC_SAMPLE(4) + SRC_SAMPLE(-4)) * 725) +   \
                 + ((SRC_SAMPLE(5) + SRC_SAMPLE(-5)) * 384)                 \
             ((SRC_SAMPLE(5) + SRC_SAMPLE(-5)) * 384) +   \
                 + ((SRC_SAMPLE(6) + SRC_SAMPLE(-6)) * 79);                 \
             ((SRC_SAMPLE(6) + SRC_SAMPLE(-6)) * 79);     \
                                                          \
                                                          \
      out2 = out2 / 30000;                                \
      out2 = out2 / 30000;                                \
                                                          \
                                                          \
            out3 = ((SRC_SAMPLE(7) + SRC_SAMPLE(-7)) * 156)                 \
      out3 = ((SRC_SAMPLE(7) + SRC_SAMPLE(-7)) * 156) +   \
                 + ((SRC_SAMPLE(8) + SRC_SAMPLE(-8)) * 298)                 \
             ((SRC_SAMPLE(8) + SRC_SAMPLE(-8)) * 298) +   \
                 + ((SRC_SAMPLE(9) + SRC_SAMPLE(-9)) * 345);                \
             ((SRC_SAMPLE(9) + SRC_SAMPLE(-9)) * 345);    \
                                                          \
                                                          \
      out3 = out3 / 30000;                                \
      out3 = out3 / 30000;                                \
                                                          \
                                                          \
            out4 = ((SRC_SAMPLE(10) + SRC_SAMPLE(-10)) * 306)               \
      out4 = ((SRC_SAMPLE(10) + SRC_SAMPLE(-10)) * 306) + \
                 + ((SRC_SAMPLE(11) + SRC_SAMPLE(-11)) * 207)               \
             ((SRC_SAMPLE(11) + SRC_SAMPLE(-11)) * 207) + \
                 + ((SRC_SAMPLE(12) + SRC_SAMPLE(-12)) * 78);               \
             ((SRC_SAMPLE(12) + SRC_SAMPLE(-12)) * 78);   \
                                                          \
                                                          \
      out4 = out4 / 30000;                                \
      out4 = out4 / 30000;                                \
                                                          \
                                                          \
@@ -132,45 +131,42 @@ tBTA_DM_PCM_RESAMPLE_CB bta_dm_pcm_cb;
                                                          \
                                                          \
      pS += SRC_CHANNELS;                                 \
      pS += SRC_CHANNELS;                                 \
    }                                                     \
    }                                                     \
    }
  } while (0)



////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
//
//
#define CONVERT_22050_TO_BLUETOOTH(pStart, pEnd)         \
#define CONVERT_22050_TO_BLUETOOTH(pStart, pEnd)         \
    {                                                                       \
  do {                                                   \
    int32_t out1, out2, out3, out4, out5;                \
    int32_t out1, out2, out3, out4, out5;                \
        SRC_TYPE    *pS = (SRC_TYPE *)pStart;                               \
    SRC_TYPE* pS = (SRC_TYPE*)(pStart);                  \
        SRC_TYPE    *pSEnd = (SRC_TYPE *)pEnd;                              \
    SRC_TYPE* pSEnd = (SRC_TYPE*)(pEnd);                 \
                                                         \
                                                         \
        while (pS < pSEnd)                                                  \
    while (pS < pSEnd) {                                 \
        {                                                                   \
      CurrentPos -= 8000;                                \
      CurrentPos -= 8000;                                \
                                                         \
                                                         \
            if (CurrentPos >= 0)                                            \
      if (CurrentPos >= 0) {                             \
            {                                                               \
        pS += SRC_CHANNELS;                              \
        pS += SRC_CHANNELS;                              \
        continue;                                        \
        continue;                                        \
      }                                                  \
      }                                                  \
      CurrentPos += dwSrcSps;                            \
      CurrentPos += dwSrcSps;                            \
                                                         \
                                                         \
            out1 = (SRC_SAMPLE(0) * 2993)                                   \
      out1 = (SRC_SAMPLE(0) * 2993) +                    \
                 + ((SRC_SAMPLE(1) + SRC_SAMPLE(-1)) * 2568)                \
             ((SRC_SAMPLE(1) + SRC_SAMPLE(-1)) * 2568) + \
                 + ((SRC_SAMPLE(2) + SRC_SAMPLE(-2)) * 1509)                \
             ((SRC_SAMPLE(2) + SRC_SAMPLE(-2)) * 1509) + \
                 + ((SRC_SAMPLE(3) + SRC_SAMPLE(-3)) * 331);                \
             ((SRC_SAMPLE(3) + SRC_SAMPLE(-3)) * 331);   \
                                                         \
                                                         \
      out1 = out1 / 30000;                               \
      out1 = out1 / 30000;                               \
                                                         \
                                                         \
            out2 = ((SRC_SAMPLE(4) + SRC_SAMPLE(-4)) * 454)                 \
      out2 = ((SRC_SAMPLE(4) + SRC_SAMPLE(-4)) * 454) +  \
                 + ((SRC_SAMPLE(5) + SRC_SAMPLE(-5)) * 620)                 \
             ((SRC_SAMPLE(5) + SRC_SAMPLE(-5)) * 620) +  \
                 + ((SRC_SAMPLE(6) + SRC_SAMPLE(-6)) * 305);                \
             ((SRC_SAMPLE(6) + SRC_SAMPLE(-6)) * 305);   \
                                                         \
                                                         \
      out2 = out2 / 30000;                               \
      out2 = out2 / 30000;                               \
                                                         \
                                                         \
            out3 = ((SRC_SAMPLE(7) + SRC_SAMPLE(-7)) * 127)                 \
      out3 = ((SRC_SAMPLE(7) + SRC_SAMPLE(-7)) * 127) +  \
                 + ((SRC_SAMPLE(8) + SRC_SAMPLE(-8)) * 350)                 \
             ((SRC_SAMPLE(8) + SRC_SAMPLE(-8)) * 350) +  \
                 + ((SRC_SAMPLE(9) + SRC_SAMPLE(-9)) * 265)                 \
             ((SRC_SAMPLE(9) + SRC_SAMPLE(-9)) * 265) +  \
                 + ((SRC_SAMPLE(10) + SRC_SAMPLE(-10)) * 6);                \
             ((SRC_SAMPLE(10) + SRC_SAMPLE(-10)) * 6);   \
                                                         \
                                                         \
      out3 = out3 / 30000;                               \
      out3 = out3 / 30000;                               \
                                                         \
                                                         \
@@ -185,36 +181,33 @@ tBTA_DM_PCM_RESAMPLE_CB bta_dm_pcm_cb;
                                                         \
                                                         \
      pS += SRC_CHANNELS;                                \
      pS += SRC_CHANNELS;                                \
    }                                                    \
    }                                                    \
    }
  } while (0)



////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
//
//
#define CONVERT_11025_TO_BLUETOOTH(pStart, pEnd)         \
#define CONVERT_11025_TO_BLUETOOTH(pStart, pEnd)         \
    {                                                                       \
  do {                                                   \
    int32_t out1;                                        \
    int32_t out1;                                        \
        SRC_TYPE    *pS = (SRC_TYPE *)pStart;                               \
    SRC_TYPE* pS = (SRC_TYPE*)(pStart);                  \
        SRC_TYPE    *pSEnd = (SRC_TYPE *)pEnd;                              \
    SRC_TYPE* pSEnd = (SRC_TYPE*)(pEnd);                 \
                                                         \
                                                         \
        while (pS < pSEnd)                                                  \
    while (pS < pSEnd) {                                 \
        {                                                                   \
      CurrentPos -= 8000;                                \
      CurrentPos -= 8000;                                \
                                                         \
                                                         \
            if (CurrentPos >= 0)                                            \
      if (CurrentPos >= 0) {                             \
            {                                                               \
        pS += SRC_CHANNELS;                              \
        pS += SRC_CHANNELS;                              \
        continue;                                        \
        continue;                                        \
      }                                                  \
      }                                                  \
      CurrentPos += dwSrcSps;                            \
      CurrentPos += dwSrcSps;                            \
                                                         \
                                                         \
            out1 = (SRC_SAMPLE(0) * 6349)                                   \
      out1 = (SRC_SAMPLE(0) * 6349) +                    \
                 + ((SRC_SAMPLE(1) + SRC_SAMPLE(-1)) * 2874)                \
             ((SRC_SAMPLE(1) + SRC_SAMPLE(-1)) * 2874) - \
                 - ((SRC_SAMPLE(2) + SRC_SAMPLE(-2)) * 1148)                \
             ((SRC_SAMPLE(2) + SRC_SAMPLE(-2)) * 1148) - \
                 - ((SRC_SAMPLE(3) + SRC_SAMPLE(-3)) * 287)                 \
             ((SRC_SAMPLE(3) + SRC_SAMPLE(-3)) * 287) +  \
                 + ((SRC_SAMPLE(4) + SRC_SAMPLE(-4)) * 675)                 \
             ((SRC_SAMPLE(4) + SRC_SAMPLE(-4)) * 675) -  \
                 - ((SRC_SAMPLE(5) + SRC_SAMPLE(-5)) * 258)                 \
             ((SRC_SAMPLE(5) + SRC_SAMPLE(-5)) * 258) -  \
                 - ((SRC_SAMPLE(6) + SRC_SAMPLE(-6)) * 206)                 \
             ((SRC_SAMPLE(6) + SRC_SAMPLE(-6)) * 206) +  \
                 + ((SRC_SAMPLE(7) + SRC_SAMPLE(-7)) * 266);                \
             ((SRC_SAMPLE(7) + SRC_SAMPLE(-7)) * 266);   \
                                                         \
                                                         \
      out1 = out1 / 30000;                               \
      out1 = out1 / 30000;                               \
                                                         \
                                                         \
@@ -223,8 +216,7 @@ tBTA_DM_PCM_RESAMPLE_CB bta_dm_pcm_cb;
                                                         \
                                                         \
      pS += SRC_CHANNELS;                                \
      pS += SRC_CHANNELS;                                \
    }                                                    \
    }                                                    \
    }
  } while (0)



////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
//
//
+16 −8
Original line number Original line Diff line number Diff line
@@ -582,14 +582,22 @@ extern tBTA_HL_CB bta_hl_cb;


#define BTA_HL_GET_CB_PTR() &(bta_hl_cb)
#define BTA_HL_GET_CB_PTR() &(bta_hl_cb)
#define BTA_HL_GET_APP_CB_PTR(app_idx) &(bta_hl_cb.acb[(app_idx)])
#define BTA_HL_GET_APP_CB_PTR(app_idx) &(bta_hl_cb.acb[(app_idx)])
#define BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx) &(bta_hl_cb.acb[(app_idx)].mcb[(mcl_idx)])
#define BTA_HL_GET_MCL_CB_PTR(app_idx, mcl_idx) \
#define BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx) &(bta_hl_cb.acb[(app_idx)].mcb[(mcl_idx)].mdl[mdl_idx])
  &(bta_hl_cb.acb[(app_idx)].mcb[(mcl_idx)])
#define BTA_HL_GET_MDL_CFG_PTR(app_idx, item_idx) &(bta_hl_cb.acb[(app_idx)].mdl_cfg[(item_idx)])
#define BTA_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx) \
#define BTA_HL_GET_ECHO_CFG_PTR(app_idx)  &(bta_hl_cb.acb[(app_idx)].sup_feature.echo_cfg)
  &(bta_hl_cb.acb[(app_idx)].mcb[(mcl_idx)].mdl[(mdl_idx)])
#define BTA_HL_GET_MDEP_CFG_PTR(app_idx, mdep_cfg_idx)  &(bta_hl_cb.acb[(app_idx)].sup_feature.mdep[mdep_cfg_idx].mdep_cfg)
#define BTA_HL_GET_MDL_CFG_PTR(app_idx, item_idx) \
  &(bta_hl_cb.acb[(app_idx)].mdl_cfg[(item_idx)])
#define BTA_HL_GET_ECHO_CFG_PTR(app_idx) \
  &(bta_hl_cb.acb[(app_idx)].sup_feature.echo_cfg)
#define BTA_HL_GET_MDEP_CFG_PTR(app_idx, mdep_cfg_idx) \
  &(bta_hl_cb.acb[(app_idx)].sup_feature.mdep[(mdep_cfg_idx)].mdep_cfg)
#define BTA_HL_GET_DATA_CFG_PTR(app_idx, mdep_cfg_idx, data_cfg_idx) \
#define BTA_HL_GET_DATA_CFG_PTR(app_idx, mdep_cfg_idx, data_cfg_idx) \
           &(bta_hl_cb.acb[(app_idx)].sup_feature.mdep[mdep_cfg_idx].mdep_cfg.data_cfg[data_cfg_idx])
  &(bta_hl_cb.acb[(app_idx)]                                         \
#define BTA_HL_GET_BUF_PTR(p_pkt) ((uint8_t *)((uint8_t *) ((p_pkt)+1) + (p_pkt)->offset))
        .sup_feature.mdep[(mdep_cfg_idx)]                            \
        .mdep_cfg.data_cfg[(data_cfg_idx)])
#define BTA_HL_GET_BUF_PTR(p_pkt) \
  ((uint8_t*)((uint8_t*)((p_pkt) + 1) + (p_pkt)->offset))


/*****************************************************************************
/*****************************************************************************
**  Function prototypes
**  Function prototypes
+7 −8
Original line number Original line Diff line number Diff line
@@ -53,12 +53,11 @@


#define AVCT_PARSE_HDR(p, label, type, cr_ipid) \
#define AVCT_PARSE_HDR(p, label, type, cr_ipid) \
  do {                                          \
  do {                                          \
    label = *(p) >> 4; \
    (label) = *(p) >> 4;                        \
    (type) = (*(p) >> 2) & 3;                   \
    (type) = (*(p) >> 2) & 3;                   \
    (cr_ipid) = *(p)++ & 3;                     \
    (cr_ipid) = *(p)++ & 3;                     \
  } while (0)
  } while (0)


#define AVCT_PKT_TYPE(p) \
#define AVCT_PKT_TYPE(p) ((*(p) >> 2) & 3)
    ((*(p) >> 2) & 3)


#endif /* AVCT_DEFS_H */
#endif /* AVCT_DEFS_H */