mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
parent
184bdbeb4c
commit
1642e5220f
3 changed files with 40 additions and 7 deletions
|
|
@ -488,7 +488,7 @@ static int update_device_props(struct device *device)
|
|||
{
|
||||
struct pw_properties *p = device->props;
|
||||
const char *s, *d;
|
||||
char temp[32];
|
||||
char temp[32], tmp[1024];
|
||||
int i;
|
||||
|
||||
s = pw_properties_get(p, SPA_KEY_DEVICE_NAME);
|
||||
|
|
@ -500,7 +500,9 @@ static int update_device_props(struct device *device)
|
|||
snprintf(temp, sizeof(temp), "%d", device->id);
|
||||
s = temp;
|
||||
}
|
||||
pw_properties_setf(p, PW_KEY_DEVICE_NAME, "alsa_card.%s", s);
|
||||
pw_properties_set(p, PW_KEY_DEVICE_NAME,
|
||||
sm_media_session_sanitize_name(tmp, sizeof(tmp),
|
||||
'_', "alsa_card.%s", s));
|
||||
|
||||
for (i = 2; i <= 99; i++) {
|
||||
if ((d = pw_properties_get(p, PW_KEY_DEVICE_NAME)) == NULL)
|
||||
|
|
@ -509,7 +511,9 @@ static int update_device_props(struct device *device)
|
|||
if (alsa_find_device(device->impl, SPA_ID_INVALID, d) == NULL)
|
||||
break;
|
||||
|
||||
pw_properties_setf(p, PW_KEY_DEVICE_NAME, "alsa_card.%s.%d", s, i);
|
||||
pw_properties_set(p, PW_KEY_DEVICE_NAME,
|
||||
sm_media_session_sanitize_name(tmp, sizeof(tmp),
|
||||
'_', "alsa_card.%s.%d", s, i));
|
||||
}
|
||||
if (i == 99)
|
||||
return -EEXIST;
|
||||
|
|
|
|||
|
|
@ -329,6 +329,30 @@ static struct device *bluez5_find_device(struct impl *impl, uint32_t id)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static int update_device_props(struct device *device)
|
||||
{
|
||||
struct pw_properties *p = device->props;
|
||||
const char *s;
|
||||
char temp[32], tmp[1024];
|
||||
|
||||
s = pw_properties_get(p, SPA_KEY_DEVICE_NAME);
|
||||
if (s == NULL)
|
||||
s = pw_properties_get(p, SPA_KEY_API_BLUEZ5_ADDRESS);
|
||||
if (s == NULL)
|
||||
s = pw_properties_get(p, SPA_KEY_DEVICE_DESCRIPTION);
|
||||
if (s == NULL) {
|
||||
snprintf(temp, sizeof(temp), "%d", device->id);
|
||||
s = temp;
|
||||
}
|
||||
if (strstr(s, "bluez_card.") == s)
|
||||
s += strlen("bluez_card.");
|
||||
|
||||
pw_properties_set(p, PW_KEY_DEVICE_NAME,
|
||||
sm_media_session_sanitize_name(tmp, sizeof(tmp),
|
||||
'_', "bluez_card.%s", s));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void bluez5_update_device(struct impl *impl, struct device *dev,
|
||||
const struct spa_device_object_info *info)
|
||||
{
|
||||
|
|
@ -338,6 +362,7 @@ static void bluez5_update_device(struct impl *impl, struct device *dev,
|
|||
spa_debug_dict(0, info->props);
|
||||
|
||||
pw_properties_update(dev->props, info->props);
|
||||
update_device_props(dev);
|
||||
}
|
||||
|
||||
static void device_destroy(void *data)
|
||||
|
|
@ -376,7 +401,6 @@ static const struct sm_object_events device_events = {
|
|||
.update = device_update,
|
||||
};
|
||||
|
||||
|
||||
static struct device *bluez5_create_device(struct impl *impl, uint32_t id,
|
||||
const struct spa_device_object_info *info)
|
||||
{
|
||||
|
|
@ -420,6 +444,7 @@ static struct device *bluez5_create_device(struct impl *impl, uint32_t id,
|
|||
device->handle = handle;
|
||||
device->device = iface;
|
||||
device->props = pw_properties_new_dict(info->props);
|
||||
update_device_props(device);
|
||||
device->sdevice = sm_media_session_export_device(impl->session,
|
||||
&device->props->dict, device->device);
|
||||
if (device->sdevice == NULL) {
|
||||
|
|
|
|||
|
|
@ -294,7 +294,7 @@ static int v4l2_update_device_props(struct device *dev)
|
|||
{
|
||||
struct pw_properties *p = dev->props;
|
||||
const char *s, *d;
|
||||
char temp[32];
|
||||
char temp[32], tmp[1024];
|
||||
int i;
|
||||
|
||||
if ((s = pw_properties_get(p, SPA_KEY_DEVICE_NAME)) == NULL) {
|
||||
|
|
@ -305,7 +305,9 @@ static int v4l2_update_device_props(struct device *dev)
|
|||
}
|
||||
}
|
||||
}
|
||||
pw_properties_setf(p, PW_KEY_DEVICE_NAME, "v4l2_device.%s", s);
|
||||
pw_properties_set(p, PW_KEY_DEVICE_NAME,
|
||||
sm_media_session_sanitize_name(tmp, sizeof(tmp),
|
||||
'_', "v4l2_device.%s", s));
|
||||
|
||||
for (i = 2; i <= 99; i++) {
|
||||
if ((d = pw_properties_get(p, PW_KEY_DEVICE_NAME)) == NULL)
|
||||
|
|
@ -314,7 +316,9 @@ static int v4l2_update_device_props(struct device *dev)
|
|||
if (v4l2_find_device(dev->impl, SPA_ID_INVALID, d) == NULL)
|
||||
break;
|
||||
|
||||
pw_properties_setf(p, PW_KEY_DEVICE_NAME, "v4l2_device.%s.%d", s, i);
|
||||
pw_properties_set(p, PW_KEY_DEVICE_NAME,
|
||||
sm_media_session_sanitize_name(tmp, sizeof(tmp),
|
||||
'_', "v4l2_device.%s.%d", s, i));
|
||||
}
|
||||
if (i == 99)
|
||||
return -EEXIST;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue