#include <jack/jack.h>
+#include <polyp/xmalloc.h>
+
+#include <polypcore/core-error.h>
#include <polypcore/iochannel.h>
#include <polypcore/source.h>
#include <polypcore/module.h>
-#include <polypcore/util.h>
+#include <polypcore/core-util.h>
#include <polypcore/modargs.h>
-#include <polypcore/xmalloc.h>
#include <polypcore/log.h>
#include <polyp/mainloop-api.h>
"client_name=<jack client name> "
"channels=<number of channels> "
"connect=<connect ports?>"
-)
+ "channel_map=<channel map>")
#define DEFAULT_SOURCE_NAME "jack_in"
"client_name",
"channels",
"connect",
+ "channel_map",
NULL
};
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;
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, JackPortIsInput|JackPortIsTerminal, 0))) {
+ if (!(u->port[i] = jack_port_register(u->client, pa_channel_position_to_string(map.map[i]), JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput|JackPortIsTerminal, 0))) {
pa_log(__FILE__": jack_port_register() failed.");
goto fail;
}
}
- if (!(u->source = pa_source_new(c, __FILE__, pa_modargs_get_value(ma, "source_name", DEFAULT_SOURCE_NAME), 0, &ss, &cm))) {
+ if (!(u->source = pa_source_new(c, __FILE__, pa_modargs_get_value(ma, "source_name", DEFAULT_SOURCE_NAME), 0, &ss, &map))) {
pa_log(__FILE__": failed to create source.");
goto fail;
}