Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/winegstreamer/gst_private.h | 13 ++++--- dlls/winegstreamer/media_source.c | 2 +- dlls/winegstreamer/quartz_parser.c | 8 ++--- dlls/winegstreamer/wg_parser.c | 56 ++++++++---------------------- 4 files changed, 28 insertions(+), 51 deletions(-)
diff --git a/dlls/winegstreamer/gst_private.h b/dlls/winegstreamer/gst_private.h index 923bba25d38..9e5de174984 100644 --- a/dlls/winegstreamer/gst_private.h +++ b/dlls/winegstreamer/gst_private.h @@ -149,12 +149,17 @@ struct wg_parser_event }; C_ASSERT(sizeof(struct wg_parser_event) == 40);
+enum wg_parser_type +{ + WG_PARSER_DECODEBIN, + WG_PARSER_AVIDEMUX, + WG_PARSER_MPEGAUDIOPARSE, + WG_PARSER_WAVPARSE, +}; + struct unix_funcs { - struct wg_parser *(CDECL *wg_decodebin_parser_create)(void); - struct wg_parser *(CDECL *wg_avi_parser_create)(void); - struct wg_parser *(CDECL *wg_mpeg_audio_parser_create)(void); - struct wg_parser *(CDECL *wg_wave_parser_create)(void); + struct wg_parser *(CDECL *wg_parser_create)(enum wg_parser_type type); void (CDECL *wg_parser_destroy)(struct wg_parser *parser);
HRESULT (CDECL *wg_parser_connect)(struct wg_parser *parser, uint64_t file_size); diff --git a/dlls/winegstreamer/media_source.c b/dlls/winegstreamer/media_source.c index 12ca14ca139..e1e6cdbceb1 100644 --- a/dlls/winegstreamer/media_source.c +++ b/dlls/winegstreamer/media_source.c @@ -1421,7 +1421,7 @@ static HRESULT media_source_constructor(IMFByteStream *bytestream, struct media_ if (FAILED(hr = MFAllocateWorkQueue(&object->async_commands_queue))) goto fail;
- if (!(parser = unix_funcs->wg_decodebin_parser_create())) + if (!(parser = unix_funcs->wg_parser_create(WG_PARSER_DECODEBIN))) { hr = E_OUTOFMEMORY; goto fail; diff --git a/dlls/winegstreamer/quartz_parser.c b/dlls/winegstreamer/quartz_parser.c index a8e7e3d979f..f532b8969de 100644 --- a/dlls/winegstreamer/quartz_parser.c +++ b/dlls/winegstreamer/quartz_parser.c @@ -1115,7 +1115,7 @@ HRESULT decodebin_parser_create(IUnknown *outer, IUnknown **out) if (!(object = calloc(1, sizeof(*object)))) return E_OUTOFMEMORY;
- if (!(object->wg_parser = unix_funcs->wg_decodebin_parser_create())) + if (!(object->wg_parser = unix_funcs->wg_parser_create(WG_PARSER_DECODEBIN))) { free(object); return E_OUTOFMEMORY; @@ -1646,7 +1646,7 @@ HRESULT wave_parser_create(IUnknown *outer, IUnknown **out) if (!(object = calloc(1, sizeof(*object)))) return E_OUTOFMEMORY;
- if (!(object->wg_parser = unix_funcs->wg_wave_parser_create())) + if (!(object->wg_parser = unix_funcs->wg_parser_create(WG_PARSER_WAVPARSE))) { free(object); return E_OUTOFMEMORY; @@ -1732,7 +1732,7 @@ HRESULT avi_splitter_create(IUnknown *outer, IUnknown **out) if (!(object = calloc(1, sizeof(*object)))) return E_OUTOFMEMORY;
- if (!(object->wg_parser = unix_funcs->wg_avi_parser_create())) + if (!(object->wg_parser = unix_funcs->wg_parser_create(WG_PARSER_AVIDEMUX))) { free(object); return E_OUTOFMEMORY; @@ -1839,7 +1839,7 @@ HRESULT mpeg_splitter_create(IUnknown *outer, IUnknown **out) if (!(object = calloc(1, sizeof(*object)))) return E_OUTOFMEMORY;
- if (!(object->wg_parser = unix_funcs->wg_mpeg_audio_parser_create())) + if (!(object->wg_parser = unix_funcs->wg_parser_create(WG_PARSER_MPEGAUDIOPARSE))) { free(object); return E_OUTOFMEMORY; diff --git a/dlls/winegstreamer/wg_parser.c b/dlls/winegstreamer/wg_parser.c index dde137ef186..e1127b9a059 100644 --- a/dlls/winegstreamer/wg_parser.c +++ b/dlls/winegstreamer/wg_parser.c @@ -49,9 +49,11 @@ typedef enum GST_DEBUG_CATEGORY_STATIC(wine); #define GST_CAT_DEFAULT wine
+typedef BOOL (*init_gst_cb)(struct wg_parser *parser); + struct wg_parser { - BOOL (*init_gst)(struct wg_parser *parser); + init_gst_cb init_gst;
struct wg_parser_stream **streams; unsigned int stream_count; @@ -1844,8 +1846,16 @@ static BOOL wave_parser_init_gst(struct wg_parser *parser) return TRUE; }
-static struct wg_parser *wg_parser_create(void) +static struct wg_parser * CDECL wg_parser_create(enum wg_parser_type type) { + static const init_gst_cb init_funcs[] = + { + [WG_PARSER_DECODEBIN] = decodebin_parser_init_gst, + [WG_PARSER_AVIDEMUX] = avi_parser_init_gst, + [WG_PARSER_MPEGAUDIOPARSE] = mpeg_audio_parser_init_gst, + [WG_PARSER_WAVPARSE] = wave_parser_init_gst, + }; + struct wg_parser *parser;
if (!(parser = calloc(1, sizeof(*parser)))) @@ -1856,47 +1866,12 @@ static struct wg_parser *wg_parser_create(void) pthread_cond_init(&parser->read_cond, NULL); pthread_cond_init(&parser->read_done_cond, NULL); parser->flushing = true; + parser->init_gst = init_funcs[type];
GST_DEBUG("Created winegstreamer parser %p.\n", parser); return parser; }
-static struct wg_parser * CDECL wg_decodebin_parser_create(void) -{ - struct wg_parser *parser; - - if ((parser = wg_parser_create())) - parser->init_gst = decodebin_parser_init_gst; - return parser; -} - -static struct wg_parser * CDECL wg_avi_parser_create(void) -{ - struct wg_parser *parser; - - if ((parser = wg_parser_create())) - parser->init_gst = avi_parser_init_gst; - return parser; -} - -static struct wg_parser * CDECL wg_mpeg_audio_parser_create(void) -{ - struct wg_parser *parser; - - if ((parser = wg_parser_create())) - parser->init_gst = mpeg_audio_parser_init_gst; - return parser; -} - -static struct wg_parser * CDECL wg_wave_parser_create(void) -{ - struct wg_parser *parser; - - if ((parser = wg_parser_create())) - parser->init_gst = wave_parser_init_gst; - return parser; -} - static void CDECL wg_parser_destroy(struct wg_parser *parser) { if (parser->bus) @@ -1915,10 +1890,7 @@ static void CDECL wg_parser_destroy(struct wg_parser *parser)
static const struct unix_funcs funcs = { - wg_decodebin_parser_create, - wg_avi_parser_create, - wg_mpeg_audio_parser_create, - wg_wave_parser_create, + wg_parser_create, wg_parser_destroy,
wg_parser_connect,