mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
bluez5: aptx-ll: produce 7.5ms packets
Put a bit more samples to packets to make it more robust. The 7.5ms interval may also fit better with other BT devices.
This commit is contained in:
parent
8f2a239504
commit
83050e647b
3 changed files with 33 additions and 2 deletions
|
|
@ -300,8 +300,17 @@ static void *codec_init(const struct media_codec *codec, uint32_t flags,
|
|||
void *config, size_t config_len, const struct spa_audio_info *info,
|
||||
void *props, size_t mtu)
|
||||
{
|
||||
struct impl *this;
|
||||
struct impl *this = NULL;
|
||||
a2dp_aptx_t conf;
|
||||
int res;
|
||||
int frequency;
|
||||
|
||||
if (config_len < sizeof(conf)) {
|
||||
res = -EINVAL;
|
||||
goto error;
|
||||
}
|
||||
|
||||
memcpy(&conf, config, sizeof(conf));
|
||||
|
||||
if ((this = calloc(1, sizeof(struct impl))) == NULL)
|
||||
goto error_errno;
|
||||
|
|
@ -322,10 +331,17 @@ static void *codec_init(const struct media_codec *codec, uint32_t flags,
|
|||
this->frame_length = this->hd ? 6 : 4;
|
||||
this->codesize = 4 * 3 * 2;
|
||||
|
||||
frequency = media_codec_get_config(aptx_frequencies, SPA_N_ELEMENTS(aptx_frequencies), conf.frequency);
|
||||
if (frequency < 0) {
|
||||
res = -EINVAL;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (this->hd)
|
||||
this->max_frames = (this->mtu - sizeof(struct rtp_header)) / this->frame_length;
|
||||
else if (codec_is_ll(codec))
|
||||
this->max_frames = SPA_MIN(256u, this->mtu) / this->frame_length;
|
||||
/* try to make 7.5ms packets */
|
||||
this->max_frames = SPA_MIN((unsigned)frequency * 75u/10000u / 4u, this->mtu / this->frame_length);
|
||||
else
|
||||
this->max_frames = this->mtu / this->frame_length;
|
||||
|
||||
|
|
|
|||
|
|
@ -61,6 +61,18 @@ int media_codec_select_config(const struct media_codec_config configs[], size_t
|
|||
return res;
|
||||
}
|
||||
|
||||
int media_codec_get_config(const struct media_codec_config configs[], size_t n,
|
||||
uint32_t conf)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < n; ++i)
|
||||
if (configs[i].config == conf)
|
||||
return configs[i].value;
|
||||
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
bool media_codec_check_caps(const struct media_codec *codec, unsigned int codec_id,
|
||||
const void *caps, size_t caps_size,
|
||||
const struct media_codec_audio_info *info,
|
||||
|
|
|
|||
|
|
@ -198,6 +198,9 @@ struct media_codec_config {
|
|||
int media_codec_select_config(const struct media_codec_config configs[], size_t n,
|
||||
uint32_t cap, int preferred_value);
|
||||
|
||||
int media_codec_get_config(const struct media_codec_config configs[], size_t n,
|
||||
uint32_t conf);
|
||||
|
||||
bool media_codec_check_caps(const struct media_codec *codec, unsigned int codec_id,
|
||||
const void *caps, size_t caps_size, const struct media_codec_audio_info *info,
|
||||
const struct spa_dict *global_settings);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue