Commit 60146e30 authored by Jacek Tomaszewski's avatar Jacek Tomaszewski Committed by Nirbheek Chauhan

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's avatarNirbheek Chauhan <nirbheek@centricular.com>
parent f710b36a
Pipeline #15794 passed with stages
in 27 minutes and 54 seconds
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment