[PATCH 2/2] winegstreamer: Allow some audio resampling in the default pipeline.
Rémi Bernon
rbernon at codeweavers.com
Wed Oct 27 10:25:04 CDT 2021
Planet Coaster requests an output format with 44100 rate for user
provided music, which may not match what the files are decoded to.
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
dlls/winegstreamer/media_source.c | 21 +++++++++++++++------
dlls/winegstreamer/wg_parser.c | 10 ++++++++--
2 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/dlls/winegstreamer/media_source.c b/dlls/winegstreamer/media_source.c
index 6ecd345cb73..6a96ddae0bd 100644
--- a/dlls/winegstreamer/media_source.c
+++ b/dlls/winegstreamer/media_source.c
@@ -922,22 +922,31 @@ static HRESULT media_stream_init_desc(struct media_stream *stream)
{
/* Expose at least one PCM and one floating point type for the
consumer to pick from. */
- static const enum wg_audio_format audio_types[] =
+ static const struct
{
- WG_AUDIO_FORMAT_S16LE,
- WG_AUDIO_FORMAT_F32LE,
+ enum wg_audio_format format;
+ UINT32 rate;
+ }
+ audio_formats[] =
+ {
+ {WG_AUDIO_FORMAT_S16LE, 48000},
+ {WG_AUDIO_FORMAT_S16LE, 44100},
+ {WG_AUDIO_FORMAT_F32LE, 48000},
+ {WG_AUDIO_FORMAT_F32LE, 44100},
};
stream_types[0] = mf_media_type_from_wg_format(&format);
type_count = 1;
- for (i = 0; i < ARRAY_SIZE(audio_types); i++)
+ for (i = 0; i < ARRAY_SIZE(audio_formats); i++)
{
struct wg_format new_format;
- if (format.u.audio.format == audio_types[i])
+ if (format.u.audio.format == audio_formats[i].format &&
+ format.u.audio.rate == audio_formats[i].rate)
continue;
new_format = format;
- new_format.u.audio.format = audio_types[i];
+ new_format.u.audio.format = audio_formats[i].format;
+ new_format.u.audio.rate = audio_formats[i].rate;
stream_types[type_count++] = mf_media_type_from_wg_format(&new_format);
}
}
diff --git a/dlls/winegstreamer/wg_parser.c b/dlls/winegstreamer/wg_parser.c
index 3b341dad9eb..b3fe25d70b1 100644
--- a/dlls/winegstreamer/wg_parser.c
+++ b/dlls/winegstreamer/wg_parser.c
@@ -1198,7 +1198,7 @@ static void pad_added_cb(GstElement *element, GstPad *pad, gpointer user)
}
else if (!strcmp(name, "audio/x-raw"))
{
- GstElement *convert;
+ GstElement *convert, *resample;
/* Currently our dsound can't handle 64-bit formats or all
* surround-sound configurations. Native dsound can't always handle
@@ -1207,11 +1207,17 @@ static void pad_added_cb(GstElement *element, GstPad *pad, gpointer user)
if (!(convert = create_element("audioconvert", "base")))
goto out;
+ if (!(resample = create_element("audioresample", "base")))
+ goto out;
+
gst_bin_add(GST_BIN(parser->container), convert);
gst_element_sync_state_with_parent(convert);
+ gst_bin_add(GST_BIN(parser->container), resample);
+ gst_element_sync_state_with_parent(resample);
+ gst_element_link(convert, resample);
stream->post_sink = gst_element_get_static_pad(convert, "sink");
- stream->post_src = gst_element_get_static_pad(convert, "src");
+ stream->post_src = gst_element_get_static_pad(resample, "src");
}
if (stream->post_sink)
--
2.33.0
More information about the wine-devel
mailing list