mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-03 09:01:50 -05:00
module-jackdbus-detect: Separate sink/source channels arguments
If a channels argument is passed module-jackdbus-detect, it is passed to both module-jack-sink and module-jack-source when those are started. This is a problem if you want a different number of input channels from output channels. In particular, if you want more of one than you physically have of the other, it will fail. This commit adds separate source_channels and sink_channels arguments to be able to specify the channels arguments to module-jack-source and module-jack-sink separately. The combined channels argument is kept for backwards compatibility and will be used as a default for source_channels and sink_channels if either of them is omitted.
This commit is contained in:
parent
64211b8f59
commit
bcc2162fb4
1 changed files with 23 additions and 5 deletions
|
|
@ -38,6 +38,8 @@ PA_MODULE_LOAD_ONCE(true);
|
||||||
PA_MODULE_VERSION(PACKAGE_VERSION);
|
PA_MODULE_VERSION(PACKAGE_VERSION);
|
||||||
PA_MODULE_USAGE(
|
PA_MODULE_USAGE(
|
||||||
"channels=<number of channels> "
|
"channels=<number of channels> "
|
||||||
|
"source_channels=<number of channels> "
|
||||||
|
"sink_channels=<number of channels> "
|
||||||
"connect=<connect ports?>");
|
"connect=<connect ports?>");
|
||||||
|
|
||||||
#define JACK_SERVICE_NAME "org.jackaudio.service"
|
#define JACK_SERVICE_NAME "org.jackaudio.service"
|
||||||
|
|
@ -59,6 +61,8 @@ PA_MODULE_USAGE(
|
||||||
|
|
||||||
static const char* const valid_modargs[] = {
|
static const char* const valid_modargs[] = {
|
||||||
"channels",
|
"channels",
|
||||||
|
"source_channels",
|
||||||
|
"sink_channels",
|
||||||
"connect",
|
"connect",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
@ -79,7 +83,7 @@ struct userdata {
|
||||||
bool filter_added, match_added;
|
bool filter_added, match_added;
|
||||||
bool is_service_started;
|
bool is_service_started;
|
||||||
bool autoconnect_ports;
|
bool autoconnect_ports;
|
||||||
uint32_t channels;
|
uint32_t channels[JACK_SS_COUNT];
|
||||||
/* Using index here protects us from module unloading without us knowing */
|
/* Using index here protects us from module unloading without us knowing */
|
||||||
int jack_module_index[JACK_SS_COUNT];
|
int jack_module_index[JACK_SS_COUNT];
|
||||||
};
|
};
|
||||||
|
|
@ -104,8 +108,8 @@ static void ensure_ports_started(struct userdata* u) {
|
||||||
if (!u->jack_module_index[i]) {
|
if (!u->jack_module_index[i]) {
|
||||||
char* args;
|
char* args;
|
||||||
pa_module* m;
|
pa_module* m;
|
||||||
if (u->channels > 0) {
|
if (u->channels[i] > 0) {
|
||||||
args = pa_sprintf_malloc("connect=%s channels=%" PRIu32, pa_yes_no(u->autoconnect_ports), u->channels);
|
args = pa_sprintf_malloc("connect=%s channels=%" PRIu32, pa_yes_no(u->autoconnect_ports), u->channels[i]);
|
||||||
} else {
|
} else {
|
||||||
args = pa_sprintf_malloc("connect=%s", pa_yes_no(u->autoconnect_ports));
|
args = pa_sprintf_malloc("connect=%s", pa_yes_no(u->autoconnect_ports));
|
||||||
}
|
}
|
||||||
|
|
@ -213,6 +217,8 @@ int pa__init(pa_module *m) {
|
||||||
pa_dbus_connection *connection = NULL;
|
pa_dbus_connection *connection = NULL;
|
||||||
struct userdata *u = NULL;
|
struct userdata *u = NULL;
|
||||||
pa_modargs *ma;
|
pa_modargs *ma;
|
||||||
|
uint32_t channels = 0;
|
||||||
|
int i;
|
||||||
|
|
||||||
pa_assert(m);
|
pa_assert(m);
|
||||||
|
|
||||||
|
|
@ -227,17 +233,29 @@ int pa__init(pa_module *m) {
|
||||||
u->core = m->core;
|
u->core = m->core;
|
||||||
u->module = m;
|
u->module = m;
|
||||||
u->autoconnect_ports = true;
|
u->autoconnect_ports = true;
|
||||||
u->channels = 0;
|
|
||||||
|
|
||||||
if (pa_modargs_get_value_boolean(ma, "connect", &u->autoconnect_ports) < 0) {
|
if (pa_modargs_get_value_boolean(ma, "connect", &u->autoconnect_ports) < 0) {
|
||||||
pa_log("Failed to parse connect= argument.");
|
pa_log("Failed to parse connect= argument.");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pa_modargs_get_value_u32(ma, "channels", &u->channels) < 0 || (u->channels > 0 && !pa_channels_valid(u->channels))) {
|
if (pa_modargs_get_value_u32(ma, "channels", &channels) < 0 || (channels > 0 && !pa_channels_valid(channels))) {
|
||||||
pa_log("Failed to parse channels= argument.");
|
pa_log("Failed to parse channels= argument.");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
for (i = 0; i < JACK_SS_COUNT; i++) {
|
||||||
|
u->channels[i] = channels;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pa_modargs_get_value_u32(ma, "source_channels", &u->channels[JACK_SS_SOURCE]) < 0 || (u->channels[JACK_SS_SOURCE] > 0 && !pa_channels_valid(u->channels[JACK_SS_SOURCE]))) {
|
||||||
|
pa_log("Failed to parse source_channels= argument.");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pa_modargs_get_value_u32(ma, "sink_channels", &u->channels[JACK_SS_SINK]) < 0 || (u->channels[JACK_SS_SINK] > 0 && !pa_channels_valid(u->channels[JACK_SS_SINK]))) {
|
||||||
|
pa_log("Failed to parse sink_channels= argument.");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(connection = pa_dbus_bus_get(m->core, DBUS_BUS_SESSION, &error)) || dbus_error_is_set(&error)) {
|
if (!(connection = pa_dbus_bus_get(m->core, DBUS_BUS_SESSION, &error)) || dbus_error_is_set(&error)) {
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue