From 637f9643ad65925452e61cca84b1d7e24bdfb572 Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Fri, 31 May 2013 16:38:30 +0000 Subject: [PATCH] [AVIFIL32] * Sync with Wine 1.5.26. svn path=/trunk/; revision=59125 --- reactos/dll/win32/avifil32/CMakeLists.txt | 13 +- reactos/dll/win32/avifil32/acmstream.c | 2 +- reactos/dll/win32/avifil32/api.c | 2 +- reactos/dll/win32/avifil32/avifil32.idl | 54 +++ reactos/dll/win32/avifil32/avifil32_idl.rgs | 29 ++ reactos/dll/win32/avifil32/avifile.c | 383 +++++++++---------- reactos/dll/win32/avifil32/avifile.rgs | 25 +- reactos/dll/win32/avifil32/avifile_private.h | 2 +- reactos/dll/win32/avifil32/extrachunk.c | 4 +- reactos/dll/win32/avifil32/extrachunk.h | 2 +- reactos/dll/win32/avifil32/factory.c | 13 +- reactos/dll/win32/avifil32/getframe.c | 5 +- reactos/dll/win32/avifil32/rsrc.rc | 2 + reactos/dll/win32/avifil32/tmpfile.c | 2 +- reactos/media/doc/README.WINE | 2 +- 15 files changed, 295 insertions(+), 245 deletions(-) create mode 100644 reactos/dll/win32/avifil32/avifil32.idl create mode 100644 reactos/dll/win32/avifil32/avifil32_idl.rgs diff --git a/reactos/dll/win32/avifil32/CMakeLists.txt b/reactos/dll/win32/avifil32/CMakeLists.txt index e316d80daec..c85f4ac196c 100644 --- a/reactos/dll/win32/avifil32/CMakeLists.txt +++ b/reactos/dll/win32/avifil32/CMakeLists.txt @@ -22,16 +22,5 @@ add_library(avifil32 SHARED set_module_type(avifil32 win32dll) target_link_libraries(avifil32 uuid wine) - -add_importlibs(avifil32 - msvcrt - msacm32 - msvfw32 - winmm - ole32 - user32 - advapi32 - kernel32 - ntdll) - +add_importlibs(avifil32 msacm32 msvfw32 winmm ole32 user32 advapi32 msvcrt kernel32 ntdll) add_cd_file(TARGET avifil32 DESTINATION reactos/system32 FOR all) diff --git a/reactos/dll/win32/avifil32/acmstream.c b/reactos/dll/win32/avifil32/acmstream.c index 7f2db0487af..260ed5a47e1 100644 --- a/reactos/dll/win32/avifil32/acmstream.c +++ b/reactos/dll/win32/avifil32/acmstream.c @@ -228,7 +228,7 @@ static HRESULT WINAPI ACMStream_fnCreate(IAVIStream *iface, LPARAM lParam1, /* check for swapped parameters */ if ((LPVOID)lParam1 != NULL && ((LPAVICOMPRESSOPTIONS)lParam1)->fccType == streamtypeAUDIO) { - register LPARAM tmp = lParam1; + LPARAM tmp = lParam1; lParam1 = lParam2; lParam2 = tmp; diff --git a/reactos/dll/win32/avifil32/api.c b/reactos/dll/win32/avifil32/api.c index 39d67b3688a..6fdf0957fcd 100644 --- a/reactos/dll/win32/avifil32/api.c +++ b/reactos/dll/win32/avifil32/api.c @@ -1248,7 +1248,7 @@ static BOOL AVISaveOptionsFmtChoose(HWND hWnd) pOptions->dwFlags |= AVICOMPRESSF_VALID; HeapFree(GetProcessHeap(), 0, afmtc.pwfxEnum); - return (ret == S_OK ? TRUE : FALSE); + return ret == S_OK; } else { ERR(": unknown streamtype 0x%08X\n", sInfo.fccType); return FALSE; diff --git a/reactos/dll/win32/avifil32/avifil32.idl b/reactos/dll/win32/avifil32/avifil32.idl new file mode 100644 index 00000000000..b4c563f4d71 --- /dev/null +++ b/reactos/dll/win32/avifil32/avifil32.idl @@ -0,0 +1,54 @@ +/* + * COM Classes for avifil32 + * + * Copyright 2010 Alexandre Julliard + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +[ + helpstring("Microsoft AVI Files"), + threading(apartment), + uuid(00020000-0000-0000-C000-000000000046) +] +coclass AVIFile { interface IAVIFile; } + +[ + helpstring("AVI Compressed Stream"), + threading(apartment), + uuid(00020001-0000-0000-c000-000000000046) +] +coclass ICMStream { interface IAVIStream; } + +[ + helpstring("Microsoft Wave File"), + threading(apartment), + uuid(00020003-0000-0000-c000-000000000046) +] +coclass WAVFile { interface IAVIFile; } + +[ + helpstring("IAVIStream & IAVIFile Proxy"), + threading(apartment), + uuid(0002000d-0000-0000-c000-000000000046) +] +coclass AVIProxy { } + +[ + helpstring("ACM Compressed Audio Stream"), + threading(apartment), + uuid(0002000f-0000-0000-c000-000000000046) +] +coclass ACMStream { interface IAVIStream; } diff --git a/reactos/dll/win32/avifil32/avifil32_idl.rgs b/reactos/dll/win32/avifil32/avifil32_idl.rgs new file mode 100644 index 00000000000..07c0706d281 --- /dev/null +++ b/reactos/dll/win32/avifil32/avifil32_idl.rgs @@ -0,0 +1,29 @@ +HKCR +{ + NoRemove Interface + { + } + NoRemove CLSID + { + '{00020000-0000-0000-C000-000000000046}' = s 'Microsoft AVI Files' + { + InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Apartment' } + } + '{00020001-0000-0000-C000-000000000046}' = s 'AVI Compressed Stream' + { + InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Apartment' } + } + '{00020003-0000-0000-C000-000000000046}' = s 'Microsoft Wave File' + { + InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Apartment' } + } + '{0002000D-0000-0000-C000-000000000046}' = s 'IAVIStream & IAVIFile Proxy' + { + InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Apartment' } + } + '{0002000F-0000-0000-C000-000000000046}' = s 'ACM Compressed Audio Stream' + { + InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Apartment' } + } + } +} diff --git a/reactos/dll/win32/avifil32/avifile.c b/reactos/dll/win32/avifil32/avifile.c index e5fd3b26d9d..62de035ae2c 100644 --- a/reactos/dll/win32/avifil32/avifile.c +++ b/reactos/dll/win32/avifil32/avifile.c @@ -34,6 +34,7 @@ #define _INC_WINDOWS #define COM_NO_WINDOWS_H +#define COBJMACROS #include #include @@ -58,54 +59,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(avifile); #define IDX_PER_BLOCK 2730 #endif -/***********************************************************************/ - -static HRESULT WINAPI IAVIFile_fnQueryInterface(IAVIFile* iface,REFIID refiid,LPVOID *obj); -static ULONG WINAPI IAVIFile_fnAddRef(IAVIFile* iface); -static ULONG WINAPI IAVIFile_fnRelease(IAVIFile* iface); -static HRESULT WINAPI IAVIFile_fnInfo(IAVIFile*iface,AVIFILEINFOW*afi,LONG size); -static HRESULT WINAPI IAVIFile_fnGetStream(IAVIFile*iface,PAVISTREAM*avis,DWORD fccType,LONG lParam); -static HRESULT WINAPI IAVIFile_fnCreateStream(IAVIFile*iface,PAVISTREAM*avis,AVISTREAMINFOW*asi); -static HRESULT WINAPI IAVIFile_fnWriteData(IAVIFile*iface,DWORD ckid,LPVOID lpData,LONG size); -static HRESULT WINAPI IAVIFile_fnReadData(IAVIFile*iface,DWORD ckid,LPVOID lpData,LONG *size); -static HRESULT WINAPI IAVIFile_fnEndRecord(IAVIFile*iface); -static HRESULT WINAPI IAVIFile_fnDeleteStream(IAVIFile*iface,DWORD fccType,LONG lParam); - -static const struct IAVIFileVtbl iavift = { - IAVIFile_fnQueryInterface, - IAVIFile_fnAddRef, - IAVIFile_fnRelease, - IAVIFile_fnInfo, - IAVIFile_fnGetStream, - IAVIFile_fnCreateStream, - IAVIFile_fnWriteData, - IAVIFile_fnReadData, - IAVIFile_fnEndRecord, - IAVIFile_fnDeleteStream -}; - -static HRESULT WINAPI IPersistFile_fnQueryInterface(IPersistFile*iface,REFIID refiid,LPVOID*obj); -static ULONG WINAPI IPersistFile_fnAddRef(IPersistFile*iface); -static ULONG WINAPI IPersistFile_fnRelease(IPersistFile*iface); -static HRESULT WINAPI IPersistFile_fnGetClassID(IPersistFile*iface,CLSID*pClassID); -static HRESULT WINAPI IPersistFile_fnIsDirty(IPersistFile*iface); -static HRESULT WINAPI IPersistFile_fnLoad(IPersistFile*iface,LPCOLESTR pszFileName,DWORD dwMode); -static HRESULT WINAPI IPersistFile_fnSave(IPersistFile*iface,LPCOLESTR pszFileName,BOOL fRemember); -static HRESULT WINAPI IPersistFile_fnSaveCompleted(IPersistFile*iface,LPCOLESTR pszFileName); -static HRESULT WINAPI IPersistFile_fnGetCurFile(IPersistFile*iface,LPOLESTR*ppszFileName); - -static const struct IPersistFileVtbl ipersistft = { - IPersistFile_fnQueryInterface, - IPersistFile_fnAddRef, - IPersistFile_fnRelease, - IPersistFile_fnGetClassID, - IPersistFile_fnIsDirty, - IPersistFile_fnLoad, - IPersistFile_fnSave, - IPersistFile_fnSaveCompleted, - IPersistFile_fnGetCurFile -}; - static HRESULT WINAPI IAVIStream_fnQueryInterface(IAVIStream*iface,REFIID refiid,LPVOID *obj); static ULONG WINAPI IAVIStream_fnAddRef(IAVIStream*iface); static ULONG WINAPI IAVIStream_fnRelease(IAVIStream* iface); @@ -140,14 +93,6 @@ static const struct IAVIStreamVtbl iavist = { typedef struct _IAVIFileImpl IAVIFileImpl; -typedef struct _IPersistFileImpl { - /* IUnknown stuff */ - const IPersistFileVtbl *lpVtbl; - - /* IPersistFile stuff */ - IAVIFileImpl *paf; -} IPersistFileImpl; - typedef struct _IAVIStreamImpl { /* IUnknown stuff */ const IAVIStreamVtbl *lpVtbl; @@ -178,12 +123,11 @@ typedef struct _IAVIStreamImpl { } IAVIStreamImpl; struct _IAVIFileImpl { - /* IUnknown stuff */ - const IAVIFileVtbl *lpVtbl; - LONG ref; - - /* IAVIFile stuff... */ - IPersistFileImpl iPersistFile; + IUnknown IUnknown_inner; + IAVIFile IAVIFile_iface; + IPersistFile IPersistFile_iface; + IUnknown *outer_unk; + LONG ref; AVIFILEINFOW fInfo; IAVIStreamImpl *ppStreams[MAX_AVISTREAMS]; @@ -207,6 +151,21 @@ struct _IAVIFileImpl { BOOL fDirty; }; +static inline IAVIFileImpl *impl_from_IUnknown(IUnknown *iface) +{ + return CONTAINING_RECORD(iface, IAVIFileImpl, IUnknown_inner); +} + +static inline IAVIFileImpl *impl_from_IAVIFile(IAVIFile *iface) +{ + return CONTAINING_RECORD(iface, IAVIFileImpl, IAVIFile_iface); +} + +static inline IAVIFileImpl *impl_from_IPersistFile(IPersistFile *iface) +{ + return CONTAINING_RECORD(iface, IAVIFileImpl, IPersistFile_iface); +} + /***********************************************************************/ static HRESULT AVIFILE_AddFrame(IAVIStreamImpl *This, DWORD ckid, DWORD size, @@ -233,87 +192,64 @@ static HRESULT AVIFILE_WriteBlock(IAVIStreamImpl *This, DWORD block, FOURCC ckid, DWORD flags, LPCVOID buffer, LONG size); -HRESULT AVIFILE_CreateAVIFile(REFIID riid, LPVOID *ppv) +static HRESULT WINAPI IUnknown_fnQueryInterface(IUnknown *iface, REFIID riid, void **ppv) { - IAVIFileImpl *pfile; - HRESULT hr; + IAVIFileImpl *This = impl_from_IUnknown(iface); - assert(riid != NULL && ppv != NULL); + TRACE("(%p,%s,%p)\n", This, debugstr_guid(riid), ppv); + if (!ppv) { + WARN("invalid parameter\n"); + return E_INVALIDARG; + } *ppv = NULL; - pfile = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IAVIFileImpl)); - if (pfile == NULL) - return AVIERR_MEMORY; - - pfile->lpVtbl = &iavift; - pfile->ref = 0; - pfile->iPersistFile.lpVtbl = &ipersistft; - pfile->iPersistFile.paf = pfile; - - hr = IAVIFile_QueryInterface((IAVIFile*)pfile, riid, ppv); - if (FAILED(hr)) - HeapFree(GetProcessHeap(), 0, pfile); - - return hr; -} - -static HRESULT WINAPI IAVIFile_fnQueryInterface(IAVIFile *iface, REFIID refiid, - LPVOID *obj) -{ - IAVIFileImpl *This = (IAVIFileImpl *)iface; - - TRACE("(%p,%s,%p)\n", This, debugstr_guid(refiid), obj); - - if (IsEqualGUID(&IID_IUnknown, refiid) || - IsEqualGUID(&IID_IAVIFile, refiid)) { - *obj = iface; - IAVIFile_AddRef(iface); - - return S_OK; - } else if (IsEqualGUID(&IID_IPersistFile, refiid)) { - *obj = &This->iPersistFile; - IAVIFile_AddRef(iface); - - return S_OK; + if (IsEqualIID(riid, &IID_IUnknown)) + *ppv = &This->IUnknown_inner; + else if (IsEqualIID(riid, &IID_IAVIFile)) + *ppv = &This->IAVIFile_iface; + else if (IsEqualGUID(riid, &IID_IPersistFile)) + *ppv = &This->IPersistFile_iface; + else { + WARN("unknown IID %s\n", debugstr_guid(riid)); + return E_NOINTERFACE; } - return OLE_E_ENUM_NOMORE; + /* Violation of the COM aggregation ref counting rule */ + IUnknown_AddRef(&This->IUnknown_inner); + return S_OK; } -static ULONG WINAPI IAVIFile_fnAddRef(IAVIFile *iface) +static ULONG WINAPI IUnknown_fnAddRef(IUnknown *iface) { - IAVIFileImpl *This = (IAVIFileImpl *)iface; + IAVIFileImpl *This = impl_from_IUnknown(iface); ULONG ref = InterlockedIncrement(&This->ref); - TRACE("(%p) -> %d\n", iface, ref); + TRACE("(%p) ref=%d\n", This, ref); return ref; } -static ULONG WINAPI IAVIFile_fnRelease(IAVIFile *iface) +static ULONG WINAPI IUnknown_fnRelease(IUnknown *iface) { - IAVIFileImpl *This = (IAVIFileImpl *)iface; - UINT i; + IAVIFileImpl *This = impl_from_IUnknown(iface); ULONG ref = InterlockedDecrement(&This->ref); + UINT i; - TRACE("(%p) -> %d\n", iface, ref); + TRACE("(%p) ref=%d\n", This, ref); if (!ref) { - if (This->fDirty) { - /* need to write headers to file */ + if (This->fDirty) AVIFILE_SaveFile(This); - } for (i = 0; i < This->fInfo.dwStreams; i++) { if (This->ppStreams[i] != NULL) { - if (This->ppStreams[i]->ref != 0) { + if (This->ppStreams[i]->ref != 0) ERR(": someone has still %u reference to stream %u (%p)!\n", - This->ppStreams[i]->ref, i, This->ppStreams[i]); - } - AVIFILE_DestructAVIStream(This->ppStreams[i]); - HeapFree(GetProcessHeap(), 0, This->ppStreams[i]); - This->ppStreams[i] = NULL; + This->ppStreams[i]->ref, i, This->ppStreams[i]); + AVIFILE_DestructAVIStream(This->ppStreams[i]); + HeapFree(GetProcessHeap(), 0, This->ppStreams[i]); + This->ppStreams[i] = NULL; } } @@ -342,10 +278,37 @@ static ULONG WINAPI IAVIFile_fnRelease(IAVIFile *iface) return ref; } -static HRESULT WINAPI IAVIFile_fnInfo(IAVIFile *iface, LPAVIFILEINFOW afi, - LONG size) +static const IUnknownVtbl unk_vtbl = { - IAVIFileImpl *This = (IAVIFileImpl *)iface; + IUnknown_fnQueryInterface, + IUnknown_fnAddRef, + IUnknown_fnRelease +}; + +static HRESULT WINAPI IAVIFile_fnQueryInterface(IAVIFile *iface, REFIID riid, void **ppv) +{ + IAVIFileImpl *This = impl_from_IAVIFile(iface); + + return IUnknown_QueryInterface(This->outer_unk, riid, ppv); +} + +static ULONG WINAPI IAVIFile_fnAddRef(IAVIFile *iface) +{ + IAVIFileImpl *This = impl_from_IAVIFile(iface); + + return IUnknown_AddRef(This->outer_unk); +} + +static ULONG WINAPI IAVIFile_fnRelease(IAVIFile *iface) +{ + IAVIFileImpl *This = impl_from_IAVIFile(iface); + + return IUnknown_Release(This->outer_unk); +} + +static HRESULT WINAPI IAVIFile_fnInfo(IAVIFile *iface, AVIFILEINFOW *afi, LONG size) +{ + IAVIFileImpl *This = impl_from_IAVIFile(iface); TRACE("(%p,%p,%d)\n",iface,afi,size); @@ -363,11 +326,10 @@ static HRESULT WINAPI IAVIFile_fnInfo(IAVIFile *iface, LPAVIFILEINFOW afi, return AVIERR_OK; } -static HRESULT WINAPI IAVIFile_fnGetStream(IAVIFile *iface, PAVISTREAM *avis, - DWORD fccType, LONG lParam) +static HRESULT WINAPI IAVIFile_fnGetStream(IAVIFile *iface, IAVIStream **avis, DWORD fccType, + LONG lParam) { - IAVIFileImpl *This = (IAVIFileImpl *)iface; - + IAVIFileImpl *This = impl_from_IAVIFile(iface); ULONG nStream; TRACE("(%p,%p,0x%08X,%d)\n", iface, avis, fccType, lParam); @@ -390,11 +352,10 @@ static HRESULT WINAPI IAVIFile_fnGetStream(IAVIFile *iface, PAVISTREAM *avis, return AVIERR_NODATA; } -static HRESULT WINAPI IAVIFile_fnCreateStream(IAVIFile *iface,PAVISTREAM *avis, - LPAVISTREAMINFOW asi) +static HRESULT WINAPI IAVIFile_fnCreateStream(IAVIFile *iface, IAVIStream **avis, + AVISTREAMINFOW *asi) { - IAVIFileImpl *This = (IAVIFileImpl *)iface; - + IAVIFileImpl *This = impl_from_IAVIFile(iface); DWORD n; TRACE("(%p,%p,%p)\n", iface, avis, asi); @@ -444,10 +405,9 @@ static HRESULT WINAPI IAVIFile_fnCreateStream(IAVIFile *iface,PAVISTREAM *avis, return AVIERR_OK; } -static HRESULT WINAPI IAVIFile_fnWriteData(IAVIFile *iface, DWORD ckid, - LPVOID lpData, LONG size) +static HRESULT WINAPI IAVIFile_fnWriteData(IAVIFile *iface, DWORD ckid, void *lpData, LONG size) { - IAVIFileImpl *This = (IAVIFileImpl *)iface; + IAVIFileImpl *This = impl_from_IAVIFile(iface); TRACE("(%p,0x%08X,%p,%d)\n", iface, ckid, lpData, size); @@ -466,10 +426,9 @@ static HRESULT WINAPI IAVIFile_fnWriteData(IAVIFile *iface, DWORD ckid, return WriteExtraChunk(&This->fileextra, ckid, lpData, size); } -static HRESULT WINAPI IAVIFile_fnReadData(IAVIFile *iface, DWORD ckid, - LPVOID lpData, LONG *size) +static HRESULT WINAPI IAVIFile_fnReadData(IAVIFile *iface, DWORD ckid, void *lpData, LONG *size) { - IAVIFileImpl *This = (IAVIFileImpl *)iface; + IAVIFileImpl *This = impl_from_IAVIFile(iface); TRACE("(%p,0x%08X,%p,%p)\n", iface, ckid, lpData, size); @@ -478,7 +437,7 @@ static HRESULT WINAPI IAVIFile_fnReadData(IAVIFile *iface, DWORD ckid, static HRESULT WINAPI IAVIFile_fnEndRecord(IAVIFile *iface) { - IAVIFileImpl *This = (IAVIFileImpl *)iface; + IAVIFileImpl *This = impl_from_IAVIFile(iface); TRACE("(%p)\n",iface); @@ -517,11 +476,9 @@ static HRESULT WINAPI IAVIFile_fnEndRecord(IAVIFile *iface) return AVIERR_OK; } -static HRESULT WINAPI IAVIFile_fnDeleteStream(IAVIFile *iface, DWORD fccType, - LONG lParam) +static HRESULT WINAPI IAVIFile_fnDeleteStream(IAVIFile *iface, DWORD fccType, LONG lParam) { - IAVIFileImpl *This = (IAVIFileImpl *)iface; - + IAVIFileImpl *This = impl_from_IAVIFile(iface); ULONG nStream; TRACE("(%p,0x%08X,%d)\n", iface, fccType, lParam); @@ -556,38 +513,42 @@ static HRESULT WINAPI IAVIFile_fnDeleteStream(IAVIFile *iface, DWORD fccType, return AVIERR_NODATA; } -/***********************************************************************/ +static const struct IAVIFileVtbl avif_vt = { + IAVIFile_fnQueryInterface, + IAVIFile_fnAddRef, + IAVIFile_fnRelease, + IAVIFile_fnInfo, + IAVIFile_fnGetStream, + IAVIFile_fnCreateStream, + IAVIFile_fnWriteData, + IAVIFile_fnReadData, + IAVIFile_fnEndRecord, + IAVIFile_fnDeleteStream +}; -static HRESULT WINAPI IPersistFile_fnQueryInterface(IPersistFile *iface, - REFIID refiid, LPVOID *obj) + +static HRESULT WINAPI IPersistFile_fnQueryInterface(IPersistFile *iface, REFIID riid, void **ppv) { - IPersistFileImpl *This = (IPersistFileImpl *)iface; + IAVIFileImpl *This = impl_from_IPersistFile(iface); - assert(This->paf != NULL); - - return IAVIFile_QueryInterface((PAVIFILE)This->paf, refiid, obj); + return IUnknown_QueryInterface(This->outer_unk, riid, ppv); } -static ULONG WINAPI IPersistFile_fnAddRef(IPersistFile *iface) +static ULONG WINAPI IPersistFile_fnAddRef(IPersistFile *iface) { - IPersistFileImpl *This = (IPersistFileImpl *)iface; + IAVIFileImpl *This = impl_from_IPersistFile(iface); - assert(This->paf != NULL); - - return IAVIFile_AddRef((PAVIFILE)This->paf); + return IUnknown_AddRef(This->outer_unk); } -static ULONG WINAPI IPersistFile_fnRelease(IPersistFile *iface) +static ULONG WINAPI IPersistFile_fnRelease(IPersistFile *iface) { - IPersistFileImpl *This = (IPersistFileImpl *)iface; + IAVIFileImpl *This = impl_from_IPersistFile(iface); - assert(This->paf != NULL); - - return IAVIFile_Release((PAVIFILE)This->paf); + return IUnknown_Release(This->outer_unk); } -static HRESULT WINAPI IPersistFile_fnGetClassID(IPersistFile *iface, - LPCLSID pClassID) +static HRESULT WINAPI IPersistFile_fnGetClassID(IPersistFile *iface, LPCLSID pClassID) { TRACE("(%p,%p)\n", iface, pClassID); @@ -601,20 +562,16 @@ static HRESULT WINAPI IPersistFile_fnGetClassID(IPersistFile *iface, static HRESULT WINAPI IPersistFile_fnIsDirty(IPersistFile *iface) { - IPersistFileImpl *This = (IPersistFileImpl *)iface; + IAVIFileImpl *This = impl_from_IPersistFile(iface); TRACE("(%p)\n", iface); - assert(This->paf != NULL); - - return (This->paf->fDirty ? S_OK : S_FALSE); + return (This->fDirty ? S_OK : S_FALSE); } -static HRESULT WINAPI IPersistFile_fnLoad(IPersistFile *iface, - LPCOLESTR pszFileName, DWORD dwMode) +static HRESULT WINAPI IPersistFile_fnLoad(IPersistFile *iface, LPCOLESTR pszFileName, DWORD dwMode) { - IPersistFileImpl *This = (IPersistFileImpl *)iface; - + IAVIFileImpl *This = impl_from_IPersistFile(iface); int len; TRACE("(%p,%s,0x%08X)\n", iface, debugstr_w(pszFileName), dwMode); @@ -623,53 +580,49 @@ static HRESULT WINAPI IPersistFile_fnLoad(IPersistFile *iface, if (pszFileName == NULL) return AVIERR_BADPARAM; - assert(This->paf != NULL); - if (This->paf->hmmio != NULL) + if (This->hmmio != NULL) return AVIERR_ERROR; /* No reuse of this object for another file! */ /* remember mode and name */ - This->paf->uMode = dwMode; + This->uMode = dwMode; len = lstrlenW(pszFileName) + 1; - This->paf->szFileName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); - if (This->paf->szFileName == NULL) + This->szFileName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + if (This->szFileName == NULL) return AVIERR_MEMORY; - lstrcpyW(This->paf->szFileName, pszFileName); + lstrcpyW(This->szFileName, pszFileName); /* try to open the file */ - This->paf->hmmio = mmioOpenW(This->paf->szFileName, NULL, - MMIO_ALLOCBUF | dwMode); - if (This->paf->hmmio == NULL) { + This->hmmio = mmioOpenW(This->szFileName, NULL, MMIO_ALLOCBUF | dwMode); + if (This->hmmio == NULL) { /* mmioOpenW not in native DLLs of Win9x -- try mmioOpenA */ LPSTR szFileName; - len = WideCharToMultiByte(CP_ACP, 0, This->paf->szFileName, -1, - NULL, 0, NULL, NULL); + len = WideCharToMultiByte(CP_ACP, 0, This->szFileName, -1, NULL, 0, NULL, NULL); szFileName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(CHAR)); if (szFileName == NULL) return AVIERR_MEMORY; - WideCharToMultiByte(CP_ACP, 0, This->paf->szFileName, -1, szFileName, - len, NULL, NULL); + WideCharToMultiByte(CP_ACP, 0, This->szFileName, -1, szFileName, len, NULL, NULL); - This->paf->hmmio = mmioOpenA(szFileName, NULL, MMIO_ALLOCBUF | dwMode); + This->hmmio = mmioOpenA(szFileName, NULL, MMIO_ALLOCBUF | dwMode); HeapFree(GetProcessHeap(), 0, szFileName); - if (This->paf->hmmio == NULL) + if (This->hmmio == NULL) return AVIERR_FILEOPEN; } /* should we create a new file? */ if (dwMode & OF_CREATE) { - memset(& This->paf->fInfo, 0, sizeof(This->paf->fInfo)); - This->paf->fInfo.dwFlags = AVIFILEINFO_HASINDEX | AVIFILEINFO_TRUSTCKTYPE; + memset(& This->fInfo, 0, sizeof(This->fInfo)); + This->fInfo.dwFlags = AVIFILEINFO_HASINDEX | AVIFILEINFO_TRUSTCKTYPE; return AVIERR_OK; } else - return AVIFILE_LoadFile(This->paf); + return AVIFILE_LoadFile(This); } -static HRESULT WINAPI IPersistFile_fnSave(IPersistFile *iface, - LPCOLESTR pszFileName,BOOL fRemember) +static HRESULT WINAPI IPersistFile_fnSave(IPersistFile *iface, LPCOLESTR pszFileName, + BOOL fRemember) { TRACE("(%p,%s,%d)\n", iface, debugstr_w(pszFileName), fRemember); @@ -678,8 +631,7 @@ static HRESULT WINAPI IPersistFile_fnSave(IPersistFile *iface, return AVIERR_OK; } -static HRESULT WINAPI IPersistFile_fnSaveCompleted(IPersistFile *iface, - LPCOLESTR pszFileName) +static HRESULT WINAPI IPersistFile_fnSaveCompleted(IPersistFile *iface, LPCOLESTR pszFileName) { TRACE("(%p,%s)\n", iface, debugstr_w(pszFileName)); @@ -688,10 +640,9 @@ static HRESULT WINAPI IPersistFile_fnSaveCompleted(IPersistFile *iface, return AVIERR_OK; } -static HRESULT WINAPI IPersistFile_fnGetCurFile(IPersistFile *iface, - LPOLESTR *ppszFileName) +static HRESULT WINAPI IPersistFile_fnGetCurFile(IPersistFile *iface, LPOLESTR *ppszFileName) { - IPersistFileImpl *This = (IPersistFileImpl *)iface; + IAVIFileImpl *This = impl_from_IPersistFile(iface); TRACE("(%p,%p)\n", iface, ppszFileName); @@ -700,22 +651,56 @@ static HRESULT WINAPI IPersistFile_fnGetCurFile(IPersistFile *iface, *ppszFileName = NULL; - assert(This->paf != NULL); - - if (This->paf->szFileName != NULL) { - int len = lstrlenW(This->paf->szFileName) + 1; + if (This->szFileName != NULL) { + int len = lstrlenW(This->szFileName) + 1; *ppszFileName = CoTaskMemAlloc(len * sizeof(WCHAR)); if (*ppszFileName == NULL) return AVIERR_MEMORY; - strcpyW(*ppszFileName, This->paf->szFileName); + strcpyW(*ppszFileName, This->szFileName); } return AVIERR_OK; } -/***********************************************************************/ +static const struct IPersistFileVtbl pf_vt = { + IPersistFile_fnQueryInterface, + IPersistFile_fnAddRef, + IPersistFile_fnRelease, + IPersistFile_fnGetClassID, + IPersistFile_fnIsDirty, + IPersistFile_fnLoad, + IPersistFile_fnSave, + IPersistFile_fnSaveCompleted, + IPersistFile_fnGetCurFile +}; + +HRESULT AVIFILE_CreateAVIFile(IUnknown *pUnkOuter, REFIID riid, void **ppv) +{ + IAVIFileImpl *obj; + HRESULT hr; + + *ppv = NULL; + obj = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IAVIFileImpl)); + if (!obj) + return AVIERR_MEMORY; + + obj->IUnknown_inner.lpVtbl = &unk_vtbl; + obj->IAVIFile_iface.lpVtbl = &avif_vt; + obj->IPersistFile_iface.lpVtbl = &pf_vt; + obj->ref = 1; + if (pUnkOuter) + obj->outer_unk = pUnkOuter; + else + obj->outer_unk = &obj->IUnknown_inner; + + hr = IUnknown_QueryInterface(&obj->IUnknown_inner, riid, ppv); + IUnknown_Release(&obj->IUnknown_inner); + + return hr; +} + static HRESULT WINAPI IAVIStream_fnQueryInterface(IAVIStream *iface, REFIID refiid, LPVOID *obj) @@ -745,7 +730,7 @@ static ULONG WINAPI IAVIStream_fnAddRef(IAVIStream *iface) /* also add ref to parent, so that it doesn't kill us */ if (This->paf != NULL) - IAVIFile_AddRef((PAVIFILE)This->paf); + IAVIFile_AddRef(&This->paf->IAVIFile_iface); return ref; } @@ -758,7 +743,7 @@ static ULONG WINAPI IAVIStream_fnRelease(IAVIStream* iface) TRACE("(%p) -> %d\n", iface, ref); if (This->paf != NULL) - IAVIFile_Release((PAVIFILE)This->paf); + IAVIFile_Release(&This->paf->IAVIFile_iface); return ref; } diff --git a/reactos/dll/win32/avifil32/avifile.rgs b/reactos/dll/win32/avifil32/avifile.rgs index 347300d3e40..b5918f918cc 100644 --- a/reactos/dll/win32/avifil32/avifile.rgs +++ b/reactos/dll/win32/avifil32/avifile.rgs @@ -2,26 +2,11 @@ HKCR { NoRemove CLSID { - '{00020000-0000-0000-C000-000000000046}' = s 'Microsoft AVI Files' - { - InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Apartment' } - } - '{00020001-0000-0000-C000-000000000046}' = s 'AVI Compressed Stream' - { - InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Apartment' } - } - '{00020003-0000-0000-C000-000000000046}' = s 'Microsoft Wave File' - { - InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Apartment' } - } - '{0002000d-0000-0000-C000-000000000046}' = s 'IAVIStream & IAVIFile Proxy' - { - InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Apartment' } - } - '{0002000f-0000-0000-C000-000000000046}' = s 'ACM Compressed Audio Stream' - { - InprocServer32 = s '%MODULE%' { val ThreadingModel = s 'Apartment' } - } + '{00020000-0000-0000-C000-000000000046}' { InprocServer = s 'avifile.dll' } + '{00020001-0000-0000-C000-000000000046}' { InprocServer = s 'avifile.dll' } + '{00020003-0000-0000-C000-000000000046}' { InprocServer = s 'avifile.dll' } + '{0002000d-0000-0000-C000-000000000046}' { InprocServer = s 'avifile.dll' } + '{0002000f-0000-0000-C000-000000000046}' { InprocServer = s 'avifile.dll' } } NoRemove AVIFile { diff --git a/reactos/dll/win32/avifil32/avifile_private.h b/reactos/dll/win32/avifil32/avifile_private.h index f274104d0b8..5aa629b0b60 100644 --- a/reactos/dll/win32/avifil32/avifile_private.h +++ b/reactos/dll/win32/avifil32/avifile_private.h @@ -58,7 +58,7 @@ DEFINE_AVIGUID(CLSID_ACMStream, 0x0002000F, 0, 0); extern HMODULE AVIFILE_hModule DECLSPEC_HIDDEN; -extern HRESULT AVIFILE_CreateAVIFile(REFIID riid, LPVOID *ppobj) DECLSPEC_HIDDEN; +extern HRESULT AVIFILE_CreateAVIFile(IUnknown *pUnkOuter, REFIID riid, LPVOID *ppobj) DECLSPEC_HIDDEN; extern HRESULT AVIFILE_CreateWAVFile(REFIID riid, LPVOID *ppobj) DECLSPEC_HIDDEN; extern HRESULT AVIFILE_CreateACMStream(REFIID riid, LPVOID *ppobj) DECLSPEC_HIDDEN; extern HRESULT AVIFILE_CreateICMStream(REFIID riid, LPVOID *ppobj) DECLSPEC_HIDDEN; diff --git a/reactos/dll/win32/avifil32/extrachunk.c b/reactos/dll/win32/avifil32/extrachunk.c index d590c12a659..2511eadb8b8 100644 --- a/reactos/dll/win32/avifil32/extrachunk.c +++ b/reactos/dll/win32/avifil32/extrachunk.c @@ -32,7 +32,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(avifile); -/* reads a chunk outof the extrachunk-structure */ +/* reads a chunk out of the extrachunk-structure */ HRESULT ReadExtraChunk(const EXTRACHUNKS *extra,FOURCC ckid,LPVOID lpData,LPLONG size) { LPBYTE lp; @@ -102,7 +102,7 @@ HRESULT WriteExtraChunk(LPEXTRACHUNKS extra,FOURCC ckid,LPCVOID lpData, LONG siz return AVIERR_OK; } -/* reads a chunk fomr the HMMIO into the extrachunk-structure */ +/* reads a chunk from the HMMIO into the extrachunk-structure */ HRESULT ReadChunkIntoExtra(LPEXTRACHUNKS extra,HMMIO hmmio,const MMCKINFO *lpck) { LPDWORD lp; diff --git a/reactos/dll/win32/avifil32/extrachunk.h b/reactos/dll/win32/avifil32/extrachunk.h index d8f98720528..53c943c2a19 100644 --- a/reactos/dll/win32/avifil32/extrachunk.h +++ b/reactos/dll/win32/avifil32/extrachunk.h @@ -42,7 +42,7 @@ HRESULT ReadExtraChunk(const EXTRACHUNKS *extra,FOURCC ckid,LPVOID lp,LPLONG siz /* writes a chunk into the extrachunk-structure */ HRESULT WriteExtraChunk(LPEXTRACHUNKS extra,FOURCC ckid,LPCVOID lp,LONG size) DECLSPEC_HIDDEN; -/* reads a chunk fomr the HMMIO into the extrachunk-structure */ +/* reads a chunk from the HMMIO into the extrachunk-structure */ HRESULT ReadChunkIntoExtra(LPEXTRACHUNKS extra,HMMIO hmmio,const MMCKINFO *lpck) DECLSPEC_HIDDEN; /* reads all non-junk chunks into the extrachunk-structure until it finds diff --git a/reactos/dll/win32/avifil32/factory.c b/reactos/dll/win32/avifil32/factory.c index fa1ee0530af..b96f37e5138 100644 --- a/reactos/dll/win32/avifil32/factory.c +++ b/reactos/dll/win32/avifil32/factory.c @@ -144,12 +144,19 @@ static HRESULT WINAPI IClassFactory_fnCreateInstance(LPCLASSFACTORY iface, TRACE("(%p,%p,%s,%p)\n", iface, pOuter, debugstr_guid(riid), ppobj); - if (ppobj == NULL || pOuter != NULL) - return E_FAIL; + if (!ppobj) + return E_INVALIDARG; *ppobj = NULL; + if (pOuter && !IsEqualGUID(&IID_IUnknown, riid)) + return E_INVALIDARG; + if (IsEqualGUID(&CLSID_AVIFile, &This->clsid)) - return AVIFILE_CreateAVIFile(riid,ppobj); + return AVIFILE_CreateAVIFile(pOuter, riid, ppobj); + + if (pOuter) + return CLASS_E_NOAGGREGATION; + if (IsEqualGUID(&CLSID_ICMStream, &This->clsid)) return AVIFILE_CreateICMStream(riid,ppobj); if (IsEqualGUID(&CLSID_WAVFile, &This->clsid)) diff --git a/reactos/dll/win32/avifil32/getframe.c b/reactos/dll/win32/avifil32/getframe.c index 57d9de19cfd..c69958e8511 100644 --- a/reactos/dll/win32/avifil32/getframe.c +++ b/reactos/dll/win32/avifil32/getframe.c @@ -311,8 +311,7 @@ static HRESULT WINAPI IGetFrame_fnSetFormat(IGetFrame *iface, if (sInfo.fccType != streamtypeVIDEO) return AVIERR_UNSUPPORTED; - This->bFormatChanges = - (sInfo.dwFlags & AVISTREAMINFO_FORMATCHANGES ? TRUE : FALSE ); + This->bFormatChanges = (sInfo.dwFlags & AVISTREAMINFO_FORMATCHANGES) != 0; This->dwFormatChangeCount = sInfo.dwFormatChangeCount; This->dwEditCount = sInfo.dwEditCount; This->lCurrentFrame = -1; @@ -434,7 +433,7 @@ static HRESULT WINAPI IGetFrame_fnSetFormat(IGetFrame *iface, } if (lpBits == NULL) { - register DWORD size = This->lpOutFormat->biClrUsed * sizeof(RGBQUAD); + DWORD size = This->lpOutFormat->biClrUsed * sizeof(RGBQUAD); size += This->lpOutFormat->biSize + This->lpOutFormat->biSizeImage; This->lpOutFormat = HeapReAlloc(GetProcessHeap(), 0, This->lpOutFormat, size); diff --git a/reactos/dll/win32/avifil32/rsrc.rc b/reactos/dll/win32/avifil32/rsrc.rc index 65818d83e50..75946eda3ab 100644 --- a/reactos/dll/win32/avifil32/rsrc.rc +++ b/reactos/dll/win32/avifil32/rsrc.rc @@ -28,6 +28,8 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL /* @makedep: avifile.rgs */ 1 WINE_REGISTRY avifile.rgs +2 WINE_REGISTRY avifil32_idl.rgs + #define WINE_FILEDESCRIPTION_STR "Wine AVI file support library" #define WINE_FILENAME_STR "avifil32.dll" #define WINE_FILEVERSION 4,0,3,1998 diff --git a/reactos/dll/win32/avifil32/tmpfile.c b/reactos/dll/win32/avifil32/tmpfile.c index 5c4cfb80711..babfbeb06a7 100644 --- a/reactos/dll/win32/avifil32/tmpfile.c +++ b/reactos/dll/win32/avifil32/tmpfile.c @@ -262,7 +262,7 @@ PAVIFILE AVIFILE_CreateAVITempFile(int nStreams, const PAVISTREAM *ppStreams) tmpFile->fInfo.dwSuggestedBufferSize = sInfo.dwSuggestedBufferSize; { - register DWORD tmp; + DWORD tmp; tmp = MulDiv(AVIStreamSampleToTime(ppStreams[i], sInfo.dwLength), tmpFile->fInfo.dwScale, tmpFile->fInfo.dwRate * 1000); diff --git a/reactos/media/doc/README.WINE b/reactos/media/doc/README.WINE index b94a702a7cc..647045088d6 100644 --- a/reactos/media/doc/README.WINE +++ b/reactos/media/doc/README.WINE @@ -43,7 +43,7 @@ reactos/dll/win32/actxprxy # Synced to Wine-1.5.26 reactos/dll/win32/advpack # Synced to Wine-1.5.26 reactos/dll/win32/atl # Synced to Wine-1.5.19 reactos/dll/win32/atl100 # Synced to Wine-1.5.19 -reactos/dll/win32/avifil32 # Synced to Wine-1.3.37 +reactos/dll/win32/avifil32 # Synced to Wine-1.5.26 reactos/dll/win32/bcrypt # Synced to Wine-1.5.19 reactos/dll/win32/browseui # Out of sync reactos/dll/win32/cabinet # Synced to Wine-1.5.19