summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacek Tomaszewski <lord.jacold@gmail.com>2018-12-12 13:14:13 +0100
committerTim-Philipp Müller <tim@centricular.com>2019-05-02 10:04:58 +0100
commit0b7e541dfd4f57d9595fadc1df82db824b3facf6 (patch)
tree64bcbaf6489751d443dd643826674a69c97b225a
parentee169f14f42734aa444d2da884d84873e917cc95 (diff)
downloadgstreamer-plugins-bad-0b7e541dfd4f57d9595fadc1df82db824b3facf6.tar.gz
wasapi: Fixed corner-cases in mapping of channel mask
'channel-mask' field should not be put in caps if channel mask is 0x0 Mapping WASAPI channel mask to GST equivalent was going only over first nChannels elements of wasapi_to_gst_pos array, translating, for example, WASAPI's 0x63f to GST's 0x3f instead of 0xc3f. When 'channel-mask' is specified as NULL, it signifies that there's need to do downmix or upmix and it makes caps negotiation with audioconvert element impossible. Just omit it. Signed-off-by: Nirbheek Chauhan <nirbheek@centricular.com>
-rw-r--r--sys/wasapi/gstwasapiutil.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/sys/wasapi/gstwasapiutil.c b/sys/wasapi/gstwasapiutil.c
index d630d6bc3..39643659b 100644
--- a/sys/wasapi/gstwasapiutil.c
+++ b/sys/wasapi/gstwasapiutil.c
@@ -695,7 +695,7 @@ static guint64
gst_wasapi_util_waveformatex_to_channel_mask (WAVEFORMATEXTENSIBLE * format,
GstAudioChannelPosition ** out_position)
{
- int ii;
+ int ii, ch;
guint64 mask = 0;
WORD nChannels = format->Format.nChannels;
DWORD dwChannelMask = format->dwChannelMask;
@@ -719,14 +719,19 @@ gst_wasapi_util_waveformatex_to_channel_mask (WAVEFORMATEXTENSIBLE * format,
/* Map WASAPI's channel mask to Gstreamer's channel mask and positions.
* If the no. of bits in the mask > nChannels, we will ignore the extra. */
- for (ii = 0; ii < nChannels; ii++) {
+ for (ii = 0, ch = 0; ii < G_N_ELEMENTS (wasapi_to_gst_pos) && ch < nChannels;
+ ii++) {
if (!(dwChannelMask & wasapi_to_gst_pos[ii].wasapi_pos))
- /* Non-positional or unknown position, warn? */
+ /* no match, try next */
continue;
mask |= G_GUINT64_CONSTANT (1) << wasapi_to_gst_pos[ii].gst_pos;
- pos[ii] = wasapi_to_gst_pos[ii].gst_pos;
+ pos[ch++] = wasapi_to_gst_pos[ii].gst_pos;
}
+ /* XXX: Warn if some channel masks couldn't be mapped? */
+
+ GST_DEBUG ("Converted WASAPI mask 0x%x -> 0x%x", dwChannelMask, mask);
+
out:
if (out_position)
*out_position = pos;
@@ -773,8 +778,12 @@ gst_wasapi_util_parse_waveformatex (WAVEFORMATEXTENSIBLE * format,
gst_structure_set (s,
"format", G_TYPE_STRING, afmt,
"channels", G_TYPE_INT, format->Format.nChannels,
- "rate", G_TYPE_INT, format->Format.nSamplesPerSec,
- "channel-mask", GST_TYPE_BITMASK, channel_mask, NULL);
+ "rate", G_TYPE_INT, format->Format.nSamplesPerSec, NULL);
+
+ if (channel_mask) {
+ gst_structure_set (s,
+ "channel-mask", GST_TYPE_BITMASK, channel_mask, NULL);
+ }
}
return TRUE;