diff options
author | mosu <mosu@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2003-11-16 10:41:25 +0000 |
---|---|---|
committer | mosu <mosu@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2003-11-16 10:41:25 +0000 |
commit | f0ae194540db747c05d47abde058f6edde8f3dfd (patch) | |
tree | 58434fbce331949d0ff91d7b38ac64c0f38cf4af | |
parent | 404489039356196146992b3f309105fb9ab1dca0 (diff) | |
download | mpv-f0ae194540db747c05d47abde058f6edde8f3dfd.tar.bz2 mpv-f0ae194540db747c05d47abde058f6edde8f3dfd.tar.xz |
Made the FLAC decoder be less greedy resulting in much better A/V sync handling.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@11477 b3059339-0415-0410-9bf9-f77b7e298cf2
-rw-r--r-- | libmpcodecs/ad_flac.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/libmpcodecs/ad_flac.c b/libmpcodecs/ad_flac.c index 5f39c8dcf7..dc1e036720 100644 --- a/libmpcodecs/ad_flac.c +++ b/libmpcodecs/ad_flac.c @@ -90,8 +90,14 @@ typedef struct flac_struct_st FLAC__StreamDecoderReadStatus flac_read_callback (const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data) { - int b = demux_read_data(((flac_struct_t*)client_data)->sh->ds, buffer, *bytes); - mp_msg(MSGT_DECAUDIO, MSGL_DBG2, "\nread %d bytes\n", b); + /* Don't be greedy. Try to read as few packets as possible. *bytes is often + > 60kb big which is more than one second of data. Reading it all at + once sucks in all packets available making d_audio->pts jump to the + pts of the last packet read which is not what we want. We're decoging + only one FLAC block anyway, so let's just read as few bytes as + neccessary. */ + int b = demux_read_data(((flac_struct_t*)client_data)->sh->ds, buffer, *bytes > 500 ? 500 : *bytes); + mp_msg(MSGT_DECAUDIO, MSGL_DBG2, "\nFLAC READ CB read %d bytes\n", b); *bytes = b; if (b <= 0) return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; |