audio-channels: allow partially valid channel_mask
authorPeter G. Baum <peter@dr-baum.net>
Fri, 3 Oct 2014 10:54:17 +0000 (12:54 +0200)
committerSebastian Dröge <sebastian@centricular.com>
Tue, 14 Oct 2014 08:29:56 +0000 (10:29 +0200)
Since WAVEFORMATEXTENSIBLE allows to have more channels than
bits in the channel mask we should allow this, too, to avoid
loss of information.

https://bugzilla.gnome.org/show_bug.cgi?id=733405

gst-libs/gst/audio/audio-channels.c

index e5d2a555c2b204a4d8c166729904424a70946b65..515eb940c3dfca7317e08594df019a741e144508 100644 (file)
@@ -301,6 +301,8 @@ gst_audio_channel_positions_to_mask (const GstAudioChannelPosition * position,
  * (which should have at least @channels entries ensured by caller).
  * If @channel_mask is set to 0, it is considered as 'not present' for purpose
  * of conversion.
+ * A partially valid @channel_mask with less bits set than the number
+ * of channels is considered valid.
  *
  * Returns: %TRUE if channel and channel mask are valid and could be converted
  */
@@ -331,14 +333,12 @@ gst_audio_channel_positions_from_mask (gint channels, guint64 channel_mask,
       if ((channel_mask & (G_GUINT64_CONSTANT (1) << i))) {
         if (j < channels)
           position[j] = default_channel_order[i];
-        if (default_channel_order[i] == GST_AUDIO_CHANNEL_POSITION_INVALID)
-          goto invalid_channel_mask;
         j++;
       }
     }
-
     if (j != channels)
-      goto invalid_channel_mask;
+      GST_WARNING ("Only partially valid channel mask 0x%016" G_GINT64_MODIFIER
+          "x for %d channels", channel_mask, channels);
   }
 
   return TRUE;
@@ -349,12 +349,6 @@ no_channel_mask:
     GST_ERROR ("no channel-mask property given");
     return FALSE;
   }
-invalid_channel_mask:
-  {
-    GST_ERROR ("Invalid channel mask 0x%016" G_GINT64_MODIFIER
-        "x for %d channels", channel_mask, channels);
-    return FALSE;
-  }
 }