summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorArun Raghavan <arun@centricular.com>2016-02-02 16:26:09 +0530
committerArun Raghavan <git@arunraghavan.net>2016-02-02 16:38:31 +0530
commitbb240714fb60fab91ac8fc52341c73bb940f2ad3 (patch)
treec34c48bc6ea1344c6e3a7a8ceb0a03ba1d79e87a /sys
parenteb142736318463e6e553c21707ba0d716f85a46f (diff)
downloadgstreamer-plugins-bad-bb240714fb60fab91ac8fc52341c73bb940f2ad3.tar.gz
tinyalsasink: Use int type if we support a single rate/channel count
Avoids using an int range if the field we're setting is not actually a range.
Diffstat (limited to 'sys')
-rw-r--r--sys/tinyalsa/tinyalsasink.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/sys/tinyalsa/tinyalsasink.c b/sys/tinyalsa/tinyalsasink.c
index 153d81c8d..0efcbb090 100644
--- a/sys/tinyalsa/tinyalsasink.c
+++ b/sys/tinyalsa/tinyalsasink.c
@@ -127,6 +127,7 @@ gst_tinyalsa_sink_getcaps (GstBaseSink * bsink, GstCaps * filter)
GValue format = { 0, };
struct pcm_params *params = NULL;
struct pcm_mask *mask;
+ int rate_min, rate_max, channels_min, channels_max;
guint16 m;
GST_DEBUG_OBJECT (sink, "Querying caps");
@@ -190,13 +191,23 @@ gst_tinyalsa_sink_getcaps (GstBaseSink * bsink, GstCaps * filter)
* standard rates in this range. We should probably filter the range to
* those, standard audio rates but even that isn't guaranteed to be accurate.
*/
- gst_caps_set_simple (caps, "rate", GST_TYPE_INT_RANGE,
- pcm_params_get_min (params, PCM_PARAM_RATE),
- pcm_params_get_max (params, PCM_PARAM_RATE), NULL);
-
- gst_caps_set_simple (caps, "channels", GST_TYPE_INT_RANGE,
- pcm_params_get_min (params, PCM_PARAM_CHANNELS),
- pcm_params_get_max (params, PCM_PARAM_CHANNELS), NULL);
+ rate_min = pcm_params_get_min (params, PCM_PARAM_RATE);
+ rate_max = pcm_params_get_max (params, PCM_PARAM_RATE);
+
+ if (rate_min == rate_max)
+ gst_caps_set_simple (caps, "rate", G_TYPE_INT, rate_min, NULL);
+ else
+ gst_caps_set_simple (caps, "rate", GST_TYPE_INT_RANGE, rate_min, rate_max,
+ NULL);
+
+ channels_min = pcm_params_get_min (params, PCM_PARAM_CHANNELS);
+ channels_max = pcm_params_get_max (params, PCM_PARAM_CHANNELS);
+
+ if (channels_min == channels_max)
+ gst_caps_set_simple (caps, "channels", G_TYPE_INT, channels_min, NULL);
+ else
+ gst_caps_set_simple (caps, "channels", GST_TYPE_INT_RANGE, channels_min,
+ channels_max, NULL);
gst_caps_replace (&sink->cached_caps, caps);