From: "刘昌辉" Subject: quartz: waveparser support wav file generated by ffmpeg Message-Id: Date: Tue, 4 Aug 2015 14:57:40 +0800 ------------------ Regards, Changhui Liu






------------------
Regards,
Changhui Liu
 
From 760e56c731819967a14139c355f03d51109d0bc9 Mon Sep 17 00:00:00 2001 From: Changhui Liu Date: Tue, 4 Aug 2015 14:23:27 +0800 Subject: quartz: waveparser support wav file generated by ffmpeg To: wine-patches Reply-To: wine-devel --- dlls/quartz/tests/filtergraph.c | 31 +++++++++++++++++++++++++++++++ dlls/quartz/waveparser.c | 20 +++++++++++++++++--- 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/dlls/quartz/tests/filtergraph.c b/dlls/quartz/tests/filtergraph.c index 2f56151..c34fac4 100644 --- a/dlls/quartz/tests/filtergraph.c +++ b/dlls/quartz/tests/filtergraph.c @@ -41,6 +41,15 @@ typedef struct TestFilterImpl static const WCHAR avifile[] = {'t','e','s','t','.','a','v','i',0}; static const WCHAR mpegfile[] = {'t','e','s','t','.','m','p','g',0}; +static const WCHAR wavfile[] = {'t','e','s','t','.','w','a','v',0}; +static BYTE g_wav_data[] = { +0x52,0x49,0x46,0x46,0xd6,0xd6,0x14,0x00,0x57,0x41,0x56,0x45,0x66,0x6d,0x74,0x20, +0x10,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x22,0x56,0x00,0x00,0x44,0xac,0x00,0x00, +0x02,0x00,0x10,0x00,0x4c,0x49,0x53,0x54,0x1a,0x00,0x00,0x00,0x49,0x4e,0x46,0x4f, +0x49,0x53,0x46,0x54,0x0e,0x00,0x00,0x00,0x4c,0x61,0x76,0x66,0x35,0x36,0x2e,0x32, +0x35,0x2e,0x31,0x30,0x31,0x00,0x64,0x61,0x74,0x61,0x12,0x00,0x00,0x00,0x6a,0x00, +0x32,0x00,0x20,0x00,0xb6,0x00,0x4b,0x01,0x72,0x01,0x22,0x01,0x93,0x00,0x39,0x00, +}; static IGraphBuilder *pgraph; @@ -156,6 +165,9 @@ static void test_render_run(const WCHAR *file) ok(hr==S_OK, "RenderFile returned: %x\n", hr); rungraph(); } + else { + trace("file not found!\n"); + } releasefiltergraph(); } @@ -1874,6 +1886,22 @@ static void test_render_filter_priority(void) ok(hr == S_OK, "CoRevokeClassObject failed with %08x\n", hr); } +void make_test_wav(const WCHAR* file) +{ + HANDLE h = CreateFileW(file, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (INVALID_HANDLE_VALUE != h) + { + DWORD bytes = 0; + WriteFile(h, g_wav_data, sizeof(g_wav_data), &bytes, NULL); + CloseHandle(h); + } +} + +void delete_test_wav(const WCHAR* file) +{ + DeleteFileW(file); +} + START_TEST(filtergraph) { HRESULT hr; @@ -1887,6 +1915,9 @@ START_TEST(filtergraph) IGraphBuilder_Release(pgraph); test_render_run(avifile); test_render_run(mpegfile); + make_test_wav(wavfile); + test_render_run(wavfile); + delete_test_wav(wavfile); test_graph_builder(); test_graph_builder_addfilter(); test_mediacontrol(); diff --git a/dlls/quartz/waveparser.c b/dlls/quartz/waveparser.c index 2ceb0fd..3ca0f21 100644 --- a/dlls/quartz/waveparser.c +++ b/dlls/quartz/waveparser.c @@ -302,10 +302,24 @@ static HRESULT WAVEParser_InputPin_PreConnect(IPin * iface, IPin * pConnectPin, pos += sizeof(chunk) + chunk.cb; hr = IAsyncReader_SyncRead(This->pReader, pos, sizeof(chunk), (BYTE *)&chunk); } - if (chunk.fcc != mmioFOURCC('d','a','t','a')) + + /*ffmpeg generate wav file has a LIST chunk like this: +00000000 52 49 46 46 d6 d6 14 00 57 41 56 45 66 6d 74 20 |RIFF....WAVEfmt | +00000010 10 00 00 00 01 00 01 00 22 56 00 00 44 ac 00 00 |........"V..D...| +00000020 02 00 10 00 4c 49 53 54 1a 00 00 00 49 4e 46 4f |....LIST....INFO| +00000030 49 53 46 54 0e 00 00 00 4c 61 76 66 35 36 2e 32 |ISFT....Lavf56.2| +00000040 35 2e 31 30 31 00 64 61 74 61 90 d6 14 00 6a 00 |5.101.data....j.| +00000050 32 00 20 00 b6 00 4b 01 72 01 22 01 93 00 39 00 |2. ...K.r."...9.| + */ + while (chunk.fcc != mmioFOURCC('d','a','t','a')) { - ERR("Expected 'data' chunk, but got %.04s\n", (LPSTR)&chunk.fcc); - return E_FAIL; + pos += sizeof(chunk) + chunk.cb; + hr = IAsyncReader_SyncRead(This->pReader, pos, sizeof(chunk), (BYTE *)&chunk); + if (FAILED(hr)) + { + ERR("Expected 'data' chunk, but not found (0x%08x)\n", hr); + return E_FAIL; + } } if (hr == S_OK) -- 1.9.1