From 8914180cb7834c659e4232ebb3e0d16ae569d42e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Thu, 16 Feb 2006 20:19:51 +0000 Subject: [PATCH] gst-libs/gst/riff/riff-media.c: Set codec_name for WAVEFORMATEX as well. When we have 'normal PCM' with 4 or 6 channe... Original commit message from CVS: * gst-libs/gst/riff/riff-media.c: (gst_riff_create_audio_caps): Set codec_name for WAVEFORMATEX as well. When we have 'normal PCM' with 4 or 6 channels, assume a default channel layout to make things work (not sure there's anything else we can do in those cases). --- ChangeLog | 7 +++++++ gst-libs/gst/riff/riff-media.c | 37 ++++++++++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7c950733df..9c5edc0cf1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-02-16 Tim-Philipp Müller + + * gst-libs/gst/riff/riff-media.c: (gst_riff_create_audio_caps): + Set codec_name for WAVEFORMATEX as well. When we have 'normal PCM' + with 4 or 6 channels, assume a default channel layout to make things + work (not sure there's anything else we can do in those cases). + 2006-02-16 Tim-Philipp Müller * gst-libs/gst/audio/multichannel.c: diff --git a/gst-libs/gst/riff/riff-media.c b/gst-libs/gst/riff/riff-media.c index 5a27b54e15..05511c7113 100644 --- a/gst-libs/gst/riff/riff-media.c +++ b/gst-libs/gst/riff/riff-media.c @@ -667,10 +667,38 @@ gst_riff_create_audio_caps (guint16 codec_id, gint ch = strf->channels; gint ws = strf->size; - caps = gst_caps_new_simple ("audio/x-raw-int", - "endianness", G_TYPE_INT, G_LITTLE_ENDIAN, + caps = gst_caps_new_simple ("audio/x-raw-int", "endianness", G_TYPE_INT, G_LITTLE_ENDIAN, "channels", G_TYPE_INT, ch, /* needed for _add_layout() */ "width", G_TYPE_INT, (int) (ba * 8 / ch), "depth", G_TYPE_INT, ws, "signed", G_TYPE_BOOLEAN, ws != 8, NULL); + + /* Add default MS channel layout if we have more than 2 channels, + * but the layout isn't specified like with WAVEEXT below. Not sure + * if this is right, but at least it makes sound output work at all + * in those cases. Somebody with a a 5.1 setup should double-check + * with chan-id.wav */ + if (ch > 2) { + guint32 channel_mask; + + switch (ch) { + case 4: + channel_mask = 0x33; + break; + case 6: + channel_mask = 0x3f; + break; + default: + GST_WARNING ("don't know default layout for %d channels", ch); + channel_mask = 0; + break; + } + + if (channel_mask) { + GST_DEBUG ("using default channel layout for %d channels", ch); + if (!gst_riff_wavext_add_channel_layout (caps, channel_mask)) { + GST_WARNING ("failed to add channel layout"); + } + } + } } else { /* FIXME: this is pretty useless - we need fixed caps */ caps = gst_caps_from_string ("audio/x-raw-int, " @@ -837,6 +865,11 @@ gst_riff_create_audio_caps (guint16 codec_id, caps = NULL; } rate_chan = FALSE; + + if (codec_name) { + *codec_name = g_strdup_printf ("Uncompressed %d-bit PCM audio", + strf->size); + } } } else if (subformat_guid[0] == 0x00000003) { GST_DEBUG ("FIXME: handle IEEE float format");