diff options
author | Mattias Agren <magren@broadcom.com> | 2012-04-11 13:14:44 -0700 |
---|---|---|
committer | Matthew Xie <mattx@google.com> | 2012-07-14 11:19:17 -0700 |
commit | 2f9c0a7966a08936e8ae7a03ab8fbf1de3b22e0e (patch) | |
tree | 524f260c46e0960216900dda7559f6f87e5873f3 | |
parent | 8e6e9356d5386501d5e0988ce23d0c9aaed31a64 (diff) | |
download | external_bluetooth_bluedroid-2f9c0a7966a08936e8ae7a03ab8fbf1de3b22e0e.zip external_bluetooth_bluedroid-2f9c0a7966a08936e8ae7a03ab8fbf1de3b22e0e.tar.gz external_bluetooth_bluedroid-2f9c0a7966a08936e8ae7a03ab8fbf1de3b22e0e.tar.bz2 |
Always check if reconfig is needed prior to starting an
avdtp stream. Added autoadjusting bitpool if sink requests
a particular range within our exported capability.
Cleanup & fixing file permissions.
Change-Id: Ib5638706d4baef072c79a70ce1497140c3357a0d
30 files changed, 224 insertions, 91 deletions
diff --git a/bta/hh/bta_hh_act.c b/bta/hh/bta_hh_act.c index 163597e..163597e 100755..100644 --- a/bta/hh/bta_hh_act.c +++ b/bta/hh/bta_hh_act.c diff --git a/bta/hh/bta_hh_api.c b/bta/hh/bta_hh_api.c index c84243d..c84243d 100755..100644 --- a/bta/hh/bta_hh_api.c +++ b/bta/hh/bta_hh_api.c diff --git a/bta/include/bta_hh_api.h b/bta/include/bta_hh_api.h index 41af74c..41af74c 100755..100644 --- a/bta/include/bta_hh_api.h +++ b/bta/include/bta_hh_api.h diff --git a/bta/include/bta_jv_api.h b/bta/include/bta_jv_api.h index 303ef2d..303ef2d 100755..100644 --- a/bta/include/bta_jv_api.h +++ b/bta/include/bta_jv_api.h diff --git a/bta/include/bta_jv_co.h b/bta/include/bta_jv_co.h index 09e09c5..09e09c5 100755..100644 --- a/bta/include/bta_jv_co.h +++ b/bta/include/bta_jv_co.h diff --git a/bta/jv/bta_jv_act.c b/bta/jv/bta_jv_act.c index 60729e3..60729e3 100755..100644 --- a/bta/jv/bta_jv_act.c +++ b/bta/jv/bta_jv_act.c diff --git a/bta/jv/bta_jv_api.c b/bta/jv/bta_jv_api.c index fd1c3d3..fd1c3d3 100755..100644 --- a/bta/jv/bta_jv_api.c +++ b/bta/jv/bta_jv_api.c diff --git a/bta/jv/bta_jv_cfg.c b/bta/jv/bta_jv_cfg.c index b37d5de..b37d5de 100755..100644 --- a/bta/jv/bta_jv_cfg.c +++ b/bta/jv/bta_jv_cfg.c diff --git a/bta/jv/bta_jv_int.h b/bta/jv/bta_jv_int.h index 7a18ea2..7a18ea2 100755..100644 --- a/bta/jv/bta_jv_int.h +++ b/bta/jv/bta_jv_int.h diff --git a/bta/jv/bta_jv_main.c b/bta/jv/bta_jv_main.c index 6c97b17..6c97b17 100755..100644 --- a/bta/jv/bta_jv_main.c +++ b/bta/jv/bta_jv_main.c diff --git a/btif/co/bta_av_co.c b/btif/co/bta_av_co.c index bddde54..b37617b 100644..100755 --- a/btif/co/bta_av_co.c +++ b/btif/co/bta_av_co.c @@ -48,9 +48,7 @@ #define BTA_AV_CO_SBC_MIN_BITPOOL_OFF 5 #define BTA_AV_CO_SBC_MAX_BITPOOL_OFF 6 - -#define BTA_AV_CO_SBC_MAX_BITPOOL 0x59 - +#define BTA_AV_CO_SBC_MAX_BITPOOL 53 /* SCMS-T protect info */ const UINT8 bta_av_co_cp_scmst[BTA_AV_CP_INFO_LEN] = "\x02\x02\x00"; @@ -75,7 +73,7 @@ const tA2D_SBC_CIE bta_av_co_sbc_caps = const tA2D_SBC_CIE btif_av_sbc_default_config = { BTIF_AV_SBC_DEFAULT_SAMP_FREQ, /* samp_freq */ - A2D_SBC_IE_CH_MD_STEREO, /* ch_mode */ + A2D_SBC_IE_CH_MD_JOINT, /* ch_mode */ A2D_SBC_IE_BLOCKS_16, /* block_len */ A2D_SBC_IE_SUBBAND_8, /* num_subbands */ A2D_SBC_IE_ALLOC_MD_L, /* alloc_mthd */ @@ -125,6 +123,8 @@ typedef struct tBTA_AV_CO_PEER peers[BTA_AV_NUM_STRS]; /* Current codec configuration - access to this variable must be protected */ tBTIF_AV_CODEC_INFO codec_cfg; + tBTIF_AV_CODEC_INFO codec_cfg_setconfig; /* remote peer setconfig preference */ + tBTA_AV_CO_CP cp; } tBTA_AV_CO_CB; @@ -263,6 +263,9 @@ BOOLEAN bta_av_co_audio_init(UINT8 *p_codec_type, UINT8 *p_codec_info, UINT8 *p_ *p_protect_info = 0; #endif + /* reset remote preference through setconfig */ + bta_av_co_cb.codec_cfg_setconfig.id = BTIF_AV_CODEC_NONE; + switch (index) { case BTIF_SV_AV_AA_SBC_INDEX: @@ -565,6 +568,15 @@ BTA_API void bta_av_co_audio_setconfig(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_ty { recfg_needed = TRUE; } + + /* if remote side requests a restricted notify sinks preferred bitpool range as all other params are + already checked for validify */ + APPL_TRACE_EVENT2("remote peer setconfig bitpool range [%d:%d]", + p_codec_info[BTA_AV_CO_SBC_MIN_BITPOOL_OFF], + p_codec_info[BTA_AV_CO_SBC_MAX_BITPOOL_OFF] ); + + bta_av_co_cb.codec_cfg_setconfig.id = BTIF_AV_CODEC_SBC; + memcpy(bta_av_co_cb.codec_cfg_setconfig.info, p_codec_info, AVDT_CODEC_SIZE); break; @@ -667,6 +679,9 @@ BTA_API void bta_av_co_audio_close(tBTA_AV_HNDL hndl, tBTA_AV_CODEC codec_type, { APPL_TRACE_ERROR0("bta_av_co_audio_close could not find peer entry"); } + + /* reset remote preference through setconfig */ + bta_av_co_cb.codec_cfg_setconfig.id = BTIF_AV_CODEC_NONE; } /******************************************************************************* @@ -825,6 +840,10 @@ static BOOLEAN bta_av_co_audio_codec_build_config(const UINT8 *p_codec_caps, UIN /* Update the bit pool boundaries with the codec capabilities */ p_codec_cfg[BTA_AV_CO_SBC_MIN_BITPOOL_OFF] = p_codec_caps[BTA_AV_CO_SBC_MIN_BITPOOL_OFF]; p_codec_cfg[BTA_AV_CO_SBC_MAX_BITPOOL_OFF] = p_codec_caps[BTA_AV_CO_SBC_MAX_BITPOOL_OFF]; + + APPL_TRACE_EVENT2("bta_av_co_audio_codec_build_config : bitpool min %d, max %d", + p_codec_cfg[BTA_AV_CO_SBC_MIN_BITPOOL_OFF], + p_codec_caps[BTA_AV_CO_SBC_MAX_BITPOOL_OFF]); break; default: APPL_TRACE_ERROR1("bta_av_co_audio_codec_build_config: unsupported codec id %d", bta_av_co_cb.codec_cfg.id); @@ -850,6 +869,13 @@ static BOOLEAN bta_av_co_audio_codec_cfg_matches_caps(UINT8 codec_id, const UINT switch(codec_id) { case BTIF_AV_CODEC_SBC: + + APPL_TRACE_EVENT4("bta_av_co_audio_codec_cfg_matches_caps : min %d/%d max %d/%d", + p_codec_caps[BTA_AV_CO_SBC_MIN_BITPOOL_OFF], + p_codec_cfg[BTA_AV_CO_SBC_MIN_BITPOOL_OFF], + p_codec_caps[BTA_AV_CO_SBC_MAX_BITPOOL_OFF], + p_codec_cfg[BTA_AV_CO_SBC_MAX_BITPOOL_OFF]); + /* Must match all items exactly except bitpool boundaries which can be adjusted */ if (!((p_codec_caps[BTA_AV_CO_SBC_FREQ_CHAN_OFF] & p_codec_cfg[BTA_AV_CO_SBC_FREQ_CHAN_OFF]) && (p_codec_caps[BTA_AV_CO_SBC_BLOCK_BAND_OFF] & p_codec_cfg[BTA_AV_CO_SBC_BLOCK_BAND_OFF]))) @@ -1090,7 +1116,6 @@ BOOLEAN bta_av_co_audio_codec_supported(tBTIF_STATUS *p_status) FUNC_TRACE(); - APPL_TRACE_DEBUG0("bta_av_co_audio_codec_supported"); /* Check AV feeding is supported */ @@ -1291,7 +1316,7 @@ BOOLEAN bta_av_co_audio_get_sbc_config(tA2D_SBC_CIE *p_sbc_config, UINT16 *p_min tBTA_AV_CO_PEER *p_peer; tBTA_AV_CO_SINK *p_sink; - FUNC_TRACE(); + APPL_TRACE_EVENT1("bta_av_co_cb.codec_cfg.id : codec 0x%x", bta_av_co_cb.codec_cfg.id); /* Minimum MTU is by default very large */ *p_minmtu = 0xFFFF; @@ -1322,6 +1347,8 @@ BOOLEAN bta_av_co_audio_get_sbc_config(tA2D_SBC_CIE *p_sbc_config, UINT16 *p_min p_sbc_config->max_bitpool = BTA_AV_CO_MIN(p_sink->codec_caps[BTA_AV_CO_SBC_MAX_BITPOOL_OFF], p_sbc_config->max_bitpool); + APPL_TRACE_EVENT2("bta_av_co_audio_get_sbc_config : sink bitpool min %d, max %d", + p_sbc_config->min_bitpool, p_sbc_config->max_bitpool); break; } } @@ -1431,3 +1458,30 @@ BOOLEAN bta_av_co_peer_cp_supported(tBTA_AV_HNDL hndl) APPL_TRACE_ERROR0("bta_av_co_peer_cp_supported did not find SBC sink"); return FALSE; } + + +/******************************************************************************* + ** + ** Function bta_av_co_get_remote_bitpool_pref + ** + ** Description Check if remote side did a setconfig within the limits + ** of our exported bitpool range. If set we will set the + ** remote preference. + ** + ** Returns TRUE if config set, FALSE otherwize + ** + *******************************************************************************/ + +BOOLEAN bta_av_co_get_remote_bitpool_pref(UINT8 *min, UINT8 *max) +{ + /* check if remote peer did a set config */ + if (bta_av_co_cb.codec_cfg_setconfig.id == BTIF_AV_CODEC_NONE) + return FALSE; + + *min = bta_av_co_cb.codec_cfg_setconfig.info[BTA_AV_CO_SBC_MIN_BITPOOL_OFF]; + *max = bta_av_co_cb.codec_cfg_setconfig.info[BTA_AV_CO_SBC_MAX_BITPOOL_OFF]; + + return TRUE; +} + + diff --git a/btif/co/bta_hl_co.c b/btif/co/bta_hl_co.c index c851807..c851807 100755..100644 --- a/btif/co/bta_hl_co.c +++ b/btif/co/bta_hl_co.c diff --git a/btif/include/btif_av_api.h b/btif/include/btif_av_api.h index f7a0304..9f9beeb 100644 --- a/btif/include/btif_av_api.h +++ b/btif/include/btif_av_api.h @@ -72,6 +72,7 @@ *****************************************************************************/ /* codec type */ +#define BTIF_AV_CODEC_NONE 0xFF #define BTIF_AV_CODEC_SBC A2D_MEDIA_CT_SBC /* SBC media codec type */ #define BTIF_AV_CODEC_PCM 0x5 /* Raw PCM */ diff --git a/btif/include/btif_av_co.h b/btif/include/btif_av_co.h index fd108d1..9945e8e 100644 --- a/btif/include/btif_av_co.h +++ b/btif/include/btif_av_co.h @@ -186,4 +186,18 @@ void bta_av_co_init(void); *******************************************************************************/ BOOLEAN bta_av_co_peer_cp_supported(tBTA_AV_HNDL hndl); +/******************************************************************************* + ** + ** Function bta_av_co_get_remote_bitpool_pref + ** + ** Description Check if remote side did a setconfig within the limits + ** of our exported bitpool range. If set we will set the + ** remote preference. + ** + ** Returns TRUE if config set, FALSE otherwize + ** + *******************************************************************************/ +BOOLEAN bta_av_co_get_remote_bitpool_pref(UINT8 *min, UINT8 *max); + + #endif diff --git a/btif/include/btif_hl.h b/btif/include/btif_hl.h index 2328609..2328609 100755..100644 --- a/btif/include/btif_hl.h +++ b/btif/include/btif_hl.h diff --git a/btif/include/btif_media.h b/btif/include/btif_media.h index 64303c6..9eda863 100644 --- a/btif/include/btif_media.h +++ b/btif/include/btif_media.h @@ -269,6 +269,7 @@ int btif_a2dp_start_media_task(void); void btif_a2dp_stop_media_task(void); void btif_a2dp_on_init(void); +void btif_a2dp_setup_codec(void); void btif_a2dp_on_idle(void); void btif_a2dp_on_open(void); void btif_a2dp_on_started(tBTA_AV_START *p_av); diff --git a/btif/include/btif_storage.h b/btif/include/btif_storage.h index 6aaa10f..6aaa10f 100755..100644 --- a/btif/include/btif_storage.h +++ b/btif/include/btif_storage.h diff --git a/btif/include/btif_util.h b/btif/include/btif_util.h index a15d1ca..a15d1ca 100755..100644 --- a/btif/include/btif_util.h +++ b/btif/include/btif_util.h diff --git a/btif/src/btif_av.c b/btif/src/btif_av.c index a3987ad..2eb9563 100644 --- a/btif/src/btif_av.c +++ b/btif/src/btif_av.c @@ -467,6 +467,7 @@ static BOOLEAN btif_av_state_opened_handler(btif_sm_event_t event, void *p_data) break; case BTIF_AV_START_STREAM_REQ_EVT: + btif_a2dp_setup_codec(); BTA_AvStart(); break; diff --git a/btif/src/btif_core.c b/btif/src/btif_core.c index 62541c8..ebe2f8b 100644 --- a/btif/src/btif_core.c +++ b/btif/src/btif_core.c @@ -453,7 +453,9 @@ void btif_enable_bluetooth_evt(tBTA_STATUS status, BD_ADDR local_bd) { /* cleanup rfcomm & l2cap api */ btif_sock_cleanup(); + btif_pan_cleanup(); + btif_enabled = 0; HAL_CBACK(bt_hal_cbacks, adapter_state_changed_cb, BT_STATE_OFF); @@ -486,7 +488,9 @@ bt_status_t btif_disable_bluetooth(void) /* cleanup rfcomm & l2cap api */ btif_sock_cleanup(); + btif_pan_cleanup(); + status = BTA_DisableBluetooth(); if (status != BTA_SUCCESS) @@ -954,9 +958,9 @@ bt_status_t btif_set_adapter_property(const bt_property_t *property) break; case BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT: { - //Nothing to do beside store the value in NV. Java - //will change the SCAN_MODE property after setting timeout, - //if required. + /* Nothing to do beside store the value in NV. Java + will change the SCAN_MODE property after setting timeout, + if required */ storage_req_id = BTIF_CORE_STORAGE_ADAPTER_WRITE; } break; diff --git a/btif/src/btif_dm.c b/btif/src/btif_dm.c index ee30090..86367ad 100644 --- a/btif/src/btif_dm.c +++ b/btif/src/btif_dm.c @@ -987,7 +987,8 @@ static void btif_dm_upstreams_evt(UINT16 event, char* p_param) case BTA_DM_DEV_UNPAIRED_EVT: bdcpy(bd_addr.address, p_data->link_down.bd_addr); - /*special handling for HID devices */ + + /*special handling for HID devices */ #if (defined(BTA_HH_INCLUDED) && (BTA_HH_INCLUDED == TRUE)) if (check_cod(&bd_addr, COD_HID_POINTING ) || check_cod(&bd_addr, COD_HID_KEYBOARD )|| check_cod(&bd_addr, COD_HID_COMBO)) { btif_hh_remove_device(bd_addr); @@ -1487,11 +1488,12 @@ void btif_dm_execute_service_request(UINT16 event, char *p_param) { bt_property_t property; bt_uuid_t local_uuids[BT_MAX_NUM_UUIDS]; - /* Now send the UUID_PROPERTY_CHANGED event to the upper layer */ + + /* Now send the UUID_PROPERTY_CHANGED event to the upper layer */ BTIF_STORAGE_FILL_PROPERTY(&property, BT_PROPERTY_UUIDS, sizeof(local_uuids), local_uuids); - btif_storage_get_adapter_property(&property); - HAL_CBACK(bt_hal_cbacks, adapter_properties_cb, + btif_storage_get_adapter_property(&property); + HAL_CBACK(bt_hal_cbacks, adapter_properties_cb, BT_STATUS_SUCCESS, 1, &property); } return; diff --git a/btif/src/btif_media_task.c b/btif/src/btif_media_task.c index a122408..92699c4 100755 --- a/btif/src/btif_media_task.c +++ b/btif/src/btif_media_task.c @@ -164,14 +164,11 @@ enum /* Define the bitrate step when trying to match bitpool value */ #ifndef BTIF_MEDIA_BITRATE_STEP -#define BTIF_MEDIA_BITRATE_STEP 10 +#define BTIF_MEDIA_BITRATE_STEP 5 #endif - - #define DEFAULT_SBC_BITRATE 220 - #ifndef A2DP_MEDIA_TASK_STACK_SIZE #define A2DP_MEDIA_TASK_STACK_SIZE 0x2000 /* In bytes */ #endif @@ -204,7 +201,7 @@ static UINT32 a2dp_media_task_stack[(A2DP_MEDIA_TASK_STACK_SIZE + 3) / 4]; /* trigger rate adjustment if deviation is more than threshold */ #define BTIF_RA_OFFSET_TRIGGER_US 3000 -#define BTIF_MEDIA_VERBOSE_ENABLED +//#define BTIF_MEDIA_VERBOSE_ENABLED #ifdef BTIF_MEDIA_VERBOSE_ENABLED #define VERBOSE(fmt, ...) \ @@ -627,6 +624,8 @@ static void btif_a2dp_encoder_init(void) msg.SamplingFreq = freq_block_tbl[sbc_config.samp_freq >> 5]; msg.MtuSize = minmtu; + APPL_TRACE_EVENT1("msg.ChannelMode %x", msg.ChannelMode); + /* Init the media task to encode SBC properly */ btif_media_task_enc_init_req(&msg); } @@ -636,6 +635,8 @@ static void btif_a2dp_encoder_update(void) UINT16 minmtu; tA2D_SBC_CIE sbc_config; tBTIF_MEDIA_UPDATE_AUDIO msg; + UINT8 pref_min; + UINT8 pref_max; APPL_TRACE_DEBUG0("btif_a2dp_encoder_update"); @@ -651,9 +652,35 @@ static void btif_a2dp_encoder_update(void) APPL_TRACE_ERROR0("btif_a2dp_encoder_update: ERROR btif_a2dp_encoder_update min_bitpool > max_bitpool"); } - msg.MinBitPool = sbc_config.min_bitpool; - msg.MaxBitPool = sbc_config.max_bitpool; + /* check if remote sink has a preferred bitpool range */ + if (bta_av_co_get_remote_bitpool_pref(&pref_min, &pref_max) == TRUE) + { + /* adjust our preferred bitpool with the remote preference if within + our capable range */ + + if (pref_min < sbc_config.min_bitpool) + pref_min = sbc_config.min_bitpool; + + if (pref_max > sbc_config.max_bitpool) + pref_max = sbc_config.max_bitpool; + + msg.MinBitPool = pref_min; + msg.MaxBitPool = pref_max; + + if ((pref_min != sbc_config.min_bitpool) || (pref_max != sbc_config.max_bitpool)) + { + APPL_TRACE_EVENT2("## adjusted our bitpool range to peer pref [%d:%d] ##", + pref_min, pref_max); + } + } + else + { + msg.MinBitPool = sbc_config.min_bitpool; + msg.MaxBitPool = sbc_config.max_bitpool; + } + msg.MinMtuSize = minmtu; + /* Update the media task to encode SBC properly */ btif_media_task_enc_update_req(&msg); } @@ -730,6 +757,50 @@ void btif_a2dp_on_init(void) //tput_mon(1, 0, 1); } + +/***************************************************************************** +** +** Function btif_a2dp_setup_codec +** +** Description +** +** Returns +** +*******************************************************************************/ + +void btif_a2dp_setup_codec(void) +{ + tBTIF_AV_MEDIA_FEEDINGS media_feeding; + tBTIF_STATUS status; + + APPL_TRACE_EVENT0("## A2DP SETUP CODEC ##"); + + GKI_disable(); + + /* for now hardcode 44.1 khz 16 bit stereo */ + media_feeding.cfg.pcm.sampling_freq = 44100; + media_feeding.cfg.pcm.bit_per_sample = 16; + media_feeding.cfg.pcm.num_channel = 2; + media_feeding.format = BTIF_AV_CODEC_PCM; + + if (bta_av_co_audio_set_codec(&media_feeding, &status)) + { + tBTIF_MEDIA_INIT_AUDIO_FEEDING mfeed; + + /* Init the encoding task */ + btif_a2dp_encoder_init(); + + /* Build the media task configuration */ + mfeed.feeding = media_feeding; + mfeed.feeding_mode = BTIF_AV_FEEDING_ASYNCHRONOUS; + /* Send message to Media task to configure transcoding */ + btif_media_task_audio_feeding_init_req(&mfeed); + } + + GKI_enable(); +} + + /***************************************************************************** ** ** Function btif_a2dp_on_idle @@ -785,30 +856,6 @@ void btif_a2dp_on_started(tBTA_AV_START *p_av) APPL_TRACE_EVENT0("## ON A2DP STARTED ##"); - GKI_disable(); - - /* for now hardcode 44.1 khz 16 bit stereo */ - media_feeding.cfg.pcm.sampling_freq = 44100; - media_feeding.cfg.pcm.bit_per_sample = 16; - media_feeding.cfg.pcm.num_channel = 2; - media_feeding.format = BTIF_AV_CODEC_PCM; - - if (bta_av_co_audio_set_codec(&media_feeding, &status)) - { - tBTIF_MEDIA_INIT_AUDIO_FEEDING mfeed; - - /* Init the encoding task */ - btif_a2dp_encoder_init(); - - /* Build the media task configuration */ - mfeed.feeding = media_feeding; - mfeed.feeding_mode = BTIF_AV_FEEDING_ASYNCHRONOUS; - /* Send message to Media task to configure transcoding */ - btif_media_task_audio_feeding_init_req(&mfeed); - } - - GKI_enable(); - if (p_av->status == BTA_AV_SUCCESS) { if (p_av->suspending == FALSE) @@ -819,7 +866,9 @@ void btif_a2dp_on_started(tBTA_AV_START *p_av) } else { - /* we were remotely started */ + /* we were remotely started, make sure codec + is setup before datapath is started */ + btif_a2dp_setup_codec(); } /* media task is autostarted upon a2dp audiopath connection */ @@ -1511,11 +1560,11 @@ static void btif_media_task_enc_update(BT_HDR *p_msg) SINT16 s16FrameLen; UINT8 protect = 0; - APPL_TRACE_DEBUG3("btif_media_task_enc_update (minmtu %d, maxbp %d. minbp %d", + APPL_TRACE_DEBUG3("btif_media_task_enc_update : minmtu %d, maxbp %d minbp %d", pUpdateAudio->MinMtuSize, pUpdateAudio->MaxBitPool, pUpdateAudio->MinBitPool); /* Only update the bitrate and MTU size while timer is running to make sure it has been initialized */ - if (btif_media_cb.is_tx_timer) + //if (btif_media_cb.is_tx_timer) { btif_media_cb.TxAaMtuSize = ((BTIF_MEDIA_AA_BUF_SIZE - BTIF_MEDIA_AA_SBC_OFFSET - sizeof(BT_HDR)) < pUpdateAudio->MinMtuSize) ? (BTIF_MEDIA_AA_BUF_SIZE - BTIF_MEDIA_AA_SBC_OFFSET @@ -1523,6 +1572,7 @@ static void btif_media_task_enc_update(BT_HDR *p_msg) /* Set the initial target bit rate */ pstrEncParams->u16BitRate = DEFAULT_SBC_BITRATE; + if (pstrEncParams->s16SamplingFreq == SBC_sf16000) s16SamplingFreq = 16000; else if (pstrEncParams->s16SamplingFreq == SBC_sf32000) @@ -1582,6 +1632,8 @@ static void btif_media_task_enc_update(BT_HDR *p_msg) s16BitPool = 0; } + APPL_TRACE_EVENT2("bitpool candidate : %d (%d kbps)", s16BitPool, pstrEncParams->u16BitRate); + if (s16BitPool > pUpdateAudio->MaxBitPool) { APPL_TRACE_WARNING1("btif_media_task_enc_update computed bitpool too large (%d)", s16BitPool); @@ -1615,6 +1667,9 @@ static void btif_media_task_enc_update(BT_HDR *p_msg) APPL_TRACE_DEBUG2("btif_media_task_enc_update final bit rate %d, final bit pool %d", btif_media_cb.encoder.u16BitRate, btif_media_cb.encoder.s16BitPool); + + /* make sure we reinitialize encoder with new settings */ + SBC_Encoder_Init(&(btif_media_cb.encoder)); } } @@ -1674,10 +1729,10 @@ static void btif_media_task_pcm2sbc_init(tBTIF_MEDIA_INIT_AUDIO_FEEDING * p_feed } /* Some AV Headsets do not support Mono => always ask for Stereo */ - if (btif_media_cb.encoder.s16ChannelMode != SBC_STEREO) + if (btif_media_cb.encoder.s16ChannelMode == SBC_MONO) { APPL_TRACE_DEBUG0("SBC Reconfiguration needed in Stereo"); - btif_media_cb.encoder.s16ChannelMode = SBC_STEREO; + btif_media_cb.encoder.s16ChannelMode = SBC_JOINT_STEREO; reconfig_needed = TRUE; } diff --git a/btif/src/btif_storage.c b/btif/src/btif_storage.c index 2c3ed69..2c3ed69 100755..100644 --- a/btif/src/btif_storage.c +++ b/btif/src/btif_storage.c diff --git a/btif/src/btif_util.c b/btif/src/btif_util.c index a9eb0b4..a9eb0b4 100755..100644 --- a/btif/src/btif_util.c +++ b/btif/src/btif_util.c diff --git a/embdrv/sbc/encoder/srce/sbc_encoder.c b/embdrv/sbc/encoder/srce/sbc_encoder.c index 281c970..ce7dbb9 100644 --- a/embdrv/sbc/encoder/srce/sbc_encoder.c +++ b/embdrv/sbc/encoder/srce/sbc_encoder.c @@ -379,6 +379,10 @@ void SBC_Encoder_Init(SBC_ENC_PARAMS *pstrEncParams) else EncMaxShiftCounter=((ENC_VX_BUFFER_SIZE-8*10*2)>>4)<<3; } + + APPL_TRACE_EVENT2("SBC_Encoder_Init : bitrate %d, bitpool %d", + pstrEncParams->u16BitRate, pstrEncParams->s16BitPool); + SbcAnalysisInit(); memset(&sbc_prtc_cb, 0, sizeof(tSBC_PRTC_CB)); diff --git a/main/Android.mk b/main/Android.mk index e7f005f..c8fbb40 100755 --- a/main/Android.mk +++ b/main/Android.mk @@ -8,15 +8,15 @@ include $(CLEAR_VARS) # HAL layer LOCAL_SRC_FILES:= \ - ../btif/src/bluetooth.c + ../btif/src/bluetooth.c # platform specific LOCAL_SRC_FILES+= \ - bte_main.c \ - bte_init.c \ - bte_version.c \ - bte_logmsg.c \ - bte_conf.c + bte_main.c \ + bte_init.c \ + bte_version.c \ + bte_logmsg.c \ + bte_conf.c # BTIF LOCAL_SRC_FILES += \ @@ -35,8 +35,8 @@ LOCAL_SRC_FILES += \ ../btif/src/btif_sock_rfc.c \ ../btif/src/btif_sock_thread.c \ ../btif/src/btif_sock_sdp.c \ - ../btif/src/btif_pan.c \ - ../btif/src/btif_sock_util.c + ../btif/src/btif_sock_util.c \ + ../btif/src/btif_pan.c # callouts LOCAL_SRC_FILES+= \ @@ -51,44 +51,41 @@ LOCAL_SRC_FILES+= \ # sbc encoder LOCAL_SRC_FILES+= \ - ../embdrv/sbc/encoder/srce/sbc_analysis.c \ - ../embdrv/sbc/encoder/srce/sbc_dct.c \ - ../embdrv/sbc/encoder/srce/sbc_dct_coeffs.c \ - ../embdrv/sbc/encoder/srce/sbc_enc_bit_alloc_mono.c \ - ../embdrv/sbc/encoder/srce/sbc_enc_bit_alloc_ste.c \ - ../embdrv/sbc/encoder/srce/sbc_enc_coeffs.c \ - ../embdrv/sbc/encoder/srce/sbc_encoder.c \ - ../embdrv/sbc/encoder/srce/sbc_packing.c \ + ../embdrv/sbc/encoder/srce/sbc_analysis.c \ + ../embdrv/sbc/encoder/srce/sbc_dct.c \ + ../embdrv/sbc/encoder/srce/sbc_dct_coeffs.c \ + ../embdrv/sbc/encoder/srce/sbc_enc_bit_alloc_mono.c \ + ../embdrv/sbc/encoder/srce/sbc_enc_bit_alloc_ste.c \ + ../embdrv/sbc/encoder/srce/sbc_enc_coeffs.c \ + ../embdrv/sbc/encoder/srce/sbc_encoder.c \ + ../embdrv/sbc/encoder/srce/sbc_packing.c \ - -# candidates for vendor lib (keep here for now) LOCAL_SRC_FILES+= \ - ../udrv/ulinux/unv_linux.c\ - ../udrv/ulinux/uipc.c - + ../udrv/ulinux/unv_linux.c\ + ../udrv/ulinux/uipc.c LOCAL_C_INCLUDES+= . \ - $(LOCAL_PATH)/../bta/include \ - $(LOCAL_PATH)/../bta/sys \ - $(LOCAL_PATH)/../bta/dm \ - $(LOCAL_PATH)/../gki/common \ - $(LOCAL_PATH)/../gki/ulinux \ - $(LOCAL_PATH)/../include \ - $(LOCAL_PATH)/../stack/include \ - $(LOCAL_PATH)/../stack/l2cap \ - $(LOCAL_PATH)/../stack/a2dp \ - $(LOCAL_PATH)/../stack/btm \ - $(LOCAL_PATH)/../stack/avdt \ - $(LOCAL_PATH)/../hcis \ - $(LOCAL_PATH)/../hcis/include \ - $(LOCAL_PATH)/../hcis/patchram \ - $(LOCAL_PATH)/../udrv/include \ - $(LOCAL_PATH)/../btif/include \ - $(LOCAL_PATH)/../btif/co \ - $(LOCAL_PATH)/../vendor/libvendor/include\ - $(LOCAL_PATH)/../brcm/include \ - $(LOCAL_PATH)/../embdrv/sbc/encoder/include \ - $(LOCAL_PATH)/../audio_a2dp_hw + $(LOCAL_PATH)/../bta/include \ + $(LOCAL_PATH)/../bta/sys \ + $(LOCAL_PATH)/../bta/dm \ + $(LOCAL_PATH)/../gki/common \ + $(LOCAL_PATH)/../gki/ulinux \ + $(LOCAL_PATH)/../include \ + $(LOCAL_PATH)/../stack/include \ + $(LOCAL_PATH)/../stack/l2cap \ + $(LOCAL_PATH)/../stack/a2dp \ + $(LOCAL_PATH)/../stack/btm \ + $(LOCAL_PATH)/../stack/avdt \ + $(LOCAL_PATH)/../hcis \ + $(LOCAL_PATH)/../hcis/include \ + $(LOCAL_PATH)/../hcis/patchram \ + $(LOCAL_PATH)/../udrv/include \ + $(LOCAL_PATH)/../btif/include \ + $(LOCAL_PATH)/../btif/co \ + $(LOCAL_PATH)/../vendor/libvendor/include\ + $(LOCAL_PATH)/../brcm/include \ + $(LOCAL_PATH)/../embdrv/sbc/encoder/include \ + $(LOCAL_PATH)/../audio_a2dp_hw LOCAL_CFLAGS += -DBUILDCFG -Werror diff --git a/stack/hid/hidh_conn.c b/stack/hid/hidh_conn.c index 29c4025..29c4025 100755..100644 --- a/stack/hid/hidh_conn.c +++ b/stack/hid/hidh_conn.c diff --git a/stack/l2cap/l2c_link.c b/stack/l2cap/l2c_link.c index daaf2a7..daaf2a7 100755..100644 --- a/stack/l2cap/l2c_link.c +++ b/stack/l2cap/l2c_link.c diff --git a/stack/l2cap/l2c_utils.c b/stack/l2cap/l2c_utils.c index 0c1fb60..0c1fb60 100755..100644 --- a/stack/l2cap/l2c_utils.c +++ b/stack/l2cap/l2c_utils.c diff --git a/udrv/ulinux/unv_linux.c b/udrv/ulinux/unv_linux.c index 3e98693..3e98693 100755..100644 --- a/udrv/ulinux/unv_linux.c +++ b/udrv/ulinux/unv_linux.c |