From ecc6e379b24dd5e37b864ae599a154880a2bd2d0 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 9 May 2013 18:06:26 +0200 Subject: audio/out: channel map selection Make all AOs use what has been introduced in the previous commit. Note that even AOs which can handle all possible layouts (like ao_null) use the new functions. This might be important if in the future ao_select_champ() possibly honors global user options about downmixing and so on. --- audio/out/ao_jack.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'audio/out/ao_jack.c') diff --git a/audio/out/ao_jack.c b/audio/out/ao_jack.c index aea64ee02c..0f8baeab86 100644 --- a/audio/out/ao_jack.c +++ b/audio/out/ao_jack.c @@ -50,7 +50,7 @@ static const ao_info_t info = LIBAO_EXTERN(jack) //! maximum number of channels supported, avoids lots of mallocs -#define MAX_CHANS 8 +#define MAX_CHANS MP_NUM_CHANNELS static jack_port_t *ports[MAX_CHANS]; static int num_ports; ///< Number of used ports == number of channels static jack_client_t *client; @@ -223,11 +223,12 @@ static int init(int rate, const struct mp_chmap *channels, int format, int flags print_help(); return 0; } - if (ao_data.channels.num > MAX_CHANS) { - mp_msg(MSGT_AO, MSGL_FATAL, "[JACK] Invalid number of channels: %i\n", - ao_data.channels.num); + + struct mp_chmap_sel sel = {0}; + mp_chmap_sel_add_waveext(&sel); + if (!ao_chmap_sel_adjust(&ao_data, &sel, &ao_data.channels)) goto err_out; - } + if (!client_name) { client_name = malloc(40); sprintf(client_name, "mpv [%d]", getpid()); @@ -283,8 +284,9 @@ static int init(int rate, const struct mp_chmap *channels, int format, int flags / (float)rate; callback_interval = 0; - mp_chmap_from_channels(&ao_data.channels, num_ports); - mp_chmap_reorder_to_alsa(&ao_data.channels); // what order does hack use? + if (!ao_chmap_sel_get_def(&ao_data, &sel, &ao_data.channels, num_ports)) + goto err_out; + ao_data.samplerate = rate; ao_data.format = AF_FORMAT_FLOAT_NE; ao_data.bps = ao_data.channels.num * rate * sizeof(float); -- cgit v1.2.3