winegstreamer: Use a single wg_parser_create() entry point.

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2021-10-01 17:18:09 -05:00 committed by Alexandre Julliard
parent 959bc42892
commit eab189810d
4 changed files with 28 additions and 51 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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,