mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
bluez5: allow same codec ID to correspond to multiple endpoints
The codec IDs are user-visible properties. Some codecs can have multiple endpoints (e.g. different caps struct, or multiple possible vendor ids), so this detail should not leak to the user.
This commit is contained in:
parent
fc2fe12794
commit
73994feda9
3 changed files with 48 additions and 31 deletions
|
|
@ -400,7 +400,8 @@ static int a2dp_codec_to_endpoint(const struct a2dp_codec *codec,
|
|||
const char * endpoint,
|
||||
char** object_path)
|
||||
{
|
||||
*object_path = spa_aprintf("%s/%s", endpoint, codec->name);
|
||||
*object_path = spa_aprintf("%s/%s", endpoint,
|
||||
codec->endpoint_name ? codec->endpoint_name : codec->name);
|
||||
if (*object_path == NULL)
|
||||
return -errno;
|
||||
return 0;
|
||||
|
|
@ -408,19 +409,21 @@ static int a2dp_codec_to_endpoint(const struct a2dp_codec *codec,
|
|||
|
||||
static const struct a2dp_codec *a2dp_endpoint_to_codec(const char *endpoint)
|
||||
{
|
||||
const char *codec_name;
|
||||
const char *ep_name;
|
||||
int i;
|
||||
|
||||
if (spa_strstartswith(endpoint, A2DP_SINK_ENDPOINT "/"))
|
||||
codec_name = endpoint + strlen(A2DP_SINK_ENDPOINT "/");
|
||||
ep_name = endpoint + strlen(A2DP_SINK_ENDPOINT "/");
|
||||
else if (spa_strstartswith(endpoint, A2DP_SOURCE_ENDPOINT "/"))
|
||||
codec_name = endpoint + strlen(A2DP_SOURCE_ENDPOINT "/");
|
||||
ep_name = endpoint + strlen(A2DP_SOURCE_ENDPOINT "/");
|
||||
else
|
||||
return NULL;
|
||||
|
||||
for (i = 0; a2dp_codecs[i]; i++) {
|
||||
const struct a2dp_codec *codec = a2dp_codecs[i];
|
||||
if (spa_streq(codec->name, codec_name))
|
||||
const char *codec_ep_name =
|
||||
codec->endpoint_name ? codec->endpoint_name : codec->name;
|
||||
if (spa_streq(ep_name, codec_ep_name))
|
||||
return codec;
|
||||
}
|
||||
return NULL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue