wine-staging/patches/mfplat-reverts/0006-Revert-winegstreamer-Convert-the-Unix-library-to-the.patch
2021-10-07 09:15:30 +11:00

1390 lines
50 KiB
Diff

From cbb33659c8d97084e41648dd6d093508d493ffd8 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Wed, 6 Oct 2021 08:38:11 +1100
Subject: [PATCH 06/17] Revert "winegstreamer: Convert the Unix library to the
__wine_unix_call interface."
This reverts commit 4ba31162c37ea237763e650f6242535d86ffb170.
---
dlls/winegstreamer/Makefile.in | 1 -
dlls/winegstreamer/gst_private.h | 32 +----
dlls/winegstreamer/main.c | 197 +--------------------------
dlls/winegstreamer/media_source.c | 44 +++---
dlls/winegstreamer/quartz_parser.c | 72 +++++-----
dlls/winegstreamer/unixlib.h | 139 ++++---------------
dlls/winegstreamer/wg_parser.c | 210 +++++++++++------------------
7 files changed, 167 insertions(+), 528 deletions(-)
diff --git a/dlls/winegstreamer/Makefile.in b/dlls/winegstreamer/Makefile.in
index e35df3cf3f9..13e61abee36 100644
--- a/dlls/winegstreamer/Makefile.in
+++ b/dlls/winegstreamer/Makefile.in
@@ -1,5 +1,4 @@
MODULE = winegstreamer.dll
-UNIXLIB = winegstreamer.so
IMPORTS = strmbase strmiids uuid ole32 mfuuid
DELAYIMPORTS = mfplat
EXTRAINCL = $(GSTREAMER_CFLAGS)
diff --git a/dlls/winegstreamer/gst_private.h b/dlls/winegstreamer/gst_private.h
index ebe0bf6f50d..91c646571cf 100644
--- a/dlls/winegstreamer/gst_private.h
+++ b/dlls/winegstreamer/gst_private.h
@@ -61,37 +61,7 @@ static inline const char *debugstr_time(REFERENCE_TIME time)
#define MEDIATIME_FROM_BYTES(x) ((LONGLONG)(x) * 10000000)
-struct wg_parser *wg_parser_create(enum wg_parser_type type, bool unlimited_buffering) DECLSPEC_HIDDEN;
-void wg_parser_destroy(struct wg_parser *parser) DECLSPEC_HIDDEN;
-
-HRESULT wg_parser_connect(struct wg_parser *parser, uint64_t file_size) DECLSPEC_HIDDEN;
-void wg_parser_disconnect(struct wg_parser *parser) DECLSPEC_HIDDEN;
-
-void wg_parser_begin_flush(struct wg_parser *parser) DECLSPEC_HIDDEN;
-void wg_parser_end_flush(struct wg_parser *parser) DECLSPEC_HIDDEN;
-
-bool wg_parser_get_next_read_offset(struct wg_parser *parser, uint64_t *offset, uint32_t *size) DECLSPEC_HIDDEN;
-void wg_parser_push_data(struct wg_parser *parser, const void *data, uint32_t size) DECLSPEC_HIDDEN;
-
-uint32_t wg_parser_get_stream_count(struct wg_parser *parser) DECLSPEC_HIDDEN;
-struct wg_parser_stream *wg_parser_get_stream(struct wg_parser *parser, uint32_t index) DECLSPEC_HIDDEN;
-
-void wg_parser_stream_get_preferred_format(struct wg_parser_stream *stream, struct wg_format *format) DECLSPEC_HIDDEN;
-void wg_parser_stream_enable(struct wg_parser_stream *stream, const struct wg_format *format) DECLSPEC_HIDDEN;
-void wg_parser_stream_disable(struct wg_parser_stream *stream) DECLSPEC_HIDDEN;
-
-bool wg_parser_stream_get_event(struct wg_parser_stream *stream, struct wg_parser_event *event) DECLSPEC_HIDDEN;
-bool wg_parser_stream_copy_buffer(struct wg_parser_stream *stream,
- void *data, uint32_t offset, uint32_t size) DECLSPEC_HIDDEN;
-void wg_parser_stream_release_buffer(struct wg_parser_stream *stream) DECLSPEC_HIDDEN;
-void wg_parser_stream_notify_qos(struct wg_parser_stream *stream,
- bool underflow, double proportion, int64_t diff, uint64_t timestamp) DECLSPEC_HIDDEN;
-
-/* Returns the duration in 100-nanosecond units. */
-uint64_t wg_parser_stream_get_duration(struct wg_parser_stream *stream) DECLSPEC_HIDDEN;
-/* start_pos and stop_pos are in 100-nanosecond units. */
-void 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) DECLSPEC_HIDDEN;
+extern const struct unix_funcs *unix_funcs;
HRESULT avi_splitter_create(IUnknown *outer, IUnknown **out) DECLSPEC_HIDDEN;
HRESULT decodebin_parser_create(IUnknown *outer, IUnknown **out) DECLSPEC_HIDDEN;
diff --git a/dlls/winegstreamer/main.c b/dlls/winegstreamer/main.c
index c799aa06d1b..6742724948e 100644
--- a/dlls/winegstreamer/main.c
+++ b/dlls/winegstreamer/main.c
@@ -27,209 +27,16 @@
#include "initguid.h"
#include "gst_guids.h"
-static unixlib_handle_t unix_handle;
-
WINE_DEFAULT_DEBUG_CHANNEL(quartz);
-struct wg_parser *wg_parser_create(enum wg_parser_type type, bool unlimited_buffering)
-{
- struct wg_parser_create_params params =
- {
- .type = type,
- .unlimited_buffering = unlimited_buffering,
- };
-
- if (__wine_unix_call(unix_handle, unix_wg_parser_create, &params))
- return NULL;
- return params.parser;
-}
-
-void wg_parser_destroy(struct wg_parser *parser)
-{
- __wine_unix_call(unix_handle, unix_wg_parser_destroy, parser);
-}
-
-HRESULT wg_parser_connect(struct wg_parser *parser, uint64_t file_size)
-{
- struct wg_parser_connect_params params =
- {
- .parser = parser,
- .file_size = file_size,
- };
-
- return __wine_unix_call(unix_handle, unix_wg_parser_connect, &params);
-}
-
-void wg_parser_disconnect(struct wg_parser *parser)
-{
- __wine_unix_call(unix_handle, unix_wg_parser_disconnect, parser);
-}
-
-void wg_parser_begin_flush(struct wg_parser *parser)
-{
- __wine_unix_call(unix_handle, unix_wg_parser_begin_flush, parser);
-}
-
-void wg_parser_end_flush(struct wg_parser *parser)
-{
- __wine_unix_call(unix_handle, unix_wg_parser_end_flush, parser);
-}
-
-bool wg_parser_get_next_read_offset(struct wg_parser *parser, uint64_t *offset, uint32_t *size)
-{
- struct wg_parser_get_next_read_offset_params params =
- {
- .parser = parser,
- };
-
- if (__wine_unix_call(unix_handle, unix_wg_parser_get_next_read_offset, &params))
- return false;
- *offset = params.offset;
- *size = params.size;
- return true;
-}
-
-void wg_parser_push_data(struct wg_parser *parser, const void *data, uint32_t size)
-{
- struct wg_parser_push_data_params params =
- {
- .parser = parser,
- .data = data,
- .size = size,
- };
-
- __wine_unix_call(unix_handle, unix_wg_parser_push_data, &params);
-}
-
-uint32_t wg_parser_get_stream_count(struct wg_parser *parser)
-{
- struct wg_parser_get_stream_count_params params =
- {
- .parser = parser,
- };
-
- __wine_unix_call(unix_handle, unix_wg_parser_get_stream_count, &params);
- return params.count;
-}
-
-struct wg_parser_stream *wg_parser_get_stream(struct wg_parser *parser, uint32_t index)
-{
- struct wg_parser_get_stream_params params =
- {
- .parser = parser,
- .index = index,
- };
-
- __wine_unix_call(unix_handle, unix_wg_parser_get_stream, &params);
- return params.stream;
-}
-
-void wg_parser_stream_get_preferred_format(struct wg_parser_stream *stream, struct wg_format *format)
-{
- struct wg_parser_stream_get_preferred_format_params params =
- {
- .stream = stream,
- .format = format,
- };
-
- __wine_unix_call(unix_handle, unix_wg_parser_stream_get_preferred_format, &params);
-}
-
-void wg_parser_stream_enable(struct wg_parser_stream *stream, const struct wg_format *format)
-{
- struct wg_parser_stream_enable_params params =
- {
- .stream = stream,
- .format = format,
- };
-
- __wine_unix_call(unix_handle, unix_wg_parser_stream_enable, &params);
-}
-
-void wg_parser_stream_disable(struct wg_parser_stream *stream)
-{
- __wine_unix_call(unix_handle, unix_wg_parser_stream_disable, stream);
-}
-
-bool wg_parser_stream_get_event(struct wg_parser_stream *stream, struct wg_parser_event *event)
-{
- struct wg_parser_stream_get_event_params params =
- {
- .stream = stream,
- .event = event,
- };
-
- return !__wine_unix_call(unix_handle, unix_wg_parser_stream_get_event, &params);
-}
-
-bool wg_parser_stream_copy_buffer(struct wg_parser_stream *stream,
- void *data, uint32_t offset, uint32_t size)
-{
- struct wg_parser_stream_copy_buffer_params params =
- {
- .stream = stream,
- .data = data,
- .offset = offset,
- .size = size,
- };
-
- return !__wine_unix_call(unix_handle, unix_wg_parser_stream_copy_buffer, &params);
-}
-
-void wg_parser_stream_release_buffer(struct wg_parser_stream *stream)
-{
- __wine_unix_call(unix_handle, unix_wg_parser_stream_release_buffer, stream);
-}
-
-void wg_parser_stream_notify_qos(struct wg_parser_stream *stream,
- bool underflow, double proportion, int64_t diff, uint64_t timestamp)
-{
- struct wg_parser_stream_notify_qos_params params =
- {
- .stream = stream,
- .underflow = underflow,
- .proportion = proportion,
- .diff = diff,
- .timestamp = timestamp,
- };
-
- __wine_unix_call(unix_handle, unix_wg_parser_stream_notify_qos, &params);
-}
-
-uint64_t wg_parser_stream_get_duration(struct wg_parser_stream *stream)
-{
- struct wg_parser_stream_get_duration_params params =
- {
- .stream = stream,
- };
-
- __wine_unix_call(unix_handle, unix_wg_parser_stream_get_duration, &params);
- return params.duration;
-}
-
-void 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)
-{
- struct wg_parser_stream_seek_params params =
- {
- .stream = stream,
- .rate = rate,
- .start_pos = start_pos,
- .stop_pos = stop_pos,
- .start_flags = start_flags,
- .stop_flags = stop_flags,
- };
-
- __wine_unix_call(unix_handle, unix_wg_parser_stream_seek, &params);
-}
+const struct unix_funcs *unix_funcs = NULL;
BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved)
{
if (reason == DLL_PROCESS_ATTACH)
{
DisableThreadLibraryCalls(instance);
- NtQueryVirtualMemory(GetCurrentProcess(), instance, MemoryWineUnixFuncs,
- &unix_handle, sizeof(unix_handle), NULL);
+ __wine_init_unix_lib(instance, reason, NULL, &unix_funcs);
}
return TRUE;
}
diff --git a/dlls/winegstreamer/media_source.c b/dlls/winegstreamer/media_source.c
index da898f20f66..18bffca1362 100644
--- a/dlls/winegstreamer/media_source.c
+++ b/dlls/winegstreamer/media_source.c
@@ -357,7 +357,7 @@ static void start_pipeline(struct media_source *source, struct source_async_comm
IMFMediaTypeHandler_GetCurrentMediaType(mth, &current_mt);
mf_media_type_to_wg_format(current_mt, &format);
- wg_parser_stream_enable(stream->wg_stream, &format);
+ unix_funcs->wg_parser_stream_enable(stream->wg_stream, &format);
IMFMediaType_Release(current_mt);
IMFMediaTypeHandler_Release(mth);
@@ -385,9 +385,9 @@ static void start_pipeline(struct media_source *source, struct source_async_comm
source->state = SOURCE_RUNNING;
if (position->vt == VT_I8)
- wg_parser_stream_seek(source->streams[0]->wg_stream, 1.0, position->hVal.QuadPart, 0,
- AM_SEEKING_AbsolutePositioning, AM_SEEKING_NoPositioning);
- wg_parser_end_flush(source->wg_parser);
+ unix_funcs->wg_parser_stream_seek(source->streams[0]->wg_stream, 1.0,
+ position->hVal.QuadPart, 0, AM_SEEKING_AbsolutePositioning, AM_SEEKING_NoPositioning);
+ unix_funcs->wg_parser_end_flush(source->wg_parser);
for (i = 0; i < source->stream_count; i++)
flush_token_queue(source->streams[i], position->vt == VT_EMPTY);
@@ -415,7 +415,7 @@ static void stop_pipeline(struct media_source *source)
{
unsigned int i;
- wg_parser_begin_flush(source->wg_parser);
+ unix_funcs->wg_parser_begin_flush(source->wg_parser);
for (i = 0; i < source->stream_count; i++)
{
@@ -423,7 +423,7 @@ static void stop_pipeline(struct media_source *source)
if (stream->state != STREAM_INACTIVE)
{
IMFMediaEventQueue_QueueEventParamVar(stream->event_queue, MEStreamStopped, &GUID_NULL, S_OK, NULL);
- wg_parser_stream_disable(stream->wg_stream);
+ unix_funcs->wg_parser_stream_disable(stream->wg_stream);
}
}
@@ -490,13 +490,13 @@ static void send_buffer(struct media_stream *stream, const struct wg_parser_even
goto out;
}
- if (!wg_parser_stream_copy_buffer(stream->wg_stream, data, 0, event->u.buffer.size))
+ if (!unix_funcs->wg_parser_stream_copy_buffer(stream->wg_stream, data, 0, event->u.buffer.size))
{
- wg_parser_stream_release_buffer(stream->wg_stream);
+ unix_funcs->wg_parser_stream_release_buffer(stream->wg_stream);
IMFMediaBuffer_Unlock(buffer);
goto out;
}
- wg_parser_stream_release_buffer(stream->wg_stream);
+ unix_funcs->wg_parser_stream_release_buffer(stream->wg_stream);
if (FAILED(hr = IMFMediaBuffer_Unlock(buffer)))
{
@@ -536,7 +536,7 @@ static void wait_on_sample(struct media_stream *stream, IUnknown *token)
for (;;)
{
- if (!wg_parser_stream_get_event(stream->wg_stream, &event))
+ if (!unix_funcs->wg_parser_stream_get_event(stream->wg_stream, &event))
return;
TRACE("Got event of type %#x.\n", event.type);
@@ -628,7 +628,7 @@ static DWORD CALLBACK read_thread(void *arg)
uint32_t size;
HRESULT hr;
- if (!wg_parser_get_next_read_offset(source->wg_parser, &offset, &size))
+ if (!unix_funcs->wg_parser_get_next_read_offset(source->wg_parser, &offset, &size))
continue;
if (offset >= file_size)
@@ -650,7 +650,7 @@ static DWORD CALLBACK read_thread(void *arg)
ERR("Failed to read %u bytes at offset %I64u, hr %#x.\n", size, offset, hr);
else if (ret_size != size)
ERR("Unexpected short read: requested %u bytes, got %u.\n", size, ret_size);
- wg_parser_push_data(source->wg_parser, SUCCEEDED(hr) ? data : NULL, ret_size);
+ unix_funcs->wg_parser_push_data(source->wg_parser, SUCCEEDED(hr) ? data : NULL, ret_size);
}
free(data);
@@ -867,7 +867,7 @@ static HRESULT media_stream_init_desc(struct media_stream *stream)
unsigned int i;
HRESULT hr;
- wg_parser_stream_get_preferred_format(stream->wg_stream, &format);
+ unix_funcs->wg_parser_stream_get_preferred_format(stream->wg_stream, &format);
if (format.major_type == WG_MAJOR_TYPE_VIDEO)
{
@@ -1327,7 +1327,7 @@ static HRESULT WINAPI media_source_Shutdown(IMFMediaSource *iface)
source->state = SOURCE_SHUTDOWN;
- wg_parser_disconnect(source->wg_parser);
+ unix_funcs->wg_parser_disconnect(source->wg_parser);
source->read_thread_shutdown = true;
WaitForSingleObject(source->read_thread, INFINITE);
@@ -1350,7 +1350,7 @@ static HRESULT WINAPI media_source_Shutdown(IMFMediaSource *iface)
IMFMediaStream_Release(&stream->IMFMediaStream_iface);
}
- wg_parser_destroy(source->wg_parser);
+ unix_funcs->wg_parser_destroy(source->wg_parser);
free(source->streams);
@@ -1427,7 +1427,7 @@ static HRESULT media_source_constructor(IMFByteStream *bytestream, struct media_
* never deselects it). Remove buffering limits from decodebin in order to
* account for this. Note that this does leak memory, but the same memory
* leak occurs with native. */
- if (!(parser = wg_parser_create(WG_PARSER_DECODEBIN, true)))
+ if (!(parser = unix_funcs->wg_parser_create(WG_PARSER_DECODEBIN, true)))
{
hr = E_OUTOFMEMORY;
goto fail;
@@ -1438,10 +1438,10 @@ static HRESULT media_source_constructor(IMFByteStream *bytestream, struct media_
object->state = SOURCE_OPENING;
- if (FAILED(hr = wg_parser_connect(parser, file_size)))
+ if (FAILED(hr = unix_funcs->wg_parser_connect(parser, file_size)))
goto fail;
- stream_count = wg_parser_get_stream_count(parser);
+ stream_count = unix_funcs->wg_parser_get_stream_count(parser);
if (!(object->streams = calloc(stream_count, sizeof(*object->streams))))
{
@@ -1451,7 +1451,7 @@ static HRESULT media_source_constructor(IMFByteStream *bytestream, struct media_
for (i = 0; i < stream_count; ++i)
{
- if (FAILED(hr = new_media_stream(object, wg_parser_get_stream(parser, i), i, &object->streams[i])))
+ if (FAILED(hr = new_media_stream(object, unix_funcs->wg_parser_get_stream(parser, i), i, &object->streams[i])))
goto fail;
if (FAILED(hr = media_stream_init_desc(object->streams[i])))
@@ -1487,7 +1487,7 @@ static HRESULT media_source_constructor(IMFByteStream *bytestream, struct media_
for (i = 0; i < object->stream_count; i++)
total_pres_time = max(total_pres_time,
- wg_parser_stream_get_duration(object->streams[i]->wg_stream));
+ unix_funcs->wg_parser_stream_get_duration(object->streams[i]->wg_stream));
if (object->stream_count)
IMFPresentationDescriptor_SetUINT64(object->pres_desc, &MF_PD_DURATION, total_pres_time);
@@ -1518,7 +1518,7 @@ static HRESULT media_source_constructor(IMFByteStream *bytestream, struct media_
}
free(object->streams);
if (stream_count != UINT_MAX)
- wg_parser_disconnect(object->wg_parser);
+ unix_funcs->wg_parser_disconnect(object->wg_parser);
if (object->read_thread)
{
object->read_thread_shutdown = true;
@@ -1526,7 +1526,7 @@ static HRESULT media_source_constructor(IMFByteStream *bytestream, struct media_
CloseHandle(object->read_thread);
}
if (object->wg_parser)
- wg_parser_destroy(object->wg_parser);
+ unix_funcs->wg_parser_destroy(object->wg_parser);
if (object->async_commands_queue)
MFUnlockWorkQueue(object->async_commands_queue);
if (object->event_queue)
diff --git a/dlls/winegstreamer/quartz_parser.c b/dlls/winegstreamer/quartz_parser.c
index 6ae1a99a14a..5dd232ea0da 100644
--- a/dlls/winegstreamer/quartz_parser.c
+++ b/dlls/winegstreamer/quartz_parser.c
@@ -623,7 +623,7 @@ static HRESULT send_sample(struct parser_source *pin, IMediaSample *sample,
IMediaSample_GetPointer(sample, &ptr);
- if (!wg_parser_stream_copy_buffer(pin->wg_stream, ptr, offset, size))
+ if (!unix_funcs->wg_parser_stream_copy_buffer(pin->wg_stream, ptr, offset, size))
{
/* The GStreamer pin has been flushed. */
return S_OK;
@@ -732,7 +732,7 @@ static void send_buffer(struct parser_source *pin, const struct wg_parser_event
}
}
- wg_parser_stream_release_buffer(pin->wg_stream);
+ unix_funcs->wg_parser_stream_release_buffer(pin->wg_stream);
}
static DWORD CALLBACK stream_thread(void *arg)
@@ -748,7 +748,7 @@ static DWORD CALLBACK stream_thread(void *arg)
EnterCriticalSection(&pin->flushing_cs);
- if (!wg_parser_stream_get_event(pin->wg_stream, &event))
+ if (!unix_funcs->wg_parser_stream_get_event(pin->wg_stream, &event))
{
LeaveCriticalSection(&pin->flushing_cs);
continue;
@@ -799,7 +799,7 @@ static DWORD CALLBACK read_thread(void *arg)
uint32_t size;
HRESULT hr;
- if (!wg_parser_get_next_read_offset(filter->wg_parser, &offset, &size))
+ if (!unix_funcs->wg_parser_get_next_read_offset(filter->wg_parser, &offset, &size))
continue;
if (offset >= file_size)
@@ -817,7 +817,7 @@ static DWORD CALLBACK read_thread(void *arg)
if (FAILED(hr))
ERR("Failed to read %u bytes at offset %I64u, hr %#x.\n", size, offset, hr);
- wg_parser_push_data(filter->wg_parser, SUCCEEDED(hr) ? data : NULL, size);
+ unix_funcs->wg_parser_push_data(filter->wg_parser, SUCCEEDED(hr) ? data : NULL, size);
}
free(data);
@@ -869,7 +869,7 @@ static void parser_destroy(struct strmbase_filter *iface)
IAsyncReader_Release(filter->reader);
filter->reader = NULL;
- wg_parser_destroy(filter->wg_parser);
+ unix_funcs->wg_parser_destroy(filter->wg_parser);
strmbase_sink_cleanup(&filter->sink);
strmbase_filter_cleanup(&filter->filter);
@@ -887,7 +887,7 @@ static HRESULT parser_init_stream(struct strmbase_filter *iface)
return S_OK;
filter->streaming = true;
- wg_parser_end_flush(filter->wg_parser);
+ unix_funcs->wg_parser_end_flush(filter->wg_parser);
/* DirectShow retains the old seek positions, but resets to them every time
* it transitions from stopped -> paused. */
@@ -895,7 +895,7 @@ static HRESULT parser_init_stream(struct strmbase_filter *iface)
seeking = &filter->sources[0]->seek;
if (seeking->llStop)
stop_flags = AM_SEEKING_AbsolutePositioning;
- wg_parser_stream_seek(filter->sources[0]->wg_stream, seeking->dRate,
+ unix_funcs->wg_parser_stream_seek(filter->sources[0]->wg_stream, seeking->dRate,
seeking->llCurrent, seeking->llStop, AM_SEEKING_AbsolutePositioning, stop_flags);
for (i = 0; i < filter->source_count; ++i)
@@ -923,7 +923,7 @@ static HRESULT parser_cleanup_stream(struct strmbase_filter *iface)
return S_OK;
filter->streaming = false;
- wg_parser_begin_flush(filter->wg_parser);
+ unix_funcs->wg_parser_begin_flush(filter->wg_parser);
for (i = 0; i < filter->source_count; ++i)
{
@@ -978,7 +978,7 @@ 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);
- if (FAILED(hr = wg_parser_connect(filter->wg_parser, file_size)))
+ if (FAILED(hr = unix_funcs->wg_parser_connect(filter->wg_parser, file_size)))
goto err;
if (!filter->init_gst(filter))
@@ -991,7 +991,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 = wg_parser_stream_get_duration(pin->wg_stream);
+ pin->seek.llDuration = pin->seek.llStop = unix_funcs->wg_parser_stream_get_duration(pin->wg_stream);
pin->seek.llCurrent = 0;
}
@@ -1026,11 +1026,11 @@ static BOOL decodebin_parser_filter_init_gst(struct parser *filter)
unsigned int i, stream_count;
WCHAR source_name[20];
- stream_count = wg_parser_get_stream_count(parser);
+ stream_count = unix_funcs->wg_parser_get_stream_count(parser);
for (i = 0; i < stream_count; ++i)
{
swprintf(source_name, ARRAY_SIZE(source_name), L"Stream %02u", i);
- if (!create_pin(filter, wg_parser_get_stream(parser, i), source_name))
+ if (!create_pin(filter, unix_funcs->wg_parser_get_stream(parser, i), source_name))
return FALSE;
}
@@ -1069,7 +1069,7 @@ static HRESULT decodebin_parser_source_get_media_type(struct parser_source *pin,
WG_VIDEO_FORMAT_RGB15,
};
- wg_parser_stream_get_preferred_format(pin->wg_stream, &format);
+ unix_funcs->wg_parser_stream_get_preferred_format(pin->wg_stream, &format);
memset(mt, 0, sizeof(AM_MEDIA_TYPE));
@@ -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 = wg_parser_create(WG_PARSER_DECODEBIN, false)))
+ if (!(object->wg_parser = unix_funcs->wg_parser_create(WG_PARSER_DECODEBIN, false)))
{
free(object);
return E_OUTOFMEMORY;
@@ -1205,7 +1205,7 @@ static HRESULT WINAPI GST_ChangeRate(IMediaSeeking *iface)
{
struct parser_source *pin = impl_from_IMediaSeeking(iface);
- wg_parser_stream_seek(pin->wg_stream, pin->seek.dRate, 0, 0,
+ unix_funcs->wg_parser_stream_seek(pin->wg_stream, pin->seek.dRate, 0, 0,
AM_SEEKING_NoPositioning, AM_SEEKING_NoPositioning);
return S_OK;
}
@@ -1247,7 +1247,7 @@ static HRESULT WINAPI GST_Seeking_SetPositions(IMediaSeeking *iface,
if (!(current_flags & AM_SEEKING_NoFlush))
{
- wg_parser_begin_flush(filter->wg_parser);
+ unix_funcs->wg_parser_begin_flush(filter->wg_parser);
for (i = 0; i < filter->source_count; ++i)
{
@@ -1269,12 +1269,12 @@ static HRESULT WINAPI GST_Seeking_SetPositions(IMediaSeeking *iface,
SourceSeekingImpl_SetPositions(iface, current, current_flags, stop, stop_flags);
- wg_parser_stream_seek(pin->wg_stream, pin->seek.dRate,
+ unix_funcs->wg_parser_stream_seek(pin->wg_stream, pin->seek.dRate,
pin->seek.llCurrent, pin->seek.llStop, current_flags, stop_flags);
if (!(current_flags & AM_SEEKING_NoFlush))
{
- wg_parser_end_flush(filter->wg_parser);
+ unix_funcs->wg_parser_end_flush(filter->wg_parser);
for (i = 0; i < filter->source_count; ++i)
{
@@ -1383,7 +1383,7 @@ static HRESULT WINAPI GST_QualityControl_Notify(IQualityControl *iface, IBaseFil
/* GST_QOS_TYPE_OVERFLOW is also used for buffers that arrive on time, but
* DirectShow filters might use Famine, so check that there actually is an
* underrun. */
- wg_parser_stream_notify_qos(pin->wg_stream, q.Type == Famine && q.Proportion < 1000,
+ unix_funcs->wg_parser_stream_notify_qos(pin->wg_stream, q.Type == Famine && q.Proportion < 1000,
1000.0 / q.Proportion, diff, timestamp);
return S_OK;
@@ -1463,7 +1463,7 @@ static HRESULT WINAPI GSTOutPin_DecideBufferSize(struct strmbase_source *iface,
ret = amt_to_wg_format(&pin->pin.pin.mt, &format);
assert(ret);
- wg_parser_stream_enable(pin->wg_stream, &format);
+ unix_funcs->wg_parser_stream_enable(pin->wg_stream, &format);
/* We do need to drop any buffers that might have been sent with the old
* caps, but this will be handled in parser_init_stream(). */
@@ -1478,7 +1478,7 @@ static void source_disconnect(struct strmbase_source *iface)
{
struct parser_source *pin = impl_source_from_IPin(&iface->pin.IPin_iface);
- wg_parser_stream_disable(pin->wg_stream);
+ unix_funcs->wg_parser_stream_disable(pin->wg_stream);
}
static void free_source_pin(struct parser_source *pin)
@@ -1544,7 +1544,7 @@ static HRESULT GST_RemoveOutputPins(struct parser *This)
if (!This->sink_connected)
return S_OK;
- wg_parser_disconnect(This->wg_parser);
+ unix_funcs->wg_parser_disconnect(This->wg_parser);
/* read_thread() needs to stay alive to service any read requests GStreamer
* sends, so we can only shut it down after GStreamer stops. */
@@ -1597,7 +1597,7 @@ static BOOL wave_parser_filter_init_gst(struct parser *filter)
{
struct wg_parser *parser = filter->wg_parser;
- if (!create_pin(filter, wg_parser_get_stream(parser, 0), L"output"))
+ if (!create_pin(filter, unix_funcs->wg_parser_get_stream(parser, 0), L"output"))
return FALSE;
return TRUE;
@@ -1609,7 +1609,7 @@ static HRESULT wave_parser_source_query_accept(struct parser_source *pin, const
AM_MEDIA_TYPE pad_mt;
HRESULT hr;
- wg_parser_stream_get_preferred_format(pin->wg_stream, &format);
+ unix_funcs->wg_parser_stream_get_preferred_format(pin->wg_stream, &format);
if (!amt_from_wg_format(&pad_mt, &format))
return E_OUTOFMEMORY;
hr = compare_media_types(mt, &pad_mt) ? S_OK : S_FALSE;
@@ -1624,7 +1624,7 @@ static HRESULT wave_parser_source_get_media_type(struct parser_source *pin,
if (index > 0)
return VFW_S_NO_MORE_ITEMS;
- wg_parser_stream_get_preferred_format(pin->wg_stream, &format);
+ unix_funcs->wg_parser_stream_get_preferred_format(pin->wg_stream, &format);
if (!amt_from_wg_format(mt, &format))
return E_OUTOFMEMORY;
return S_OK;
@@ -1640,7 +1640,7 @@ HRESULT wave_parser_create(IUnknown *outer, IUnknown **out)
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
- if (!(object->wg_parser = wg_parser_create(WG_PARSER_WAVPARSE, false)))
+ if (!(object->wg_parser = unix_funcs->wg_parser_create(WG_PARSER_WAVPARSE, false)))
{
free(object);
return E_OUTOFMEMORY;
@@ -1678,11 +1678,11 @@ static BOOL avi_splitter_filter_init_gst(struct parser *filter)
uint32_t i, stream_count;
WCHAR source_name[20];
- stream_count = wg_parser_get_stream_count(parser);
+ stream_count = unix_funcs->wg_parser_get_stream_count(parser);
for (i = 0; i < stream_count; ++i)
{
swprintf(source_name, ARRAY_SIZE(source_name), L"Stream %02u", i);
- if (!create_pin(filter, wg_parser_get_stream(parser, i), source_name))
+ if (!create_pin(filter, unix_funcs->wg_parser_get_stream(parser, i), source_name))
return FALSE;
}
@@ -1695,7 +1695,7 @@ static HRESULT avi_splitter_source_query_accept(struct parser_source *pin, const
AM_MEDIA_TYPE pad_mt;
HRESULT hr;
- wg_parser_stream_get_preferred_format(pin->wg_stream, &format);
+ unix_funcs->wg_parser_stream_get_preferred_format(pin->wg_stream, &format);
if (!amt_from_wg_format(&pad_mt, &format))
return E_OUTOFMEMORY;
hr = compare_media_types(mt, &pad_mt) ? S_OK : S_FALSE;
@@ -1710,7 +1710,7 @@ static HRESULT avi_splitter_source_get_media_type(struct parser_source *pin,
if (index > 0)
return VFW_S_NO_MORE_ITEMS;
- wg_parser_stream_get_preferred_format(pin->wg_stream, &format);
+ unix_funcs->wg_parser_stream_get_preferred_format(pin->wg_stream, &format);
if (!amt_from_wg_format(mt, &format))
return E_OUTOFMEMORY;
return S_OK;
@@ -1726,7 +1726,7 @@ HRESULT avi_splitter_create(IUnknown *outer, IUnknown **out)
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
- if (!(object->wg_parser = wg_parser_create(WG_PARSER_AVIDEMUX, false)))
+ if (!(object->wg_parser = unix_funcs->wg_parser_create(WG_PARSER_AVIDEMUX, false)))
{
free(object);
return E_OUTOFMEMORY;
@@ -1767,7 +1767,7 @@ static BOOL mpeg_splitter_filter_init_gst(struct parser *filter)
{
struct wg_parser *parser = filter->wg_parser;
- if (!create_pin(filter, wg_parser_get_stream(parser, 0), L"Audio"))
+ if (!create_pin(filter, unix_funcs->wg_parser_get_stream(parser, 0), L"Audio"))
return FALSE;
return TRUE;
@@ -1779,7 +1779,7 @@ static HRESULT mpeg_splitter_source_query_accept(struct parser_source *pin, cons
AM_MEDIA_TYPE pad_mt;
HRESULT hr;
- wg_parser_stream_get_preferred_format(pin->wg_stream, &format);
+ unix_funcs->wg_parser_stream_get_preferred_format(pin->wg_stream, &format);
if (!amt_from_wg_format(&pad_mt, &format))
return E_OUTOFMEMORY;
hr = compare_media_types(mt, &pad_mt) ? S_OK : S_FALSE;
@@ -1794,7 +1794,7 @@ static HRESULT mpeg_splitter_source_get_media_type(struct parser_source *pin,
if (index > 0)
return VFW_S_NO_MORE_ITEMS;
- wg_parser_stream_get_preferred_format(pin->wg_stream, &format);
+ unix_funcs->wg_parser_stream_get_preferred_format(pin->wg_stream, &format);
if (!amt_from_wg_format(mt, &format))
return E_OUTOFMEMORY;
return S_OK;
@@ -1833,7 +1833,7 @@ HRESULT mpeg_splitter_create(IUnknown *outer, IUnknown **out)
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
- if (!(object->wg_parser = wg_parser_create(WG_PARSER_MPEGAUDIOPARSE, false)))
+ if (!(object->wg_parser = unix_funcs->wg_parser_create(WG_PARSER_MPEGAUDIOPARSE, false)))
{
free(object);
return E_OUTOFMEMORY;
diff --git a/dlls/winegstreamer/unixlib.h b/dlls/winegstreamer/unixlib.h
index 90101893541..dade020916a 100644
--- a/dlls/winegstreamer/unixlib.h
+++ b/dlls/winegstreamer/unixlib.h
@@ -24,12 +24,9 @@
#include <stdbool.h>
#include <stdint.h>
#include "windef.h"
-#include "winternl.h"
#include "wtypes.h"
#include "mmreg.h"
-#include "wine/unixlib.h"
-
struct wg_format
{
enum wg_major_type
@@ -128,123 +125,41 @@ enum wg_parser_type
WG_PARSER_WAVPARSE,
};
-struct wg_parser_create_params
-{
- struct wg_parser *parser;
- enum wg_parser_type type;
- bool unlimited_buffering;
-};
-
-struct wg_parser_connect_params
-{
- struct wg_parser *parser;
- UINT64 file_size;
-};
-
-struct wg_parser_get_next_read_offset_params
-{
- struct wg_parser *parser;
- UINT32 size;
- UINT64 offset;
-};
-
-struct wg_parser_push_data_params
-{
- struct wg_parser *parser;
- const void *data;
- UINT32 size;
-};
-
-struct wg_parser_get_stream_count_params
-{
- struct wg_parser *parser;
- UINT32 count;
-};
-
-struct wg_parser_get_stream_params
-{
- struct wg_parser *parser;
- UINT32 index;
- struct wg_parser_stream *stream;
-};
-
-struct wg_parser_stream_get_preferred_format_params
-{
- struct wg_parser_stream *stream;
- struct wg_format *format;
-};
-
-struct wg_parser_stream_enable_params
-{
- struct wg_parser_stream *stream;
- const struct wg_format *format;
-};
-
-struct wg_parser_stream_get_event_params
-{
- struct wg_parser_stream *stream;
- struct wg_parser_event *event;
-};
-
-struct wg_parser_stream_copy_buffer_params
-{
- struct wg_parser_stream *stream;
- void *data;
- UINT32 offset;
- UINT32 size;
-};
-
-struct wg_parser_stream_notify_qos_params
-{
- struct wg_parser_stream *stream;
- bool underflow;
- DOUBLE proportion;
- INT64 diff;
- UINT64 timestamp;
-};
-
-struct wg_parser_stream_get_duration_params
-{
- struct wg_parser_stream *stream;
- UINT64 duration;
-};
-
-struct wg_parser_stream_seek_params
-{
- struct wg_parser_stream *stream;
- DOUBLE rate;
- UINT64 start_pos, stop_pos;
- DWORD start_flags, stop_flags;
-};
-
-enum unix_funcs
+struct unix_funcs
{
- unix_wg_parser_create,
- unix_wg_parser_destroy,
+ struct wg_parser *(CDECL *wg_parser_create)(enum wg_parser_type type, bool unlimited_buffering);
+ void (CDECL *wg_parser_destroy)(struct wg_parser *parser);
- unix_wg_parser_connect,
- unix_wg_parser_disconnect,
+ HRESULT (CDECL *wg_parser_connect)(struct wg_parser *parser, uint64_t file_size);
+ void (CDECL *wg_parser_disconnect)(struct wg_parser *parser);
- unix_wg_parser_begin_flush,
- unix_wg_parser_end_flush,
+ void (CDECL *wg_parser_begin_flush)(struct wg_parser *parser);
+ void (CDECL *wg_parser_end_flush)(struct wg_parser *parser);
- unix_wg_parser_get_next_read_offset,
- unix_wg_parser_push_data,
+ bool (CDECL *wg_parser_get_next_read_offset)(struct wg_parser *parser,
+ uint64_t *offset, uint32_t *size);
+ void (CDECL *wg_parser_push_data)(struct wg_parser *parser,
+ const void *data, uint32_t size);
- unix_wg_parser_get_stream_count,
- unix_wg_parser_get_stream,
+ 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);
- unix_wg_parser_stream_get_preferred_format,
- unix_wg_parser_stream_enable,
- unix_wg_parser_stream_disable,
+ void (CDECL *wg_parser_stream_get_preferred_format)(struct wg_parser_stream *stream, struct wg_format *format);
+ void (CDECL *wg_parser_stream_enable)(struct wg_parser_stream *stream, const struct wg_format *format);
+ void (CDECL *wg_parser_stream_disable)(struct wg_parser_stream *stream);
- unix_wg_parser_stream_get_event,
- unix_wg_parser_stream_copy_buffer,
- unix_wg_parser_stream_release_buffer,
- unix_wg_parser_stream_notify_qos,
+ bool (CDECL *wg_parser_stream_get_event)(struct wg_parser_stream *stream, struct wg_parser_event *event);
+ bool (CDECL *wg_parser_stream_copy_buffer)(struct wg_parser_stream *stream,
+ void *data, uint32_t offset, uint32_t size);
+ void (CDECL *wg_parser_stream_release_buffer)(struct wg_parser_stream *stream);
+ void (CDECL *wg_parser_stream_notify_qos)(struct wg_parser_stream *stream,
+ bool underflow, double proportion, int64_t diff, uint64_t timestamp);
- unix_wg_parser_stream_get_duration,
- unix_wg_parser_stream_seek,
+ /* 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. */
+ void (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);
};
#endif /* __WINE_WINEGSTREAMER_UNIXLIB_H */
diff --git a/dlls/winegstreamer/wg_parser.c b/dlls/winegstreamer/wg_parser.c
index 72dfab8f3d6..694f8b57ed1 100644
--- a/dlls/winegstreamer/wg_parser.c
+++ b/dlls/winegstreamer/wg_parser.c
@@ -34,6 +34,8 @@
#include <gst/video/video.h>
#include <gst/audio/audio.h>
+#include "ntstatus.h"
+#define WIN32_NO_STATUS
#include "winternl.h"
#include "dshow.h"
@@ -501,25 +503,18 @@ static bool wg_format_compare(const struct wg_format *a, const struct wg_format
return false;
}
-static NTSTATUS wg_parser_get_stream_count(void *args)
+static uint32_t CDECL wg_parser_get_stream_count(struct wg_parser *parser)
{
- struct wg_parser_get_stream_count_params *params = args;
-
- params->count = params->parser->stream_count;
- return S_OK;
+ return parser->stream_count;
}
-static NTSTATUS wg_parser_get_stream(void *args)
+static struct wg_parser_stream * CDECL wg_parser_get_stream(struct wg_parser *parser, uint32_t index)
{
- struct wg_parser_get_stream_params *params = args;
-
- params->stream = params->parser->streams[params->index];
- return S_OK;
+ return parser->streams[index];
}
-static NTSTATUS wg_parser_begin_flush(void *args)
+static void CDECL wg_parser_begin_flush(struct wg_parser *parser)
{
- struct wg_parser *parser = args;
unsigned int i;
pthread_mutex_lock(&parser->mutex);
@@ -531,26 +526,18 @@ static NTSTATUS wg_parser_begin_flush(void *args)
if (parser->streams[i]->enabled)
pthread_cond_signal(&parser->streams[i]->event_cond);
}
-
- return S_OK;
}
-static NTSTATUS wg_parser_end_flush(void *args)
+static void CDECL wg_parser_end_flush(struct wg_parser *parser)
{
- struct wg_parser *parser = args;
-
pthread_mutex_lock(&parser->mutex);
parser->flushing = false;
pthread_mutex_unlock(&parser->mutex);
-
- return S_OK;
}
-static NTSTATUS wg_parser_get_next_read_offset(void *args)
+static bool CDECL wg_parser_get_next_read_offset(struct wg_parser *parser,
+ uint64_t *offset, uint32_t *size)
{
- struct wg_parser_get_next_read_offset_params *params = args;
- struct wg_parser *parser = params->parser;
-
pthread_mutex_lock(&parser->mutex);
while (parser->sink_connected && !parser->read_request.data)
@@ -559,23 +546,19 @@ static NTSTATUS wg_parser_get_next_read_offset(void *args)
if (!parser->sink_connected)
{
pthread_mutex_unlock(&parser->mutex);
- return VFW_E_WRONG_STATE;
+ return false;
}
- params->offset = parser->read_request.offset;
- params->size = parser->read_request.size;
+ *offset = parser->read_request.offset;
+ *size = parser->read_request.size;
pthread_mutex_unlock(&parser->mutex);
- return S_OK;
+ return true;
}
-static NTSTATUS wg_parser_push_data(void *args)
+static void CDECL wg_parser_push_data(struct wg_parser *parser,
+ const void *data, uint32_t size)
{
- const struct wg_parser_push_data_params *params = args;
- struct wg_parser *parser = params->parser;
- const void *data = params->data;
- uint32_t size = params->size;
-
pthread_mutex_lock(&parser->mutex);
parser->read_request.size = size;
parser->read_request.done = true;
@@ -585,24 +568,15 @@ static NTSTATUS wg_parser_push_data(void *args)
parser->read_request.data = NULL;
pthread_mutex_unlock(&parser->mutex);
pthread_cond_signal(&parser->read_done_cond);
-
- return S_OK;
}
-static NTSTATUS wg_parser_stream_get_preferred_format(void *args)
+static void CDECL wg_parser_stream_get_preferred_format(struct wg_parser_stream *stream, struct wg_format *format)
{
- const struct wg_parser_stream_get_preferred_format_params *params = args;
-
- *params->format = params->stream->preferred_format;
- return S_OK;
+ *format = stream->preferred_format;
}
-static NTSTATUS wg_parser_stream_enable(void *args)
+static void CDECL wg_parser_stream_enable(struct wg_parser_stream *stream, const struct wg_format *format)
{
- const struct wg_parser_stream_enable_params *params = args;
- struct wg_parser_stream *stream = params->stream;
- const struct wg_format *format = params->format;
-
stream->current_format = *format;
stream->enabled = true;
@@ -633,21 +607,15 @@ static NTSTATUS wg_parser_stream_enable(void *args)
}
gst_pad_push_event(stream->my_sink, gst_event_new_reconfigure());
- return S_OK;
}
-static NTSTATUS wg_parser_stream_disable(void *args)
+static void CDECL wg_parser_stream_disable(struct wg_parser_stream *stream)
{
- struct wg_parser_stream *stream = args;
-
stream->enabled = false;
- return S_OK;
}
-static NTSTATUS wg_parser_stream_get_event(void *args)
+static bool CDECL wg_parser_stream_get_event(struct wg_parser_stream *stream, struct wg_parser_event *event)
{
- const struct wg_parser_stream_get_event_params *params = args;
- struct wg_parser_stream *stream = params->stream;
struct wg_parser *parser = stream->parser;
pthread_mutex_lock(&parser->mutex);
@@ -659,10 +627,10 @@ static NTSTATUS wg_parser_stream_get_event(void *args)
{
pthread_mutex_unlock(&parser->mutex);
GST_DEBUG("Filter is flushing.\n");
- return VFW_E_WRONG_STATE;
+ return false;
}
- *params->event = stream->event;
+ *event = stream->event;
if (stream->event.type != WG_PARSER_EVENT_BUFFER)
{
@@ -671,37 +639,33 @@ static NTSTATUS wg_parser_stream_get_event(void *args)
}
pthread_mutex_unlock(&parser->mutex);
- return S_OK;
+ return true;
}
-static NTSTATUS wg_parser_stream_copy_buffer(void *args)
+static bool CDECL wg_parser_stream_copy_buffer(struct wg_parser_stream *stream,
+ void *data, uint32_t offset, uint32_t size)
{
- const struct wg_parser_stream_copy_buffer_params *params = args;
- struct wg_parser_stream *stream = params->stream;
struct wg_parser *parser = stream->parser;
- uint32_t offset = params->offset;
- uint32_t size = params->size;
pthread_mutex_lock(&parser->mutex);
if (!stream->buffer)
{
pthread_mutex_unlock(&parser->mutex);
- return VFW_E_WRONG_STATE;
+ return false;
}
assert(stream->event.type == WG_PARSER_EVENT_BUFFER);
assert(offset < stream->map_info.size);
assert(offset + size <= stream->map_info.size);
- memcpy(params->data, stream->map_info.data + offset, size);
+ memcpy(data, stream->map_info.data + offset, size);
pthread_mutex_unlock(&parser->mutex);
- return S_OK;
+ return true;
}
-static NTSTATUS wg_parser_stream_release_buffer(void *args)
+static void CDECL wg_parser_stream_release_buffer(struct wg_parser_stream *stream)
{
- struct wg_parser_stream *stream = args;
struct wg_parser *parser = stream->parser;
pthread_mutex_lock(&parser->mutex);
@@ -715,24 +679,17 @@ static NTSTATUS wg_parser_stream_release_buffer(void *args)
pthread_mutex_unlock(&parser->mutex);
pthread_cond_signal(&stream->event_empty_cond);
-
- return S_OK;
}
-static NTSTATUS wg_parser_stream_get_duration(void *args)
+static uint64_t CDECL wg_parser_stream_get_duration(struct wg_parser_stream *stream)
{
- struct wg_parser_stream_get_duration_params *params = args;
-
- params->duration = params->stream->duration;
- return S_OK;
+ return stream->duration;
}
-static NTSTATUS wg_parser_stream_seek(void *args)
+static void 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)
{
GstSeekType start_type = GST_SEEK_TYPE_SET, stop_type = GST_SEEK_TYPE_SET;
- const struct wg_parser_stream_seek_params *params = args;
- DWORD start_flags = params->start_flags;
- DWORD stop_flags = params->stop_flags;
GstSeekFlags flags = 0;
if (start_flags & AM_SEEKING_SeekToKeyFrame)
@@ -747,39 +704,34 @@ static NTSTATUS wg_parser_stream_seek(void *args)
if ((stop_flags & AM_SEEKING_PositioningBitsMask) == AM_SEEKING_NoPositioning)
stop_type = GST_SEEK_TYPE_NONE;
- if (!gst_pad_push_event(params->stream->my_sink, gst_event_new_seek(params->rate, GST_FORMAT_TIME,
- flags, start_type, params->start_pos * 100, stop_type, params->stop_pos * 100)))
+ if (!gst_pad_push_event(stream->my_sink, gst_event_new_seek(rate, GST_FORMAT_TIME,
+ flags, start_type, start_pos * 100, stop_type, stop_pos * 100)))
GST_ERROR("Failed to seek.\n");
-
- return S_OK;
}
-static NTSTATUS wg_parser_stream_notify_qos(void *args)
+static void CDECL wg_parser_stream_notify_qos(struct wg_parser_stream *stream,
+ bool underflow, double proportion, int64_t diff, uint64_t timestamp)
{
- const struct wg_parser_stream_notify_qos_params *params = args;
- struct wg_parser_stream *stream = params->stream;
GstClockTime stream_time;
GstEvent *event;
/* We return timestamps in stream time, i.e. relative to the start of the
* file (or other medium), but gst_event_new_qos() expects the timestamp in
* running time. */
- stream_time = gst_segment_to_running_time(&stream->segment, GST_FORMAT_TIME, params->timestamp * 100);
+ stream_time = gst_segment_to_running_time(&stream->segment, GST_FORMAT_TIME, timestamp * 100);
if (stream_time == -1)
{
/* This can happen legitimately if the sample falls outside of the
* segment bounds. GStreamer elements shouldn't present the sample in
* that case, but DirectShow doesn't care. */
GST_LOG("Ignoring QoS event.\n");
- return S_OK;
+ return;
}
- if (!(event = gst_event_new_qos(params->underflow ? GST_QOS_TYPE_UNDERFLOW : GST_QOS_TYPE_OVERFLOW,
- params->proportion, params->diff * 100, stream_time)))
+ if (!(event = gst_event_new_qos(underflow ? GST_QOS_TYPE_UNDERFLOW : GST_QOS_TYPE_OVERFLOW,
+ proportion, diff * 100, stream_time)))
GST_ERROR("Failed to create QOS event.\n");
gst_pad_push_event(stream->my_sink, event);
-
- return S_OK;
}
static GstAutoplugSelectResult autoplug_select_cb(GstElement *bin, GstPad *pad,
@@ -1575,16 +1527,14 @@ static gboolean src_event_cb(GstPad *pad, GstObject *parent, GstEvent *event)
return ret;
}
-static NTSTATUS wg_parser_connect(void *args)
+static HRESULT CDECL wg_parser_connect(struct wg_parser *parser, uint64_t file_size)
{
GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE("quartz_src",
GST_PAD_SRC, GST_PAD_ALWAYS, GST_STATIC_CAPS_ANY);
- const struct wg_parser_connect_params *params = args;
- struct wg_parser *parser = params->parser;
unsigned int i;
int ret;
- parser->file_size = params->file_size;
+ parser->file_size = file_size;
parser->sink_connected = true;
if (!parser->bus)
@@ -1734,9 +1684,8 @@ out:
return E_FAIL;
}
-static NTSTATUS wg_parser_disconnect(void *args)
+static void CDECL wg_parser_disconnect(struct wg_parser *parser)
{
- struct wg_parser *parser = args;
unsigned int i;
/* Unblock all of our streams. */
@@ -1769,8 +1718,6 @@ static NTSTATUS wg_parser_disconnect(void *args)
gst_element_set_bus(parser->container, NULL);
gst_object_unref(parser->container);
parser->container = NULL;
-
- return S_OK;
}
static BOOL decodebin_parser_init_gst(struct wg_parser *parser)
@@ -1931,7 +1878,7 @@ static void init_gstreamer_once(void)
gst_version_string(), GST_VERSION_MAJOR, GST_VERSION_MINOR, GST_VERSION_MICRO);
}
-static NTSTATUS wg_parser_create(void *args)
+static struct wg_parser * CDECL wg_parser_create(enum wg_parser_type type, bool unlimited_buffering)
{
static const init_gst_cb init_funcs[] =
{
@@ -1942,32 +1889,28 @@ static NTSTATUS wg_parser_create(void *args)
};
static pthread_once_t once = PTHREAD_ONCE_INIT;
- struct wg_parser_create_params *params = args;
struct wg_parser *parser;
if (pthread_once(&once, init_gstreamer_once))
- return E_FAIL;
+ return NULL;
if (!(parser = calloc(1, sizeof(*parser))))
- return E_OUTOFMEMORY;
+ return NULL;
pthread_mutex_init(&parser->mutex, NULL);
pthread_cond_init(&parser->init_cond, NULL);
pthread_cond_init(&parser->read_cond, NULL);
pthread_cond_init(&parser->read_done_cond, NULL);
parser->flushing = true;
- parser->init_gst = init_funcs[params->type];
- parser->unlimited_buffering = params->unlimited_buffering;
+ parser->init_gst = init_funcs[type];
+ parser->unlimited_buffering = unlimited_buffering;
GST_DEBUG("Created winegstreamer parser %p.\n", parser);
- params->parser = parser;
- return S_OK;
+ return parser;
}
-static NTSTATUS wg_parser_destroy(void *args)
+static void CDECL wg_parser_destroy(struct wg_parser *parser)
{
- struct wg_parser *parser = args;
-
if (parser->bus)
{
gst_bus_set_sync_handler(parser->bus, NULL, NULL, NULL);
@@ -1980,36 +1923,41 @@ static NTSTATUS wg_parser_destroy(void *args)
pthread_cond_destroy(&parser->read_done_cond);
free(parser);
- return S_OK;
}
-const unixlib_entry_t __wine_unix_call_funcs[] =
+static const struct unix_funcs funcs =
{
-#define X(name) [unix_ ## name] = name
- X(wg_parser_create),
- X(wg_parser_destroy),
+ wg_parser_create,
+ wg_parser_destroy,
- X(wg_parser_connect),
- X(wg_parser_disconnect),
+ wg_parser_connect,
+ wg_parser_disconnect,
- X(wg_parser_begin_flush),
- X(wg_parser_end_flush),
+ wg_parser_begin_flush,
+ wg_parser_end_flush,
- X(wg_parser_get_next_read_offset),
- X(wg_parser_push_data),
+ wg_parser_get_next_read_offset,
+ wg_parser_push_data,
- X(wg_parser_get_stream_count),
- X(wg_parser_get_stream),
+ wg_parser_get_stream_count,
+ wg_parser_get_stream,
- X(wg_parser_stream_get_preferred_format),
- X(wg_parser_stream_enable),
- X(wg_parser_stream_disable),
+ wg_parser_stream_get_preferred_format,
+ wg_parser_stream_enable,
+ wg_parser_stream_disable,
- X(wg_parser_stream_get_event),
- X(wg_parser_stream_copy_buffer),
- X(wg_parser_stream_release_buffer),
- X(wg_parser_stream_notify_qos),
+ wg_parser_stream_get_event,
+ wg_parser_stream_copy_buffer,
+ wg_parser_stream_release_buffer,
+ wg_parser_stream_notify_qos,
- X(wg_parser_stream_get_duration),
- X(wg_parser_stream_seek),
+ wg_parser_stream_get_duration,
+ wg_parser_stream_seek,
};
+
+NTSTATUS CDECL __wine_init_unix_lib(HMODULE module, DWORD reason, const void *ptr_in, void *ptr_out)
+{
+ if (reason == DLL_PROCESS_ATTACH)
+ *(const struct unix_funcs **)ptr_out = &funcs;
+ return STATUS_SUCCESS;
+}
--
2.33.0