Commit 06d72b61 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

winegstreamer: Use strmbase_source_init().

parent d49417c0
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "winuser.h" #include "winuser.h"
#include "dshow.h" #include "dshow.h"
#include "strmif.h" #include "strmif.h"
#include "wine/heap.h"
#include "wine/strmbase.h" #include "wine/strmbase.h"
#define MEDIATIME_FROM_BYTES(x) ((LONGLONG)(x) * 10000000) #define MEDIATIME_FROM_BYTES(x) ((LONGLONG)(x) * 10000000)
......
...@@ -104,7 +104,7 @@ static const IPinVtbl GST_InputPin_Vtbl; ...@@ -104,7 +104,7 @@ static const IPinVtbl GST_InputPin_Vtbl;
static const IBaseFilterVtbl GST_Vtbl; static const IBaseFilterVtbl GST_Vtbl;
static const IQualityControlVtbl GSTOutPin_QualityControl_Vtbl; static const IQualityControlVtbl GSTOutPin_QualityControl_Vtbl;
static HRESULT GST_AddPin(GSTImpl *This, const PIN_INFO *piOutput, const AM_MEDIA_TYPE *amt); static BOOL create_pin(GSTImpl *filter, const PIN_INFO *pin_info, const AM_MEDIA_TYPE *mt);
static HRESULT GST_RemoveOutputPins(GSTImpl *This); static HRESULT GST_RemoveOutputPins(GSTImpl *This);
static HRESULT WINAPI GST_ChangeCurrent(IMediaSeeking *iface); static HRESULT WINAPI GST_ChangeCurrent(IMediaSeeking *iface);
static HRESULT WINAPI GST_ChangeStop(IMediaSeeking *iface); static HRESULT WINAPI GST_ChangeStop(IMediaSeeking *iface);
...@@ -825,9 +825,9 @@ static void init_new_decoded_pad(GstElement *bin, GstPad *pad, GSTImpl *This) ...@@ -825,9 +825,9 @@ static void init_new_decoded_pad(GstElement *bin, GstPad *pad, GSTImpl *This)
return; return;
} }
hr = GST_AddPin(This, &piOutput, &amt); if (!create_pin(This, &piOutput, &amt))
if (FAILED(hr)) { {
ERR("%08x\n", hr); ERR("Failed to allocate memory.\n");
return; return;
} }
...@@ -1771,13 +1771,12 @@ static void free_source_pin(GSTOutPin *pin) ...@@ -1771,13 +1771,12 @@ static void free_source_pin(GSTOutPin *pin)
gst_object_unref(pin->my_sink); gst_object_unref(pin->my_sink);
CloseHandle(pin->caps_event); CloseHandle(pin->caps_event);
DeleteMediaType(pin->pmt); DeleteMediaType(pin->pmt);
FreeMediaType(&pin->pin.pin.mtCurrent);
gst_segment_free(pin->segment); gst_segment_free(pin->segment);
if (pin->gstpool) if (pin->gstpool)
gst_object_unref(pin->gstpool); gst_object_unref(pin->gstpool);
if (pin->pin.pAllocator)
IMemAllocator_Release(pin->pin.pAllocator); strmbase_source_cleanup(&pin->pin);
CoTaskMemFree(pin); heap_free(pin);
} }
static const IPinVtbl GST_OutputPin_Vtbl = { static const IPinVtbl GST_OutputPin_Vtbl = {
...@@ -1811,27 +1810,30 @@ static const BaseOutputPinFuncTable output_BaseOutputFuncTable = { ...@@ -1811,27 +1810,30 @@ static const BaseOutputPinFuncTable output_BaseOutputFuncTable = {
GSTOutPin_DecideAllocator, GSTOutPin_DecideAllocator,
}; };
static HRESULT GST_AddPin(GSTImpl *This, const PIN_INFO *piOutput, const AM_MEDIA_TYPE *amt) static BOOL create_pin(GSTImpl *filter, const PIN_INFO *pin_info, const AM_MEDIA_TYPE *mt)
{ {
HRESULT hr; GSTOutPin *pin, **new_array;
This->ppPins = CoTaskMemRealloc(This->ppPins, (This->cStreams + 1) * sizeof(IPin *));
if (!(new_array = CoTaskMemRealloc(filter->ppPins, (filter->cStreams + 1) * sizeof(*new_array))))
hr = BaseOutputPin_Construct(&GST_OutputPin_Vtbl, sizeof(GSTOutPin), piOutput, &output_BaseOutputFuncTable, &This->filter.csFilter, (IPin**)(This->ppPins + This->cStreams)); return FALSE;
if (SUCCEEDED(hr)) { filter->ppPins = new_array;
GSTOutPin *pin = This->ppPins[This->cStreams];
memset((char*)pin + sizeof(pin->pin), 0, sizeof(GSTOutPin) - sizeof(pin->pin)); if (!(pin = heap_alloc_zero(sizeof(*pin))))
pin->pmt = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE)); return FALSE;
CopyMediaType(pin->pmt, amt);
pin->pin.pin.pinInfo.pFilter = &This->filter.IBaseFilter_iface; strmbase_source_init(&pin->pin, &GST_OutputPin_Vtbl, pin_info,
pin->caps_event = CreateEventW(NULL, 0, 0, NULL); &output_BaseOutputFuncTable, &filter->filter.csFilter);
pin->segment = gst_segment_new(); pin->pmt = CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));
This->cStreams++; CopyMediaType(pin->pmt, mt);
pin->IQualityControl_iface.lpVtbl = &GSTOutPin_QualityControl_Vtbl; pin->caps_event = CreateEventW(NULL, FALSE, FALSE, NULL);
SourceSeeking_Init(&pin->seek, &GST_Seeking_Vtbl, GST_ChangeStop, GST_ChangeCurrent, GST_ChangeRate, &This->filter.csFilter); pin->segment = gst_segment_new();
BaseFilterImpl_IncrementPinVersion(&This->filter); pin->IQualityControl_iface.lpVtbl = &GSTOutPin_QualityControl_Vtbl;
} else SourceSeeking_Init(&pin->seek, &GST_Seeking_Vtbl, GST_ChangeStop,
ERR("Failed with error %x\n", hr); GST_ChangeCurrent, GST_ChangeRate, &filter->filter.csFilter);
return hr; BaseFilterImpl_IncrementPinVersion(&filter->filter);
filter->ppPins[filter->cStreams++] = pin;
return TRUE;
} }
static HRESULT GST_RemoveOutputPins(GSTImpl *This) static HRESULT GST_RemoveOutputPins(GSTImpl *This)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment