avifil32: Basic COM cleanup for the IAVIStream iface.

This commit is contained in:
Michael Stefaniuc 2013-09-02 22:20:01 +02:00 committed by Alexandre Julliard
parent 4135900235
commit 555fbc985c

View File

@ -70,7 +70,7 @@ static HRESULT WINAPI IAVIStream_fnReadData(IAVIStream*iface,DWORD fcc,LPVOID lp
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 = {
static const struct IAVIStreamVtbl avist_vt = {
IAVIStream_fnQueryInterface,
IAVIStream_fnAddRef,
IAVIStream_fnRelease,
@ -90,11 +90,9 @@ static const struct IAVIStreamVtbl iavist = {
typedef struct _IAVIFileImpl IAVIFileImpl;
typedef struct _IAVIStreamImpl {
/* IUnknown stuff */
const IAVIStreamVtbl *lpVtbl;
LONG ref;
IAVIStream IAVIStream_iface;
LONG ref;
/* IAVIStream stuff */
IAVIFileImpl *paf;
DWORD nStream; /* the n-th stream in file */
AVISTREAMINFOW sInfo;
@ -118,6 +116,11 @@ typedef struct _IAVIStreamImpl {
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;
IAVIFile IAVIFile_iface;
@ -338,7 +341,7 @@ static HRESULT WINAPI IAVIFile_fnGetStream(IAVIFile *iface, IAVIStream **avis, D
/* 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;
@ -395,7 +398,7 @@ static HRESULT WINAPI IAVIFile_fnCreateStream(IAVIFile *iface, IAVIStream **avis
AVIFILE_UpdateInfo(This);
/* return it */
*avis = (PAVISTREAM)This->ppStreams[n];
*avis = &This->ppStreams[n]->IAVIStream_iface;
IAVIStream_AddRef(*avis);
return AVIERR_OK;
@ -698,31 +701,35 @@ HRESULT AVIFILE_CreateAVIFile(IUnknown *pUnkOuter, REFIID riid, void **ppv)
}
static HRESULT WINAPI IAVIStream_fnQueryInterface(IAVIStream *iface,
REFIID refiid, LPVOID *obj)
static HRESULT WINAPI IAVIStream_fnQueryInterface(IAVIStream *iface, REFIID riid, void **ppv)
{
IAVIStreamImpl *This = (IAVIStreamImpl *)iface;
IAVIStreamImpl *This = impl_from_IAVIStream(iface);
TRACE("(%p,%s,%p)\n", iface, debugstr_guid(refiid), obj);
TRACE("(%p,%s,%p)\n", This, debugstr_guid(riid), ppv);
if (IsEqualGUID(&IID_IUnknown, refiid) ||
IsEqualGUID(&IID_IAVIStream, refiid)) {
*obj = This;
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)
@ -731,12 +738,12 @@ static ULONG WINAPI IAVIStream_fnAddRef(IAVIStream *iface)
return ref;
}
static ULONG WINAPI IAVIStream_fnRelease(IAVIStream* iface)
static ULONG WINAPI IAVIStream_fnRelease(IAVIStream *iface)
{
IAVIStreamImpl *This = (IAVIStreamImpl *)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);
@ -744,8 +751,7 @@ static ULONG WINAPI IAVIStream_fnRelease(IAVIStream* iface)
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);
@ -753,10 +759,9 @@ static HRESULT WINAPI IAVIStream_fnCreate(IAVIStream *iface, LPARAM lParam1,
return AVIERR_UNSUPPORTED;
}
static HRESULT WINAPI IAVIStream_fnInfo(IAVIStream *iface,LPAVISTREAMINFOW psi,
LONG size)
static HRESULT WINAPI IAVIStream_fnInfo(IAVIStream *iface, AVISTREAMINFOW *psi, LONG size)
{
IAVIStreamImpl *This = (IAVIStreamImpl *)iface;
IAVIStreamImpl *This = impl_from_IAVIStream(iface);
TRACE("(%p,%p,%d)\n", iface, psi, size);
@ -772,11 +777,9 @@ static HRESULT WINAPI IAVIStream_fnInfo(IAVIStream *iface,LPAVISTREAMINFOW psi,
return AVIERR_OK;
}
static LONG WINAPI IAVIStream_fnFindSample(IAVIStream *iface, LONG pos,
LONG flags)
static LONG WINAPI IAVIStream_fnFindSample(IAVIStream *iface, LONG pos, LONG flags)
{
IAVIStreamImpl *This = (IAVIStreamImpl *)iface;
IAVIStreamImpl *This = impl_from_IAVIStream(iface);
LONG offset = 0;
TRACE("(%p,%d,0x%08X)\n",iface,pos,flags);
@ -872,10 +875,10 @@ static LONG WINAPI IAVIStream_fnFindSample(IAVIStream *iface, LONG pos,
return pos;
}
static HRESULT WINAPI IAVIStream_fnReadFormat(IAVIStream *iface, LONG pos,
LPVOID format, LONG *formatsize)
static HRESULT WINAPI IAVIStream_fnReadFormat(IAVIStream *iface, LONG pos, void *format,
LONG *formatsize)
{
IAVIStreamImpl *This = (IAVIStreamImpl *)iface;
IAVIStreamImpl *This = impl_from_IAVIStream(iface);
TRACE("(%p,%d,%p,%p)\n", iface, pos, format, formatsize);
@ -911,12 +914,11 @@ static HRESULT WINAPI IAVIStream_fnReadFormat(IAVIStream *iface, LONG pos,
return AVIERR_OK;
}
static HRESULT WINAPI IAVIStream_fnSetFormat(IAVIStream *iface, LONG pos,
LPVOID format, LONG formatsize)
static HRESULT WINAPI IAVIStream_fnSetFormat(IAVIStream *iface, LONG pos, void *format,
LONG formatsize)
{
IAVIStreamImpl *This = (IAVIStreamImpl *)iface;
LPBITMAPINFOHEADER lpbiNew = format;
IAVIStreamImpl *This = impl_from_IAVIStream(iface);
BITMAPINFOHEADER *lpbiNew = format;
TRACE("(%p,%d,%p,%d)\n", iface, pos, format, formatsize);
@ -1020,15 +1022,12 @@ static HRESULT WINAPI IAVIStream_fnSetFormat(IAVIStream *iface, LONG pos,
}
}
static HRESULT WINAPI IAVIStream_fnRead(IAVIStream *iface, LONG start,
LONG samples, LPVOID buffer,
LONG buffersize, LPLONG bytesread,
LPLONG samplesread)
static HRESULT WINAPI IAVIStream_fnRead(IAVIStream *iface, LONG start, LONG samples, void *buffer,
LONG buffersize, LONG *bytesread, LONG *samplesread)
{
IAVIStreamImpl *This = (IAVIStreamImpl *)iface;
DWORD size;
HRESULT hr;
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);
@ -1142,15 +1141,11 @@ static HRESULT WINAPI IAVIStream_fnRead(IAVIStream *iface, LONG start,
}
}
static HRESULT WINAPI IAVIStream_fnWrite(IAVIStream *iface, LONG start,
LONG samples, LPVOID buffer,
LONG buffersize, DWORD flags,
LPLONG sampwritten,
LPLONG byteswritten)
static HRESULT WINAPI IAVIStream_fnWrite(IAVIStream *iface, LONG start, LONG samples, void *buffer,
LONG buffersize, DWORD flags, LONG *sampwritten, LONG *byteswritten)
{
IAVIStreamImpl *This = (IAVIStreamImpl *)iface;
FOURCC ckid;
IAVIStreamImpl *This = impl_from_IAVIStream(iface);
FOURCC ckid;
HRESULT hr;
TRACE("(%p,%d,%d,%p,%d,0x%08X,%p,%p)\n", iface, start, samples,
@ -1236,10 +1231,9 @@ static HRESULT WINAPI IAVIStream_fnWrite(IAVIStream *iface, LONG start,
return hr;
}
static HRESULT WINAPI IAVIStream_fnDelete(IAVIStream *iface, LONG start,
LONG samples)
static HRESULT WINAPI IAVIStream_fnDelete(IAVIStream *iface, LONG start, LONG samples)
{
IAVIStreamImpl *This = (IAVIStreamImpl *)iface;
IAVIStreamImpl *This = impl_from_IAVIStream(iface);
FIXME("(%p,%d,%d): stub\n", iface, start, samples);
@ -1275,10 +1269,9 @@ static HRESULT WINAPI IAVIStream_fnDelete(IAVIStream *iface, LONG start,
return AVIERR_UNSUPPORTED;
}
static HRESULT WINAPI IAVIStream_fnReadData(IAVIStream *iface, DWORD fcc,
LPVOID lp, LPLONG lpread)
static HRESULT WINAPI IAVIStream_fnReadData(IAVIStream *iface, DWORD fcc, void *lp, LONG *lpread)
{
IAVIStreamImpl *This = (IAVIStreamImpl *)iface;
IAVIStreamImpl *This = impl_from_IAVIStream(iface);
TRACE("(%p,0x%08X,%p,%p)\n", iface, fcc, lp, lpread);
@ -1299,10 +1292,9 @@ static HRESULT WINAPI IAVIStream_fnReadData(IAVIStream *iface, DWORD fcc,
return ReadExtraChunk(&This->extra, fcc, lp, lpread);
}
static HRESULT WINAPI IAVIStream_fnWriteData(IAVIStream *iface, DWORD fcc,
LPVOID lp, LONG size)
static HRESULT WINAPI IAVIStream_fnWriteData(IAVIStream *iface, DWORD fcc, void *lp, LONG size)
{
IAVIStreamImpl *This = (IAVIStreamImpl *)iface;
IAVIStreamImpl *This = impl_from_IAVIStream(iface);
TRACE("(%p,0x%08x,%p,%d)\n", iface, fcc, lp, size);
@ -1347,8 +1339,7 @@ static HRESULT WINAPI IAVIStream_fnWriteData(IAVIStream *iface, DWORD fcc,
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);
@ -1514,7 +1505,7 @@ static void AVIFILE_ConstructAVIStream(IAVIFileImpl *paf, DWORD nr, const AVISTR
pstream = paf->ppStreams[nr];
pstream->lpVtbl = &iavist;
pstream->IAVIStream_iface.lpVtbl = &avist_vt;
pstream->ref = 0;
pstream->paf = paf;
pstream->nStream = nr;
@ -2353,7 +2344,7 @@ static HRESULT AVIFILE_SaveIndex(const IAVIFileImpl *This)
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);
@ -2523,8 +2514,8 @@ static void AVIFILE_UpdateInfo(IAVIFileImpl *This)
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;
}