Skip to content
This repository has been archived by the owner on Jan 25, 2021. It is now read-only.

Commit

Permalink
a2dp-api: add <pa_a2dp_source>.handle_update_buffer_size()
Browse files Browse the repository at this point in the history
  • Loading branch information
EHfive committed Apr 3, 2019
1 parent 985e398 commit d303d8d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/modules/bluetooth/a2dp/a2dp-api.h
Expand Up @@ -173,6 +173,8 @@ typedef struct pa_a2dp_source {

void (*get_block_size)(size_t write_link_mtu, size_t *write_block_size, void **codec_data);

size_t (*handle_update_buffer_size)(void **codec_data);

void (*setup_stream)(void **codec_data);

/* Pass read_cb_data to pa_a2dp_source_read_cb, pa_a2dp_source_read_buf_free_cb */
Expand Down
7 changes: 5 additions & 2 deletions src/modules/bluetooth/module-bluez5-device.c
Expand Up @@ -616,9 +616,12 @@ static void update_buffer_size(struct userdata *u) {
* there should at least be room for two chunks in the buffer. Generally, write_block_size
* is larger than 512. If not, use the next multiple of write_block_size which is larger
* than 1024. */
new_bufsize = 2 * u->write_block_size;
if (u->transport->a2dp_source && u->transport->a2dp_source->handle_update_buffer_size)
new_bufsize = (int) u->transport->a2dp_source->handle_update_buffer_size(&u->a2dp_info.a2dp_source_data);
else
new_bufsize = (int) (2 * u->write_block_size);
if (new_bufsize < 1024)
new_bufsize = (1024 / u->write_block_size + 1) * u->write_block_size;
new_bufsize = (int) ((1024 / u->write_block_size + 1) * u->write_block_size);

/* The kernel internally doubles the buffer size that was set by setsockopt and getsockopt
* returns the doubled value. */
Expand Down

0 comments on commit d303d8d

Please sign in to comment.