[pulseaudio-discuss] [PATCH 2/3] module-waveout: Allow sink and source be on different devices.
Thomas Martitz
kugel at rockbox.org
Tue Oct 30 03:35:25 PDT 2012
This patch allows one to create sink and source on different devices. This
is useful e.g. to have a source on a virtual microphone, but the sink on
a real soundcard.
---
src/modules/module-waveout.c | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/src/modules/module-waveout.c b/src/modules/module-waveout.c
index 53efce9..6ac23bc 100644
--- a/src/modules/module-waveout.c
+++ b/src/modules/module-waveout.c
@@ -49,6 +49,8 @@ PA_MODULE_USAGE(
"sink_name=<name for the sink> "
"source_name=<name for the source> "
"device=<device number> "
+ "sink_device=<device number> "
+ "source_device=<device number> "
"device_name=<name of the device> "
"record=<enable source?> "
"playback=<enable sink?> "
@@ -95,6 +97,8 @@ static const char* const valid_modargs[] = {
"sink_name",
"source_name",
"device",
+ "sink_device",
+ "source_device",
"device_name",
"record",
"playback",
@@ -497,7 +501,7 @@ int pa__init(pa_module *m) {
MMRESULT result;
int nfrags, frag_size;
pa_bool_t record = TRUE, playback = TRUE;
- unsigned int device;
+ unsigned int device, source_device;
pa_sample_spec ss;
pa_channel_map map;
pa_modargs *ma = NULL;
@@ -525,10 +529,23 @@ int pa__init(pa_module *m) {
/* Set the device to be opened. If set device_name is used,
* else device if set and lastly WAVE_MAPPER is the default */
device = WAVE_MAPPER;
+ /* check device first, for backwards compatibility */
if (pa_modargs_get_value_u32(ma, "device", &device) < 0) {
pa_log("failed to parse device argument");
goto fail;
}
+ if (pa_modargs_get_value_u32(ma, "sink_device", &device) < 0) {
+ pa_log("failed to parse device argument");
+ goto fail;
+ }
+
+ source_device = device; /* default is source == sink */
+ if (pa_modargs_get_value_u32(ma, "source_device", &source_device) < 0) {
+ pa_log("failed to parse device argument");
+ goto fail;
+ }
+
+ /* TODO: sink/source_device_name */
if ((device_name = pa_modargs_get_value(ma, "device_name", NULL)) != NULL) {
unsigned int num_devices = waveOutGetNumDevs();
for (i = 0; i < num_devices; i++) {
@@ -567,12 +584,12 @@ int pa__init(pa_module *m) {
u = pa_xmalloc(sizeof(struct userdata));
if (record) {
- result = waveInOpen(&hwi, device, &wf, 0, 0, WAVE_FORMAT_DIRECT | WAVE_FORMAT_QUERY);
+ result = waveInOpen(&hwi, source_device, &wf, 0, 0, WAVE_FORMAT_DIRECT | WAVE_FORMAT_QUERY);
if (result != MMSYSERR_NOERROR) {
pa_log_warn("Sample spec not supported by WaveIn, falling back to default sample rate.");
ss.rate = wf.nSamplesPerSec = m->core->default_sample_spec.rate;
}
- result = waveInOpen(&hwi, device, &wf, (DWORD_PTR) chunk_ready_cb, (DWORD_PTR) u, CALLBACK_FUNCTION);
+ result = waveInOpen(&hwi, source_device, &wf, (DWORD_PTR) chunk_ready_cb, (DWORD_PTR) u, CALLBACK_FUNCTION);
if (result != MMSYSERR_NOERROR) {
char errortext[MAXERRORLENGTH];
pa_log("Failed to open WaveIn.");
--
1.7.10.4
More information about the pulseaudio-discuss
mailing list