[TRY #2] avifil32: use chunksize specified by the chunk itself, avoids a noticable ticking sound heard when reading past the chunk boundry

Julius Schwartzenberg julius.schwartzenberg at gmail.com
Wed Jan 20 15:57:27 CST 2010


It solves a ticking sound which was heard because the original code
would just play right through the chunk and also try to play back parts
of the next chunk header. This happened when the buffer size was larger
then than the data that was left in the current chunk. This ticking was
also heard in Civilization II (with the other patches applied). This
patch solves it by using the chunk size specified in the chunk's own
header and not playing past that size.
---
 dlls/avifil32/avifile.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/dlls/avifil32/avifile.c b/dlls/avifil32/avifile.c
index e627196..702ba1c 100644
--- a/dlls/avifil32/avifile.c
+++ b/dlls/avifil32/avifile.c
@@ -1103,6 +1103,7 @@ static HRESULT WINAPI IAVIStream_fnRead(IAVIStream *iface, LONG start,
     samples *= This->sInfo.dwSampleSize;
 
     while (samples > 0 && buffersize > 0) {
+      LONG blocksize;
       if (block != This->dwCurrentFrame) {
 	hr = AVIFILE_ReadBlock(This, block, NULL, 0);
 	if (FAILED(hr))
@@ -1110,7 +1111,9 @@ static HRESULT WINAPI IAVIStream_fnRead(IAVIStream *iface, LONG start,
       }
 
       size = min((DWORD)samples, (DWORD)buffersize);
-      size = min(size, This->cbBuffer - offset);
+      blocksize = This->lpBuffer[1];
+      TRACE("blocksize = %u\n",blocksize);
+      size = min(size, blocksize - offset);
       memcpy(buffer, ((BYTE*)&This->lpBuffer[2]) + offset, size);
 
       block++;
-- 
1.6.3.3




More information about the wine-patches mailing list