summaryrefslogtreecommitdiffstats
path: root/audio/out
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-06-07 15:58:28 +0200
committerwm4 <wm4@nowhere>2013-06-07 15:58:28 +0200
commite54ab16d1a0305938f331f33e843a152f237fb55 (patch)
tree7f73dc3c7de8466588c86fb332b16f805a9d0c6c /audio/out
parent4e6098ed498c0d4b736f4e0dd9eb5b7e3a08c5b4 (diff)
downloadmpv-e54ab16d1a0305938f331f33e843a152f237fb55.tar.bz2
mpv-e54ab16d1a0305938f331f33e843a152f237fb55.tar.xz
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.
Diffstat (limited to 'audio/out')
-rw-r--r--audio/out/ao_jack.c10
1 files changed, 5 insertions, 5 deletions
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);