[pulseaudio-commits] r1223 - in /trunk/src/modules: module-alsa-sink.c module-alsa-source.c module-oss.c
svnmailer-noreply at 0pointer.de
svnmailer-noreply at 0pointer.de
Sat Aug 12 09:27:02 PDT 2006
Author: lennart
Date: Sat Aug 12 18:26:59 2006
New Revision: 1223
URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=1223&root=pulseaudio&view=rev
Log:
generate default sink/source names from the device files they belong to
Modified:
trunk/src/modules/module-alsa-sink.c
trunk/src/modules/module-alsa-source.c
trunk/src/modules/module-oss.c
Modified: trunk/src/modules/module-alsa-sink.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/modules/module-alsa-sink.c?rev=1223&root=pulseaudio&r1=1222&r2=1223&view=diff
==============================================================================
--- trunk/src/modules/module-alsa-sink.c (original)
+++ trunk/src/modules/module-alsa-sink.c Sat Aug 12 18:26:59 2006
@@ -87,7 +87,6 @@
NULL
};
-#define DEFAULT_SINK_NAME "alsa_output"
#define DEFAULT_DEVICE "default"
static void update_usage(struct userdata *u) {
@@ -367,6 +366,9 @@
snd_pcm_info_t *pcm_info = NULL;
int err;
char *t;
+ const char *name;
+ char *name_buf = NULL;
+ int namereg_fail;
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
pa_log(__FILE__": failed to parse module arguments");
@@ -427,7 +429,14 @@
u->mixer_handle = NULL;
}
- if (!(u->sink = pa_sink_new(c, __FILE__, pa_modargs_get_value(ma, "sink_name", DEFAULT_SINK_NAME), 0, &ss, &map))) {
+ if ((name = pa_modargs_get_value(ma, "sink_name", NULL)))
+ namereg_fail = 1;
+ else {
+ name = name_buf = pa_sprintf_malloc("alsa_output.%s", dev);
+ namereg_fail = 0;
+ }
+
+ if (!(u->sink = pa_sink_new(c, __FILE__, name, namereg_fail, &ss, &map))) {
pa_log(__FILE__": Failed to create sink object");
goto fail;
}
@@ -502,6 +511,9 @@
u->sink->get_hw_mute(u->sink);
finish:
+
+ pa_xfree(name_buf);
+
if (ma)
pa_modargs_free(ma);
Modified: trunk/src/modules/module-alsa-source.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/modules/module-alsa-source.c?rev=1223&root=pulseaudio&r1=1222&r2=1223&view=diff
==============================================================================
--- trunk/src/modules/module-alsa-source.c (original)
+++ trunk/src/modules/module-alsa-source.c Sat Aug 12 18:26:59 2006
@@ -88,7 +88,6 @@
NULL
};
-#define DEFAULT_SOURCE_NAME "alsa_input"
#define DEFAULT_DEVICE "default"
static void update_usage(struct userdata *u) {
@@ -360,6 +359,9 @@
snd_pcm_info_t *pcm_info = NULL;
int err;
char *t;
+ const char *name;
+ char *name_buf = NULL;
+ int namereg_fail;
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
pa_log(__FILE__": failed to parse module arguments");
@@ -420,7 +422,14 @@
u->mixer_handle = NULL;
}
- if (!(u->source = pa_source_new(c, __FILE__, pa_modargs_get_value(ma, "source_name", DEFAULT_SOURCE_NAME), 0, &ss, &map))) {
+ if ((name = pa_modargs_get_value(ma, "source_name", NULL)))
+ namereg_fail = 1;
+ else {
+ name = name_buf = pa_sprintf_malloc("alsa_input.%s", dev);
+ namereg_fail = 0;
+ }
+
+ if (!(u->source = pa_source_new(c, __FILE__, name, namereg_fail, &ss, &map))) {
pa_log(__FILE__": Failed to create source object");
goto fail;
}
@@ -492,7 +501,9 @@
u->source->get_hw_mute(u->source);
finish:
- if (ma)
+ pa_xfree(name_buf);
+
+ if (ma)
pa_modargs_free(ma);
if (pcm_info)
Modified: trunk/src/modules/module-oss.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/modules/module-oss.c?rev=1223&root=pulseaudio&r1=1222&r2=1223&view=diff
==============================================================================
--- trunk/src/modules/module-oss.c (original)
+++ trunk/src/modules/module-oss.c Sat Aug 12 18:26:59 2006
@@ -36,6 +36,7 @@
#include <limits.h>
#include <pulse/xmalloc.h>
+#include <pulse/util.h>
#include <pulsecore/core-error.h>
#include <pulsecore/iochannel.h>
@@ -96,8 +97,6 @@
NULL
};
-#define DEFAULT_SINK_NAME "oss_output"
-#define DEFAULT_SOURCE_NAME "oss_input"
#define DEFAULT_DEVICE "/dev/dsp"
static void update_usage(struct userdata *u) {
@@ -354,6 +353,9 @@
pa_channel_map map;
pa_modargs *ma = NULL;
char hwdesc[64], *t;
+ const char *name;
+ char *name_buf = NULL;
+ int namereg_fail;
assert(c);
assert(m);
@@ -431,7 +433,14 @@
}
if (mode != O_WRONLY) {
- if (!(u->source = pa_source_new(c, __FILE__, pa_modargs_get_value(ma, "source_name", DEFAULT_SOURCE_NAME), 0, &ss, &map)))
+ if ((name = pa_modargs_get_value(ma, "source_name", NULL)))
+ namereg_fail = 1;
+ else {
+ name = name_buf = pa_sprintf_malloc("oss_input.%s", pa_path_get_filename(p));
+ namereg_fail = 0;
+ }
+
+ if (!(u->source = pa_source_new(c, __FILE__, name, namereg_fail, &ss, &map)))
goto fail;
u->source->userdata = u;
@@ -450,8 +459,18 @@
} else
u->source = NULL;
+ pa_xfree(name_buf);
+ name_buf = NULL;
+
if (mode != O_RDONLY) {
- if (!(u->sink = pa_sink_new(c, __FILE__, pa_modargs_get_value(ma, "sink_name", DEFAULT_SINK_NAME), 0, &ss, &map)))
+ if ((name = pa_modargs_get_value(ma, "sink_name", NULL)))
+ namereg_fail = 1;
+ else {
+ name = name_buf = pa_sprintf_malloc("oss_output.%s", pa_path_get_filename(p));
+ namereg_fail = 0;
+ }
+
+ if (!(u->sink = pa_sink_new(c, __FILE__, name, namereg_fail, &ss, &map)))
goto fail;
u->sink->get_latency = sink_get_latency_cb;
@@ -469,6 +488,9 @@
} else
u->sink = NULL;
+ pa_xfree(name_buf);
+ name_buf = NULL;
+
assert(u->source || u->sink);
u->io = pa_iochannel_new(c->mainloop, u->source ? fd : -1, u->sink ? fd : -1);
@@ -516,6 +538,8 @@
if (ma)
pa_modargs_free(ma);
+
+ pa_xfree(name_buf);
return -1;
}
More information about the pulseaudio-commits
mailing list