diff options
author | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2006-06-25 09:02:47 +0000 |
---|---|---|
committer | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2006-06-25 09:02:47 +0000 |
commit | 6e809b6f5218a9e1bddfe2b14018c0c11ac35c8d (patch) | |
tree | 6dcad5a9a595e5ceb64edffe82042dfd3e4bb90d /libao2 | |
parent | 6811f8c042a43cf1468e76e739b1e331c298c82d (diff) |
respect AOPLAY_FINAL_CHUNK and do not discard samples read from buffer
on underrun.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@18812 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libao2')
-rw-r--r-- | libao2/ao_jack.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/libao2/ao_jack.c b/libao2/ao_jack.c index 87608ff452..ce7395e6e3 100644 --- a/libao2/ao_jack.c +++ b/libao2/ao_jack.c @@ -130,10 +130,13 @@ static int write_buffer(unsigned char* data, int len) { * * Assumes the data in the buffer is of type float, the number of bytes * read is res * num_bufs * sizeof(float), where res is the return value. + * If there is not enough data in the buffer remaining parts will be filled + * with silence. */ static int read_buffer(float **bufs, int cnt, int num_bufs) { int buffered = buf_used(); int i, j; + int orig_cnt = cnt; if (cnt * sizeof(float) * num_bufs > buffered) cnt = buffered / sizeof(float) / num_bufs; for (i = 0; i < cnt; i++) { @@ -142,6 +145,9 @@ static int read_buffer(float **bufs, int cnt, int num_bufs) { read_pos = (read_pos + sizeof(float)) % BUFFSIZE; } } + for (i = cnt; i < orig_cnt; i++) + for (j = 0; j < num_bufs; j++) + bufs[j][i] = 0; return cnt; } @@ -177,11 +183,11 @@ 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 (read_buffer(bufs, nframes, num_ports) < nframes) - underrun = 1; if (paused || underrun) silence(bufs, nframes, num_ports); + else + if (read_buffer(bufs, nframes, num_ports) < nframes) + underrun = 1; if (estimate) { float now = (float)GetTimer() / 1000000.0; float diff = callback_time + callback_interval - now; @@ -349,6 +355,7 @@ static int get_space() { * \brief write data into buffer and reset underrun flag */ static int play(void *data, int len, int flags) { + if (!(flags & AOPLAY_FINAL_CHUNK)) len -= len % ao_data.outburst; underrun = 0; return write_buffer(data, len); |