[STRMBASE] Sync with Wine Staging 1.9.16. CORE-11866
authorAmine Khaldi <amine.khaldi@reactos.org>
Tue, 23 Aug 2016 19:35:53 +0000 (19:35 +0000)
committerAmine Khaldi <amine.khaldi@reactos.org>
Tue, 23 Aug 2016 19:35:53 +0000 (19:35 +0000)
svn path=/trunk/; revision=72447

reactos/media/doc/README.WINE
reactos/sdk/lib/3rdparty/strmbase/mediatype.c
reactos/sdk/lib/3rdparty/strmbase/qualitycontrol.c
reactos/sdk/lib/3rdparty/strmbase/video.c

index 57e9e57..73c9328 100644 (file)
@@ -252,7 +252,7 @@ In addition the following libs, dlls and source files are mostly based on code p
 from Winehq CVS. If you are looking to update something in these files
 check Wine current sources first as it may already be fixed.
 
-reactos/sdk/lib/3rdparty/strmbase           # Synced to WineStaging-1.9.11
+reactos/sdk/lib/3rdparty/strmbase           # Synced to WineStaging-1.9.16
 
 reactos/sdk/lib/rtl/actctx.c                # Partly synced with WineStaging-1.7.55
 reactos/sdk/lib/rtl/timerqueue.c            # Partly synced with WineStaging-1.7.55
index d032ff7..0a53357 100644 (file)
@@ -104,11 +104,11 @@ HRESULT WINAPI EnumMediaTypes_Construct(BasePin *basePin, BasePin_GetMediaType e
     IEnumMediaTypesImpl * pEnumMediaTypes = CoTaskMemAlloc(sizeof(IEnumMediaTypesImpl));
     AM_MEDIA_TYPE amt;
 
+    *ppEnum = NULL;
+
     if (!pEnumMediaTypes)
-    {
-        *ppEnum = NULL;
         return E_OUTOFMEMORY;
-    }
+
     pEnumMediaTypes->IEnumMediaTypes_iface.lpVtbl = &IEnumMediaTypesImpl_Vtbl;
     pEnumMediaTypes->refCount = 1;
     pEnumMediaTypes->uIndex = 0;
@@ -122,14 +122,13 @@ HRESULT WINAPI EnumMediaTypes_Construct(BasePin *basePin, BasePin_GetMediaType e
 
     pEnumMediaTypes->enumMediaDetails.cMediaTypes = i;
     pEnumMediaTypes->enumMediaDetails.pMediaTypes = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE) * i);
+    memset(pEnumMediaTypes->enumMediaDetails.pMediaTypes, 0, sizeof(AM_MEDIA_TYPE) * i);
     for (i = 0; i < pEnumMediaTypes->enumMediaDetails.cMediaTypes; i++)
     {
         enumFunc(basePin,i,&amt);
         if (FAILED(CopyMediaType(&pEnumMediaTypes->enumMediaDetails.pMediaTypes[i], &amt)))
         {
-            while (i--)
-                FreeMediaType(&pEnumMediaTypes->enumMediaDetails.pMediaTypes[i]);
-            CoTaskMemFree(pEnumMediaTypes->enumMediaDetails.pMediaTypes);
+            IEnumMediaTypes_Release(&pEnumMediaTypes->IEnumMediaTypes_iface);
             return E_OUTOFMEMORY;
         }
     }
index 4c2475c..1905dbc 100644 (file)
 
 #include "strmbase_private.h"
 
-HRESULT QualityControlImpl_Create(IPin *input, IBaseFilter *self, QualityControlImpl **ppv) {
+#define XTIME_FMT "%u.%03u"
+#define XTIME(u) (int)(u/10000000), (int)((u / 10000)%1000)
+
+HRESULT QualityControlImpl_Create(IPin *input, IBaseFilter *self, QualityControlImpl **ppv)
+{
     QualityControlImpl *This;
-    *ppv = HeapAlloc(GetProcessHeap(),0,sizeof(QualityControlImpl));
+    TRACE("%p, %p, %p\n", input, self, ppv);
+    *ppv = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(QualityControlImpl));
     if (!*ppv)
         return E_OUTOFMEMORY;
     This = *ppv;
@@ -35,6 +40,8 @@ HRESULT QualityControlImpl_Create(IPin *input, IBaseFilter *self, QualityControl
     This->self = self;
     This->tonotify = NULL;
     This->clock = NULL;
+    This->current_rstart = This->current_rstop = -1;
+    TRACE("-> %p\n", This);
     return S_OK;
 }
 
@@ -43,26 +50,41 @@ void QualityControlImpl_Destroy(QualityControlImpl *This)
     HeapFree(GetProcessHeap(),0,This);
 }
 
