mirror of
https://github.com/mpv-player/mpv
synced 2025-02-06 15:11:58 +00:00
audio: make empty device ID mean default device
This will make it easier for AOs to add explicit default device entries. (See next commit.) Hopefully this change doesn't lead accidentally to bogus "Default" entries to appear, but then it can only happen if the device ID is empty, which would mean the underlying audio API returned bogus entries.
This commit is contained in:
parent
84513ba58b
commit
a2b93e0c27
@ -529,14 +529,10 @@ struct ao_hotplug *ao_hotplug_create(struct mpv_global *global,
|
||||
|
||||
static void get_devices(struct ao *ao, struct ao_device_list *list)
|
||||
{
|
||||
int num = list->num_devices;
|
||||
if (ao->driver->list_devs) {
|
||||
ao->driver->list_devs(ao, list);
|
||||
} else {
|
||||
char name[80] = "Default";
|
||||
if (num > 1)
|
||||
mp_snprintf_cat(name, sizeof(name), " (%s)", ao->driver->name);
|
||||
ao_device_list_add(list, ao, &(struct ao_device_desc){"", name});
|
||||
ao_device_list_add(list, ao, &(struct ao_device_desc){"", ""});
|
||||
}
|
||||
}
|
||||
|
||||
@ -599,8 +595,19 @@ void ao_device_list_add(struct ao_device_list *list, struct ao *ao,
|
||||
{
|
||||
struct ao_device_desc c = *e;
|
||||
const char *dname = ao->driver->name;
|
||||
if ((!c.desc || !c.desc[0]) && c.name)
|
||||
char buf[80];
|
||||
if (!c.desc || !c.desc[0]) {
|
||||
if (c.name && c.name[0]) {
|
||||
c.desc = c.name;
|
||||
} else if (list->num_devices) {
|
||||
// Assume this is the default device.
|
||||
snprintf(buf, sizeof(buf), "Default (%s)", dname);
|
||||
c.desc = buf;
|
||||
} else {
|
||||
// First default device (and maybe the only one).
|
||||
c.desc = "Default";
|
||||
}
|
||||
}
|
||||
c.name = c.name[0] ? talloc_asprintf(list, "%s/%s", dname, c.name)
|
||||
: talloc_strdup(list, dname);
|
||||
c.desc = talloc_strdup(list, c.desc);
|
||||
|
Loading…
Reference in New Issue
Block a user