ao_jack: allow more control about channel layouts

This commit is contained in:
wm4
2013-07-07 18:37:55 +02:00
parent 886d982aa3
commit 2c732a46ba
3 changed files with 37 additions and 1 deletions

View File

@@ -60,6 +60,21 @@ jack
Automatically create connections to output ports (default: enabled).
When enabled, the maximum number of output channels will be limited to
the number of available output ports.
std-channel-layout=alsa|waveext|any
Select the standard channel layout (default: alsa). JACK itself has no
notion of channel layouts (i.e. assigning which speaker a given
channel is supposed to map to) - it just takes whatever the application
outputs, and reroutes it to whatever the user defines. This means the
user and the application is in charge of dealing with the channel
layout. ``alsa`` uses the old MPlayer layout, which is inspired by
ALSA's standard layouts. In this mode, ao_jack will refuse to play 3
or 7 channels (because these don't really have a defined meaning in
MPlayer). ``waveext`` uses WAVE_FORMAT_EXTENSIBLE order, which even
though it was defined by Microsoft, is the standard on many systems.
The value ``any`` makes JACK accept whatever comes from the audio
filter chain, regardless of channel layout and without reordering. This
mode is probably not very useful, other than debugging or when used
with fixed setups.
coreaudio (Mac OS X only)
native Mac OS X audio output driver

View File

@@ -70,6 +70,7 @@ void mp_chmap_sel_add_waveext(struct mp_chmap_sel *s)
s->allow_waveext = true;
}
// Classic ALSA-based MPlayer layouts.
void mp_chmap_sel_add_alsa_def(struct mp_chmap_sel *s)
{
for (int n = 0; n < MP_NUM_CHANNELS; n++) {

View File

@@ -188,6 +188,7 @@ static int init(struct ao *ao, char *params)
const char **matching_ports = NULL;
char *port_name = NULL;
char *client_name = NULL;
char *stdlayout = NULL;
int autostart = 0;
int connect = 1;
struct priv *p = talloc_zero(ao, struct priv);
@@ -197,6 +198,7 @@ static int init(struct ao *ao, char *params)
{"estimate", OPT_ARG_BOOL, &p->estimate, NULL},
{"autostart", OPT_ARG_BOOL, &autostart, NULL},
{"connect", OPT_ARG_BOOL, &connect, NULL},
{"std-channel-layout", OPT_ARG_MSTRZ, &stdlayout, NULL},
{NULL}
};
jack_options_t open_options = JackUseExactName;
@@ -210,7 +212,23 @@ static int init(struct ao *ao, char *params)
}
struct mp_chmap_sel sel = {0};
mp_chmap_sel_add_waveext(&sel);
if (stdlayout) {
if (strcmp(stdlayout, "waveext") == 0) {
mp_chmap_sel_add_waveext(&sel);
} else if (strcmp(stdlayout, "alsa") == 0) {
mp_chmap_sel_add_alsa_def(&sel);
} else if (strcmp(stdlayout, "any") == 0) {
mp_chmap_sel_add_any(&sel);
} else {
mp_msg(MSGT_AO, MSGL_FATAL, "[JACK] std-channel-layout suboption "
"expects 'alsa' or 'waveext' as value.\n");
goto err_out;
}
} else {
mp_chmap_sel_add_waveext(&sel);
}
if (!ao_chmap_sel_adjust(ao, &sel, &ao->channels))
goto err_out;
@@ -286,12 +304,14 @@ static int init(struct ao *ao, char *params)
free(matching_ports);
free(port_name);
free(client_name);
free(stdlayout);
return 0;
err_out:
free(matching_ports);
free(port_name);
free(client_name);
free(stdlayout);
if (p->client)
jack_client_close(p->client);
return -1;