From 5d04be2bb442fb9e52bdc1ea490c498cf8667a24 Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Fri, 1 Jun 2012 09:58:23 +0200 Subject: Allow only possible pixel rates when setting --- src/cameras/uca-pco-camera.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/cameras/uca-pco-camera.c') diff --git a/src/cameras/uca-pco-camera.c b/src/cameras/uca-pco-camera.c index 953bef3..bba69c2 100644 --- a/src/cameras/uca-pco-camera.c +++ b/src/cameras/uca-pco-camera.c @@ -681,7 +681,24 @@ static void uca_pco_camera_set_property(GObject *object, guint property_id, cons break; case PROP_SENSOR_PIXELRATE: - pco_set_pixelrate(priv->pco, g_value_get_uint(value)); + { + guint desired_pixel_rate = g_value_get_uint(value); + guint32 pixel_rate = 0; + + for (guint i = 0; i < priv->pixelrates->n_values; i++) { + if (g_value_get_uint(g_value_array_get_nth(priv->pixelrates, i)) == desired_pixel_rate) { + pixel_rate = desired_pixel_rate; + break; + } + } + + if (pixel_rate != 0) { + if (pco_set_pixelrate(priv->pco, pixel_rate) != PCO_NOERROR) + g_warning("Cannot set pixel rate"); + } + else + g_warning("%i Hz is not possible. Please check the \"sensor-pixelrates\" property", desired_pixel_rate); + } break; case PROP_DOUBLE_IMAGE_MODE: -- cgit v1.2.3