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

Commit 0ee577cf authored by Jakub Pawlowski's avatar Jakub Pawlowski
Browse files

Use standard types instead of OI_INT* and OI_UINT* types

Test: mma -j45
Change-Id: Ieadd33bfe1be9439e1aeb9a7844260a6e33d8dcd
parent 2a5614d1
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -97,9 +97,9 @@ static tBTIF_A2DP_SINK_CB btif_a2dp_sink_cb;
static int btif_a2dp_sink_state = BTIF_A2DP_SINK_STATE_OFF;

static OI_CODEC_SBC_DECODER_CONTEXT btif_a2dp_sink_context;
static OI_UINT32 btif_a2dp_sink_context_data[CODEC_DATA_WORDS(
static uint32_t btif_a2dp_sink_context_data[CODEC_DATA_WORDS(
    2, SBC_CODEC_FAST_FILTER_BUFFERS)];
static OI_INT16
static int16_t
    btif_a2dp_sink_pcm_data[15 * SBC_MAX_SAMPLES_PER_FRAME * SBC_MAX_CHANNELS];

static void btif_a2dp_sink_startup_delayed(void* context);
@@ -331,7 +331,7 @@ static void btif_a2dp_sink_handle_inc_media(tBT_SBC_HDR* p_msg) {
  uint8_t* sbc_start_frame = ((uint8_t*)(p_msg + 1) + p_msg->offset + 1);
  int count;
  uint32_t pcmBytes, availPcmBytes;
  OI_INT16* pcmDataPointer =
  int16_t* pcmDataPointer =
      btif_a2dp_sink_pcm_data; /* Will be overwritten on next packet receipt */
  OI_STATUS status;
  int num_sbc_frames = p_msg->num_frames_to_be_processed;
@@ -351,8 +351,8 @@ static void btif_a2dp_sink_handle_inc_media(tBT_SBC_HDR* p_msg) {
    pcmBytes = availPcmBytes;
    status = OI_CODEC_SBC_DecodeFrame(
        &btif_a2dp_sink_context, (const OI_BYTE**)&sbc_start_frame,
        (OI_UINT32*)&sbc_frame_len, (OI_INT16*)pcmDataPointer,
        (OI_UINT32*)&pcmBytes);
        (uint32_t*)&sbc_frame_len, (int16_t*)pcmDataPointer,
        (uint32_t*)&pcmBytes);
    if (!OI_SUCCESS(status)) {
      APPL_TRACE_ERROR("%s: Decoding failure: %d", __func__, status);
      break;
+9 −9
Original line number Diff line number Diff line
@@ -44,28 +44,28 @@ INLINE void OI_BITSTREAM_ReadInit(OI_BITSTREAM *bs, const OI_BYTE *buffer);

INLINE void OI_BITSTREAM_WriteInit(OI_BITSTREAM *bs, OI_BYTE *buffer);

INLINE OI_UINT32 OI_BITSTREAM_ReadUINT(OI_BITSTREAM *bs, OI_UINT bits);
INLINE uint32_t OI_BITSTREAM_ReadUINT(OI_BITSTREAM *bs, OI_UINT bits);

INLINE OI_UINT8 OI_BITSTREAM_ReadUINT4Aligned(OI_BITSTREAM *bs);
INLINE uint8_t OI_BITSTREAM_ReadUINT4Aligned(OI_BITSTREAM *bs);

INLINE OI_UINT8 OI_BITSTREAM_ReadUINT8Aligned(OI_BITSTREAM *bs);
INLINE uint8_t OI_BITSTREAM_ReadUINT8Aligned(OI_BITSTREAM *bs);

INLINE void OI_BITSTREAM_WriteUINT(OI_BITSTREAM *bs,
                                   OI_UINT16 value,
                                   uint16_t value,
                                   OI_UINT bits);

/*
 * Use knowledge that the bitstream is aligned to optimize the write of a byte
 */
PRIVATE void OI_BITSTREAM_WriteUINT8Aligned(OI_BITSTREAM *bs,
                                            OI_UINT8 datum);
                                            uint8_t datum);

/*
 * Use knowledge that the bitstream is aligned to optimize the write pair of nibbles
 */
PRIVATE void OI_BITSTREAM_Write2xUINT4Aligned(OI_BITSTREAM *bs,
                                              OI_UINT8 datum1,
                                              OI_UINT8 datum2);
                                              uint8_t datum1,
                                              uint8_t datum2);

/** Internally the bitstream looks ahead in the stream. When
 * OI_SBC_ReadScalefactors() goes to temporarily break the abstraction, it will
@@ -102,7 +102,7 @@ do {\
    \
    while ((bitPtr) <= 16) {\
        (bitPtr) += 8;\
        *(ptr)++ = (OI_UINT8)((value) >> 24);\
        *(ptr)++ = (uint8_t)((value) >> 24);\
        (value) <<= 8;\
    }\
} while (0)
@@ -111,7 +111,7 @@ do {\
do {\
    while ((bitPtr) < 32) {\
        (bitPtr) += 8;\
        *(ptr)++ = (OI_UINT8)((value) >> 24);\
        *(ptr)++ = (uint8_t)((value) >> 24);\
        (value) <<= 8;\
    }\
} while (0)
+12 −12
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ extern "C" {
 *  - array[5] contains bits 7-0.
 */
typedef struct  {
    OI_UINT8    addr[OI_BD_ADDR_BYTE_SIZE] ;   /**< Bluetooth device address represented as an array of 8-bit values */
    uint8_t    addr[OI_BD_ADDR_BYTE_SIZE] ;   /**< Bluetooth device address represented as an array of 8-bit values */
} OI_BD_ADDR ;

/**
@@ -75,12 +75,12 @@ typedef struct {
/**
 * 16-bit representation of a 128-bit UUID
 */
typedef OI_UINT16 OI_UUID16;
typedef uint16_t OI_UUID16;

/**
 * 32-bit representation of a 128-bit UUID
 */
typedef OI_UINT32 OI_UUID32;
typedef uint32_t OI_UUID32;

/**
 * number of bytes in a 128 bit UUID
@@ -101,8 +101,8 @@ typedef OI_UINT32 OI_UUID32;
 * stored as bytes in big-endian order.
 */
typedef struct {
    OI_UINT32 ms32bits;                                    /**< most significant 32 bits of 128-bit UUID */
    OI_UINT8 base[OI_BT_UUID128_SIZE - sizeof(OI_UINT32)]; /**< remainder of 128-bit UUID, array of 8-bit values */
    uint32_t ms32bits;                                    /**< most significant 32 bits of 128-bit UUID */
    uint8_t base[OI_BT_UUID128_SIZE - sizeof(uint32_t)]; /**< remainder of 128-bit UUID, array of 8-bit values */
} OI_UUID128;

/** @} */
@@ -134,7 +134,7 @@ typedef struct {
 *  - array[15] contains bits 120- 127.
 */
typedef struct {
    OI_UINT8    key[OI_BT_LINK_KEY_SIZE] ;   /**< link key represented as an array of 8-bit values */
    uint8_t    key[OI_BT_LINK_KEY_SIZE] ;   /**< link key represented as an array of 8-bit values */
} OI_LINK_KEY ;


@@ -142,7 +142,7 @@ typedef struct {
#define OI_BT_OOB_NUM_BYTES     16

typedef struct {
    OI_UINT8    value[OI_BT_OOB_NUM_BYTES] ;   /**< same struct used for C and R values */
    uint8_t    value[OI_BT_OOB_NUM_BYTES] ;   /**< same struct used for C and R values */
} OI_OOB_DATA ;


@@ -166,7 +166,7 @@ typedef enum {

/** data type for a PIN (PINs are treated as strings, so endianness does not apply.) */
typedef struct  {
    OI_UINT8    pin[OI_BT_PIN_CODE_SIZE] ; /**< PIN represented as an array of 8-bit values */
    uint8_t    pin[OI_BT_PIN_CODE_SIZE] ; /**< PIN represented as an array of 8-bit values */
} OI_PIN_CODE ;

/** maximum number of SCO connections per device, which is 3 as of version 2.0+EDR
@@ -174,16 +174,16 @@ typedef struct {
#define OI_BT_MAX_SCO_CONNECTIONS  3

/** data type for clock offset */
typedef OI_UINT16   OI_BT_CLOCK_OFFSET ;
typedef uint16_t   OI_BT_CLOCK_OFFSET ;

/** data type for a LM handle */
typedef OI_UINT16 OI_HCI_LM_HANDLE;
typedef uint16_t OI_HCI_LM_HANDLE;

/** opaque data type for a SCO or ACL connection handle */
typedef struct _OI_HCI_CONNECTION *OI_HCI_CONNECTION_HANDLE;

/** data type for HCI Error Code, as defined in oi_hcispec.h */
typedef OI_UINT8    OI_HCI_ERROR_CODE ;
typedef uint8_t    OI_HCI_ERROR_CODE ;

/**
 * The Bluetooth device type is indicated by a 24-bit bitfield, represented as a
@@ -191,7 +191,7 @@ typedef OI_UINT8 OI_HCI_ERROR_CODE ;
 * in the file oi_bt_assigned_nos.h and in the Bluetooth "Assigned Numbers" specification
 * at http://www.bluetooth.org/assigned-numbers/.
 */
typedef OI_UINT32   OI_BT_DEVICE_CLASS ;
typedef uint32_t   OI_BT_DEVICE_CLASS ;

#define OI_BT_DEV_CLASS_FORMAT_MASK        0x000003    /**< Bits 0-1 contain format type. */
#define OI_BT_DEV_CLASS_MINOR_DEVICE_MASK  0x0000FC    /**< Bits 2-7 contain minor device class value. */
+64 −64
Original line number Diff line number Diff line
@@ -120,56 +120,56 @@ Declarations of codec functions, data types, and macros.
@{
*/

typedef OI_INT16 SBC_BUFFER_T;
typedef int16_t SBC_BUFFER_T;


/** Used internally. */
typedef struct {
    OI_UINT16 frequency;    /**< The sampling frequency. Input parameter. */
    OI_UINT8 freqIndex;
    uint16_t frequency;    /**< The sampling frequency. Input parameter. */
    uint8_t freqIndex;

    OI_UINT8 nrof_blocks;   /**< The block size used to encode the stream. Input parameter. */
    OI_UINT8 blocks;
    uint8_t nrof_blocks;   /**< The block size used to encode the stream. Input parameter. */
    uint8_t blocks;


    OI_UINT8 nrof_subbands; /**< The number of subbands of the encoded stream. Input parameter. */
    OI_UINT8 subbands;
    uint8_t nrof_subbands; /**< The number of subbands of the encoded stream. Input parameter. */
    uint8_t subbands;

    OI_UINT8 mode;          /**< The mode of the encoded channel. Input parameter. */
    OI_UINT8 nrof_channels; /**< The number of channels of the encoded stream. */
    uint8_t mode;          /**< The mode of the encoded channel. Input parameter. */
    uint8_t nrof_channels; /**< The number of channels of the encoded stream. */

    OI_UINT8 alloc;         /**< The bit allocation method. Input parameter. */
    OI_UINT8 bitpool;       /**< Size of the bit allocation pool used to encode the stream. Input parameter. */
    OI_UINT8 crc;           /**< Parity check byte used for error detection. */
    OI_UINT8 join;          /**< Whether joint stereo has been used. */
    OI_UINT8 enhanced;
    OI_UINT8 min_bitpool;   /**< This value is only used when encoding. SBC_MAX_BITPOOL if variable
    uint8_t alloc;         /**< The bit allocation method. Input parameter. */
    uint8_t bitpool;       /**< Size of the bit allocation pool used to encode the stream. Input parameter. */
    uint8_t crc;           /**< Parity check byte used for error detection. */
    uint8_t join;          /**< Whether joint stereo has been used. */
    uint8_t enhanced;
    uint8_t min_bitpool;   /**< This value is only used when encoding. SBC_MAX_BITPOOL if variable
                                 bitpools are disallowed, otherwise the minimum bitpool size that will
                                 be used by the bit allocator.  */

    OI_UINT8 cachedInfo;    /**< Information about the previous frame */
    uint8_t cachedInfo;    /**< Information about the previous frame */
} OI_CODEC_SBC_FRAME_INFO;

/** Used internally. */
typedef struct {
    const OI_CHAR *codecInfo;
    OI_CODEC_SBC_FRAME_INFO frameInfo;
    OI_INT8 scale_factor[SBC_MAX_CHANNELS*SBC_MAX_BANDS];
    OI_UINT32 frameCount;
    OI_INT32 *subdata;
    int8_t scale_factor[SBC_MAX_CHANNELS*SBC_MAX_BANDS];
    uint32_t frameCount;
    int32_t *subdata;

    SBC_BUFFER_T *filterBuffer[SBC_MAX_CHANNELS];
    OI_INT32 filterBufferLen;
    int32_t filterBufferLen;
    OI_UINT filterBufferOffset;

    union {
        OI_UINT8 uint8[SBC_MAX_CHANNELS*SBC_MAX_BANDS];
        OI_UINT32 uint32[SBC_MAX_CHANNELS*SBC_MAX_BANDS/4];
        uint8_t uint8[SBC_MAX_CHANNELS*SBC_MAX_BANDS];
        uint32_t uint32[SBC_MAX_CHANNELS*SBC_MAX_BANDS/4];
    } bits;
    OI_UINT8 maxBitneed;    /**< Running maximum bitneed */
    uint8_t maxBitneed;    /**< Running maximum bitneed */
    OI_BYTE formatByte;
    OI_UINT8 pcmStride;
    OI_UINT8 maxChannels;
    uint8_t pcmStride;
    uint8_t maxChannels;
} OI_CODEC_SBC_COMMON_CONTEXT;


@@ -180,33 +180,33 @@ typedef struct {
#define SBC_CODEC_MIN_FILTER_BUFFERS 16
#define SBC_CODEC_FAST_FILTER_BUFFERS 27

/* Expands to the number of OI_UINT32s needed to ensure enough memory to encode
/* Expands to the number of uint32_ts needed to ensure enough memory to encode
 * or decode streams of numChannels channels, using numBuffers buffers.
 * Example:
 * OI_UINT32 decoderData[CODEC_DATA_WORDS(SBC_MAX_CHANNELS, SBC_DECODER_FAST_SYNTHESIS_BUFFERS)];
 * uint32_t decoderData[CODEC_DATA_WORDS(SBC_MAX_CHANNELS, SBC_DECODER_FAST_SYNTHESIS_BUFFERS)];
 * */
#define CODEC_DATA_WORDS(numChannels, numBuffers) \
    ((\
        (sizeof(OI_INT32) * SBC_MAX_BLOCKS * (numChannels) * SBC_MAX_BANDS) \
        (sizeof(int32_t) * SBC_MAX_BLOCKS * (numChannels) * SBC_MAX_BANDS) \
         + (sizeof(SBC_BUFFER_T) * SBC_MAX_CHANNELS * SBC_MAX_BANDS * (numBuffers)) \
         + (sizeof (OI_UINT32) - 1) \
    ) / sizeof(OI_UINT32))
         + (sizeof (uint32_t) - 1) \
    ) / sizeof(uint32_t))

/** Opaque parameter to decoding functions; maintains decoder context. */
typedef struct {
    OI_CODEC_SBC_COMMON_CONTEXT common;
    OI_UINT8 limitFrameFormat;              /* Boolean, set by OI_CODEC_SBC_DecoderLimit() */
    OI_UINT8 restrictSubbands;
    OI_UINT8 enhancedEnabled;
    OI_UINT8 bufferedBlocks;
    uint8_t limitFrameFormat;              /* Boolean, set by OI_CODEC_SBC_DecoderLimit() */
    uint8_t restrictSubbands;
    uint8_t enhancedEnabled;
    uint8_t bufferedBlocks;
} OI_CODEC_SBC_DECODER_CONTEXT;

typedef struct {
    OI_UINT32 data[CODEC_DATA_WORDS(1, SBC_CODEC_FAST_FILTER_BUFFERS)];
    uint32_t data[CODEC_DATA_WORDS(1, SBC_CODEC_FAST_FILTER_BUFFERS)];
} OI_CODEC_SBC_CODEC_DATA_MONO;

typedef struct {
    OI_UINT32 data[CODEC_DATA_WORDS(2, SBC_CODEC_FAST_FILTER_BUFFERS)];
    uint32_t data[CODEC_DATA_WORDS(2, SBC_CODEC_FAST_FILTER_BUFFERS)];
} OI_CODEC_SBC_CODEC_DATA_STEREO;

/**
@@ -231,10 +231,10 @@ typedef struct {
 *                  for decoding glitches if synchronization were to be lost.
 */
OI_STATUS OI_CODEC_SBC_DecoderReset(OI_CODEC_SBC_DECODER_CONTEXT *context,
                                    OI_UINT32 *decoderData,
                                    OI_UINT32 decoderDataBytes,
                                    OI_UINT8 maxChannels,
                                    OI_UINT8 pcmStride,
                                    uint32_t *decoderData,
                                    uint32_t decoderDataBytes,
                                    uint8_t maxChannels,
                                    uint8_t pcmStride,
                                    OI_BOOL enhanced);

/**
@@ -258,7 +258,7 @@ OI_STATUS OI_CODEC_SBC_DecoderReset(OI_CODEC_SBC_DECODER_CONTEXT *context,
 */
OI_STATUS OI_CODEC_SBC_DecoderLimit(OI_CODEC_SBC_DECODER_CONTEXT *context,
                                    OI_BOOL enhanced,
                                    OI_UINT8 subbands);
                                    uint8_t subbands);

/**
 * This function sets the decoder parameters for a raw decode where the decoder parameters are not
@@ -288,12 +288,12 @@ OI_STATUS OI_CODEC_SBC_DecoderLimit(OI_CODEC_SBC_DECODER_CONTEXT *context,
 */
OI_STATUS OI_CODEC_SBC_DecoderConfigureRaw(OI_CODEC_SBC_DECODER_CONTEXT *context,
                                           OI_BOOL enhanced,
                                           OI_UINT8 frequency,
                                           OI_UINT8 mode,
                                           OI_UINT8 subbands,
                                           OI_UINT8 blocks,
                                           OI_UINT8 alloc,
                                           OI_UINT8 maxBitpool);
                                           uint8_t frequency,
                                           uint8_t mode,
                                           uint8_t subbands,
                                           uint8_t blocks,
                                           uint8_t alloc,
                                           uint8_t maxBitpool);

/**
 * Decode one SBC frame. The frame has no header bytes. The context must have been previously
@@ -313,7 +313,7 @@ OI_STATUS OI_CODEC_SBC_DecoderConfigureRaw(OI_CODEC_SBC_DECODER_CONTEXT *context
 *                      bytes of frame data. This value will be updated to reflect
 *                      the number of bytes remaining after a decoding operation.
 *
 * @param pcmData       Address of an array of OI_INT16 pairs, which will be
 * @param pcmData       Address of an array of int16_t pairs, which will be
 *                      populated with the decoded audio data. This address
 *                      is not updated.
 *
@@ -324,11 +324,11 @@ OI_STATUS OI_CODEC_SBC_DecoderConfigureRaw(OI_CODEC_SBC_DECODER_CONTEXT *context
 *                      frameBytes.
 */
OI_STATUS OI_CODEC_SBC_DecodeRaw(OI_CODEC_SBC_DECODER_CONTEXT *context,
                                 OI_UINT8 bitpool,
                                 uint8_t bitpool,
                                 const OI_BYTE **frameData,
                                 OI_UINT32 *frameBytes,
                                 OI_INT16 *pcmData,
                                 OI_UINT32 *pcmBytes);
                                 uint32_t *frameBytes,
                                 int16_t *pcmData,
                                 uint32_t *pcmBytes);

/**
 * Decode one SBC frame.
@@ -344,7 +344,7 @@ OI_STATUS OI_CODEC_SBC_DecodeRaw(OI_CODEC_SBC_DECODER_CONTEXT *context,
 *                      bytes of frame data. This value will be updated to reflect
 *                      the number of bytes remaining after a decoding operation.
 *
 * @param pcmData       Address of an array of OI_INT16 pairs, which will be
 * @param pcmData       Address of an array of int16_t pairs, which will be
 *                      populated with the decoded audio data. This address
 *                      is not updated.
 *
@@ -356,9 +356,9 @@ OI_STATUS OI_CODEC_SBC_DecodeRaw(OI_CODEC_SBC_DECODER_CONTEXT *context,
 */
OI_STATUS OI_CODEC_SBC_DecodeFrame(OI_CODEC_SBC_DECODER_CONTEXT *context,
                                   const OI_BYTE **frameData,
                                   OI_UINT32 *frameBytes,
                                   OI_INT16 *pcmData,
                                   OI_UINT32 *pcmBytes);
                                   uint32_t *frameBytes,
                                   int16_t *pcmData,
                                   uint32_t *pcmBytes);

/**
 * Calculate the number of SBC frames but don't decode. CRC's are not checked,
@@ -369,8 +369,8 @@ OI_STATUS OI_CODEC_SBC_DecodeFrame(OI_CODEC_SBC_DECODER_CONTEXT *context,
 * @param frameBytes    Number of bytes avaiable in the frameData buffer
 *
 */
OI_UINT8 OI_CODEC_SBC_FrameCount(OI_BYTE  *frameData,
                                 OI_UINT32 frameBytes);
uint8_t OI_CODEC_SBC_FrameCount(OI_BYTE  *frameData,
                                 uint32_t frameBytes);

/**
 * Analyze an SBC frame but don't do the decode.
@@ -389,7 +389,7 @@ OI_UINT8 OI_CODEC_SBC_FrameCount(OI_BYTE *frameData,
 */
OI_STATUS OI_CODEC_SBC_SkipFrame(OI_CODEC_SBC_DECODER_CONTEXT *context,
                                 const OI_BYTE **frameData,
                                 OI_UINT32 *frameBytes);
                                 uint32_t *frameBytes);

