Code: Select all
static uint32_t bt_app_hf_client_outgoing_cb(uint8_t *p_buf, uint32_t sz)
{
//request 240 byt read per time from bt stack cb
int32_t out_len_bytes = 0;
if (rb_bytes_filled(ringbuf_algo_out) >= sz)
{
out_len_bytes = rb_read(ringbuf_algo_out, (char*) p_buf, sz,0);
return out_len_bytes;
}
else
{
return 0;
}
}
volatile char hf_pkt = 0;
uint8_t tmp[1024*4];
volatile uint8_t hf_counter=0;
static void bt_app_hf_client_incoming_cb(const uint8_t *buf, uint32_t sz)
{
// 240byt frame came forom bt stack handler
#define HF_IN_PCKT_COUNT 10
if (bt_stream_reader)
{
if (audio_element_get_state(bt_stream_reader) == AEL_STATE_RUNNING)
{
memcpy(&tmp[hf_counter*sz], buf, sz);
if (hf_counter >= (HF_IN_PCKT_COUNT-1))
{
hf_active = true;
audio_element_output(bt_stream_reader, (char *)tmp, HF_IN_PCKT_COUNT*sz);
hf_counter = 0;
}
else
{
hf_counter++;
}
esp_hf_client_outgoing_data_ready();
}
}
}