Maarten Lankhorst wrote:
This patch fixes AM_MEDIA_TYPE->pbFormat not being handled correctly, unfortunately, this also means some stuff has to be rewritten to avoid memleaks, instead of CoTaskMemFree(AM_MEDIA_TYPE), DeleteMediaType has to be used.. This also fixes the errors i had with msn webcam, i feel like i stumbled over every bug in quartz now......
@@ -45,6 +46,7 @@ void DeleteMediaType(AM_MEDIA_TYPE * pMe IUnknown_Release(pMediaType->pUnk); pMediaType->pUnk = NULL; }
- CoTaskMemFree(pMediaType);
}
BOOL CompareMediaTypes(const AM_MEDIA_TYPE * pmt1, const AM_MEDIA_TYPE * pmt2, BOOL bWildcards)
This change is wrong. DeleteMediaType is not supposed to free the memory used for the AM_MEDIA_TYPE structure itself as the function is also used in places where the AM_MEDIA_TYPE was not allocated using CoTaskMemAlloc.
Rob
Robert Shearman wrote:
Maarten Lankhorst wrote:
This patch fixes AM_MEDIA_TYPE->pbFormat not being handled correctly, unfortunately, this also means some stuff has to be rewritten to avoid memleaks, instead of CoTaskMemFree(AM_MEDIA_TYPE), DeleteMediaType has to be used.. This also fixes the errors i had with msn webcam, i feel like i stumbled over every bug in quartz now......
@@ -45,6 +46,7 @@ void DeleteMediaType(AM_MEDIA_TYPE * pMe IUnknown_Release(pMediaType->pUnk); pMediaType->pUnk = NULL; }
- CoTaskMemFree(pMediaType);
}
BOOL CompareMediaTypes(const AM_MEDIA_TYPE * pmt1, const AM_MEDIA_TYPE * pmt2, BOOL bWildcards)
This change is wrong. DeleteMediaType is not supposed to free the memory used for the AM_MEDIA_TYPE structure itself as the function is also used in places where the AM_MEDIA_TYPE was not allocated using CoTaskMemAlloc.
Rob
This change is right, if you don't want to release the format block you need to use freemediatype... quoting msdn...
*DeleteMediaType*
The **DeleteMediaType* *function deletes an allocated *AM_MEDIA_TYPE* http://msdn.microsoft.com/library/en-us/directshow/htm/am_media_typestructure.asp structure, including the format block.
*Syntax*
|*void WINAPI *DeleteMediaType*( * *AM_MEDIA_TYPE* /*pmt/ *);* |
*Parameters*
/pmt /
Pointer to an *AM_MEDIA_TYPE* structure.
*Return Value*
No return value.
*Remarks*
Use this function to release any media type structure that was allocated using either *CoTaskMemAlloc* or *CreateMediaType* http://msdn.microsoft.com/library/en-us/directshow/htm/createmediatype.asp.
If you prefer not to link to the base class library, you can use the following code directly:
|void MyDeleteMediaType(AM_MEDIA_TYPE *pmt) { if (pmt != NULL) { MyFreeMediaType(*pmt); // See FreeMediaType for the implementation. CoTaskMemFree(pmt); } } |
*Requirements*
* Header:* Declared in Mtype.h; include Streams.h.
* Library:* Use Strmbase.lib (retail builds) or Strmbasd.lib (debug builds).
Maarten Lankhorst wrote:
Robert Shearman wrote:
Maarten Lankhorst wrote:
This patch fixes AM_MEDIA_TYPE->pbFormat not being handled correctly, unfortunately, this also means some stuff has to be rewritten to avoid memleaks, instead of CoTaskMemFree(AM_MEDIA_TYPE), DeleteMediaType has to be used.. This also fixes the errors i had with msn webcam, i feel like i stumbled over every bug in quartz now......
@@ -45,6 +46,7 @@ void DeleteMediaType(AM_MEDIA_TYPE * pMe IUnknown_Release(pMediaType->pUnk); pMediaType->pUnk = NULL; }
- CoTaskMemFree(pMediaType);
}
BOOL CompareMediaTypes(const AM_MEDIA_TYPE * pmt1, const AM_MEDIA_TYPE * pmt2, BOOL bWildcards)
This change is wrong. DeleteMediaType is not supposed to free the memory used for the AM_MEDIA_TYPE structure itself as the function is also used in places where the AM_MEDIA_TYPE was not allocated using CoTaskMemAlloc.
Rob
This change is right, if you don't want to release the format block you need to use freemediatype... quoting msdn...
Ok, the way it was designed in Wine didn't match the DShow SDK way. You still need to fix up the callers before making this change then.
Rob