From e54ab16d1a0305938f331f33e843a152f237fb55 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 7 Jun 2013 15:58:28 +0200 Subject: ao_jack: align data sizes on audio frame size Fixes crashes when playing with certain numbers of channels. The core assumes AOs accept data aligned on channels * samplesize, and ao_jack's play() function broke that assumption: mpv: core/mplayer.c:2348: fill_audio_out_buffers: Assertion `played % unitsize == 0' failed. Fix by aligning the buffer and chunk sizes as needed. --- audio/out/ao_jack.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'audio') diff --git a/audio/out/ao_jack.c b/audio/out/ao_jack.c index d6affed85d..4a38a532e0 100644 --- a/audio/out/ao_jack.c +++ b/audio/out/ao_jack.c @@ -56,7 +56,6 @@ static volatile float callback_time = 0; #define CHUNK_SIZE (16 * 1024) //! number of "virtual" chunks the buffer consists of #define NUM_CHUNKS 8 -#define BUFFSIZE (NUM_CHUNKS * CHUNK_SIZE) //! buffer for audio data static AVFifoBuffer *buffer; @@ -159,7 +158,7 @@ static int outputaudio(jack_nframes_t nframes, void *arg) int i; for (i = 0; i < num_ports; i++) bufs[i] = jack_port_get_buffer(ports[i], nframes); - if (paused || underrun) + if (paused || underrun || !buffer) silence(bufs, nframes, num_ports); else if (read_buffer(bufs, nframes, num_ports) < nframes) underrun = 1; @@ -239,7 +238,6 @@ static int init(struct ao *ao, char *params) mp_msg(MSGT_AO, MSGL_FATAL, "[JACK] cannot open server\n"); goto err_out; } - buffer = av_fifo_alloc(BUFFSIZE); jack_set_process_callback(client, outputaudio, ao); // list matching ports if connections should be made @@ -296,8 +294,10 @@ static int init(struct ao *ao, char *params) ao->format = AF_FORMAT_FLOAT_NE; ao->bps = ao->channels.num * ao->samplerate * sizeof(float); - ao->buffersize = CHUNK_SIZE * NUM_CHUNKS; - ao->outburst = CHUNK_SIZE; + int unitsize = ao->channels.num * sizeof(float); + ao->outburst = CHUNK_SIZE / unitsize * unitsize; + ao->buffersize = NUM_CHUNKS * ao->outburst; + buffer = av_fifo_alloc(ao->buffersize); free(matching_ports); free(port_name); free(client_name); -- cgit v1.2.3