/* Common functions */

@@ -401,7 +401,7 @@ OI_STATUS OI_CODEC_SBC_SkipFrame(OI_CODEC_SBC_DECODER_CONTEXT *context,
  @return the length of an individual encoded frame in
  bytes
  */
OI_UINT16 OI_CODEC_SBC_CalculateFramelen(OI_CODEC_SBC_FRAME_INFO *frame);
uint16_t OI_CODEC_SBC_CalculateFramelen(OI_CODEC_SBC_FRAME_INFO *frame);


/**
@@ -412,8 +412,8 @@ OI_UINT16 OI_CODEC_SBC_CalculateFramelen(OI_CODEC_SBC_FRAME_INFO *frame);
 *
 * @return the maximum bitpool that will fit in the specified frame length
 */
OI_UINT16 OI_CODEC_SBC_CalculateBitpool(OI_CODEC_SBC_FRAME_INFO *frame,
                                        OI_UINT16 frameLen);
uint16_t OI_CODEC_SBC_CalculateBitpool(OI_CODEC_SBC_FRAME_INFO *frame,
                                        uint16_t frameLen);

/**
  Calculate the bit rate.
@@ -423,7 +423,7 @@ OI_UINT16 OI_CODEC_SBC_CalculateBitpool(OI_CODEC_SBC_FRAME_INFO *frame,
  @return the approximate bit rate in bits per second,
  assuming that stream parameters are constant
  */
OI_UINT32 OI_CODEC_SBC_CalculateBitrate(OI_CODEC_SBC_FRAME_INFO *frame);
uint32_t OI_CODEC_SBC_CalculateBitrate(OI_CODEC_SBC_FRAME_INFO *frame);

/**
  Calculate decoded audio data length for one frame.
@@ -433,7 +433,7 @@ OI_UINT32 OI_CODEC_SBC_CalculateBitrate(OI_CODEC_SBC_FRAME_INFO *frame);
  @return length of decoded audio data for a
  single frame, in bytes
  */
OI_UINT16 OI_CODEC_SBC_CalculatePcmBytes(OI_CODEC_SBC_COMMON_CONTEXT *common);
uint16_t OI_CODEC_SBC_CalculatePcmBytes(OI_CODEC_SBC_COMMON_CONTEXT *common);

/**
 * Get the codec version text.
+44 −44

File changed.

Preview size limit exceeded, changes collapsed.

Loading