Author: akhaldi Date: Tue Apr 22 11:31:44 2014 New Revision: 62870
URL: http://svn.reactos.org/svn/reactos?rev=62870&view=rev Log: [AVIFIL32] * Sync with Wine 1.7.17. CORE-8080
Modified: trunk/reactos/dll/win32/avifil32/api.c trunk/reactos/dll/win32/avifil32/avifil32.idl trunk/reactos/dll/win32/avifil32/avifile.c trunk/reactos/dll/win32/avifil32/avifile_private.h trunk/reactos/dll/win32/avifil32/factory.c trunk/reactos/dll/win32/avifil32/icmstream.c trunk/reactos/dll/win32/avifil32/wavfile.c trunk/reactos/media/doc/README.WINE
Modified: trunk/reactos/dll/win32/avifil32/api.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/avifil32/api.c?re... ============================================================================== --- trunk/reactos/dll/win32/avifil32/api.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/avifil32/api.c [iso-8859-1] Tue Apr 22 11:31:44 2014 @@ -1493,7 +1493,7 @@ HRESULT hr; int len;
- TRACE("%s,%p,%p,%d,%p,%p)\n", debugstr_a(szFile), pclsidHandler, + TRACE("(%s,%p,%p,%d,%p,%p)\n", debugstr_a(szFile), pclsidHandler, lpfnCallback, nStream, ppavi, plpOptions);
if (szFile == NULL || ppavi == NULL || plpOptions == NULL)
Modified: trunk/reactos/dll/win32/avifil32/avifil32.idl URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/avifil32/avifil32... ============================================================================== --- trunk/reactos/dll/win32/avifil32/avifil32.idl [iso-8859-1] (original) +++ trunk/reactos/dll/win32/avifil32/avifil32.idl [iso-8859-1] Tue Apr 22 11:31:44 2014 @@ -17,6 +17,8 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ + +#pragma makedep register
[ helpstring("Microsoft AVI Files"),
Modified: trunk/reactos/dll/win32/avifil32/avifile.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/avifil32/avifile.... ============================================================================== --- trunk/reactos/dll/win32/avifil32/avifile.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/avifil32/avifile.c [iso-8859-1] Tue Apr 22 11:31:44 2014 @@ -36,46 +36,12 @@ #define IDX_PER_BLOCK 2730 #endif
-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); -static HRESULT WINAPI IAVIStream_fnCreate(IAVIStream*iface,LPARAM lParam1,LPARAM lParam2); -static HRESULT WINAPI IAVIStream_fnInfo(IAVIStream*iface,AVISTREAMINFOW *psi,LONG size); -static LONG WINAPI IAVIStream_fnFindSample(IAVIStream*iface,LONG pos,LONG flags); -static HRESULT WINAPI IAVIStream_fnReadFormat(IAVIStream*iface,LONG pos,LPVOID format,LONG *formatsize); -static HRESULT WINAPI IAVIStream_fnSetFormat(IAVIStream*iface,LONG pos,LPVOID format,LONG formatsize); -static HRESULT WINAPI IAVIStream_fnRead(IAVIStream*iface,LONG start,LONG samples,LPVOID buffer,LONG buffersize,LONG *bytesread,LONG *samplesread); -static HRESULT WINAPI IAVIStream_fnWrite(IAVIStream*iface,LONG start,LONG samples,LPVOID buffer,LONG buffersize,DWORD flags,LONG *sampwritten,LONG *byteswritten); -static HRESULT WINAPI IAVIStream_fnDelete(IAVIStream*iface,LONG start,LONG samples); -static HRESULT WINAPI IAVIStream_fnReadData(IAVIStream*iface,DWORD fcc,LPVOID lp,LONG *lpread); -static HRESULT WINAPI IAVIStream_fnWriteData(IAVIStream*iface,DWORD fcc,LPVOID lp,LONG size); -static HRESULT WINAPI IAVIStream_fnSetInfo(IAVIStream*iface,AVISTREAMINFOW*info,LONG infolen); - -static const struct IAVIStreamVtbl iavist = { - IAVIStream_fnQueryInterface, - IAVIStream_fnAddRef, - IAVIStream_fnRelease, - IAVIStream_fnCreate, - IAVIStream_fnInfo, - IAVIStream_fnFindSample, - IAVIStream_fnReadFormat, - IAVIStream_fnSetFormat, - IAVIStream_fnRead, - IAVIStream_fnWrite, - IAVIStream_fnDelete, - IAVIStream_fnReadData, - IAVIStream_fnWriteData, - IAVIStream_fnSetInfo -}; - typedef struct _IAVIFileImpl IAVIFileImpl;
typedef struct _IAVIStreamImpl { - /* IUnknown stuff */ - const IAVIStreamVtbl *lpVtbl; - LONG ref; - - /* IAVIStream stuff */ + IAVIStream IAVIStream_iface; + LONG ref; + IAVIFileImpl *paf; DWORD nStream; /* the n-th stream in file */ AVISTREAMINFOW sInfo; @@ -98,6 +64,11 @@ AVIINDEXENTRY *idxFmtChanges; DWORD nIdxFmtChanges; /* upper index limit of idxFmtChanges */ } IAVIStreamImpl; + +static inline IAVIStreamImpl *impl_from_IAVIStream(IAVIStream *iface) +{ + return CONTAINING_RECORD(iface, IAVIStreamImpl, IAVIStream_iface); +}
struct _IAVIFileImpl { IUnknown IUnknown_inner; @@ -319,7 +290,7 @@ /* Does the requested stream exist? */ if (nStream < This->fInfo.dwStreams && This->ppStreams[nStream] != NULL) { - *avis = (PAVISTREAM)This->ppStreams[nStream]; + *avis = &This->ppStreams[nStream]->IAVIStream_iface; IAVIStream_AddRef(*avis);
return AVIERR_OK; @@ -376,7 +347,7 @@ AVIFILE_UpdateInfo(This);
/* return it */ - *avis = (PAVISTREAM)This->ppStreams[n]; + *avis = &This->ppStreams[n]->IAVIStream_iface; IAVIStream_AddRef(*avis);
return AVIERR_OK; @@ -679,31 +650,35 @@ }
-static HRESULT WINAPI IAVIStream_fnQueryInterface(IAVIStream *iface, - REFIID refiid, LPVOID *obj) -{ - IAVIStreamImpl *This = (IAVIStreamImpl *)iface; - - TRACE("(%p,%s,%p)\n", iface, debugstr_guid(refiid), obj); - - if (IsEqualGUID(&IID_IUnknown, refiid) || - IsEqualGUID(&IID_IAVIStream, refiid)) { - *obj = This; +static HRESULT WINAPI IAVIStream_fnQueryInterface(IAVIStream *iface, REFIID riid, void **ppv) +{ + IAVIStreamImpl *This = impl_from_IAVIStream(iface); + + TRACE("(%p,%s,%p)\n", This, debugstr_guid(riid), ppv); + + if (!ppv) { + WARN("invalid parameter\n"); + return E_INVALIDARG; + } + *ppv = NULL; + + if (IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IAVIStream, riid)) { + *ppv = iface; IAVIStream_AddRef(iface);
return S_OK; } /* FIXME: IAVIStreaming interface */
- return OLE_E_ENUM_NOMORE; + return E_NOINTERFACE; }
static ULONG WINAPI IAVIStream_fnAddRef(IAVIStream *iface) { - IAVIStreamImpl *This = (IAVIStreamImpl *)iface; + IAVIStreamImpl *This = impl_from_IAVIStream(iface); ULONG ref = InterlockedIncrement(&This->ref);
- TRACE("(%p) -> %d\n", iface, ref); + TRACE("(%p) ref=%d\n", This, ref);
/* also add ref to parent, so that it doesn't kill us */ if (This->paf != NULL) @@ -712,12 +687,12 @@ return ref; }
-static ULONG WINAPI IAVIStream_fnRelease(IAVIStream* iface) -{ - IAVIStreamImpl *This = (IAVIStreamImpl *)iface; +static ULONG WINAPI IAVIStream_fnRelease(IAVIStream *iface) +{ + IAVIStreamImpl *This = impl_from_IAVIStream(iface); ULONG ref = InterlockedDecrement(&This->ref);
- TRACE("(%p) -> %d\n", iface, ref); + TRACE("(%p) ref=%d\n", This, ref);
if (This->paf != NULL) IAVIFile_Release(&This->paf->IAVIFile_iface); @@ -725,8 +700,7 @@ return ref; }
-static HRESULT WINAPI IAVIStream_fnCreate(IAVIStream *iface, LPARAM lParam1, - LPARAM lParam2) +static HRESULT WINAPI IAVIStream_fnCreate(IAVIStream *iface, LPARAM lParam1, LPARAM lParam2) { TRACE("(%p,0x%08lX,0x%08lX)\n", iface, lParam1, lParam2);
@@ -734,10 +708,9 @@ return AVIERR_UNSUPPORTED; }
-static HRESULT WINAPI IAVIStream_fnInfo(IAVIStream *iface,LPAVISTREAMINFOW psi, - LONG size) -{ - IAVIStreamImpl *This = (IAVIStreamImpl *)iface; +static HRESULT WINAPI IAVIStream_fnInfo(IAVIStream *iface, AVISTREAMINFOW *psi, LONG size) +{ + IAVIStreamImpl *This = impl_from_IAVIStream(iface);
TRACE("(%p,%p,%d)\n", iface, psi, size);
@@ -753,11 +726,9 @@ return AVIERR_OK; }
-static LONG WINAPI IAVIStream_fnFindSample(IAVIStream *iface, LONG pos, - LONG flags) -{ - IAVIStreamImpl *This = (IAVIStreamImpl *)iface; - +static LONG WINAPI IAVIStream_fnFindSample(IAVIStream *iface, LONG pos, LONG flags) +{ + IAVIStreamImpl *This = impl_from_IAVIStream(iface); LONG offset = 0;
TRACE("(%p,%d,0x%08X)\n",iface,pos,flags); @@ -853,10 +824,10 @@ return pos; }
-static HRESULT WINAPI IAVIStream_fnReadFormat(IAVIStream *iface, LONG pos, - LPVOID format, LONG *formatsize) -{ - IAVIStreamImpl *This = (IAVIStreamImpl *)iface; +static HRESULT WINAPI IAVIStream_fnReadFormat(IAVIStream *iface, LONG pos, void *format, + LONG *formatsize) +{ + IAVIStreamImpl *This = impl_from_IAVIStream(iface);
TRACE("(%p,%d,%p,%p)\n", iface, pos, format, formatsize);
@@ -892,12 +863,11 @@ return AVIERR_OK; }
-static HRESULT WINAPI IAVIStream_fnSetFormat(IAVIStream *iface, LONG pos, - LPVOID format, LONG formatsize) -{ - IAVIStreamImpl *This = (IAVIStreamImpl *)iface; - - LPBITMAPINFOHEADER lpbiNew = format; +static HRESULT WINAPI IAVIStream_fnSetFormat(IAVIStream *iface, LONG pos, void *format, + LONG formatsize) +{ + IAVIStreamImpl *This = impl_from_IAVIStream(iface); + BITMAPINFOHEADER *lpbiNew = format;
TRACE("(%p,%d,%p,%d)\n", iface, pos, format, formatsize);
@@ -1001,15 +971,12 @@ } }
-static HRESULT WINAPI IAVIStream_fnRead(IAVIStream *iface, LONG start, - LONG samples, LPVOID buffer, - LONG buffersize, LPLONG bytesread, - LPLONG samplesread) -{ - IAVIStreamImpl *This = (IAVIStreamImpl *)iface; - - DWORD size; - HRESULT hr; +static HRESULT WINAPI IAVIStream_fnRead(IAVIStream *iface, LONG start, LONG samples, void *buffer, + LONG buffersize, LONG *bytesread, LONG *samplesread) +{ + IAVIStreamImpl *This = impl_from_IAVIStream(iface); + DWORD size; + HRESULT hr;
TRACE("(%p,%d,%d,%p,%d,%p,%p)\n", iface, start, samples, buffer, buffersize, bytesread, samplesread); @@ -1123,15 +1090,11 @@ } }
-static HRESULT WINAPI IAVIStream_fnWrite(IAVIStream *iface, LONG start, - LONG samples, LPVOID buffer, - LONG buffersize, DWORD flags, - LPLONG sampwritten, - LPLONG byteswritten) -{ - IAVIStreamImpl *This = (IAVIStreamImpl *)iface; - - FOURCC ckid; +static HRESULT WINAPI IAVIStream_fnWrite(IAVIStream *iface, LONG start, LONG samples, void *buffer, + LONG buffersize, DWORD flags, LONG *sampwritten, LONG *byteswritten) +{ + IAVIStreamImpl *This = impl_from_IAVIStream(iface); + FOURCC ckid; HRESULT hr;
TRACE("(%p,%d,%d,%p,%d,0x%08X,%p,%p)\n", iface, start, samples, @@ -1217,10 +1180,9 @@ return hr; }
-static HRESULT WINAPI IAVIStream_fnDelete(IAVIStream *iface, LONG start, - LONG samples) -{ - IAVIStreamImpl *This = (IAVIStreamImpl *)iface; +static HRESULT WINAPI IAVIStream_fnDelete(IAVIStream *iface, LONG start, LONG samples) +{ + IAVIStreamImpl *This = impl_from_IAVIStream(iface);
FIXME("(%p,%d,%d): stub\n", iface, start, samples);
@@ -1256,10 +1218,9 @@ return AVIERR_UNSUPPORTED; }
-static HRESULT WINAPI IAVIStream_fnReadData(IAVIStream *iface, DWORD fcc, - LPVOID lp, LPLONG lpread) -{ - IAVIStreamImpl *This = (IAVIStreamImpl *)iface; +static HRESULT WINAPI IAVIStream_fnReadData(IAVIStream *iface, DWORD fcc, void *lp, LONG *lpread) +{ + IAVIStreamImpl *This = impl_from_IAVIStream(iface);
TRACE("(%p,0x%08X,%p,%p)\n", iface, fcc, lp, lpread);
@@ -1280,10 +1241,9 @@ return ReadExtraChunk(&This->extra, fcc, lp, lpread); }
-static HRESULT WINAPI IAVIStream_fnWriteData(IAVIStream *iface, DWORD fcc, - LPVOID lp, LONG size) -{ - IAVIStreamImpl *This = (IAVIStreamImpl *)iface; +static HRESULT WINAPI IAVIStream_fnWriteData(IAVIStream *iface, DWORD fcc, void *lp, LONG size) +{ + IAVIStreamImpl *This = impl_from_IAVIStream(iface);
TRACE("(%p,0x%08x,%p,%d)\n", iface, fcc, lp, size);
@@ -1313,7 +1273,7 @@
if (fcc == ckidSTREAMHANDLERDATA) { if (This->lpHandlerData != NULL) { - FIXME(": handler data already set -- overwirte?\n"); + FIXME(": handler data already set -- overwrite?\n"); return AVIERR_UNSUPPORTED; }
@@ -1328,15 +1288,30 @@ return WriteExtraChunk(&This->extra, fcc, lp, size); }
-static HRESULT WINAPI IAVIStream_fnSetInfo(IAVIStream *iface, - LPAVISTREAMINFOW info, LONG infolen) +static HRESULT WINAPI IAVIStream_fnSetInfo(IAVIStream *iface, AVISTREAMINFOW *info, LONG infolen) { FIXME("(%p,%p,%d): stub\n", iface, info, infolen);
return E_FAIL; }
-/***********************************************************************/ +static const struct IAVIStreamVtbl avist_vt = { + IAVIStream_fnQueryInterface, + IAVIStream_fnAddRef, + IAVIStream_fnRelease, + IAVIStream_fnCreate, + IAVIStream_fnInfo, + IAVIStream_fnFindSample, + IAVIStream_fnReadFormat, + IAVIStream_fnSetFormat, + IAVIStream_fnRead, + IAVIStream_fnWrite, + IAVIStream_fnDelete, + IAVIStream_fnReadData, + IAVIStream_fnWriteData, + IAVIStream_fnSetInfo +}; +
static HRESULT AVIFILE_AddFrame(IAVIStreamImpl *This, DWORD ckid, DWORD size, DWORD offset, DWORD flags) { @@ -1495,7 +1470,7 @@
pstream = paf->ppStreams[nr];
- pstream->lpVtbl = &iavist; + pstream->IAVIStream_iface.lpVtbl = &avist_vt; pstream->ref = 0; pstream->paf = paf; pstream->nStream = nr; @@ -2102,7 +2077,7 @@ if (This->dwMoviChunkPos == 0) AVIFILE_ComputeMoviStart(This);
- /* written one record to much? */ + /* written one record too much? */ if (This->ckLastRecord.dwFlags & MMIO_DIRTY) { This->dwNextFramePos -= 3 * sizeof(DWORD); if (This->nIdxRecords > 0) @@ -2334,7 +2309,7 @@ if (This->ppStreams[0]->sInfo.dwSampleSize == 0) stepsize = 1; else - stepsize = AVIStreamTimeToSample((PAVISTREAM)This->ppStreams[0], 1000000); + stepsize = AVIStreamTimeToSample(&This->ppStreams[0]->IAVIStream_iface, 1000000);
assert(stepsize > 0);
@@ -2504,8 +2479,8 @@ This->fInfo.dwRate = psi->dwRate; This->fInfo.dwLength = psi->dwLength; } else { - n = AVIStreamSampleToSample((PAVISTREAM)This->ppStreams[0], - (PAVISTREAM)This->ppStreams[i],psi->dwLength); + n = AVIStreamSampleToSample(&This->ppStreams[0]->IAVIStream_iface, + &This->ppStreams[i]->IAVIStream_iface, psi->dwLength); if (This->fInfo.dwLength < n) This->fInfo.dwLength = n; }
Modified: trunk/reactos/dll/win32/avifil32/avifile_private.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/avifil32/avifile_... ============================================================================== --- trunk/reactos/dll/win32/avifil32/avifile_private.h [iso-8859-1] (original) +++ trunk/reactos/dll/win32/avifil32/avifile_private.h [iso-8859-1] Tue Apr 22 11:31:44 2014 @@ -62,7 +62,7 @@ extern HMODULE AVIFILE_hModule 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_CreateWAVFile(IUnknown *outer_unk, REFIID riid, void **ret_iface) DECLSPEC_HIDDEN; extern HRESULT AVIFILE_CreateACMStream(REFIID riid, LPVOID *ppobj) DECLSPEC_HIDDEN; extern HRESULT AVIFILE_CreateICMStream(REFIID riid, LPVOID *ppobj) DECLSPEC_HIDDEN; extern PAVIEDITSTREAM AVIFILE_CreateEditStream(PAVISTREAM pstream) DECLSPEC_HIDDEN;
Modified: trunk/reactos/dll/win32/avifil32/factory.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/avifil32/factory.... ============================================================================== --- trunk/reactos/dll/win32/avifil32/factory.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/avifil32/factory.c [iso-8859-1] Tue Apr 22 11:31:44 2014 @@ -133,14 +133,14 @@
if (IsEqualGUID(&CLSID_AVIFile, &This->clsid)) return AVIFILE_CreateAVIFile(pOuter, riid, ppobj); + if (IsEqualGUID(&CLSID_WAVFile, &This->clsid)) + return AVIFILE_CreateWAVFile(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)) - return AVIFILE_CreateWAVFile(riid,ppobj); if (IsEqualGUID(&CLSID_ACMStream, &This->clsid)) return AVIFILE_CreateACMStream(riid,ppobj);
Modified: trunk/reactos/dll/win32/avifil32/icmstream.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/avifil32/icmstrea... ============================================================================== --- trunk/reactos/dll/win32/avifil32/icmstream.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/avifil32/icmstream.c [iso-8859-1] Tue Apr 22 11:31:44 2014 @@ -299,7 +299,7 @@ return This->lLastKey; } } else if (flags & FIND_ANY) { - return pos; /* We really don't know, reread is to expensive, so guess. */ + return pos; /* We really don't know, reread is too expensive, so guess. */ } else if (flags & FIND_FORMAT) { if (flags & FIND_PREV) return 0;
Modified: trunk/reactos/dll/win32/avifil32/wavfile.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/avifil32/wavfile.... ============================================================================== --- trunk/reactos/dll/win32/avifil32/wavfile.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/avifil32/wavfile.c [iso-8859-1] Tue Apr 22 11:31:44 2014 @@ -67,111 +67,14 @@
/***********************************************************************/
-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 iwavft = { - 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 iwavpft = { - 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); -static HRESULT WINAPI IAVIStream_fnCreate(IAVIStream*iface,LPARAM lParam1,LPARAM lParam2); -static HRESULT WINAPI IAVIStream_fnInfo(IAVIStream*iface,AVISTREAMINFOW *psi,LONG size); -static LONG WINAPI IAVIStream_fnFindSample(IAVIStream*iface,LONG pos,LONG flags); -static HRESULT WINAPI IAVIStream_fnReadFormat(IAVIStream*iface,LONG pos,LPVOID format,LONG *formatsize); -static HRESULT WINAPI IAVIStream_fnSetFormat(IAVIStream*iface,LONG pos,LPVOID format,LONG formatsize); -static HRESULT WINAPI IAVIStream_fnRead(IAVIStream*iface,LONG start,LONG samples,LPVOID buffer,LONG buffersize,LONG *bytesread,LONG *samplesread); -static HRESULT WINAPI IAVIStream_fnWrite(IAVIStream*iface,LONG start,LONG samples,LPVOID buffer,LONG buffersize,DWORD flags,LONG *sampwritten,LONG *byteswritten); -static HRESULT WINAPI IAVIStream_fnDelete(IAVIStream*iface,LONG start,LONG samples); -static HRESULT WINAPI IAVIStream_fnReadData(IAVIStream*iface,DWORD fcc,LPVOID lp,LONG *lpread); -static HRESULT WINAPI IAVIStream_fnWriteData(IAVIStream*iface,DWORD fcc,LPVOID lp,LONG size); -static HRESULT WINAPI IAVIStream_fnSetInfo(IAVIStream*iface,AVISTREAMINFOW*info,LONG infolen); - -static const struct IAVIStreamVtbl iwavst = { - IAVIStream_fnQueryInterface, - IAVIStream_fnAddRef, - IAVIStream_fnRelease, - IAVIStream_fnCreate, - IAVIStream_fnInfo, - IAVIStream_fnFindSample, - IAVIStream_fnReadFormat, - IAVIStream_fnSetFormat, - IAVIStream_fnRead, - IAVIStream_fnWrite, - IAVIStream_fnDelete, - IAVIStream_fnReadData, - IAVIStream_fnWriteData, - IAVIStream_fnSetInfo -}; - -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; - - /* IAVIStream stuff */ - IAVIFileImpl *paf; -} IAVIStreamImpl; - -struct _IAVIFileImpl { - /* IUnknown stuff */ - const IAVIFileVtbl *lpVtbl; - LONG ref; - +typedef struct _IAVIFileImpl { + IUnknown IUnknown_inner; + IAVIFile IAVIFile_iface; + IPersistFile IPersistFile_iface; + IAVIStream IAVIStream_iface; + IUnknown *outer_unk; + LONG ref; /* IAVIFile, IAVIStream stuff... */ - IPersistFileImpl iPersistFile; - IAVIStreamImpl iAVIStream; - AVIFILEINFOW fInfo; AVISTREAMINFOW sInfo;
@@ -187,7 +90,7 @@ LPWSTR szFileName; UINT uMode; BOOL fDirty; -}; +} IAVIFileImpl;
/***********************************************************************/
@@ -195,108 +98,112 @@ static HRESULT AVIFILE_LoadSunFile(IAVIFileImpl *This); static HRESULT AVIFILE_SaveFile(const IAVIFileImpl *This);
-HRESULT AVIFILE_CreateWAVFile(REFIID riid, LPVOID *ppv) -{ - IAVIFileImpl *pfile; - HRESULT hr; - - assert(riid != NULL && ppv != NULL); - - *ppv = NULL; - - pfile = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IAVIFileImpl)); - if (pfile == NULL) - return AVIERR_MEMORY; - - pfile->lpVtbl = &iwavft; - pfile->iPersistFile.lpVtbl = &iwavpft; - pfile->iAVIStream.lpVtbl = &iwavst; - pfile->ref = 0; - pfile->iPersistFile.paf = pfile; - pfile->iAVIStream.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); +static inline IAVIFileImpl *impl_from_IUnknown(IUnknown *iface) +{ + return CONTAINING_RECORD(iface, IAVIFileImpl, IUnknown_inner); +} + +static HRESULT WINAPI IUnknown_fnQueryInterface(IUnknown *iface, REFIID riid, void **ret_iface) +{ + IAVIFileImpl *This = impl_from_IUnknown(iface); + + TRACE("(%p,%s,%p)\n", This, debugstr_guid(riid), ret_iface); + + if (IsEqualGUID(&IID_IUnknown, riid)) + *ret_iface = &This->IUnknown_inner; + else if (IsEqualGUID(&IID_IAVIFile, riid)) + *ret_iface = &This->IAVIFile_iface; + else if (IsEqualGUID(&IID_IAVIStream, riid)) + *ret_iface = &This->IAVIStream_iface; + else if (IsEqualGUID(&IID_IPersistFile, riid)) + *ret_iface = &This->IPersistFile_iface; + else { + WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ret_iface); + *ret_iface = NULL; + return E_NOINTERFACE; + } + + /* Violation of the COM aggregation ref counting rule */ + IUnknown_AddRef(&This->IUnknown_inner); return S_OK; - } else if (This->fInfo.dwStreams == 1 && - IsEqualGUID(&IID_IAVIStream, refiid)) { - *obj = &This->iAVIStream; - IAVIFile_AddRef(iface); - return S_OK; - } else if (IsEqualGUID(&IID_IPersistFile, refiid)) { - *obj = &This->iPersistFile; - IAVIFile_AddRef(iface); - return S_OK; - } - - return OLE_E_ENUM_NOMORE; +} + +static ULONG WINAPI IUnknown_fnAddRef(IUnknown *iface) +{ + IAVIFileImpl *This = impl_from_IUnknown(iface); + ULONG ref = InterlockedIncrement(&This->ref); + + TRACE("(%p) ref=%d\n", This, ref); + + return ref; +} + +static ULONG WINAPI IUnknown_fnRelease(IUnknown *iface) +{ + IAVIFileImpl *This = impl_from_IUnknown(iface); + ULONG ref = InterlockedDecrement(&This->ref); + + TRACE("(%p) ref=%d\n", This, ref); + + if (!ref) { + /* need to write headers to file */ + if (This->fDirty) + AVIFILE_SaveFile(This); + + HeapFree(GetProcessHeap(), 0, This->lpFormat); + This->lpFormat = NULL; + This->cbFormat = 0; + HeapFree(GetProcessHeap(), 0, This->extra.lp); + This->extra.lp = NULL; + This->extra.cb = 0; + HeapFree(GetProcessHeap(), 0, This->szFileName); + This->szFileName = NULL; + if (This->hmmio) { + mmioClose(This->hmmio, 0); + This->hmmio = NULL; + } + HeapFree(GetProcessHeap(), 0, This); + } + + return ref; +} + +static const IUnknownVtbl unk_vtbl = +{ + IUnknown_fnQueryInterface, + IUnknown_fnAddRef, + IUnknown_fnRelease +}; + +static inline IAVIFileImpl *impl_from_IAVIFile(IAVIFile *iface) +{ + return CONTAINING_RECORD(iface, IAVIFileImpl, IAVIFile_iface); +} + +static HRESULT WINAPI IAVIFile_fnQueryInterface(IAVIFile *iface, REFIID riid, void **ret_iface) +{ + IAVIFileImpl *This = impl_from_IAVIFile(iface); + + return IUnknown_QueryInterface(This->outer_unk, riid, ret_iface); }
static ULONG WINAPI IAVIFile_fnAddRef(IAVIFile *iface) { - IAVIFileImpl *This = (IAVIFileImpl *)iface; - - TRACE("(%p)\n",iface); - - return InterlockedIncrement(&This->ref); + IAVIFileImpl *This = impl_from_IAVIFile(iface); + + return IUnknown_AddRef(This->outer_unk); }
static ULONG WINAPI IAVIFile_fnRelease(IAVIFile *iface) { - IAVIFileImpl *This = (IAVIFileImpl *)iface; - ULONG ref = InterlockedDecrement(&This->ref); - - TRACE("(%p)\n",iface); - - if (!ref) { - if (This->fDirty) { - /* need to write headers to file */ - AVIFILE_SaveFile(This); - } - - if (This->lpFormat != NULL) { - HeapFree(GetProcessHeap(), 0, This->lpFormat); - This->lpFormat = NULL; - This->cbFormat = 0; - } - if (This->extra.lp != NULL) { - HeapFree(GetProcessHeap(), 0, This->extra.lp); - This->extra.lp = NULL; - This->extra.cb = 0; - } - HeapFree(GetProcessHeap(), 0, This->szFileName); - This->szFileName = NULL; - if (This->hmmio != NULL) { - mmioClose(This->hmmio, 0); - This->hmmio = NULL; - } - - HeapFree(GetProcessHeap(), 0, This); - return 0; - } - return ref; -} - -static HRESULT WINAPI IAVIFile_fnInfo(IAVIFile *iface, LPAVIFILEINFOW afi, - LONG size) -{ - IAVIFileImpl *This = (IAVIFileImpl *)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);
@@ -327,10 +234,10 @@ return AVIERR_OK; }
-static HRESULT WINAPI IAVIFile_fnGetStream(IAVIFile *iface, PAVISTREAM *avis, - DWORD fccType, LONG lParam) -{ - IAVIFileImpl *This = (IAVIFileImpl *)iface; +static HRESULT WINAPI IAVIFile_fnGetStream(IAVIFile *iface, IAVIStream **avis, DWORD fccType, + LONG lParam) +{ + IAVIFileImpl *This = impl_from_IAVIFile(iface);
TRACE("(%p,%p,0x%08X,%d)\n", iface, avis, fccType, lParam);
@@ -346,16 +253,16 @@ if (fccType != 0 && fccType != streamtypeAUDIO) return AVIERR_NODATA;
- *avis = (PAVISTREAM)&This->iAVIStream; - IAVIFile_AddRef(iface); - - return AVIERR_OK; -} - -static HRESULT WINAPI IAVIFile_fnCreateStream(IAVIFile *iface,PAVISTREAM *avis, - LPAVISTREAMINFOW asi) -{ - IAVIFileImpl *This = (IAVIFileImpl *)iface; + *avis = &This->IAVIStream_iface; + IAVIStream_AddRef(*avis); + + return AVIERR_OK; +} + +static HRESULT WINAPI IAVIFile_fnCreateStream(IAVIFile *iface, IAVIStream **avis, + AVISTREAMINFOW *asi) +{ + IAVIFileImpl *This = impl_from_IAVIFile(iface);
TRACE("(%p,%p,%p)\n", iface, avis, asi);
@@ -397,16 +304,15 @@ This->ckData.dwDataOffset = 0; This->ckData.cksize = 0;
- *avis = (PAVISTREAM)&This->iAVIStream; - IAVIFile_AddRef(iface); - - return AVIERR_OK; -} - -static HRESULT WINAPI IAVIFile_fnWriteData(IAVIFile *iface, DWORD ckid, - LPVOID lpData, LONG size) -{ - IAVIFileImpl *This = (IAVIFileImpl *)iface; + *avis = &This->IAVIStream_iface; + IAVIStream_AddRef(*avis); + + return AVIERR_OK; +} + +static HRESULT WINAPI IAVIFile_fnWriteData(IAVIFile *iface, DWORD ckid, void *lpData, LONG size) +{ + IAVIFileImpl *This = impl_from_IAVIFile(iface);
TRACE("(%p,0x%08X,%p,%d)\n", iface, ckid, lpData, size);
@@ -425,10 +331,9 @@ return WriteExtraChunk(&This->extra, ckid, lpData, size); }
-static HRESULT WINAPI IAVIFile_fnReadData(IAVIFile *iface, DWORD ckid, - LPVOID lpData, LONG *size) -{ - IAVIFileImpl *This = (IAVIFileImpl *)iface; +static HRESULT WINAPI IAVIFile_fnReadData(IAVIFile *iface, DWORD ckid, void *lpData, LONG *size) +{ + IAVIFileImpl *This = impl_from_IAVIFile(iface);
TRACE("(%p,0x%08X,%p,%p)\n", iface, ckid, lpData, size);
@@ -445,10 +350,9 @@ return AVIERR_OK; }
-static HRESULT WINAPI IAVIFile_fnDeleteStream(IAVIFile *iface, DWORD fccType, - LONG lParam) -{ - IAVIFileImpl *This = (IAVIFileImpl *)iface; +static HRESULT WINAPI IAVIFile_fnDeleteStream(IAVIFile *iface, DWORD fccType, LONG lParam) +{ + IAVIFileImpl *This = impl_from_IAVIFile(iface);
TRACE("(%p,0x%08X,%d)\n", iface, fccType, lParam);
@@ -486,34 +390,46 @@ return AVIERR_OK; }
+static const struct IAVIFileVtbl iwavft = { + 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) -{ - IPersistFileImpl *This = (IPersistFileImpl *)iface; - - assert(This->paf != NULL); - - return IAVIFile_QueryInterface((PAVIFILE)This->paf, refiid, obj); +static inline IAVIFileImpl *impl_from_IPersistFile(IPersistFile *iface) +{ + return CONTAINING_RECORD(iface, IAVIFileImpl, IPersistFile_iface); +} + +static HRESULT WINAPI IPersistFile_fnQueryInterface(IPersistFile *iface, REFIID riid, + void **ret_iface) +{ + IAVIFileImpl *This = impl_from_IPersistFile(iface); + + return IUnknown_QueryInterface(This->outer_unk, riid, ret_iface); }
static ULONG WINAPI IPersistFile_fnAddRef(IPersistFile *iface) { - IPersistFileImpl *This = (IPersistFileImpl *)iface; - - assert(This->paf != NULL); - - return IAVIFile_AddRef((PAVIFILE)This->paf); + IAVIFileImpl *This = impl_from_IPersistFile(iface); + + return IUnknown_AddRef(This->outer_unk); }
static ULONG WINAPI IPersistFile_fnRelease(IPersistFile *iface) { - IPersistFileImpl *This = (IPersistFileImpl *)iface; - - assert(This->paf != NULL); - - return IAVIFile_Release((PAVIFILE)This->paf); + IAVIFileImpl *This = impl_from_IPersistFile(iface); + + return IUnknown_Release(This->outer_unk); }
static HRESULT WINAPI IPersistFile_fnGetClassID(IPersistFile *iface, @@ -531,20 +447,16 @@
static HRESULT WINAPI IPersistFile_fnIsDirty(IPersistFile *iface) { - IPersistFileImpl *This = (IPersistFileImpl *)iface; - - TRACE("(%p)\n", iface); - - assert(This->paf != NULL); - - return (This->paf->fDirty ? S_OK : S_FALSE); -} - -static HRESULT WINAPI IPersistFile_fnLoad(IPersistFile *iface, - LPCOLESTR pszFileName, DWORD dwMode) -{ - IAVIFileImpl *This = ((IPersistFileImpl*)iface)->paf; - + IAVIFileImpl *This = impl_from_IPersistFile(iface); + + TRACE("(%p)\n", iface); + + return (This->fDirty ? S_OK : S_FALSE); +} + +static HRESULT WINAPI IPersistFile_fnLoad(IPersistFile *iface, LPCOLESTR pszFileName, DWORD dwMode) +{ + IAVIFileImpl *This = impl_from_IPersistFile(iface); WCHAR wszStreamFmt[50]; INT len;
@@ -554,7 +466,6 @@ if (pszFileName == NULL) return AVIERR_BADPARAM;
- assert(This != NULL); if (This->hmmio != NULL) return AVIERR_ERROR; /* No reuse of this object for another file! */
@@ -626,10 +537,9 @@ return AVIERR_OK; }
-static HRESULT WINAPI IPersistFile_fnGetCurFile(IPersistFile *iface, - LPOLESTR *ppszFileName) -{ - IPersistFileImpl *This = (IPersistFileImpl *)iface; +static HRESULT WINAPI IPersistFile_fnGetCurFile(IPersistFile *iface, LPOLESTR *ppszFileName) +{ + IAVIFileImpl *This = impl_from_IPersistFile(iface);
TRACE("(%p,%p)\n", iface, ppszFileName);
@@ -638,49 +548,57 @@
*ppszFileName = NULL;
- assert(This->paf != NULL); - - if (This->paf->szFileName != NULL) { - int len = lstrlenW(This->paf->szFileName) + 1; + if (This->szFileName) { + int len = lstrlenW(This->szFileName) + 1;
*ppszFileName = CoTaskMemAlloc(len * sizeof(WCHAR)); if (*ppszFileName == NULL) return AVIERR_MEMORY;
- strcpyW(*ppszFileName, This->paf->szFileName); - } - - return AVIERR_OK; -} + strcpyW(*ppszFileName, This->szFileName); + } + + return AVIERR_OK; +} + +static const struct IPersistFileVtbl iwavpft = { + 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) -{ - IAVIStreamImpl *This = (IAVIStreamImpl *)iface; - - assert(This->paf != NULL); - - return IAVIFile_QueryInterface((PAVIFILE)This->paf, refiid, obj); +static inline IAVIFileImpl *impl_from_IAVIStream(IAVIStream *iface) +{ + return CONTAINING_RECORD(iface, IAVIFileImpl, IAVIStream_iface); +} + +static HRESULT WINAPI IAVIStream_fnQueryInterface(IAVIStream *iface, REFIID riid, void **ret_iface) +{ + IAVIFileImpl *This = impl_from_IAVIStream(iface); + + return IUnknown_QueryInterface(This->outer_unk, riid, ret_iface); }
static ULONG WINAPI IAVIStream_fnAddRef(IAVIStream *iface) { - IAVIStreamImpl *This = (IAVIStreamImpl *)iface; - - assert(This->paf != NULL); - - return IAVIFile_AddRef((PAVIFILE)This->paf); + IAVIFileImpl *This = impl_from_IAVIStream(iface); + + return IUnknown_AddRef(This->outer_unk); }
static ULONG WINAPI IAVIStream_fnRelease(IAVIStream* iface) { - IAVIStreamImpl *This = (IAVIStreamImpl *)iface; - - assert(This->paf != NULL); - - return IAVIFile_Release((PAVIFILE)This->paf); + IAVIFileImpl *This = impl_from_IAVIStream(iface); + + return IUnknown_Release(This->outer_unk); }
static HRESULT WINAPI IAVIStream_fnCreate(IAVIStream *iface, LPARAM lParam1, @@ -692,10 +610,9 @@ return AVIERR_UNSUPPORTED; }
-static HRESULT WINAPI IAVIStream_fnInfo(IAVIStream *iface,LPAVISTREAMINFOW psi, - LONG size) -{ - IAVIStreamImpl *This = (IAVIStreamImpl *)iface; +static HRESULT WINAPI IAVIStream_fnInfo(IAVIStream *iface, AVISTREAMINFOW *psi, LONG size) +{ + IAVIFileImpl *This = impl_from_IAVIStream(iface);
TRACE("(%p,%p,%d)\n", iface, psi, size);
@@ -704,17 +621,16 @@ if (size < 0) return AVIERR_BADSIZE;
- memcpy(psi, &This->paf->sInfo, min((DWORD)size, sizeof(This->paf->sInfo))); - - if ((DWORD)size < sizeof(This->paf->sInfo)) + memcpy(psi, &This->sInfo, min((DWORD)size, sizeof(This->sInfo))); + + if ((DWORD)size < sizeof(This->sInfo)) return AVIERR_BUFFERTOOSMALL; return AVIERR_OK; }
-static LONG WINAPI IAVIStream_fnFindSample(IAVIStream *iface, LONG pos, - LONG flags) -{ - IAVIFileImpl *This = ((IAVIStreamImpl*)iface)->paf; +static LONG WINAPI IAVIStream_fnFindSample(IAVIStream *iface, LONG pos, LONG flags) +{ + IAVIFileImpl *This = impl_from_IAVIStream(iface);
TRACE("(%p,%d,0x%08X)\n",iface,pos,flags);
@@ -748,10 +664,10 @@ return pos; }
-static HRESULT WINAPI IAVIStream_fnReadFormat(IAVIStream *iface, LONG pos, - LPVOID format, LONG *formatsize) -{ - IAVIStreamImpl *This = (IAVIStreamImpl *)iface; +static HRESULT WINAPI IAVIStream_fnReadFormat(IAVIStream *iface, LONG pos, void *format, + LONG *formatsize) +{ + IAVIFileImpl *This = impl_from_IAVIStream(iface);
TRACE("(%p,%d,%p,%p)\n", iface, pos, format, formatsize);
@@ -760,26 +676,26 @@
/* only interested in needed buffersize? */ if (format == NULL || *formatsize <= 0) { - *formatsize = This->paf->cbFormat; + *formatsize = This->cbFormat;
return AVIERR_OK; }
/* copy initial format (only as much as will fit) */ - memcpy(format, This->paf->lpFormat, min(*formatsize, This->paf->cbFormat)); - if (*formatsize < This->paf->cbFormat) { - *formatsize = This->paf->cbFormat; + memcpy(format, This->lpFormat, min(*formatsize, This->cbFormat)); + if (*formatsize < This->cbFormat) { + *formatsize = This->cbFormat; return AVIERR_BUFFERTOOSMALL; }
- *formatsize = This->paf->cbFormat; - return AVIERR_OK; -} - -static HRESULT WINAPI IAVIStream_fnSetFormat(IAVIStream *iface, LONG pos, - LPVOID format, LONG formatsize) -{ - IAVIFileImpl *This = ((IAVIStreamImpl*)iface)->paf; + *formatsize = This->cbFormat; + return AVIERR_OK; +} + +static HRESULT WINAPI IAVIStream_fnSetFormat(IAVIStream *iface, LONG pos, void *format, + LONG formatsize) +{ + IAVIFileImpl *This = impl_from_IAVIStream(iface);
TRACE("(%p,%d,%p,%d)\n", iface, pos, format, formatsize);
@@ -831,12 +747,10 @@ return AVIERR_OK; }
-static HRESULT WINAPI IAVIStream_fnRead(IAVIStream *iface, LONG start, - LONG samples, LPVOID buffer, - LONG buffersize, LPLONG bytesread, - LPLONG samplesread) -{ - IAVIFileImpl *This = ((IAVIStreamImpl*)iface)->paf; +static HRESULT WINAPI IAVIStream_fnRead(IAVIStream *iface, LONG start, LONG samples, void *buffer, + LONG buffersize, LONG *bytesread, LONG *samplesread) +{ + IAVIFileImpl *This = impl_from_IAVIStream(iface);
TRACE("(%p,%d,%d,%p,%d,%p,%p)\n", iface, start, samples, buffer, buffersize, bytesread, samplesread); @@ -904,13 +818,10 @@ return AVIERR_OK; }
-static HRESULT WINAPI IAVIStream_fnWrite(IAVIStream *iface, LONG start, - LONG samples, LPVOID buffer, - LONG buffersize, DWORD flags, - LPLONG sampwritten, - LPLONG byteswritten) -{ - IAVIFileImpl *This = ((IAVIStreamImpl*)iface)->paf; +static HRESULT WINAPI IAVIStream_fnWrite(IAVIStream *iface, LONG start, LONG samples, void *buffer, + LONG buffersize, DWORD flags, LONG *sampwritten, LONG *byteswritten) +{ + IAVIFileImpl *This = impl_from_IAVIStream(iface);
TRACE("(%p,%d,%d,%p,%d,0x%08X,%p,%p)\n", iface, start, samples, buffer, buffersize, flags, sampwritten, byteswritten); @@ -939,7 +850,7 @@
/* do we have anything to write? */ if (buffer != NULL && buffersize > 0) { - This->fDirty = 1; + This->fDirty = TRUE;
if (mmioSeek(This->hmmio, This->ckData.dwDataOffset + start * This->sInfo.dwSampleSize, SEEK_SET) == -1) @@ -961,10 +872,9 @@ return AVIERR_OK; }
-static HRESULT WINAPI IAVIStream_fnDelete(IAVIStream *iface, LONG start, - LONG samples) -{ - IAVIFileImpl *This = ((IAVIStreamImpl*)iface)->paf; +static HRESULT WINAPI IAVIStream_fnDelete(IAVIStream *iface, LONG start, LONG samples) +{ + IAVIFileImpl *This = impl_from_IAVIStream(iface);
TRACE("(%p,%d,%d)\n", iface, start, samples);
@@ -1002,27 +912,23 @@ return AVIERR_UNSUPPORTED; }
- This->fDirty = 1; - - return AVIERR_OK; -} - -static HRESULT WINAPI IAVIStream_fnReadData(IAVIStream *iface, DWORD fcc, - LPVOID lp, LPLONG lpread) -{ - IAVIStreamImpl *This = (IAVIStreamImpl *)iface; - - assert(This->paf != NULL); - - return IAVIFile_ReadData((PAVIFILE)This->paf, fcc, lp, lpread); -} - -static HRESULT WINAPI IAVIStream_fnWriteData(IAVIStream *iface, DWORD fcc, - LPVOID lp, LONG size) -{ - IAVIStreamImpl *This = (IAVIStreamImpl *)iface; - - return IAVIFile_WriteData((PAVIFILE)This->paf, fcc, lp, size); + This->fDirty = TRUE; + + return AVIERR_OK; +} + +static HRESULT WINAPI IAVIStream_fnReadData(IAVIStream *iface, DWORD fcc, void *lp, LONG *lpread) +{ + IAVIFileImpl *This = impl_from_IAVIStream(iface); + + return IAVIFile_ReadData(&This->IAVIFile_iface, fcc, lp, lpread); +} + +static HRESULT WINAPI IAVIStream_fnWriteData(IAVIStream *iface, DWORD fcc, void *lp, LONG size) +{ + IAVIFileImpl *This = impl_from_IAVIStream(iface); + + return IAVIFile_WriteData(&This->IAVIFile_iface, fcc, lp, size); }
static HRESULT WINAPI IAVIStream_fnSetInfo(IAVIStream *iface, @@ -1031,6 +937,50 @@ FIXME("(%p,%p,%d): stub\n", iface, info, infolen);
return E_FAIL; +} + +static const struct IAVIStreamVtbl iwavst = { + IAVIStream_fnQueryInterface, + IAVIStream_fnAddRef, + IAVIStream_fnRelease, + IAVIStream_fnCreate, + IAVIStream_fnInfo, + IAVIStream_fnFindSample, + IAVIStream_fnReadFormat, + IAVIStream_fnSetFormat, + IAVIStream_fnRead, + IAVIStream_fnWrite, + IAVIStream_fnDelete, + IAVIStream_fnReadData, + IAVIStream_fnWriteData, + IAVIStream_fnSetInfo +}; + +HRESULT AVIFILE_CreateWAVFile(IUnknown *outer_unk, REFIID riid, void **ret_iface) +{ + IAVIFileImpl *pfile; + HRESULT hr; + + *ret_iface = NULL; + + pfile = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*pfile)); + if (!pfile) + return AVIERR_MEMORY; + + pfile->IUnknown_inner.lpVtbl = &unk_vtbl; + pfile->IAVIFile_iface.lpVtbl = &iwavft; + pfile->IPersistFile_iface.lpVtbl = &iwavpft; + pfile->IAVIStream_iface.lpVtbl = &iwavst; + pfile->ref = 1; + if (outer_unk) + pfile->outer_unk = outer_unk; + else + pfile->outer_unk = &pfile->IUnknown_inner; + + hr = IUnknown_QueryInterface(&pfile->IUnknown_inner, riid, ret_iface); + IUnknown_Release(&pfile->IUnknown_inner); + + return hr; }
/***********************************************************************/ @@ -1206,7 +1156,7 @@ This->lpFormat->nAvgBytesPerSec = This->lpFormat->nBlockAlign * This->lpFormat->nSamplesPerSec;
- This->fDirty = 0; + This->fDirty = FALSE;
This->sInfo.fccType = streamtypeAUDIO; This->sInfo.fccHandler = 0;
Modified: trunk/reactos/media/doc/README.WINE URL: http://svn.reactos.org/svn/reactos/trunk/reactos/media/doc/README.WINE?rev=6... ============================================================================== --- trunk/reactos/media/doc/README.WINE [iso-8859-1] (original) +++ trunk/reactos/media/doc/README.WINE [iso-8859-1] Tue Apr 22 11:31:44 2014 @@ -54,7 +54,7 @@ reactos/dll/win32/atl # Synced to Wine-1.7.1 reactos/dll/win32/atl100 # Synced to Wine-1.7.1 reactos/dll/win32/atl80 # Synced to Wine-1.7.1 -reactos/dll/win32/avifil32 # Synced to Wine-1.7.1 +reactos/dll/win32/avifil32 # Synced to Wine-1.7.17 reactos/dll/win32/bcrypt # Synced to Wine-1.7.1 reactos/dll/win32/browseui # Out of sync reactos/dll/win32/cabinet # Synced to Wine-1.7.1