[cheese] Add cheese_camera_device_find_full_format() helper
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cheese] Add cheese_camera_device_find_full_format() helper
- Date: Mon, 2 Sep 2013 21:20:00 +0000 (UTC)
commit 4cb89c66167a1945e936707b5d2d3e5b4c9f2871
Author: Hans de Goede <hdegoede redhat com>
Date: Mon Jun 10 14:27:04 2013 +0200
Add cheese_camera_device_find_full_format() helper
Signed-off-by: Hans de Goede <hdegoede redhat com>
libcheese/cheese-camera-device.c | 46 ++++++++++++++++++++++++++++---------
1 files changed, 35 insertions(+), 11 deletions(-)
---
diff --git a/libcheese/cheese-camera-device.c b/libcheese/cheese-camera-device.c
index 83c9ecc..9997f55 100644
--- a/libcheese/cheese-camera-device.c
+++ b/libcheese/cheese-camera-device.c
@@ -321,6 +321,33 @@ cheese_camera_device_format_update_framerate (CheeseVideoFormatFull *format,
}
/*
+ * cheese_camera_device_find_full_format:
+ * @device: a #CheeseCameraDevice
+ * @format: #CheeseVideoFormat to find the matching #CheeseVideoFormatFull for
+ *
+ * Find a #CheeseVideoFormatFull matching the passed in #CheeseVideoFormat.
+ */
+static CheeseVideoFormatFull *
+cheese_camera_device_find_full_format (CheeseCameraDevice *device,
+ CheeseVideoFormat* format)
+{
+ GList *l;
+
+ for (l = device->priv->formats; l != NULL; l = g_list_next (l))
+ {
+ CheeseVideoFormatFull *item = l->data;
+
+ if ((item != NULL) &&
+ (item->width == format->width) && (item->height == format->height))
+ {
+ return item;
+ }
+ }
+
+ return NULL;
+}
+
+/*
* cheese_camera_device_add_format:
* @device: a #CheeseCameraDevice
* @format: the #CheeseVideoFormatFull to add
@@ -333,19 +360,16 @@ cheese_camera_device_add_format (CheeseCameraDevice *device,
const GValue *framerate)
{
CheeseCameraDevicePrivate *priv = device->priv;
- GList *l;
+ CheeseVideoFormatFull *existing;
- for (l = priv->formats; l != NULL; l = g_list_next (l))
- {
- CheeseVideoFormatFull *item = l->data;
+ existing = cheese_camera_device_find_full_format (device,
+ (CheeseVideoFormat *)format);
- if ((item != NULL) &&
- (item->width == format->width) &&
- (item->height == format->height))
- {
- cheese_camera_device_format_update_framerate (item, framerate);
- return;
- }
+ if (existing)
+ {
+ g_slice_free (CheeseVideoFormatFull, format);
+ cheese_camera_device_format_update_framerate (existing, framerate);
+ return;
}
cheese_camera_device_get_highest_framerate (framerate, &format->fr_numerator,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]