-HRESULT WINAPI QualityControlImpl_QueryInterface(IQualityControl *iface, REFIID riid, void **ppv) {
-    QualityControlImpl *This = (QualityControlImpl*)iface;
+static inline QualityControlImpl *impl_from_IQualityControl(IQualityControl *iface)
+{
+    return CONTAINING_RECORD(iface, QualityControlImpl, IQualityControl_iface);
+}
+
+HRESULT WINAPI QualityControlImpl_QueryInterface(IQualityControl *iface, REFIID riid, void **ppv)
+{
+    QualityControlImpl *This = impl_from_IQualityControl(iface);
     return IBaseFilter_QueryInterface(This->self, riid, ppv);
 }
 
-ULONG WINAPI QualityControlImpl_AddRef(IQualityControl *iface) {
-    QualityControlImpl *This = (QualityControlImpl*)iface;
+ULONG WINAPI QualityControlImpl_AddRef(IQualityControl *iface)
+{
+    QualityControlImpl *This = impl_from_IQualityControl(iface);
     return IBaseFilter_AddRef(This->self);
 }
 
-ULONG WINAPI QualityControlImpl_Release(IQualityControl *iface) {
-    QualityControlImpl *This = (QualityControlImpl*)iface;
+ULONG WINAPI QualityControlImpl_Release(IQualityControl *iface)
+{
+    QualityControlImpl *This = impl_from_IQualityControl(iface);
     return IBaseFilter_Release(This->self);
 }
 
-HRESULT WINAPI QualityControlImpl_Notify(IQualityControl *iface, IBaseFilter *sender, Quality qm) {
+HRESULT WINAPI QualityControlImpl_Notify(IQualityControl *iface, IBaseFilter *sender, Quality qm)
+{
+    QualityControlImpl *This = impl_from_IQualityControl(iface);
     HRESULT hr = S_FALSE;
-    QualityControlImpl *This = (QualityControlImpl*)iface;
+
+    TRACE("%p %p { 0x%x %u " XTIME_FMT " " XTIME_FMT " }\n",
+            This, sender, qm.Type, qm.Proportion,
+            XTIME(qm.Late), XTIME(qm.TimeStamp));
+
     if (This->tonotify)
         return IQualityControl_Notify(This->tonotify, This->self, qm);
+
     if (This->input) {
         IPin *to = NULL;
         IPin_ConnectedTo(This->input, &to);
@@ -76,11 +98,14 @@ HRESULT WINAPI QualityControlImpl_Notify(IQualityControl *iface, IBaseFilter *se
             IPin_Release(to);
         }
     }
+
     return hr;
 }
 
-HRESULT WINAPI QualityControlImpl_SetSink(IQualityControl *iface, IQualityControl *tonotify) {
-    QualityControlImpl *This = (QualityControlImpl*)iface;
+HRESULT WINAPI QualityControlImpl_SetSink(IQualityControl *iface, IQualityControl *tonotify)
+{
+    QualityControlImpl *This = impl_from_IQualityControl(iface);
+    TRACE("%p %p\n", This, tonotify);
     This->tonotify = tonotify;
     return S_OK;
 }
@@ -97,7 +122,9 @@ HRESULT WINAPI QualityControlImpl_SetSink(IQualityControl *iface, IQualityContro
 #define UPDATE_RUNNING_AVG_P(avg,val) DO_RUNNING_AVG(avg,val,16)
 #define UPDATE_RUNNING_AVG_N(avg,val) DO_RUNNING_AVG(avg,val,4)
 
-void QualityControlRender_Start(QualityControlImpl *This, REFERENCE_TIME tStart) {
+void QualityControlRender_Start(QualityControlImpl *This, REFERENCE_TIME tStart)
+{
+    TRACE("%p " XTIME_FMT "\n", This, XTIME(tStart));
     This->avg_render = This->last_in_time = This->last_left = This->avg_duration = This->avg_pt = -1;
     This->clockstart = tStart;
     This->avg_rate = -1.0;
@@ -107,7 +134,9 @@ void QualityControlRender_Start(QualityControlImpl *This, REFERENCE_TIME tStart)
 }
 
 
-void QualityControlRender_SetClock(QualityControlImpl *This, IReferenceClock *clock) {
+void QualityControlRender_SetClock(QualityControlImpl *This, IReferenceClock *clock)
+{
+    TRACE("%p %p\n", This, clock);
     This->clock = clock;
 }
 
@@ -116,6 +145,9 @@ static BOOL QualityControlRender_IsLate(QualityControlImpl *This, REFERENCE_TIME
 {
     REFERENCE_TIME max_lateness = 200000;
 
+    TRACE("%p " XTIME_FMT " " XTIME_FMT " " XTIME_FMT "\n",
+            This, XTIME(jitter), XTIME(start), XTIME(stop));
+
     /* we can add a valid stop time */
     if (stop >= start)
         max_lateness += stop;
@@ -137,8 +169,12 @@ static BOOL QualityControlRender_IsLate(QualityControlImpl *This, REFERENCE_TIME
     return FALSE;
 }
 
-HRESULT QualityControlRender_WaitFor(QualityControlImpl *This, IMediaSample *sample, HANDLE ev) {
+HRESULT QualityControlRender_WaitFor(QualityControlImpl *This, IMediaSample *sample, HANDLE ev)
+{
     REFERENCE_TIME start = -1, stop = -1, jitter = 0;
+
+    TRACE("%p %p %p\n", This, sample, ev);
+
     This->current_rstart = This->current_rstop = -1;
     This->current_jitter = 0;
     if (!This->clock || FAILED(IMediaSample_GetTime(sample, &start, &stop)))
@@ -178,6 +214,8 @@ void QualityControlRender_DoQOS(QualityControlImpl *priv)
     REFERENCE_TIME start, stop, jitter, pt, entered, left, duration;
     double rate;
 
+    TRACE("%p\n", priv);
+
     if (!priv->clock || priv->current_rstart < 0)
         return;
 
@@ -217,14 +255,12 @@ void QualityControlRender_DoQOS(QualityControlImpl *priv)
         pt = priv->avg_pt;
     }
 
-#define XTIME(u) (int)(u/10000000), (int)((u / 10000)%1000)
-    TRACE("start: %u.%03u, entered %u.%03u, left %u.%03u, pt: %u.%03u, "
-          "duration %u.%03u, jitter %u.%03u\n", XTIME(start), XTIME(entered),
+    TRACE("start: " XTIME_FMT ", entered " XTIME_FMT ", left " XTIME_FMT ", pt: " XTIME_FMT ", "
+          "duration " XTIME_FMT ", jitter " XTIME_FMT "\n", XTIME(start), XTIME(entered),
           XTIME(left), XTIME(pt), XTIME(duration), XTIME(jitter));
 
-    TRACE("avg_duration: %u.%03u, avg_pt: %u.%03u, avg_rate: %g\n",
+    TRACE("avg_duration: " XTIME_FMT ", avg_pt: " XTIME_FMT ", avg_rate: %g\n",
       XTIME(priv->avg_duration), XTIME(priv->avg_pt), priv->avg_rate);
-#undef XTIME
 
     /* collect running averages. for first observations, we copy the
     * values */
@@ -277,7 +313,7 @@ void QualityControlRender_DoQOS(QualityControlImpl *priv)
         q.Late = priv->current_jitter;
         q.TimeStamp = priv->current_rstart;
         TRACE("Late: %i from %i, rate: %g\n", (int)(q.Late/10000), (int)(q.TimeStamp/10000), 1./priv->avg_rate);
-        hr = IQualityControl_Notify((IQualityControl *)priv, priv->self, q);
+        hr = IQualityControl_Notify(&priv->IQualityControl_iface, priv->self, q);
         priv->qos_handled = hr == S_OK;
     }
 
@@ -286,15 +322,25 @@ void QualityControlRender_DoQOS(QualityControlImpl *priv)
 }
 
 
-void QualityControlRender_BeginRender(QualityControlImpl *This) {
+void QualityControlRender_BeginRender(QualityControlImpl *This)
+{
+    TRACE("%p\n", This);
+
     This->start = -1;
+
     if (!This->clock)
         return;
+
     IReferenceClock_GetTime(This->clock, &This->start);
+    TRACE("at: " XTIME_FMT "\n", XTIME(This->start));
 }
 
-void QualityControlRender_EndRender(QualityControlImpl *This) {
+void QualityControlRender_EndRender(QualityControlImpl *This)
+{
     REFERENCE_TIME elapsed;
+
+    TRACE("%p\n", This);
+
     if (!This->clock || This->start < 0 || FAILED(IReferenceClock_GetTime(This->clock, &This->stop)))
         return;
 
index 91d5a99..ba147d7 100644 (file)
@@ -358,10 +358,8 @@ HRESULT WINAPI BaseControlVideoImpl_SetSourcePosition(IBasicVideo *iface, LONG L
     BaseControlVideo *This = impl_from_IBasicVideo(iface);
 
     TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This, iface, Left, Top, Width, Height);
-    SourceRect.left = Left;
-    SourceRect.top = Top;
-    SourceRect.right = Left + Width;
-    SourceRect.bottom = Top + Height;
+
+    SetRect(&SourceRect, Left, Top, Left + Width, Top + Height);
     This->pFuncsTable->pfnSetSourceRect(This, &SourceRect);
 
     return S_OK;
@@ -398,10 +396,7 @@ HRESULT WINAPI BaseControlVideoImpl_SetDestinationPosition(IBasicVideo *iface, L
 
     TRACE("(%p/%p)->(%d, %d, %d, %d)\n", This, iface, Left, Top, Width, Height);
 
-    DestRect.left = Left;
-    DestRect.top = Top;
-    DestRect.right = Left + Width;
-    DestRect.bottom = Top + Height;
+    SetRect(&DestRect, Left, Top, Left + Width, Top + Height);
     This->pFuncsTable->pfnSetTargetRect(This, &DestRect);
 
     return S_OK;