summaryrefslogtreecommitdiffstats
path: root/gst
diff options
context:
space:
mode:
authorSebastian Dröge <slomo@circular-chaos.org>2008-10-28 16:25:00 +0000
committerSebastian Dröge <slomo@circular-chaos.org>2008-10-28 16:25:00 +0000
commite4493882765edefb70c2dcbc4eaf21d17d5a2b0a (patch)
treed2b897a9ac98e575ccfc90d90380d30d265de85f /gst
parent0331f0c33bae42b8f871a0014895679d4d67a811 (diff)
downloadgst-plugins-bad-e4493882765edefb70c2dcbc4eaf21d17d5a2b0a.tar.gz
gst-plugins-bad-e4493882765edefb70c2dcbc4eaf21d17d5a2b0a.tar.bz2
gst-plugins-bad-e4493882765edefb70c2dcbc4eaf21d17d5a2b0a.zip
gst/audioresample/gstaudioresample.c: Fixate the rate to the nearest supported rate instead of the first one. Fixes b...
Original commit message from CVS: * gst/audioresample/gstaudioresample.c: (gst_audioresample_class_init), (audioresample_fixate_caps): Fixate the rate to the nearest supported rate instead of the first one. Fixes bug #549510.
Diffstat (limited to 'gst')
-rw-r--r--gst/audioresample/gstaudioresample.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/gst/audioresample/gstaudioresample.c b/gst/audioresample/gstaudioresample.c
index 9aa9bf77..ea1af706 100644
--- a/gst/audioresample/gstaudioresample.c
+++ b/gst/audioresample/gstaudioresample.c
@@ -112,6 +112,8 @@ static gboolean audioresample_get_unit_size (GstBaseTransform * base,
GstCaps * caps, guint * size);
static GstCaps *audioresample_transform_caps (GstBaseTransform * base,
GstPadDirection direction, GstCaps * caps);
+static void audioresample_fixate_caps (GstBaseTransform * base,
+ GstPadDirection direction, GstCaps * caps, GstCaps * othercaps);
static gboolean audioresample_transform_size (GstBaseTransform * trans,
GstPadDirection direction, GstCaps * incaps, guint insize,
GstCaps * outcaps, guint * outsize);
@@ -172,6 +174,8 @@ gst_audioresample_class_init (GstAudioresampleClass * klass)
GST_DEBUG_FUNCPTR (audioresample_get_unit_size);
GST_BASE_TRANSFORM_CLASS (klass)->transform_caps =
GST_DEBUG_FUNCPTR (audioresample_transform_caps);
+ GST_BASE_TRANSFORM_CLASS (klass)->fixate_caps =
+ GST_DEBUG_FUNCPTR (audioresample_fixate_caps);
GST_BASE_TRANSFORM_CLASS (klass)->set_caps =
GST_DEBUG_FUNCPTR (audioresample_set_caps);
GST_BASE_TRANSFORM_CLASS (klass)->transform =
@@ -272,6 +276,22 @@ audioresample_transform_caps (GstBaseTransform * base,
return res;
}
+/* Fixate rate to the allowed rate that has the smallest difference */
+static void
+audioresample_fixate_caps (GstBaseTransform * base,
+ GstPadDirection direction, GstCaps * caps, GstCaps * othercaps)
+{
+ GstStructure *s;
+ gint rate;
+
+ s = gst_caps_get_structure (caps, 0);
+ if (!gst_structure_get_int (s, "rate", &rate))
+ return;
+
+ s = gst_caps_get_structure (othercaps, 0);
+ gst_structure_fixate_field_nearest_int (s, "rate", rate);
+}
+
static gboolean
resample_set_state_from_caps (ResampleState * state, GstCaps * incaps,
GstCaps * outcaps, gint * channels, gint * inrate, gint * outrate)