Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/winegstreamer/gstdemux.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/dlls/winegstreamer/gstdemux.c b/dlls/winegstreamer/gstdemux.c index 5c6266f4bd0..9b47bf4f88c 100644 --- a/dlls/winegstreamer/gstdemux.c +++ b/dlls/winegstreamer/gstdemux.c @@ -823,10 +823,10 @@ static gboolean event_sink(GstPad *pad, GstObject *parent, GstEvent *event)
static DWORD CALLBACK push_data(LPVOID iface) { - LONGLONG maxlen, curlen; struct parser *This = iface; GstMapInfo mapping; GstBuffer *buffer; + LONGLONG maxlen; HRESULT hr;
if (!(buffer = gst_buffer_new_allocate(NULL, 16384, NULL))) @@ -837,10 +837,7 @@ static DWORD CALLBACK push_data(LPVOID iface)
IBaseFilter_AddRef(&This->filter.IBaseFilter_iface);
- if (!This->stop) - IAsyncReader_Length(This->reader, &maxlen, &curlen); - else - maxlen = This->stop; + maxlen = This->stop ? This->stop : This->filesize;
TRACE("Starting..\n"); for (;;) {
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/winegstreamer/gstdemux.c | 35 +++++++++-------------------------- 1 file changed, 9 insertions(+), 26 deletions(-)
diff --git a/dlls/winegstreamer/gstdemux.c b/dlls/winegstreamer/gstdemux.c index 9b47bf4f88c..1701bf58194 100644 --- a/dlls/winegstreamer/gstdemux.c +++ b/dlls/winegstreamer/gstdemux.c @@ -821,13 +821,13 @@ static gboolean event_sink(GstPad *pad, GstObject *parent, GstEvent *event) return TRUE; }
+static GstFlowReturn request_buffer_src(GstPad *pad, GstObject *parent, guint64 offset, guint size, GstBuffer **buffer); + static DWORD CALLBACK push_data(LPVOID iface) { struct parser *This = iface; - GstMapInfo mapping; GstBuffer *buffer; LONGLONG maxlen; - HRESULT hr;
if (!(buffer = gst_buffer_new_allocate(NULL, 16384, NULL))) { @@ -835,8 +835,6 @@ static DWORD CALLBACK push_data(LPVOID iface) return 0; }
- IBaseFilter_AddRef(&This->filter.IBaseFilter_iface); - maxlen = This->stop ? This->stop : This->filesize;
TRACE("Starting..\n"); @@ -848,42 +846,27 @@ static DWORD CALLBACK push_data(LPVOID iface) break; len = min(16384, maxlen - This->nextofs);
- if (!gst_buffer_map_range(buffer, -1, len, &mapping, GST_MAP_WRITE)) - { - ERR("Failed to map buffer.\n"); - break; - } - hr = IAsyncReader_SyncRead(This->reader, This->nextofs, len, mapping.data); - gst_buffer_unmap(buffer, &mapping); - if (hr != S_OK) + if ((ret = request_buffer_src(This->my_src, NULL, This->nextofs, len, &buffer)) < 0) { - ERR("Failed to read data, hr %#x.\n", hr); + ERR("Failed to read data, ret %s.\n", gst_flow_get_name(ret)); break; }
This->nextofs += len;
buffer->duration = buffer->pts = -1; - ret = gst_pad_push(This->my_src, buffer); - if (ret >= 0) - hr = S_OK; - else - ERR("Sending returned: %i\n", ret); - if (ret == GST_FLOW_ERROR) - hr = E_FAIL; - else if (ret == GST_FLOW_FLUSHING) - hr = VFW_E_WRONG_STATE; - if (hr != S_OK) + if ((ret = gst_pad_push(This->my_src, buffer)) < 0) + { + ERR("Failed to push data, ret %s.\n", gst_flow_get_name(ret)); break; + } }
gst_buffer_unref(buffer);
gst_pad_push_event(This->my_src, gst_event_new_eos());
- TRACE("Stopping.. %08x\n", hr); - - IBaseFilter_Release(&This->filter.IBaseFilter_iface); + TRACE("Stopping.\n");
return 0; }
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/winegstreamer/gstdemux.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/dlls/winegstreamer/gstdemux.c b/dlls/winegstreamer/gstdemux.c index 1701bf58194..e73693de939 100644 --- a/dlls/winegstreamer/gstdemux.c +++ b/dlls/winegstreamer/gstdemux.c @@ -829,15 +829,16 @@ static DWORD CALLBACK push_data(LPVOID iface) GstBuffer *buffer; LONGLONG maxlen;
+ GST_DEBUG("Starting push thread."); + if (!(buffer = gst_buffer_new_allocate(NULL, 16384, NULL))) { - ERR("Failed to allocate memory.\n"); + GST_ERROR("Failed to allocate memory."); return 0; }
maxlen = This->stop ? This->stop : This->filesize;
- TRACE("Starting..\n"); for (;;) { ULONG len; int ret; @@ -848,7 +849,7 @@ static DWORD CALLBACK push_data(LPVOID iface)
if ((ret = request_buffer_src(This->my_src, NULL, This->nextofs, len, &buffer)) < 0) { - ERR("Failed to read data, ret %s.\n", gst_flow_get_name(ret)); + GST_ERROR("Failed to read data, ret %s.", gst_flow_get_name(ret)); break; }
@@ -857,7 +858,7 @@ static DWORD CALLBACK push_data(LPVOID iface) buffer->duration = buffer->pts = -1; if ((ret = gst_pad_push(This->my_src, buffer)) < 0) { - ERR("Failed to push data, ret %s.\n", gst_flow_get_name(ret)); + GST_ERROR("Failed to push data, ret %s.", gst_flow_get_name(ret)); break; } } @@ -866,7 +867,7 @@ static DWORD CALLBACK push_data(LPVOID iface)
gst_pad_push_event(This->my_src, gst_event_new_eos());
- TRACE("Stopping.\n"); + GST_DEBUG("Stopping push thread.");
return 0; }
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/winegstreamer/gstdemux.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/dlls/winegstreamer/gstdemux.c b/dlls/winegstreamer/gstdemux.c index e73693de939..a4d49c75a1b 100644 --- a/dlls/winegstreamer/gstdemux.c +++ b/dlls/winegstreamer/gstdemux.c @@ -74,7 +74,7 @@ struct parser pthread_cond_t init_cond; bool no_more_pads, has_duration, error;
- HANDLE push_thread; + pthread_t push_thread;
HANDLE read_thread; pthread_cond_t read_cond, read_done_cond; @@ -823,7 +823,7 @@ static gboolean event_sink(GstPad *pad, GstObject *parent, GstEvent *event)
static GstFlowReturn request_buffer_src(GstPad *pad, GstObject *parent, guint64 offset, guint size, GstBuffer **buffer);
-static DWORD CALLBACK push_data(LPVOID iface) +static void *push_data(void *iface) { struct parser *This = iface; GstBuffer *buffer; @@ -834,7 +834,7 @@ static DWORD CALLBACK push_data(LPVOID iface) if (!(buffer = gst_buffer_new_allocate(NULL, 16384, NULL))) { GST_ERROR("Failed to allocate memory."); - return 0; + return NULL; }
maxlen = This->stop ? This->stop : This->filesize; @@ -869,7 +869,7 @@ static DWORD CALLBACK push_data(LPVOID iface)
GST_DEBUG("Stopping push thread.");
- return 0; + return NULL; }
static GstFlowReturn got_data_sink(GstPad *pad, GstObject *parent, GstBuffer *buffer) @@ -1426,16 +1426,22 @@ static gboolean activate_push(GstPad *pad, gboolean activate) TRACE("Deactivating\n"); IAsyncReader_BeginFlush(This->reader); if (This->push_thread) { - WaitForSingleObject(This->push_thread, -1); - CloseHandle(This->push_thread); - This->push_thread = NULL; + pthread_join(This->push_thread, NULL); + This->push_thread = 0; } IAsyncReader_EndFlush(This->reader); if (This->filter.state == State_Stopped) This->nextofs = This->start; } else if (!This->push_thread) { + int ret; + TRACE("Activating\n"); - This->push_thread = CreateThread(NULL, 0, push_data, This, 0, NULL); + if ((ret = pthread_create(&This->push_thread, NULL, push_data, This))) + { + GST_ERROR("Failed to create push thread: %s", strerror(errno)); + This->push_thread = 0; + return FALSE; + } } LeaveCriticalSection(&This->filter.filter_cs); return TRUE;