summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/modules/alsa/alsa-sink.c43
-rw-r--r--src/modules/alsa/alsa-source.c43
-rw-r--r--src/modules/alsa/module-alsa-card.c36
-rw-r--r--src/modules/alsa/module-alsa-sink.c2
-rw-r--r--src/modules/alsa/module-alsa-source.c2
5 files changed, 92 insertions, 34 deletions
diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index 61fb408b..749396fc 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -1209,6 +1209,32 @@ finish:
pa_log_debug("Thread shutting down");
}
+static void set_sink_name(pa_sink_new_data *data, pa_modargs *ma, const char *device_id, const char *device_name) {
+ const char *n;
+ char *t;
+
+ pa_assert(data);
+ pa_assert(ma);
+ pa_assert(device_name);
+
+ if ((n = pa_modargs_get_value(ma, "sink_name", NULL))) {
+ pa_sink_new_data_set_name(data, n);
+ data->namereg_fail = TRUE;
+ return;
+ }
+
+ if ((n = pa_modargs_get_value(ma, "name", NULL)))
+ data->namereg_fail = TRUE;
+ else {
+ n = device_id ? device_id : device_name;
+ data->namereg_fail = FALSE;
+ }
+
+ t = pa_sprintf_malloc("alsa_output.%s", n);
+ pa_sink_new_data_set_name(data, t);
+ pa_xfree(t);
+}
+
pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_card *card, const pa_alsa_profile_info *profile) {
struct userdata *u = NULL;
@@ -1220,9 +1246,6 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
size_t frame_size;
snd_pcm_info_t *pcm_info = NULL;
int err;
- const char *name;
- char *name_buf = NULL;
- pa_bool_t namereg_fail;
pa_bool_t use_mmap = TRUE, b, use_tsched = TRUE, d;
pa_usec_t usec;
pa_sink_new_data data;
@@ -1404,22 +1427,11 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
}
}
- if ((name = pa_modargs_get_value(ma, "sink_name", NULL)))
- namereg_fail = TRUE;
- else if ((name = pa_modargs_get_value(ma, "name", NULL))) {
- name = name_buf = pa_sprintf_malloc("alsa_output.%s", name);
- namereg_fail = TRUE;
- } else {
- name = name_buf = pa_sprintf_malloc("alsa_output.%s", u->device_name);
- namereg_fail = FALSE;
- }
-
pa_sink_new_data_init(&data);
data.driver = driver;
data.module = m;
data.card = card;
- pa_sink_new_data_set_name(&data, name);
- data.namereg_fail = namereg_fail;
+ set_sink_name(&data, ma, dev_id, u->device_name);
pa_sink_new_data_set_sample_spec(&data, &ss);
pa_sink_new_data_set_channel_map(&data, &map);
@@ -1436,7 +1448,6 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
u->sink = pa_sink_new(m->core, &data, PA_SINK_HARDWARE|PA_SINK_LATENCY);
pa_sink_new_data_done(&data);
- pa_xfree(name_buf);
if (!u->sink) {
pa_log("Failed to create sink object");
diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c
index 3a7b3081..fe4eddb5 100644
--- a/src/modules/alsa/alsa-source.c
+++ b/src/modules/alsa/alsa-source.c
@@ -1044,6 +1044,32 @@ finish:
pa_log_debug("Thread shutting down");
}
+static void set_source_name(pa_source_new_data *data, pa_modargs *ma, const char *device_id, const char *device_name) {
+ const char *n;
+ char *t;
+
+ pa_assert(data);
+ pa_assert(ma);
+ pa_assert(device_name);
+
+ if ((n = pa_modargs_get_value(ma, "source_name", NULL))) {
+ pa_source_new_data_set_name(data, n);
+ data->namereg_fail = TRUE;
+ return;
+ }
+
+ if ((n = pa_modargs_get_value(ma, "name", NULL)))
+ data->namereg_fail = TRUE;
+ else {
+ n = device_id ? device_id : device_name;
+ data->namereg_fail = FALSE;
+ }
+
+ t = pa_sprintf_malloc("alsa_input.%s", n);
+ pa_source_new_data_set_name(data, t);
+ pa_xfree(t);
+}
+
pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, pa_card *card, const pa_alsa_profile_info *profile) {
struct userdata *u = NULL;
@@ -1055,9 +1081,6 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
size_t frame_size;
snd_pcm_info_t *pcm_info = NULL;
int err;
- const char *name;
- char *name_buf = NULL;
- pa_bool_t namereg_fail;
pa_bool_t use_mmap = TRUE, b, use_tsched = TRUE, d;
pa_source_new_data data;
@@ -1229,22 +1252,11 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
}
}
- if ((name = pa_modargs_get_value(ma, "source_name", NULL)))
- namereg_fail = TRUE;
- else if ((name = pa_modargs_get_value(ma, "name", NULL))) {
- name = name_buf = pa_sprintf_malloc("alsa_input.%s", name);
- namereg_fail = TRUE;
- } else {
- name = name_buf = pa_sprintf_malloc("alsa_input.%s", u->device_name);
- namereg_fail = FALSE;
- }
-
pa_source_new_data_init(&data);
data.driver = driver;
data.module = m;
data.card = card;
- pa_source_new_data_set_name(&data, name);
- data.namereg_fail = namereg_fail;
+ set_source_name(&data, ma, dev_id, u->device_name);
pa_source_new_data_set_sample_spec(&data, &ss);
pa_source_new_data_set_channel_map(&data, &map);
@@ -1261,7 +1273,6 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
u->source = pa_source_new(m->core, &data, PA_SOURCE_HARDWARE|PA_SOURCE_LATENCY);
pa_source_new_data_done(&data);
- pa_xfree(name_buf);
if (!u->source) {
pa_log("Failed to create source object");
diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c
index f2506024..9a00edd9 100644
--- a/src/modules/alsa/module-alsa-card.c
+++ b/src/modules/alsa/module-alsa-card.c
@@ -37,7 +37,10 @@ PA_MODULE_DESCRIPTION("ALSA Card");
PA_MODULE_VERSION(PACKAGE_VERSION);
PA_MODULE_LOAD_ONCE(FALSE);
PA_MODULE_USAGE(
- "name=<name for the sink/source> "
+ "name=<name for the card/sink/source, to be prefixed> "
+ "card_name=<name for card> "
+ "sink_name=<name for sink> "
+ "source_name=<name for source> "
"device_id=<ALSA card index> "
"format=<sample format> "
"rate=<sample rate> "
@@ -51,6 +54,9 @@ PA_MODULE_USAGE(
static const char* const valid_modargs[] = {
"name",
+ "card_name",
+ "sink_name",
+ "source_name",
"device_id",
"format",
"rate",
@@ -189,6 +195,32 @@ static void init_profile(struct userdata *u) {
u->source = pa_alsa_source_new(u->module, u->modargs, __FILE__, u->card, d->source_profile);
}
+static void set_card_name(pa_card_new_data *data, pa_modargs *ma, const char *device_id) {
+ char *t;
+ const char *n;
+
+ pa_assert(data);
+ pa_assert(ma);
+ pa_assert(device_id);
+
+ if ((n = pa_modargs_get_value(ma, "card_name", NULL))) {
+ pa_card_new_data_set_name(data, n);
+ data->namereg_fail = TRUE;
+ return;
+ }
+
+ if ((n = pa_modargs_get_value(ma, "name", NULL)))
+ data->namereg_fail = TRUE;
+ else {
+ n = device_id;
+ data->namereg_fail = FALSE;
+ }
+
+ t = pa_sprintf_malloc("alsa_card.%s", n);
+ pa_card_new_data_set_name(data, t);
+ pa_xfree(t);
+}
+
int pa__init(pa_module*m) {
pa_card_new_data data;
pa_modargs *ma;
@@ -224,7 +256,7 @@ int pa__init(pa_module*m) {
data.module = m;
pa_alsa_init_proplist_card(data.proplist, alsa_card_index);
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_STRING, u->device_id);
- pa_card_new_data_set_name(&data, pa_modargs_get_value(ma, "name", u->device_id));
+ set_card_name(&data, ma, u->device_id);
data.profiles = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
if (pa_alsa_probe_profiles(u->device_id, &m->core->default_sample_spec, enumerate_cb, data.profiles) < 0) {
diff --git a/src/modules/alsa/module-alsa-sink.c b/src/modules/alsa/module-alsa-sink.c
index 6a66ad32..6cf48b58 100644
--- a/src/modules/alsa/module-alsa-sink.c
+++ b/src/modules/alsa/module-alsa-sink.c
@@ -38,6 +38,7 @@ PA_MODULE_DESCRIPTION("ALSA Sink");
PA_MODULE_VERSION(PACKAGE_VERSION);
PA_MODULE_LOAD_ONCE(FALSE);
PA_MODULE_USAGE(
+ "name=<name of the sink, to be prefixed> "
"sink_name=<name for the sink> "
"device=<ALSA device> "
"device_id=<ALSA card index> "
@@ -53,6 +54,7 @@ PA_MODULE_USAGE(
"tsched_buffer_watermark=<lower fill watermark>");
static const char* const valid_modargs[] = {
+ "name",
"sink_name",
"device",
"device_id",
diff --git a/src/modules/alsa/module-alsa-source.c b/src/modules/alsa/module-alsa-source.c
index 7dc22fea..1e7c387c 100644
--- a/src/modules/alsa/module-alsa-source.c
+++ b/src/modules/alsa/module-alsa-source.c
@@ -62,6 +62,7 @@ PA_MODULE_DESCRIPTION("ALSA Source");
PA_MODULE_VERSION(PACKAGE_VERSION);
PA_MODULE_LOAD_ONCE(FALSE);
PA_MODULE_USAGE(
+ "name=<name for the source, to be prefixed> "
"source_name=<name for the source> "
"device=<ALSA device> "
"device_id=<ALSA card index> "
@@ -77,6 +78,7 @@ PA_MODULE_USAGE(
"tsched_buffer_watermark=<upper fill watermark>");
static const char* const valid_modargs[] = {
+ "name",
"source_name",
"device",
"device_id",