rem: switch (bvw->priv->speakersetup) { case BVW_AUDIO_SOUND_STEREO: channels = 2; break; case BVW_AUDIO_SOUND_4CHANNEL: channels = 4; break; case BVW_AUDIO_SOUND_5CHANNEL: channels = 5; break; case BVW_AUDIO_SOUND_41CHANNEL:  case BVW_AUDIO_SOUND_51CHANNEL: channels = 6; break; case BVW_AUDIO_SOUND_AC3PASSTHRU: default: break; }  if (channels == -1)
add: if ((channels = get_num_audio_channels (bvw)) == -1)
context: cb_audio_fixate (GstPad *pad,		 const GstCaps *in_caps,		 BaconVideoWidget *bvw){  gint channels = -1, n, count, diff = -1;  const GstStructure *s, *closest = NULL;  const GValue *v;  switch (bvw->priv->speakersetup) {    case BVW_AUDIO_SOUND_STEREO:      channels = 2;      break;    case BVW_AUDIO_SOUND_4CHANNEL:      channels = 4;      break;    case BVW_AUDIO_SOUND_5CHANNEL:      channels = 5;      break;    case BVW_AUDIO_SOUND_41CHANNEL:      /* so alsa has this as 5.1, but empty center speaker. We don't really       * do that yet. ;-). So we'll take the placebo approach. */    case BVW_AUDIO_SOUND_51CHANNEL:      channels = 6;      break;    case BVW_AUDIO_SOUND_AC3PASSTHRU:    default:      break;  }  if (channels == -1)    return NULL;  /* there might be multiple structures, and one might contain the   * channelcount that we want. Try that. */  count = gst_caps_get_size (in_caps);  for (n = 0; n < count; n++) {    s = gst_caps_get_structure (in_caps, n);    v = gst_structure_get_value (s, "channels");    if (!v)      continue;    /* get channel count (or list of ~) */    if (G_VALUE_TYPE (v) == G_TYPE_INT) {      gint c = g_value_get_int (v);      if (channels == c) {        if (count == 1)          return NULL;        return gst_caps_new_full (gst_structure_copy (s), NULL);      } else if (!closest || abs (c - channels) < diff) {        diff = abs (c - channels);        closest = s;      }    } else if (G_VALUE_TYPE (v) == GST_TYPE_INT_RANGE) {      gint c1 = gst_value_get_int_range_min (v),           c2 = gst_value_get_int_range_max (v);      if (c1 <= channels  && c2 >= channels) {        GstCaps *caps;        caps = gst_caps_new_full (gst_structure_copy (s), NULL);        gst_caps_structure_fixate_field_nearest_int (            gst_caps_get_structure (caps, 0), "channels", channels);        return caps;      } else if (!closest ||                 (c1 > channels && c1 - channels < diff) ||                 (c2 < channels && channels - c2 < diff)) {        closest = s; /* FIXME: fixate already? */        diff = c1 > channels ? c1 - channels : channels - c2;      }    } else if (G_VALUE_TYPE (v) == GST_TYPE_LIST) {      const GValue *kid;      gint nkid, kidcount = gst_value_list_get_size (v), kidc;      for (nkid = 0; nkid < kidcount; nkid++) {        kid = gst_value_list_get_value (v, nkid);        if (G_VALUE_TYPE (kid) != G_TYPE_INT)          continue;        kidc = g_value_get_int (kid);        if (kidc == channels) {          GstCaps *caps;          caps = gst_caps_new_full (gst_structure_copy (s), NULL);          gst_caps_structure_fixate_field_nearest_int (              gst_caps_get_structure (caps, 0), "channels", channels);          return caps;        } else if (!closest || abs (kidc - channels) < diff) {          diff = abs (kidc - channels);          closest = s;        }      }    }  }  /* FIXME: we could do something with closest here... */  return NULL;}