mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
bluez5: add codec check_caps + check vendor codec id for ldac & aptx
This commit is contained in:
parent
ce335b6d88
commit
0908588d0c
4 changed files with 28 additions and 2 deletions
|
|
@ -86,6 +86,10 @@ static int codec_select_config(const struct a2dp_codec *codec, uint32_t flags,
|
||||||
|
|
||||||
memcpy(&conf, caps, sizeof(conf));
|
memcpy(&conf, caps, sizeof(conf));
|
||||||
|
|
||||||
|
if (codec->vendor.vendor_id != conf.info.vendor_id ||
|
||||||
|
codec->vendor.codec_id != conf.info.codec_id)
|
||||||
|
return -ENOTSUP;
|
||||||
|
|
||||||
if (conf.frequency & APTX_SAMPLING_FREQ_48000)
|
if (conf.frequency & APTX_SAMPLING_FREQ_48000)
|
||||||
conf.frequency = APTX_SAMPLING_FREQ_48000;
|
conf.frequency = APTX_SAMPLING_FREQ_48000;
|
||||||
else if (conf.frequency & APTX_SAMPLING_FREQ_44100)
|
else if (conf.frequency & APTX_SAMPLING_FREQ_44100)
|
||||||
|
|
|
||||||
|
|
@ -138,8 +138,10 @@ static int codec_select_config(const struct a2dp_codec *codec, uint32_t flags,
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
memcpy(&conf, caps, sizeof(conf));
|
memcpy(&conf, caps, sizeof(conf));
|
||||||
conf.info.vendor_id = LDAC_VENDOR_ID;
|
|
||||||
conf.info.codec_id = LDAC_CODEC_ID;
|
if (codec->vendor.vendor_id != conf.info.vendor_id ||
|
||||||
|
codec->vendor.codec_id != conf.info.codec_id)
|
||||||
|
return -ENOTSUP;
|
||||||
|
|
||||||
if (conf.frequency & LDACBT_SAMPLING_FREQ_044100)
|
if (conf.frequency & LDACBT_SAMPLING_FREQ_044100)
|
||||||
conf.frequency = LDACBT_SAMPLING_FREQ_044100;
|
conf.frequency = LDACBT_SAMPLING_FREQ_044100;
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,24 @@
|
||||||
|
|
||||||
#include "a2dp-codecs.h"
|
#include "a2dp-codecs.h"
|
||||||
|
|
||||||
|
bool a2dp_codec_check_caps(const struct a2dp_codec *codec, unsigned int codec_id, const void *caps, size_t caps_size)
|
||||||
|
{
|
||||||
|
uint8_t config[A2DP_MAX_CAPS_SIZE];
|
||||||
|
int res;
|
||||||
|
|
||||||
|
if (codec_id != codec->codec_id)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (caps == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
res = codec->select_config(codec, 0, caps, caps_size, NULL, config);
|
||||||
|
if (res < 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return ((size_t)res == caps_size);
|
||||||
|
}
|
||||||
|
|
||||||
#if ENABLE_MP3
|
#if ENABLE_MP3
|
||||||
const a2dp_mpeg_t bluez_a2dp_mpeg = {
|
const a2dp_mpeg_t bluez_a2dp_mpeg = {
|
||||||
.layer =
|
.layer =
|
||||||
|
|
|
||||||
|
|
@ -377,4 +377,6 @@ struct a2dp_codec {
|
||||||
|
|
||||||
extern const struct a2dp_codec **a2dp_codecs;
|
extern const struct a2dp_codec **a2dp_codecs;
|
||||||
|
|
||||||
|
bool a2dp_codec_check_caps(const struct a2dp_codec *codec, unsigned int codec_id, const void *caps, size_t caps_size);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue