From 2c732a46ba37182692748acd2b72310d21c451f8 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 7 Jul 2013 18:37:55 +0200 Subject: ao_jack: allow more control about channel layouts --- DOCS/man/en/ao.rst | 15 +++++++++++++++ audio/chmap_sel.c | 1 + audio/out/ao_jack.c | 22 +++++++++++++++++++++- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/DOCS/man/en/ao.rst b/DOCS/man/en/ao.rst index e86fa2cc2c..f8af559ee9 100644 --- a/DOCS/man/en/ao.rst +++ b/DOCS/man/en/ao.rst @@ -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 diff --git a/audio/chmap_sel.c b/audio/chmap_sel.c index 8e5be5c86e..215ba5add8 100644 --- a/audio/chmap_sel.c +++ b/audio/chmap_sel.c @@ -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++) { diff --git a/audio/out/ao_jack.c b/audio/out/ao_jack.c index 9c38dcde97..964eb5bce6 100644 --- a/audio/out/ao_jack.c +++ b/audio/out/ao_jack.c @@ -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; -- cgit v1.2.3