/* $Id$ */
/***
- This file is part of polypaudio.
+ This file is part of PulseAudio.
- polypaudio is free software; you can redistribute it and/or modify
+ PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
- polypaudio is distributed in the hope that it will be useful, but
+ PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
- along with polypaudio; if not, write to the Free Software
+ along with PulseAudio; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA.
***/
#include <jack/jack.h>
-#include <polypcore/iochannel.h>
-#include <polypcore/sink.h>
-#include <polypcore/module.h>
-#include <polypcore/util.h>
-#include <polypcore/modargs.h>
-#include <polypcore/xmalloc.h>
-#include <polypcore/log.h>
-#include <polyp/mainloop-api.h>
+#include <pulse/xmalloc.h>
+
+#include <pulsecore/core-error.h>
+#include <pulsecore/iochannel.h>
+#include <pulsecore/sink.h>
+#include <pulsecore/module.h>
+#include <pulsecore/core-util.h>
+#include <pulsecore/modargs.h>
+#include <pulsecore/log.h>
+#include <pulse/mainloop-api.h>
#include "module-jack-sink-symdef.h"
"server_name=<jack server name> "
"client_name=<jack client name> "
"channels=<number of channels> "
- "connect=<connect ports?>"
-)
+ "connect=<connect ports?> "
+ "channel_map=<channel map>")
#define DEFAULT_SINK_NAME "jack_out"
jack_nframes_t frames_requested;
int quit_requested;
+ int pipe_fd_type;
int pipe_fds[2];
pa_io_event *io_event;
"client_name",
"channels",
"connect",
+ "channel_map",
NULL
};
assert(u);
assert(u->pipe_fds[0] == fd);
- read(fd, &x, 1);
+ pa_read(fd, &x, 1, &u->pipe_fd_type);
if (u->quit_requested) {
stop_sink(u);
assert(u);
assert(u->pipe_fds[1] >= 0);
- write(u->pipe_fds[1], &c, 1);
+ pa_write(u->pipe_fds[1], &c, 1, &u->pipe_fd_type);
}
static void jack_shutdown(void *arg) {
int pa__init(pa_core *c, pa_module*m) {
struct userdata *u = NULL;
pa_sample_spec ss;
- pa_channel_map cm;
+ pa_channel_map map;
pa_modargs *ma = NULL;
jack_status_t status;
const char *server_name, *client_name;
uint32_t channels = 0;
- int connect = 1;
+ int do_connect = 1;
unsigned i;
const char **ports = NULL, **p;
goto fail;
}
- if (pa_modargs_get_value_boolean(ma, "connect", &connect) < 0) {
+ if (pa_modargs_get_value_boolean(ma, "connect", &do_connect) < 0) {
pa_log(__FILE__": failed to parse connect= argument.");
goto fail;
}
server_name = pa_modargs_get_value(ma, "server_name", NULL);
- client_name = pa_modargs_get_value(ma, "client_name", "polypaudio");
+ client_name = pa_modargs_get_value(ma, "client_name", "PulseAudio");
u = pa_xnew0(struct userdata, 1);
m->userdata = u;
u->core = c;
u->module = m;
u->pipe_fds[0] = u->pipe_fds[1] = -1;
+ u->pipe_fd_type = 0;
pthread_mutex_init(&u->mutex, NULL);
pthread_cond_init(&u->cond, NULL);
if (pipe(u->pipe_fds) < 0) {
- pa_log(__FILE__": pipe() failed: %s", strerror(errno));
+ pa_log(__FILE__": pipe() failed: %s", pa_cstrerror(errno));
goto fail;
}
pa_log(__FILE__": failed to parse channels= argument.");
goto fail;
}
+
+ pa_channel_map_init_auto(&map, channels, PA_CHANNEL_MAP_ALSA);
+ if (pa_modargs_get_channel_map(ma, &map) < 0 || map.channels != channels) {
+ pa_log(__FILE__": failed to parse channel_map= argument.");
+ goto fail;
+ }
pa_log_info(__FILE__": Successfully connected as '%s'", jack_get_client_name(u->client));
assert(pa_sample_spec_valid(&ss));
- pa_channel_map_init_auto(&cm, channels);
-
for (i = 0; i < ss.channels; i++) {
- if (!(u->port[i] = jack_port_register(u->client, pa_channel_position_to_string(cm.map[i]), JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput|JackPortIsTerminal, 0))) {
+ if (!(u->port[i] = jack_port_register(u->client, pa_channel_position_to_string(map.map[i]), JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput|JackPortIsTerminal, 0))) {
pa_log(__FILE__": jack_port_register() failed.");
goto fail;
}
}
- if (!(u->sink = pa_sink_new(c, __FILE__, pa_modargs_get_value(ma, "sink_name", DEFAULT_SINK_NAME), 0, &ss, &cm))) {
+ if (!(u->sink = pa_sink_new(c, __FILE__, pa_modargs_get_value(ma, "sink_name", DEFAULT_SINK_NAME), 0, &ss, &map))) {
pa_log(__FILE__": failed to create sink.");
goto fail;
}
goto fail;
}
- if (connect) {
+ if (do_connect) {
for (i = 0, p = ports; i < ss.channels; i++, p++) {
if (!*p) {