Commit 2df0b960 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

winegstreamer: Introduce a new wg_init_gstreamer unixlib entry.

parent 3099e6af
......@@ -16,6 +16,7 @@ C_SRCS = \
quartz_parser.c \
quartz_transform.c \
resampler.c \
unixlib.c \
video_decoder.c \
video_processor.c \
wg_allocator.c \
......
......@@ -616,6 +616,9 @@ static BOOL CALLBACK init_gstreamer_proc(INIT_ONCE *once, void *param, void **ct
{
HINSTANCE handle;
if (WINE_UNIX_CALL(unix_wg_init_gstreamer, NULL))
return FALSE;
/* Unloading glib is a bad idea.. it installs atexit handlers,
* so never unload the dll after loading */
GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_PIN,
......
......@@ -1392,9 +1392,6 @@ static HRESULT parser_create(enum wg_parser_type type, struct parser **parser)
{
struct parser *object;
if (!init_gstreamer())
return E_FAIL;
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
......
......@@ -25,13 +25,25 @@
#include <gst/gst.h>
extern bool init_gstreamer(void) DECLSPEC_HIDDEN;
/* unixlib.c */
GST_DEBUG_CATEGORY_EXTERN(wine) DECLSPEC_HIDDEN;
#define GST_CAT_DEFAULT wine
extern NTSTATUS wg_init_gstreamer(void *args) DECLSPEC_HIDDEN;
/* wg_parser.c */
extern GstElement *create_element(const char *name, const char *plugin_set) DECLSPEC_HIDDEN;
/* wg_format.c */
extern void wg_format_from_caps(struct wg_format *format, const GstCaps *caps) DECLSPEC_HIDDEN;
extern bool wg_format_compare(const struct wg_format *a, const struct wg_format *b) DECLSPEC_HIDDEN;
extern GstCaps *wg_format_to_caps(const struct wg_format *format) DECLSPEC_HIDDEN;
/* wg_transform.c */
extern NTSTATUS wg_transform_create(void *args) DECLSPEC_HIDDEN;
extern NTSTATUS wg_transform_destroy(void *args) DECLSPEC_HIDDEN;
extern NTSTATUS wg_transform_set_output_format(void *args) DECLSPEC_HIDDEN;
......@@ -39,6 +51,8 @@ extern NTSTATUS wg_transform_push_data(void *args) DECLSPEC_HIDDEN;
extern NTSTATUS wg_transform_read_data(void *args) DECLSPEC_HIDDEN;
extern NTSTATUS wg_transform_get_status(void *args) DECLSPEC_HIDDEN;
/* wg_allocator.c */
/* wg_allocator_release_sample can be used to release any sample that was requested. */
typedef struct wg_sample *(*wg_allocator_request_sample_cb)(gsize size, void *context);
extern GstAllocator *wg_allocator_create(wg_allocator_request_sample_cb request_sample,
......
/*
* winegstreamer Unix library interface
*
* Copyright 2020-2021 Zebediah Figura for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#if 0
#pragma makedep unix
#endif
#include "config.h"
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
#include <gst/gst.h>
#include <gst/video/video.h>
#include <gst/audio/audio.h>
#include <gst/tag/tag.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "winternl.h"
#include "dshow.h"
#include "unix_private.h"
/* GStreamer callbacks may be called on threads not created by Wine, and
* therefore cannot access the Wine TEB. This means that we must use GStreamer
* debug logging instead of Wine debug logging. In order to be safe we forbid
* any use of Wine debug logging in this entire file. */
GST_DEBUG_CATEGORY(wine);
NTSTATUS wg_init_gstreamer(void *arg)
{
char arg0[] = "wine";
char arg1[] = "--gst-disable-registry-fork";
char *args[] = {arg0, arg1, NULL};
int argc = ARRAY_SIZE(args) - 1;
char **argv = args;
GError *err;
if (!gst_init_check(&argc, &argv, &err))
{
fprintf(stderr, "winegstreamer: failed to initialize GStreamer: %s\n", err->message);
g_error_free(err);
return STATUS_UNSUCCESSFUL;
}
GST_DEBUG_CATEGORY_INIT(wine, "WINE", GST_DEBUG_FG_RED, "Wine GStreamer support");
GST_INFO("GStreamer library version %s; wine built with %d.%d.%d.",
gst_version_string(), GST_VERSION_MAJOR, GST_VERSION_MINOR, GST_VERSION_MICRO);
return STATUS_SUCCESS;
}
......@@ -335,6 +335,8 @@ struct wg_transform_get_status_params
enum unix_funcs
{
unix_wg_init_gstreamer,
unix_wg_parser_create,
unix_wg_parser_destroy,
......
......@@ -35,9 +35,6 @@
#include "wine/list.h"
GST_DEBUG_CATEGORY_EXTERN(wine);
#define GST_CAT_DEFAULT wine
typedef struct
{
GstMemory parent;
......
......@@ -40,9 +40,6 @@
#include "unix_private.h"
GST_DEBUG_CATEGORY_EXTERN(wine);
#define GST_CAT_DEFAULT wine
static enum wg_audio_format wg_audio_format_from_gst(GstAudioFormat format)
{
switch (format)
......
......@@ -49,14 +49,6 @@ typedef enum
GST_AUTOPLUG_SELECT_SKIP,
} GstAutoplugSelectResult;
/* GStreamer callbacks may be called on threads not created by Wine, and
* therefore cannot access the Wine TEB. This means that we must use GStreamer
* debug logging instead of Wine debug logging. In order to be safe we forbid
* any use of Wine debug logging in this entire file. */
GST_DEBUG_CATEGORY(wine);
#define GST_CAT_DEFAULT wine
typedef BOOL (*init_gst_cb)(struct wg_parser *parser);
struct wg_parser
......@@ -1680,35 +1672,6 @@ static BOOL wave_parser_init_gst(struct wg_parser *parser)
return TRUE;
}
static void init_gstreamer_once(void)
{
char arg0[] = "wine";
char arg1[] = "--gst-disable-registry-fork";
char *args[] = {arg0, arg1, NULL};
int argc = ARRAY_SIZE(args) - 1;
char **argv = args;
GError *err;
if (!gst_init_check(&argc, &argv, &err))
{
fprintf(stderr, "winegstreamer: failed to initialize GStreamer: %s\n", err->message);
g_error_free(err);
return;
}
GST_DEBUG_CATEGORY_INIT(wine, "WINE", GST_DEBUG_FG_RED, "Wine GStreamer support");
GST_INFO("GStreamer library version %s; wine built with %d.%d.%d.",
gst_version_string(), GST_VERSION_MAJOR, GST_VERSION_MINOR, GST_VERSION_MICRO);
}
bool init_gstreamer(void)
{
static pthread_once_t init_once = PTHREAD_ONCE_INIT;
return !pthread_once(&init_once, init_gstreamer_once);
}
static NTSTATUS wg_parser_create(void *args)
{
static const init_gst_cb init_funcs[] =
......@@ -1722,9 +1685,6 @@ static NTSTATUS wg_parser_create(void *args)
struct wg_parser_create_params *params = args;
struct wg_parser *parser;
if (!init_gstreamer())
return E_FAIL;
if (!(parser = calloc(1, sizeof(*parser))))
return E_OUTOFMEMORY;
......@@ -1763,6 +1723,8 @@ static NTSTATUS wg_parser_destroy(void *args)
const unixlib_entry_t __wine_unix_call_funcs[] =
{
#define X(name) [unix_ ## name] = name
X(wg_init_gstreamer),
X(wg_parser_create),
X(wg_parser_destroy),
......
......@@ -39,9 +39,6 @@
#include "unix_private.h"
GST_DEBUG_CATEGORY_EXTERN(wine);
#define GST_CAT_DEFAULT wine
#define GST_SAMPLE_FLAG_WG_CAPS_CHANGED (GST_MINI_OBJECT_FLAG_LAST << 0)
struct wg_transform
......@@ -360,9 +357,6 @@ NTSTATUS wg_transform_create(void *args)
const gchar *media_type;
GstEvent *event;
if (!init_gstreamer())
return STATUS_UNSUCCESSFUL;
if (!(transform = calloc(1, sizeof(*transform))))
return STATUS_NO_MEMORY;
if (!(transform->container = gst_bin_new("wg_transform")))
......
......@@ -2541,6 +2541,9 @@ HRESULT WINAPI winegstreamer_create_wm_sync_reader(IUnknown *outer, void **out)
TRACE("out %p.\n", out);
if (!init_gstreamer())
return E_FAIL;
if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
......
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