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

Commit 93f5cd0e authored by Hemant Gupta's avatar Hemant Gupta Committed by Mike Lockwood
Browse files

SBC Decoder for A2DP SINK

Change-Id: Ic8d1dd81d1788324ec140fe0d1379dfff33deb54
parent 8b9f7716
Loading
Loading
Loading
Loading
+19 −37
Original line number Diff line number Diff line
@@ -80,8 +80,6 @@
OI_CODEC_SBC_DECODER_CONTEXT context;
OI_UINT32 contextData[CODEC_DATA_WORDS(2, SBC_CODEC_FAST_FILTER_BUFFERS)];
OI_INT16 pcmData[15*SBC_MAX_SAMPLES_PER_FRAME*SBC_MAX_CHANNELS];
void *dlhandle = NULL;
oi_sbc_decoder_vendor_interface_t *oi_sbc_decode_vnd_if = NULL;
#endif

/*****************************************************************************
@@ -313,7 +311,17 @@ static void btif_a2dp_ctrl_cb(tUIPC_CH_ID ch_id, tUIPC_EVENT event);
static void btif_a2dp_encoder_update(void);
const char* dump_media_event(UINT16 event);
#ifdef BTA_AVK_INCLUDED
void btif_load_decoder_library();
extern OI_STATUS OI_CODEC_SBC_DecodeFrame(OI_CODEC_SBC_DECODER_CONTEXT *context,
                                          const OI_BYTE **frameData,
                                          unsigned long *frameBytes,
                                          OI_INT16 *pcmData,
                                          unsigned long *pcmBytes);
extern OI_STATUS OI_CODEC_SBC_DecoderReset(OI_CODEC_SBC_DECODER_CONTEXT *context,
                                           unsigned long *decoderData,
                                           unsigned long decoderDataBytes,
                                           OI_UINT8 maxChannels,
                                           OI_UINT8 pcmStride,
                                           OI_BOOL enhanced);
#endif
static void btif_media_flush_q(BUFFER_Q *p_q);
static void btif_media_task_aa_handle_stop_decoding(void );
@@ -1563,8 +1571,10 @@ static void btif_media_task_handle_inc_media(tBT_SBC_HDR*p_msg)
    for(count = 0; count < num_sbc_frames && sbc_frame_len != 0; count ++)
    {
        pcmBytes = availPcmBytes;
        status = oi_sbc_decode_vnd_if->OI_CODEC_SBC_DecodeFrame(&context, (const OI_BYTE**)&sbc_start_frame,
                                                        &sbc_frame_len, pcmDataPointer, &pcmBytes);
        status = OI_CODEC_SBC_DecodeFrame(&context, (const OI_BYTE**)&sbc_start_frame,
                                                        (OI_UINT32 *)&sbc_frame_len,
                                                        (OI_INT16 *)pcmDataPointer,
                                                        (OI_UINT32 *)&pcmBytes);
        if (!OI_SUCCESS(status)) {
            APPL_TRACE_ERROR1("Decoding failure: %d\n", status);
            break;
@@ -2172,13 +2182,6 @@ static void btif_media_task_aa_handle_clear_track (void)
    APPL_TRACE_DEBUG0("btif_media_task_aa_handle_clear_track");
    btStopTrack();
    btDeleteTrack();
    if (dlhandle)
    {
        APPL_TRACE_DEBUG0("Unload Decoder lib");
        dlclose(dlhandle);
        dlhandle = NULL;
        oi_sbc_decode_vnd_if = NULL;
    }
}

/*******************************************************************************
@@ -2196,10 +2199,9 @@ static void btif_media_task_aa_handle_decoder_reset(BT_HDR *p_msg)
    tA2D_STATUS a2d_status;
    tA2D_SBC_CIE sbc_cie;
    OI_STATUS       status;
    UINT32          freq_multiple; /* frequency multiple for 20ms of data */
    UINT32          num_blocks;
    UINT32          num_subbands;
    UINT32          num_channel;
    UINT32          freq_multiple = 48*20; /* frequency multiple for 20ms of data , initialize with 48K*/
    UINT32          num_blocks = 16;
    UINT32          num_subbands = 8;

    APPL_TRACE_DEBUG6("btif_media_task_aa_handle_decoder_reset p_codec_info[%x:%x:%x:%x:%x:%x]",
            p_buf->codec_info[1], p_buf->codec_info[2], p_buf->codec_info[3],
@@ -2214,8 +2216,7 @@ static void btif_media_task_aa_handle_decoder_reset(BT_HDR *p_msg)
    btif_media_cb.is_source = FALSE;
    btif_media_cb.rx_flush = FALSE;
    APPL_TRACE_DEBUG0("Reset to sink role");
    btif_load_decoder_library();
    status = oi_sbc_decode_vnd_if->OI_CODEC_SBC_DecoderReset(&context, contextData, sizeof(contextData), 2, 2, FALSE);
    status = OI_CODEC_SBC_DecoderReset(&context, contextData, sizeof(contextData), 2, 2, FALSE);
    if (!OI_SUCCESS(status)) {
        APPL_TRACE_ERROR1("OI_CODEC_SBC_DecoderReset failed with error code %d\n", status);
    }
@@ -2970,22 +2971,3 @@ void dump_codec_info(unsigned char *p_codec)

}
#ifdef BTA_AVK_INCLUDED
void btif_load_decoder_library()
{
    dlhandle = dlopen("liboi_sbc_decoder.so", RTLD_NOW);
    APPL_TRACE_DEBUG0("Load decoder library");
    if (!dlhandle)
    {
        APPL_TRACE_ERROR0("!!! Failed to load oi_sbc_decoder.so !!!");
        return;
    }

    oi_sbc_decode_vnd_if = (oi_sbc_decoder_vendor_interface_t *) dlsym(dlhandle, "OI_SBC_DECODER_VENDOR_LIB_INTERFACE");
    if (!oi_sbc_decode_vnd_if)
    {
        APPL_TRACE_ERROR0("!!! Failed to get oi sbc decode vendor interface !!!");
        return;
    }
}
#endif
+7 −0
Original line number Diff line number Diff line
LOCAL_PATH := $(call my-dir)

include $(call all-subdir-makefiles)

# Cleanup our locals
#bdroid_C_INCLUDES :=
#bdroid_CFLaGS :=
+7 −0
Original line number Diff line number Diff line
LOCAL_PATH := $(call my-dir)

include $(call all-subdir-makefiles)

# Cleanup our locals
#bdroid_C_INCLUDES :=
#bdroid_CFLaGS :=
+28 −0
Original line number Diff line number Diff line
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

# sbc decoder
LOCAL_SRC_FILES+= \
        ./srce/alloc.c \
        ./srce/bitalloc.c \
        ./srce/bitalloc-sbc.c \
        ./srce/bitstream-decode.c \
        ./srce/decoder-oina.c \
        ./srce/decoder-private.c \
        ./srce/decoder-sbc.c \
        ./srce/dequant.c \
        ./srce/framing.c \
        ./srce/framing-sbc.c \
        ./srce/oi_codec_version.c \
        ./srce/synthesis-sbc.c \
        ./srce/synthesis-dct8.c \
        ./srce/synthesis-8-generated.c \

LOCAL_C_INCLUDES += $(LOCAL_PATH)/include
LOCAL_C_INCLUDES += $(LOCAL_PATH)/srce

LOCAL_MODULE:= libbt-qcom_sbc_decoder
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE_CLASS := STATIC_LIBRARIES

include $(BUILD_STATIC_LIBRARY)
+86 −0
Original line number Diff line number Diff line
/******************************************************************************
 *
 *  Copyright (C) 2014 The Android Open Source Project
 *  Copyright 2002 - 2004 Open Interface North America, Inc. All rights reserved.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at:
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 ******************************************************************************/
#ifndef _OI_ASSERT_H
#define _OI_ASSERT_H
/** @file
  This file provides macros and functions for compile-time and run-time assertions.

  When the OI_DEBUG preprocessor value is defined, the macro OI_ASSERT is compiled into
  the program, providing for a runtime assertion failure check.
  C_ASSERT is a macro that can be used to perform compile time checks.
*/
/**********************************************************************************
  $Revision: #1 $
***********************************************************************************/


/** \addtogroup Debugging Debugging APIs */
/**@{*/

#ifdef __cplusplus
extern "C" {
#endif


#ifdef OI_DEBUG

/** The macro OI_ASSERT takes a condition argument. If the asserted condition
    does not evaluate to true, the OI_ASSERT macro calls the host-dependent function,
    OI_AssertFail(), which reports the failure and generates a runtime error.
*/
void OI_AssertFail(char* file, int line, char* reason);


#define OI_ASSERT(condition) \
    { if (!(condition)) OI_AssertFail(__FILE__, __LINE__, #condition); }

#define OI_ASSERT_FAIL(msg) \
    { OI_AssertFail(__FILE__, __LINE__, msg); }

#else


#define OI_ASSERT(condition)
#define OI_ASSERT_FAIL(msg)

#endif


/**
   C_ASSERT() can be used to perform many compile-time assertions: type sizes, field offsets, etc.
   An assertion failure results in compile time error C2118: negative subscript.
   Unfortunately, this elegant macro doesn't work with GCC, so it's all commented out
   for now. Perhaps later.....
*/

#ifndef C_ASSERT
// #define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1]
// #define C_ASSERT(e)
#endif


/*****************************************************************************/
#ifdef __cplusplus
}
#endif

/**@}*/

#endif /* _OI_ASSERT_H */
Loading