[TRY #2] avifil32: Overwrite dwRate in the audiostream with the nBlockAlign from the wave header

Julius Schwartzenberg julius.schwartzenberg at gmail.com
Mon Jan 11 17:30:54 CST 2010


---
 dlls/avifil32/avifile.c   |    9 ++++++++-
 dlls/avifil32/tests/api.c |    4 ++--
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/dlls/avifil32/avifile.c b/dlls/avifil32/avifile.c
index 57ebb11..aa1df3b 100644
--- a/dlls/avifil32/avifile.c
+++ b/dlls/avifil32/avifile.c
@@ -1819,7 +1819,14 @@ static HRESULT AVIFILE_LoadFile(IAVIFileImpl *This)
 	  if (FAILED(hr))
 	    return hr;
 	};
-
+	if (pStream->lpFormat != NULL && pStream->sInfo.fccType == streamtypeAUDIO)
+	{
+	  WAVEFORMATEX *wfx = pStream->lpFormat;          /* wfx->nBlockAlign = wfx->nChannels * wfx->wBitsPerSample / 8; could be added */
+	  pStream->sInfo.dwSampleSize = wfx->nBlockAlign; /* to deal with corrupt wfx->nBlockAlign but Windows doesn't do this */
+	  TRACE("Block size reset to %u, chan=%u bpp=%u\n", wfx->nBlockAlign, wfx->nChannels, wfx->wBitsPerSample);
+	  pStream->sInfo.dwScale = 1;
+	  pStream->sInfo.dwRate = wfx->nSamplesPerSec;
+	}
 	if (mmioAscend(This->hmmio, &ck, 0) != S_OK)
 	  return AVIERR_FILEREAD;
       }
diff --git a/dlls/avifil32/tests/api.c b/dlls/avifil32/tests/api.c
index 28bae04..a68ce9c 100644
--- a/dlls/avifil32/tests/api.c
+++ b/dlls/avifil32/tests/api.c
@@ -404,7 +404,7 @@ static void test_ash1_corruption(void)
 
     /* The result will still be 2, because the value is dynamically replaced with the nBlockAlign
        value from the stream format header. The next test will prove this */
-    todo_wine{ ok(asi1.dwSampleSize == 2, "got %u (expected 2)\n", asi1.dwSampleSize); }
+    ok(asi1.dwSampleSize == 2, "got %u (expected 2)\n", asi1.dwSampleSize);
 
     AVIStreamRelease(pStream1);
     AVIFileRelease(pFile);
@@ -438,7 +438,7 @@ static void test_ash1_corruption2(void)
     ok(AVIStreamInfo(pStream1, &asi1, sizeof(AVISTREAMINFO)) == 0, "Unable to read stream info\n");
 
     /* The result will also be the corrupt value, as explained above. */
-    todo_wine{ ok(asi1.dwSampleSize == 0xdead, "got 0x%x (expected 0xdead)\n", asi1.dwSampleSize); }
+    ok(asi1.dwSampleSize == 0xdead, "got 0x%x (expected 0xdead)\n", asi1.dwSampleSize);
 
     AVIStreamRelease(pStream1);
     AVIFileRelease(pFile);
-- 
1.6.3.3




More information about the wine-patches mailing list