Commit 4ba31162 authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

winegstreamer: Convert the Unix library to the __wine_unix_call interface.

parent 494039d0
MODULE = winegstreamer.dll
UNIXLIB = winegstreamer.so
IMPORTS = strmbase strmiids uuid ole32 mfuuid
DELAYIMPORTS = mfplat
EXTRAINCL = $(GSTREAMER_CFLAGS)
......
......@@ -61,7 +61,37 @@ static inline const char *debugstr_time(REFERENCE_TIME time)
#define MEDIATIME_FROM_BYTES(x) ((LONGLONG)(x) * 10000000)
extern const struct unix_funcs *unix_funcs;
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;
HRESULT avi_splitter_create(IUnknown *outer, IUnknown **out) DECLSPEC_HIDDEN;
HRESULT decodebin_parser_create(IUnknown *outer, IUnknown **out) DECLSPEC_HIDDEN;
......
......@@ -27,16 +27,209 @@
#include "initguid.h"
#include "gst_guids.h"
static unixlib_handle_t unix_handle;
WINE_DEFAULT_DEBUG_CHANNEL(quartz);
const struct unix_funcs *unix_funcs = NULL;
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);
}
BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved)
{
if (reason == DLL_PROCESS_ATTACH)
{
DisableThreadLibraryCalls(instance);
__wine_init_unix_lib(instance, reason, NULL, &unix_funcs);
NtQueryVirtualMemory(GetCurrentProcess(), instance, MemoryWineUnixFuncs,
&unix_handle, sizeof(unix_handle), NULL);
}
return TRUE;
}
......
......@@ -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);
unix_funcs->wg_parser_stream_enable(stream->wg_stream, &format);
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)
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);
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);
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;
unix_funcs->wg_parser_begin_flush(source->wg_parser);
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);
unix_funcs->wg_parser_stream_disable(stream->wg_stream);
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 (!unix_funcs->wg_parser_stream_copy_buffer(stream->wg_stream, data, 0, event->u.buffer.size))
if (!wg_parser_stream_copy_buffer(stream->wg_stream, data, 0, event->u.buffer.size))
{
unix_funcs->wg_parser_stream_release_buffer(stream->wg_stream);
wg_parser_stream_release_buffer(stream->wg_stream);
IMFMediaBuffer_Unlock(buffer);
goto out;
}
unix_funcs->wg_parser_stream_release_buffer(stream->wg_stream);
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 (!unix_funcs->wg_parser_stream_get_event(stream->wg_stream, &event))
if (!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 (!unix_funcs->wg_parser_get_next_read_offset(source->wg_parser, &offset, &size))
if (!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);
unix_funcs->wg_parser_push_data(source->wg_parser, SUCCEEDED(hr) ? data : NULL, ret_size);
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;
unix_funcs->wg_parser_stream_get_preferred_format(stream->wg_stream, &format);
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;
unix_funcs->wg_parser_disconnect(source->wg_parser);
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);
}
unix_funcs->wg_parser_destroy(source->wg_parser);
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 = unix_funcs->wg_parser_create(WG_PARSER_DECODEBIN, true)))
if (!(parser = 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 = unix_funcs->wg_parser_connect(parser, file_size)))
if (FAILED(hr = wg_parser_connect(parser, file_size)))
goto fail;
stream_count = unix_funcs->wg_parser_get_stream_count(parser);
stream_count = 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, unix_funcs->wg_parser_get_stream(parser, i), i, &object->streams[i])))
if (FAILED(hr = new_media_stream(object, 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,
unix_funcs->wg_parser_stream_get_duration(object->streams[i]->wg_stream));
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)
unix_funcs->wg_parser_disconnect(object->wg_parser);
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)
unix_funcs->wg_parser_destroy(object->wg_parser);
wg_parser_destroy(object->wg_parser);
if (object->async_commands_queue)
MFUnlockWorkQueue(object->async_commands_queue);
if (object->event_queue)
......
......@@ -24,9 +24,12 @@
#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
......@@ -125,41 +128,123 @@ enum wg_parser_type
WG_PARSER_WAVPARSE,
};
struct unix_funcs
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 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_create,
unix_wg_parser_destroy,
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_connect,
unix_wg_parser_disconnect,
void (CDECL *wg_parser_begin_flush)(struct wg_parser *parser);
void (CDECL *wg_parser_end_flush)(struct wg_parser *parser);
unix_wg_parser_begin_flush,
unix_wg_parser_end_flush,
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_next_read_offset,
unix_wg_parser_push_data,
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_get_stream_count,
unix_wg_parser_get_stream,
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_preferred_format,
unix_wg_parser_stream_enable,
unix_wg_parser_stream_disable,
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_event,
unix_wg_parser_stream_copy_buffer,
unix_wg_parser_stream_release_buffer,
unix_wg_parser_stream_notify_qos,
/* 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);
unix_wg_parser_stream_get_duration,
unix_wg_parser_stream_seek,
};
#endif /* __WINE_WINEGSTREAMER_UNIXLIB_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment