Skip to content

Commit 1bdf3e5

Browse files
author
ganghe
committed
[int][new][zbt] Merge Zephyr branch
Project: Bluetooth redmine: #5146, REDMINE-id ext-redmine: bug|feat#id Support Zephyr BLE stack/profile Affected branch: [master] Merge remote-tracking branch 'remotes/origin/zephyr' Change-Id: I215c9d190e5bc67056a698c70ca2890ebf933940
2 parents 893f3ff + 68f7663 commit 1bdf3e5

File tree

663 files changed

+369304
-11
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

663 files changed

+369304
-11
lines changed

Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,5 +304,5 @@ menu "Bluetooth"
304304
if !KCONFIG_V2 || KCONFIG_BOARD_V2
305305
rsource "Kconfig.hw"
306306
endif
307-
307+
rsource "zephyr_bt/Kconfig"
308308
endmenu

SConscript

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,12 @@ if GetDepend('BLUETOOTH'):
1818
path = os.path.join(cwd, d)
1919
objs = objs + SConscript(os.path.join(d, 'SConscript'))
2020

21-
if GetDepend('CFG_BT_HOST') or GetDepend('CFG_BLE_HOST') or GetDepend('ZBT'):
22-
d='stack'
23-
path = os.path.join(cwd, d)
24-
objs = objs + SConscript(os.path.join(d, 'SConscript'))
25-
if GetDepend('ZBT'):
26-
d='lib'
27-
path = os.path.join(cwd, d)
28-
objs = objs + SConscript(os.path.join(d, 'SConscript'))
21+
d='zephyr_bt'
22+
path = os.path.join(cwd, d)
23+
objs = objs + SConscript(os.path.join(d, 'SConscript'))
24+
25+
if GetDepend('CFG_BT_HOST') or GetDepend('CFG_BLE_HOST'):
26+
print("Do nothing")
2927
else:
3028
d='lib'
3129
path = os.path.join(cwd, d)

include/bf0_ble_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ if (!(EX)) \
108108
#define RW_ASSERT(expr)
109109
#endif
110110

111+
#undef BT_ASSERT
111112
#define BT_ASSERT(expr) RW_ASSERT(expr)
112113
#define BT_OOM_ASSERT(expr) RW_ASSERT(expr)
113114
#define RW_WAITING_FOREVER -1

service/bt/bt_finsh/bts2_app_av_snk.c

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@
6565
#include "vbe_eq_drc_api.h"
6666
#define A2DP_VBE_OUT_BUFFER_SIZE 8192
6767
#endif
68+
69+
#include "sifli_resample.h"
70+
static sifli_resample_t *resample;
71+
6872
uint8_t bts2s_avsnk_openFlag;//0x00:dont open a2dp profile; 0x01:open a2dp profile;
6973
uint8_t frms_per_payload;
7074

@@ -409,10 +413,18 @@ static void decode_playback_thread(void *args)
409413
}
410414
param.write_channnel_num = 2;
411415
param.write_bits_per_sample = 16;
412-
param.write_cache_size = 8192;
416+
param.write_cache_size = 32000;
413417
debug_tx_cnt = 0;
414418
inst_data->snk_data.audio_client = audio_open(AUDIO_TYPE_BT_MUSIC, AUDIO_TX, &param, audio_bt_music_client_cb, NULL);
415419
is_stopped = 0;
420+
421+
if (!resample)
422+
{
423+
USER_TRACE("resample from %d to 48k", param.write_samplerate);
424+
resample = sifli_resample_open(param.write_channnel_num, param.write_samplerate, 48000);
425+
RT_ASSERT(resample);
426+
}
427+
416428
#if PKG_USING_VBE_DRC
417429
inst_data->snk_data.vbe_out = rt_malloc(A2DP_VBE_OUT_BUFFER_SIZE);
418430
RT_ASSERT(inst_data->snk_data.vbe_out);
@@ -456,7 +468,24 @@ static void decode_playback_thread(void *args)
456468
#if PKG_USING_VBE_DRC
457469
ret_write = audio_write(inst_data->snk_data.audio_client, inst_data->snk_data.vbe_out, vbe_out_size);
458470
#else
459-
ret_write = audio_write(inst_data->snk_data.audio_client, decode_data, decode_len);
471+
472+
if (get_server_current_device() == AUDIO_DEVICE_BLE_BAP_SINK)
473+
{
474+
int try_times = 0;
475+
uint32_t bytes = sifli_resample_process(resample, (int16_t *)decode_data, decode_len, 0);
476+
while (1)
477+
{
478+
ret_write = audio_write(inst_data->snk_data.audio_client, (uint8_t *)sifli_resample_get_output(resample), bytes);
479+
if (ret_write)
480+
break;
481+
rt_thread_mdelay(10);
482+
try_times++;
483+
if (try_times > 20)
484+
break;
485+
}
486+
}
487+
else
488+
ret_write = audio_write(inst_data->snk_data.audio_client, decode_data, decode_len);
460489
#endif
461490
if (ret_write < 0)
462491
{
@@ -465,6 +494,10 @@ static void decode_playback_thread(void *args)
465494
}
466495
else if (ret_write == 0)
467496
{
497+
if (get_server_current_device() == AUDIO_DEVICE_BLE_BAP_SINK)
498+
{
499+
USER_TRACE("--a2dp drop data\n");
500+
}
468501
break;
469502
}
470503
else
@@ -536,6 +569,8 @@ static void stop_audio_playback(bts2s_av_inst_data *inst)
536569
rt_event_recv(g_playback_evt, PLAYBACK_STOPPED_EVENT_FLAG, RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR, RT_WAITING_FOREVER, &evt);
537570
inst->snk_data.play_state = FALSE;
538571
#if defined(AUDIO_USING_MANAGER) && defined(AUDIO_BT_AUDIO)
572+
sifli_resample_close(resample);
573+
resample = NULL;
539574
audio_close(inst->snk_data.audio_client);
540575
inst->snk_data.audio_client = NULL;
541576
#endif
@@ -568,6 +603,8 @@ static void stop_audio_playback_temporarily(bts2s_av_inst_data *inst)
568603
rt_event_recv(g_playback_evt, PLAYBACK_STOPPED_EVENT_FLAG, RT_EVENT_FLAG_OR | RT_EVENT_FLAG_CLEAR, RT_WAITING_FOREVER, &evt);
569604
inst->snk_data.play_state = FALSE;
570605
#if defined(AUDIO_USING_MANAGER) && defined(AUDIO_BT_AUDIO)
606+
sifli_resample_close(resample);
607+
resample = NULL;
571608
audio_close(inst->snk_data.audio_client);
572609
inst->snk_data.audio_client = NULL;
573610
#endif

0 commit comments

Comments
 (0)