[Mplayer-cvslog] CVS: main/libmpcodecs ad_flac.c,1.1,1.2

Moritz Bunkus CVS mosu at mplayerhq.hu
Sun Nov 16 11:41:51 CET 2003


Update of /cvsroot/mplayer/main/libmpcodecs
In directory mail:/var/tmp.root/cvs-serv1574

Modified Files:
	ad_flac.c 
Log Message:
Made the FLAC decoder be less greedy resulting in much better A/V sync handling.

Index: ad_flac.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/ad_flac.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ad_flac.c	4 Oct 2003 22:00:24 -0000	1.1
+++ ad_flac.c	16 Nov 2003 10:41:25 -0000	1.2
@@ -90,8 +90,14 @@
 
 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;



More information about the MPlayer-cvslog mailing list