[pulseaudio] Friendly naming of sinks in speaker list

This commit is contained in:
ejurgensen 2016-07-21 23:15:06 +02:00
parent eb40415348
commit 4399466f21
2 changed files with 19 additions and 18 deletions

View File

@ -1012,7 +1012,7 @@ alsa_init(void)
device->advertised = 1; device->advertised = 1;
device->has_video = 0; device->has_video = 0;
DPRINTF(E_INFO, L_LAUDIO, "Adding ALSA device '%s' using friendly name '%s'\n", card_name, nickname); DPRINTF(E_INFO, L_LAUDIO, "Adding ALSA device '%s' with name '%s'\n", card_name, nickname);
player_device_add(device); player_device_add(device);

View File

@ -264,19 +264,12 @@ static void
sinklist_cb(pa_context *ctx, const pa_sink_info *i, int eol, void *userdata) sinklist_cb(pa_context *ctx, const pa_sink_info *i, int eol, void *userdata)
{ {
struct output_device *device; struct output_device *device;
uint32_t id; const char *name;
if (eol > 0) if (eol > 0)
return; return;
id = djb_hash(i->name, strlen(i->name)); DPRINTF(E_DBG, L_LAUDIO, "Event for Pulseaudio sink '%s' (id %" PRIu32 ")\n", i->name, i->index);
if (!id)
{
DPRINTF(E_LOG, L_LAUDIO, "Could not hash Pulseaudio sink name (%s)\n", i->name);
return;
}
DPRINTF(E_DBG, L_LAUDIO, "Event for Pulseaudio sink '%s' (id %" PRIu32 ")\n", i->name, id);
device = calloc(1, sizeof(struct output_device)); device = calloc(1, sizeof(struct output_device));
if (!device) if (!device)
@ -285,14 +278,25 @@ sinklist_cb(pa_context *ctx, const pa_sink_info *i, int eol, void *userdata)
return; return;
} }
device->id = id; if (i->index == 0)
device->name = strdup(i->name); {
name = cfg_getstr(cfg_getsec(cfg, "audio"), "nickname");
DPRINTF(E_LOG, L_LAUDIO, "Adding Pulseaudio sink '%s' (%s) with name '%s'\n", i->description, i->name, name);
}
else
{
name = i->description;
DPRINTF(E_LOG, L_LAUDIO, "Adding Pulseaudio sink '%s' (%s)\n", i->description, i->name);
}
device->id = i->index;
device->name = strdup(name);
device->type = OUTPUT_TYPE_PULSE; device->type = OUTPUT_TYPE_PULSE;
device->type_name = outputs_name(device->type); device->type_name = outputs_name(device->type);
device->advertised = 1; device->advertised = 1;
DPRINTF(E_LOG, L_LAUDIO, "Adding Pulseaudio sink '%s' (%s)\n", i->description, i->name);
player_device_add(device); player_device_add(device);
} }
@ -632,14 +636,11 @@ static int
pulse_init(void) pulse_init(void)
{ {
struct pulse *p = &pulse; struct pulse *p = &pulse;
cfg_t *cfg_audio;
char *type; char *type;
int state; int state;
int ret; int ret;
cfg_audio = cfg_getsec(cfg, "audio"); type = cfg_getstr(cfg_getsec(cfg, "audio"), "type");
type = cfg_getstr(cfg_audio, "type");
if (type && (strcasecmp(type, "pulseaudio") != 0)) if (type && (strcasecmp(type, "pulseaudio") != 0))
return -1; return -1;