Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/winegstreamer/gst_private.h | 1 + dlls/winegstreamer/gstdemux.c | 6 ------ dlls/winegstreamer/wg_parser.c | 5 +++++ 3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/dlls/winegstreamer/gst_private.h b/dlls/winegstreamer/gst_private.h index 33c87f2c1ec..2ac10ee37d3 100644 --- a/dlls/winegstreamer/gst_private.h +++ b/dlls/winegstreamer/gst_private.h @@ -145,6 +145,7 @@ struct wg_parser GstPad *my_src, *their_sink;
guint64 file_size, start_offset, next_offset, stop_offset; + guint64 next_pull_offset;
pthread_t push_thread;
diff --git a/dlls/winegstreamer/gstdemux.c b/dlls/winegstreamer/gstdemux.c index 4e476c78e9e..a4164ab643b 100644 --- a/dlls/winegstreamer/gstdemux.c +++ b/dlls/winegstreamer/gstdemux.c @@ -66,8 +66,6 @@ struct parser * separate lock. */ bool streaming, sink_connected;
- uint64_t next_pull_offset; - HANDLE read_thread;
BOOL (*init_gst)(struct parser *filter); @@ -796,8 +794,6 @@ static GstFlowReturn read_buffer(struct parser *This, guint64 ofs, guint len, Gs
TRACE("filter %p, offset %s, length %u, buffer %p.\n", This, wine_dbgstr_longlong(ofs), len, buffer);
- if (ofs == GST_BUFFER_OFFSET_NONE) - ofs = This->next_pull_offset; if (ofs >= This->file_size) { WARN("Reading past eof: %s, %u\n", wine_dbgstr_longlong(ofs), len); @@ -805,7 +801,6 @@ static GstFlowReturn read_buffer(struct parser *This, guint64 ofs, guint len, Gs } if (len + ofs > This->file_size) len = This->file_size - ofs; - This->next_pull_offset = ofs + len;
gst_buffer_map(buffer, &info, GST_MAP_WRITE); hr = IAsyncReader_SyncRead(This->reader, ofs, len, info.data); @@ -998,7 +993,6 @@ static HRESULT parser_sink_connect(struct strmbase_sink *iface, IPin *peer, cons
filter->sink_connected = true; filter->read_thread = CreateThread(NULL, 0, read_thread, filter, 0, NULL); - filter->next_pull_offset = 0;
if (FAILED(hr = unix_funcs->wg_parser_connect(filter->wg_parser, filter->file_size))) goto err; diff --git a/dlls/winegstreamer/wg_parser.c b/dlls/winegstreamer/wg_parser.c index 96c6fc1e715..f2f878ffabc 100644 --- a/dlls/winegstreamer/wg_parser.c +++ b/dlls/winegstreamer/wg_parser.c @@ -989,6 +989,10 @@ static GstFlowReturn request_buffer_src(GstPad *pad, GstObject *parent, guint64
GST_LOG("pad %p, offset %" G_GINT64_MODIFIER "u, length %u, buffer %p.", pad, offset, size, *buffer);
+ if (offset == GST_BUFFER_OFFSET_NONE) + offset = parser->next_pull_offset; + parser->next_pull_offset = offset + size; + if (!*buffer) *buffer = new_buffer = gst_buffer_new_and_alloc(size);
@@ -1325,6 +1329,7 @@ static HRESULT CDECL wg_parser_connect(struct wg_parser *parser, uint64_t file_s gst_pad_set_element_private(parser->my_src, parser);
parser->start_offset = parser->next_offset = parser->stop_offset = 0; + parser->next_pull_offset = 0;
if (!parser->init_gst(parser)) return E_FAIL;
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/winegstreamer/gstdemux.c | 8 -------- dlls/winegstreamer/wg_parser.c | 4 ++++ 2 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/dlls/winegstreamer/gstdemux.c b/dlls/winegstreamer/gstdemux.c index a4164ab643b..53977ed52c4 100644 --- a/dlls/winegstreamer/gstdemux.c +++ b/dlls/winegstreamer/gstdemux.c @@ -794,14 +794,6 @@ static GstFlowReturn read_buffer(struct parser *This, guint64 ofs, guint len, Gs
TRACE("filter %p, offset %s, length %u, buffer %p.\n", This, wine_dbgstr_longlong(ofs), len, buffer);
- if (ofs >= This->file_size) - { - WARN("Reading past eof: %s, %u\n", wine_dbgstr_longlong(ofs), len); - return GST_FLOW_EOS; - } - if (len + ofs > This->file_size) - len = This->file_size - ofs; - gst_buffer_map(buffer, &info, GST_MAP_WRITE); hr = IAsyncReader_SyncRead(This->reader, ofs, len, info.data); gst_buffer_unmap(buffer, &info); diff --git a/dlls/winegstreamer/wg_parser.c b/dlls/winegstreamer/wg_parser.c index f2f878ffabc..9fb3c4383fc 100644 --- a/dlls/winegstreamer/wg_parser.c +++ b/dlls/winegstreamer/wg_parser.c @@ -992,6 +992,10 @@ static GstFlowReturn request_buffer_src(GstPad *pad, GstObject *parent, guint64 if (offset == GST_BUFFER_OFFSET_NONE) offset = parser->next_pull_offset; parser->next_pull_offset = offset + size; + if (offset >= parser->file_size) + return GST_FLOW_EOS; + if (offset + size >= parser->file_size) + size = parser->file_size - offset;
if (!*buffer) *buffer = new_buffer = gst_buffer_new_and_alloc(size);
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/winegstreamer/gst_private.h | 8 ++++---- dlls/winegstreamer/gstdemux.c | 29 +++++------------------------ dlls/winegstreamer/wg_parser.c | 27 ++++++++++++++++----------- 3 files changed, 25 insertions(+), 39 deletions(-)
diff --git a/dlls/winegstreamer/gst_private.h b/dlls/winegstreamer/gst_private.h index 2ac10ee37d3..31fca81ce6c 100644 --- a/dlls/winegstreamer/gst_private.h +++ b/dlls/winegstreamer/gst_private.h @@ -157,11 +157,11 @@ struct wg_parser pthread_cond_t read_cond, read_done_cond; struct { - GstBuffer *buffer; + void *data; uint64_t offset; uint32_t size; bool done; - GstFlowReturn ret; + bool ret; } read_request;
bool flushing, sink_connected; @@ -228,8 +228,8 @@ struct unix_funcs void (CDECL *wg_parser_end_flush)(struct wg_parser *parser);
bool (CDECL *wg_parser_get_read_request)(struct wg_parser *parser, - GstBuffer **buffer, uint64_t *offset, uint32_t *size); - void (CDECL *wg_parser_complete_read_request)(struct wg_parser *parser, GstFlowReturn ret); + void **data, uint64_t *offset, uint32_t *size); + void (CDECL *wg_parser_complete_read_request)(struct wg_parser *parser, bool ret);
uint32_t (CDECL *wg_parser_get_stream_count)(struct wg_parser *parser); struct wg_parser_stream *(CDECL *wg_parser_get_stream)(struct wg_parser *parser, uint32_t index); diff --git a/dlls/winegstreamer/gstdemux.c b/dlls/winegstreamer/gstdemux.c index 53977ed52c4..ab901a34843 100644 --- a/dlls/winegstreamer/gstdemux.c +++ b/dlls/winegstreamer/gstdemux.c @@ -787,25 +787,6 @@ static DWORD CALLBACK stream_thread(void *arg) return 0; }
-static GstFlowReturn read_buffer(struct parser *This, guint64 ofs, guint len, GstBuffer *buffer) -{ - HRESULT hr; - GstMapInfo info; - - TRACE("filter %p, offset %s, length %u, buffer %p.\n", This, wine_dbgstr_longlong(ofs), len, buffer); - - gst_buffer_map(buffer, &info, GST_MAP_WRITE); - hr = IAsyncReader_SyncRead(This->reader, ofs, len, info.data); - gst_buffer_unmap(buffer, &info); - if (FAILED(hr)) - { - ERR("Failed to read data, hr %#x.\n", hr); - return GST_FLOW_ERROR; - } - - return GST_FLOW_OK; -} - static DWORD CALLBACK read_thread(void *arg) { struct parser *filter = arg; @@ -814,15 +795,15 @@ static DWORD CALLBACK read_thread(void *arg)
while (filter->sink_connected) { - GstBuffer *buffer; uint64_t offset; uint32_t size; + HRESULT hr; + void *data;
- if (!unix_funcs->wg_parser_get_read_request(filter->wg_parser, &buffer, &offset, &size)) + if (!unix_funcs->wg_parser_get_read_request(filter->wg_parser, &data, &offset, &size)) continue; - - unix_funcs->wg_parser_complete_read_request(filter->wg_parser, - read_buffer(filter, offset, size, buffer)); + hr = IAsyncReader_SyncRead(filter->reader, offset, size, data); + unix_funcs->wg_parser_complete_read_request(filter->wg_parser, SUCCEEDED(hr)); }
TRACE("Streaming stopped; exiting.\n"); diff --git a/dlls/winegstreamer/wg_parser.c b/dlls/winegstreamer/wg_parser.c index 9fb3c4383fc..ccd60853007 100644 --- a/dlls/winegstreamer/wg_parser.c +++ b/dlls/winegstreamer/wg_parser.c @@ -350,11 +350,11 @@ static void CDECL wg_parser_end_flush(struct wg_parser *parser) }
static bool CDECL wg_parser_get_read_request(struct wg_parser *parser, - GstBuffer **buffer, uint64_t *offset, uint32_t *size) + void **data, uint64_t *offset, uint32_t *size) { pthread_mutex_lock(&parser->mutex);
- while (parser->sink_connected && !parser->read_request.buffer) + while (parser->sink_connected && !parser->read_request.data) pthread_cond_wait(&parser->read_cond, &parser->mutex);
if (!parser->sink_connected) @@ -363,7 +363,7 @@ static bool CDECL wg_parser_get_read_request(struct wg_parser *parser, return false; }
- *buffer = parser->read_request.buffer; + *data = parser->read_request.data; *offset = parser->read_request.offset; *size = parser->read_request.size;
@@ -371,12 +371,12 @@ static bool CDECL wg_parser_get_read_request(struct wg_parser *parser, return true; }
-static void CDECL wg_parser_complete_read_request(struct wg_parser *parser, GstFlowReturn ret) +static void CDECL wg_parser_complete_read_request(struct wg_parser *parser, bool ret) { pthread_mutex_lock(&parser->mutex); parser->read_request.done = true; parser->read_request.ret = ret; - parser->read_request.buffer = NULL; + parser->read_request.data = NULL; pthread_mutex_unlock(&parser->mutex); pthread_cond_signal(&parser->read_done_cond); } @@ -985,7 +985,8 @@ static GstFlowReturn request_buffer_src(GstPad *pad, GstObject *parent, guint64 { struct wg_parser *parser = gst_pad_get_element_private(pad); GstBuffer *new_buffer = NULL; - GstFlowReturn ret; + GstMapInfo map_info; + bool ret;
GST_LOG("pad %p, offset %" G_GINT64_MODIFIER "u, length %u, buffer %p.", pad, offset, size, *buffer);
@@ -1000,10 +1001,12 @@ static GstFlowReturn request_buffer_src(GstPad *pad, GstObject *parent, guint64 if (!*buffer) *buffer = new_buffer = gst_buffer_new_and_alloc(size);
+ gst_buffer_map(*buffer, &map_info, GST_MAP_WRITE); + pthread_mutex_lock(&parser->mutex);
- assert(!parser->read_request.buffer); - parser->read_request.buffer = *buffer; + assert(!parser->read_request.data); + parser->read_request.data = map_info.data; parser->read_request.offset = offset; parser->read_request.size = size; parser->read_request.done = false; @@ -1020,12 +1023,14 @@ static GstFlowReturn request_buffer_src(GstPad *pad, GstObject *parent, guint64
pthread_mutex_unlock(&parser->mutex);
- GST_LOG("Request returned %s.", gst_flow_get_name(ret)); + gst_buffer_unmap(*buffer, &map_info);
- if (ret != GST_FLOW_OK && new_buffer) + GST_LOG("Request returned %d.", ret); + + if (!ret && new_buffer) gst_buffer_unref(new_buffer);
- return ret; + return ret ? GST_FLOW_OK : GST_FLOW_ERROR; }
static gboolean query_function(GstPad *pad, GstObject *parent, GstQuery *query)
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/winegstreamer/gst_private.h | 2 ++ dlls/winegstreamer/gstdemux.c | 2 +- dlls/winegstreamer/wg_parser.c | 6 ++++++ 3 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/dlls/winegstreamer/gst_private.h b/dlls/winegstreamer/gst_private.h index 31fca81ce6c..e90de8803e5 100644 --- a/dlls/winegstreamer/gst_private.h +++ b/dlls/winegstreamer/gst_private.h @@ -245,6 +245,8 @@ struct unix_funcs void (CDECL *wg_parser_stream_notify_qos)(struct wg_parser_stream *stream, bool underflow, double proportion, int64_t diff, uint64_t timestamp);
+ /* Returns the duration in 100-nanosecond units. */ + uint64_t (CDECL *wg_parser_stream_get_duration)(struct wg_parser_stream *stream); /* start_pos and stop_pos are in 100-nanosecond units. */ bool (CDECL *wg_parser_stream_seek)(struct wg_parser_stream *stream, double rate, uint64_t start_pos, uint64_t stop_pos, DWORD start_flags, DWORD stop_flags); diff --git a/dlls/winegstreamer/gstdemux.c b/dlls/winegstreamer/gstdemux.c index ab901a34843..3bea994521b 100644 --- a/dlls/winegstreamer/gstdemux.c +++ b/dlls/winegstreamer/gstdemux.c @@ -977,7 +977,7 @@ static HRESULT parser_sink_connect(struct strmbase_sink *iface, IPin *peer, cons { struct parser_source *pin = filter->sources[i];
- pin->seek.llDuration = pin->seek.llStop = pin->wg_stream->duration; + pin->seek.llDuration = pin->seek.llStop = unix_funcs->wg_parser_stream_get_duration(pin->wg_stream); pin->seek.llCurrent = 0; }
diff --git a/dlls/winegstreamer/wg_parser.c b/dlls/winegstreamer/wg_parser.c index ccd60853007..5d10ddf753c 100644 --- a/dlls/winegstreamer/wg_parser.c +++ b/dlls/winegstreamer/wg_parser.c @@ -492,6 +492,11 @@ static void CDECL wg_parser_stream_release_buffer(struct wg_parser_stream *strea pthread_cond_signal(&stream->event_empty_cond); }
+static uint64_t CDECL wg_parser_stream_get_duration(struct wg_parser_stream *stream) +{ + return stream->duration; +} + static bool CDECL wg_parser_stream_seek(struct wg_parser_stream *stream, double rate, uint64_t start_pos, uint64_t stop_pos, DWORD start_flags, DWORD stop_flags) { @@ -1724,6 +1729,7 @@ static const struct unix_funcs funcs = wg_parser_stream_release_buffer, wg_parser_stream_notify_qos,
+ wg_parser_stream_get_duration, wg_parser_stream_seek, };
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/winegstreamer/gstdemux.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/dlls/winegstreamer/gstdemux.c b/dlls/winegstreamer/gstdemux.c index 3bea994521b..d85bb02160e 100644 --- a/dlls/winegstreamer/gstdemux.c +++ b/dlls/winegstreamer/gstdemux.c @@ -864,12 +864,11 @@ static void parser_destroy(struct strmbase_filter *iface) static HRESULT parser_init_stream(struct strmbase_filter *iface) { struct parser *filter = impl_from_strmbase_filter(iface); - struct wg_parser *parser = filter->wg_parser; DWORD stop_flags = AM_SEEKING_NoPositioning; const SourceSeeking *seeking; unsigned int i;
- if (!parser->container) + if (!filter->sink_connected) return S_OK;
filter->streaming = true; @@ -903,10 +902,9 @@ static HRESULT parser_init_stream(struct strmbase_filter *iface) static HRESULT parser_cleanup_stream(struct strmbase_filter *iface) { struct parser *filter = impl_from_strmbase_filter(iface); - struct wg_parser *parser = filter->wg_parser; unsigned int i;
- if (!parser->container) + if (!filter->sink_connected) return S_OK;
filter->streaming = false;
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/winegstreamer/gst_private.h | 52 -------------------------------- dlls/winegstreamer/wg_parser.c | 52 ++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 52 deletions(-)
diff --git a/dlls/winegstreamer/gst_private.h b/dlls/winegstreamer/gst_private.h index e90de8803e5..75025fdf7d5 100644 --- a/dlls/winegstreamer/gst_private.h +++ b/dlls/winegstreamer/gst_private.h @@ -133,40 +133,6 @@ struct wg_format } u; };
-struct wg_parser -{ - BOOL (*init_gst)(struct wg_parser *parser); - - struct wg_parser_stream **streams; - unsigned int stream_count; - - GstElement *container; - GstBus *bus; - GstPad *my_src, *their_sink; - - guint64 file_size, start_offset, next_offset, stop_offset; - guint64 next_pull_offset; - - pthread_t push_thread; - - pthread_mutex_t mutex; - - pthread_cond_t init_cond; - bool no_more_pads, has_duration, error; - - pthread_cond_t read_cond, read_done_cond; - struct - { - void *data; - uint64_t offset; - uint32_t size; - bool done; - bool ret; - } read_request; - - bool flushing, sink_connected; -}; - enum wg_parser_event_type { WG_PARSER_EVENT_NONE = 0, @@ -195,24 +161,6 @@ struct wg_parser_event } u; };
-struct wg_parser_stream -{ - struct wg_parser *parser; - - GstPad *their_src, *post_sink, *post_src, *my_sink; - GstElement *flip; - struct wg_format preferred_format, current_format; - - pthread_cond_t event_cond, event_empty_cond; - struct wg_parser_event event; - GstBuffer *buffer; - GstMapInfo map_info; - - bool flushing, eos, enabled, has_caps; - - uint64_t duration; -}; - struct unix_funcs { struct wg_parser *(CDECL *wg_decodebin_parser_create)(void); diff --git a/dlls/winegstreamer/wg_parser.c b/dlls/winegstreamer/wg_parser.c index 5d10ddf753c..272029217a9 100644 --- a/dlls/winegstreamer/wg_parser.c +++ b/dlls/winegstreamer/wg_parser.c @@ -36,6 +36,58 @@ WINE_DEFAULT_DEBUG_CHANNEL(gstreamer); GST_DEBUG_CATEGORY_STATIC(wine); #define GST_CAT_DEFAULT wine
+struct wg_parser +{ + BOOL (*init_gst)(struct wg_parser *parser); + + struct wg_parser_stream **streams; + unsigned int stream_count; + + GstElement *container; + GstBus *bus; + GstPad *my_src, *their_sink; + + guint64 file_size, start_offset, next_offset, stop_offset; + guint64 next_pull_offset; + + pthread_t push_thread; + + pthread_mutex_t mutex; + + pthread_cond_t init_cond; + bool no_more_pads, has_duration, error; + + pthread_cond_t read_cond, read_done_cond; + struct + { + void *data; + uint64_t offset; + uint32_t size; + bool done; + bool ret; + } read_request; + + bool flushing, sink_connected; +}; + +struct wg_parser_stream +{ + struct wg_parser *parser; + + GstPad *their_src, *post_sink, *post_src, *my_sink; + GstElement *flip; + struct wg_format preferred_format, current_format; + + pthread_cond_t event_cond, event_empty_cond; + struct wg_parser_event event; + GstBuffer *buffer; + GstMapInfo map_info; + + bool flushing, eos, enabled, has_caps; + + uint64_t duration; +}; + static enum wg_audio_format wg_audio_format_from_gst(GstAudioFormat format) { switch (format)