winegstreamer: Append audioconvert and audioresample elements.

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 <rbernon@codeweavers.com>
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Rémi Bernon 2022-02-22 12:23:24 -06:00 committed by Alexandre Julliard
parent d84d9054f5
commit 0052ffbfa0
3 changed files with 54 additions and 1 deletions

View File

@ -26,6 +26,7 @@
#include <gst/gst.h>
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;

View File

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

View File

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