From 0052ffbfa0e7672278b3d5fcdb767d604fa0f565 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Bernon?= Date: Tue, 22 Feb 2022 12:23:24 -0600 Subject: [PATCH] winegstreamer: Append audioconvert and audioresample elements. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit So that we can decode WMA to something else than the default avdec_wmav2 F32LE / non-interleaved format. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=51931 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=52391 Signed-off-by: RĂ©mi Bernon Signed-off-by: Zebediah Figura Signed-off-by: Alexandre Julliard --- dlls/winegstreamer/unix_private.h | 1 + dlls/winegstreamer/wg_parser.c | 2 +- dlls/winegstreamer/wg_transform.c | 52 +++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/dlls/winegstreamer/unix_private.h b/dlls/winegstreamer/unix_private.h index f9c4da2f6ea..d3f32484ee6 100644 --- a/dlls/winegstreamer/unix_private.h +++ b/dlls/winegstreamer/unix_private.h @@ -26,6 +26,7 @@ #include extern bool init_gstreamer(void) DECLSPEC_HIDDEN; +extern GstElement *create_element(const char *name, const char *plugin_set) DECLSPEC_HIDDEN; 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; diff --git a/dlls/winegstreamer/wg_parser.c b/dlls/winegstreamer/wg_parser.c index e5ed496387e..85c28895159 100644 --- a/dlls/winegstreamer/wg_parser.c +++ b/dlls/winegstreamer/wg_parser.c @@ -692,7 +692,7 @@ static gboolean sink_query_cb(GstPad *pad, GstObject *parent, GstQuery *query) } } -static GstElement *create_element(const char *name, const char *plugin_set) +GstElement *create_element(const char *name, const char *plugin_set) { GstElement *element; diff --git a/dlls/winegstreamer/wg_transform.c b/dlls/winegstreamer/wg_transform.c index ad30653c147..d20d7640ded 100644 --- a/dlls/winegstreamer/wg_transform.c +++ b/dlls/winegstreamer/wg_transform.c @@ -72,11 +72,36 @@ NTSTATUS wg_transform_destroy(void *args) return STATUS_SUCCESS; } +static bool transform_append_element(struct wg_transform *transform, GstElement *element, + GstElement **first, GstElement **last) +{ + gchar *name = gst_element_get_name(element); + bool success = false; + + if (!gst_bin_add(GST_BIN(transform->container), element) || + (*last && !gst_element_link(*last, element))) + { + GST_ERROR("Failed to link %s element.", name); + } + else + { + GST_DEBUG("Linked %s element %p.", name, element); + if (!*first) + *first = element; + *last = element; + success = true; + } + + g_free(name); + return success; +} + NTSTATUS wg_transform_create(void *args) { struct wg_transform_create_params *params = args; struct wg_format output_format = *params->output_format; struct wg_format input_format = *params->input_format; + GstElement *first = NULL, *last = NULL, *element; GstCaps *src_caps = NULL, *sink_caps = NULL; NTSTATUS status = STATUS_UNSUCCESSFUL; GstPadTemplate *template = NULL; @@ -111,6 +136,33 @@ NTSTATUS wg_transform_create(void *args) gst_pad_set_element_private(transform->my_sink, transform); gst_pad_set_chain_function(transform->my_sink, transform_sink_chain_cb); + switch (output_format.major_type) + { + case WG_MAJOR_TYPE_AUDIO: + /* The MF audio decoder transforms allow decoding to various formats + * as well as resampling the audio at the same time, whereas + * GStreamer decoder plugins usually only support decoding to a + * single format and at the original rate. + * + * The WMA decoder transform also has output samples interleaved on + * Windows, whereas GStreamer avdec_wmav2 output uses + * non-interleaved format. + */ + if (!(element = create_element("audioconvert", "base")) + || !transform_append_element(transform, element, &first, &last)) + goto out_free_sink_pad; + if (!(element = create_element("audioresample", "base")) + || !transform_append_element(transform, element, &first, &last)) + goto out_free_sink_pad; + break; + + case WG_MAJOR_TYPE_VIDEO: + case WG_MAJOR_TYPE_WMA: + case WG_MAJOR_TYPE_UNKNOWN: + GST_FIXME("Format %u not implemented!", output_format.major_type); + goto out_free_sink_pad; + } + gst_element_set_state(transform->container, GST_STATE_PAUSED); if (!gst_element_get_state(transform->container, NULL, NULL, -1)) goto out_free_sink_pad;