[Scummvm-cvs-logs] CVS: scummvm/sound vorbis.cpp,1.12,1.13

Torbj?rn Andersson eriktorbjorn at users.sourceforge.net
Sun Mar 21 09:10:16 CET 2004


Update of /cvsroot/scummvm/scummvm/sound
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4000

Modified Files:
	vorbis.cpp 
Log Message:
When I played an Ogg Vorbis-encoded FotAQ I noticed that whenever a sound
effect happened during a line of speech there was a chance - not a
certainty - that the speech would get cut off prematurely.

As far as I can tell, this is because the Vorbis decoder isn't the only one
who's accessing the same file. Now the Vorbis decoder will explicitly seek
to the position where it expects the file to be at before reading from it.
I hope this is the correct fix. It does fix the problem for me, at least.

I don't know if any of the other decoders needs a similar patch. I couldn't
reproduce the problem with my MP3-encoded FotAQ, but there are other
possible explanations for that, e.g. the bug gets harder to trigger the
more sound data that is decoded in each pass.


Index: vorbis.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sound/vorbis.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- vorbis.cpp	22 Feb 2004 14:11:11 -0000	1.12
+++ vorbis.cpp	21 Mar 2004 16:59:10 -0000	1.13
@@ -71,6 +71,9 @@
 		nmemb = 0;
 	else if (nmemb > f->len - f->curr_pos)
 		nmemb = f->len - f->curr_pos;
+	// There is no guarantee that the Vorbis stream is alone in accessing
+	// the file, so make sure the current position is what we think it is.
+	f->file->seek(f->start + f->curr_pos);
 	result = f->file->read(ptr, nmemb);
 	if (result == -1) {
 		f->curr_pos = f->file->pos() - f->start;





More information about the Scummvm-git-logs mailing list