mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-16 08:42:28 +00:00
stm32: added samplerate compensation support
embedded: update audio api
This commit is contained in:
parent
8955f6de72
commit
32d9a3dfcc
@ -133,9 +133,12 @@ static void driver_timer_handler_source(btstack_timer_source_t * ts){
|
|||||||
btstack_run_loop_add_timer(ts);
|
btstack_run_loop_add_timer(ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static uint32_t sink_samplerate = 0;
|
||||||
|
|
||||||
static int btstack_audio_embedded_sink_init(
|
static int btstack_audio_embedded_sink_init(
|
||||||
uint8_t channels,
|
uint8_t channels,
|
||||||
uint32_t samplerate,
|
uint32_t samplerate,
|
||||||
void (*playback)(int16_t * buffer, uint16_t num_samples)
|
void (*playback)(int16_t * buffer, uint16_t num_samples)
|
||||||
){
|
){
|
||||||
btstack_assert(playback != NULL);
|
btstack_assert(playback != NULL);
|
||||||
@ -148,15 +151,21 @@ static int btstack_audio_embedded_sink_init(
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
playback_callback = playback;
|
playback_callback = playback;
|
||||||
|
sink_samplerate = samplerate;
|
||||||
hal_audio_sink_init(channels, samplerate, &btstack_audio_audio_played);
|
hal_audio_sink_init(channels, samplerate, &btstack_audio_audio_played);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint32_t btstack_audio_embedded_sink_get_samplerate() {
|
||||||
|
return sink_samplerate;
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint32_t source_samplerate = 0;
|
||||||
|
|
||||||
static int btstack_audio_embedded_source_init(
|
static int btstack_audio_embedded_source_init(
|
||||||
uint8_t channels,
|
uint8_t channels,
|
||||||
uint32_t samplerate,
|
uint32_t samplerate,
|
||||||
void (*recording)(const int16_t * buffer, uint16_t num_samples)
|
void (*recording)(const int16_t * buffer, uint16_t num_samples)
|
||||||
){
|
){
|
||||||
if (!recording){
|
if (!recording){
|
||||||
@ -165,12 +174,16 @@ static int btstack_audio_embedded_source_init(
|
|||||||
}
|
}
|
||||||
|
|
||||||
recording_callback = recording;
|
recording_callback = recording;
|
||||||
|
source_samplerate = samplerate;
|
||||||
hal_audio_source_init(channels, samplerate, &btstack_audio_audio_recorded);
|
hal_audio_source_init(channels, samplerate, &btstack_audio_audio_recorded);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint32_t btstack_audio_embedded_source_get_samplerate() {
|
||||||
|
return source_samplerate;
|
||||||
|
}
|
||||||
|
|
||||||
static void btstack_audio_embedded_sink_set_volume(uint8_t volume){
|
static void btstack_audio_embedded_sink_set_volume(uint8_t volume){
|
||||||
UNUSED(volume);
|
UNUSED(volume);
|
||||||
}
|
}
|
||||||
@ -261,6 +274,7 @@ static void btstack_audio_embedded_source_close(void){
|
|||||||
|
|
||||||
static const btstack_audio_sink_t btstack_audio_embedded_sink = {
|
static const btstack_audio_sink_t btstack_audio_embedded_sink = {
|
||||||
.init = &btstack_audio_embedded_sink_init,
|
.init = &btstack_audio_embedded_sink_init,
|
||||||
|
.get_samplerate = &btstack_audio_embedded_sink_get_samplerate,
|
||||||
.set_volume = &btstack_audio_embedded_sink_set_volume,
|
.set_volume = &btstack_audio_embedded_sink_set_volume,
|
||||||
.start_stream = &btstack_audio_embedded_sink_start_stream,
|
.start_stream = &btstack_audio_embedded_sink_start_stream,
|
||||||
.stop_stream = &btstack_audio_embedded_sink_stop_stream,
|
.stop_stream = &btstack_audio_embedded_sink_stop_stream,
|
||||||
@ -269,6 +283,7 @@ static const btstack_audio_sink_t btstack_audio_embedded_sink = {
|
|||||||
|
|
||||||
static const btstack_audio_source_t btstack_audio_embedded_source = {
|
static const btstack_audio_source_t btstack_audio_embedded_source = {
|
||||||
.init = &btstack_audio_embedded_source_init,
|
.init = &btstack_audio_embedded_source_init,
|
||||||
|
.get_samplerate = &btstack_audio_embedded_source_get_samplerate,
|
||||||
.set_gain = &btstack_audio_embedded_source_set_gain,
|
.set_gain = &btstack_audio_embedded_source_set_gain,
|
||||||
.start_stream = &btstack_audio_embedded_source_start_stream,
|
.start_stream = &btstack_audio_embedded_source_start_stream,
|
||||||
.stop_stream = &btstack_audio_embedded_source_stop_stream,
|
.stop_stream = &btstack_audio_embedded_source_stop_stream,
|
||||||
|
@ -71,6 +71,7 @@ ${BTSTACK_ROOT}/src/ble/le_device_db_memory.c \
|
|||||||
${BTSTACK_ROOT}/src/ble/le_device_db_tlv.c \
|
${BTSTACK_ROOT}/src/ble/le_device_db_tlv.c \
|
||||||
${BTSTACK_ROOT}/src/ble/sm.c \
|
${BTSTACK_ROOT}/src/ble/sm.c \
|
||||||
${BTSTACK_ROOT}/src/btstack_audio.c \
|
${BTSTACK_ROOT}/src/btstack_audio.c \
|
||||||
|
${BTSTACK_ROOT}/src/btstack_sample_rate_compensation.c \
|
||||||
${BTSTACK_ROOT}/src/btstack_crypto.c \
|
${BTSTACK_ROOT}/src/btstack_crypto.c \
|
||||||
${BTSTACK_ROOT}/src/btstack_hid_parser.c \
|
${BTSTACK_ROOT}/src/btstack_hid_parser.c \
|
||||||
${BTSTACK_ROOT}/src/btstack_linked_list.c \
|
${BTSTACK_ROOT}/src/btstack_linked_list.c \
|
||||||
@ -304,6 +305,7 @@ LDSCRIPT = STM32F407VGTx_FLASH.ld
|
|||||||
LIBS = -lPDMFilter_CM4_GCC -lc -lm -lnosys
|
LIBS = -lPDMFilter_CM4_GCC -lc -lm -lnosys
|
||||||
LIBDIR = -Lpdm
|
LIBDIR = -Lpdm
|
||||||
LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
|
LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
|
||||||
|
#LDFLAGS += -u_printf_float
|
||||||
|
|
||||||
# default action: build all
|
# default action: build all
|
||||||
EXAMPLES = \
|
EXAMPLES = \
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#define HAVE_EMBEDDED_TIME_MS
|
#define HAVE_EMBEDDED_TIME_MS
|
||||||
#define HAVE_HAL_AUDIO
|
#define HAVE_HAL_AUDIO
|
||||||
#define HAVE_HAL_AUDIO_SINK_STEREO_ONLY
|
#define HAVE_HAL_AUDIO_SINK_STEREO_ONLY
|
||||||
|
#define HAVE_BTSTACK_AUDIO_EFFECTIVE_SAMPLERATE
|
||||||
|
|
||||||
// BTstack features that can be enabled
|
// BTstack features that can be enabled
|
||||||
#define ENABLE_BLE
|
#define ENABLE_BLE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user