summaryrefslogtreecommitdiffstats
path: root/sys/v4l2/gstv4l2object.c
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@gmail.com>2006-09-26 11:06:17 +0000
committerWim Taymans <wim.taymans@gmail.com>2006-09-26 11:06:17 +0000
commitd9db447dfaa832a383905bf588c0472d9a8c27e5 (patch)
tree92c0f687278e91289c2b10b5ff3090780654d50e /sys/v4l2/gstv4l2object.c
parent9cadd004a874b3181f4994df6bf87268f3aa9ca3 (diff)
sys/v4l2/: Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Original commit message from CVS: * sys/v4l2/gstv4l2object.c: (gst_v4l2_class_probe_devices), (gst_v4l2_probe_needs_probe), (gst_v4l2_object_install_properties_helper), (gst_v4l2_object_new), (gst_v4l2_object_destroy), (gst_v4l2_object_set_property_helper), (gst_v4l2_object_get_property_helper), (gst_v4l2_set_defaults), (gst_v4l2_object_start), (gst_v4l2_object_stop): * sys/v4l2/gstv4l2object.h: * sys/v4l2/gstv4l2src.c: (gst_v4l2src_class_init), (gst_v4l2src_init), (gst_v4l2src_dispose), (gst_v4l2src_set_property), (gst_v4l2src_get_property), (gst_v4l2src_fixate), (gst_v4l2src_get_caps), (gst_v4l2src_set_caps), (gst_v4l2src_get_read), (gst_v4l2src_get_mmap), (gst_v4l2src_create): * sys/v4l2/v4l2_calls.c: (gst_v4l2_get_capabilities), (gst_v4l2_open), (gst_v4l2_close), (gst_v4l2_get_norm), (gst_v4l2_set_norm), (gst_v4l2_get_frequency), (gst_v4l2_set_frequency), (gst_v4l2_signal_strength), (gst_v4l2_get_attribute), (gst_v4l2_set_attribute), (gst_v4l2_get_input), (gst_v4l2_set_input): * sys/v4l2/v4l2src_calls.c: (gst_v4l2src_fill_format_list), (gst_v4l2src_queue_frame), (gst_v4l2src_grab_frame), (gst_v4l2src_get_capture), (gst_v4l2src_set_capture), (gst_v4l2src_capture_init), (gst_v4l2src_capture_start), (gst_v4l2src_capture_stop), (gst_v4l2src_capture_deinit), (gst_v4l2src_get_size_limits), (gst_v4l2src_set_fps), (gst_v4l2src_get_fps), (gst_v4l2src_buffer_finalize), (gst_v4l2src_buffer_new): Fix pass at code cleanups, move errors cases out of the normal flow for additional code clarity.
Diffstat (limited to 'sys/v4l2/gstv4l2object.c')
-rw-r--r--sys/v4l2/gstv4l2object.c53
1 files changed, 17 insertions, 36 deletions
diff --git a/sys/v4l2/gstv4l2object.c b/sys/v4l2/gstv4l2object.c
index d67dfe53..bec30eb6 100644
--- a/sys/v4l2/gstv4l2object.c
+++ b/sys/v4l2/gstv4l2object.c
@@ -110,7 +110,6 @@ gst_v4l2_class_probe_devices (GstElementClass * klass, gboolean check,
g_free (device);
}
}
-
init = TRUE;
}
@@ -150,9 +149,7 @@ gst_v4l2_probe_needs_probe (GstPropertyProbe * probe,
G_OBJECT_WARN_INVALID_PROPERTY_ID (probe, prop_id, pspec);
break;
}
-
return ret;
-
}
static GValueArray *
@@ -254,19 +251,18 @@ gst_v4l2_object_install_properties_helper (GObjectClass * gobject_class)
GST_TYPE_V4L2_DEVICE_FLAGS, 0, G_PARAM_READABLE));
g_object_class_install_property
(gobject_class, PROP_STD,
- g_param_spec_string ("std", "std",
- "standard (norm) to use", NULL, G_PARAM_READWRITE));
+ g_param_spec_string ("std", "Std",
+ "Standard (norm) to use", NULL, G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class, PROP_INPUT,
g_param_spec_string ("input",
- "input",
- "input/output (channel) to switch to", NULL, G_PARAM_READWRITE));
+ "Input",
+ "Input/output (channel) to switch to", NULL, G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class, PROP_FREQUENCY,
g_param_spec_ulong ("frequency",
- "frequency",
- "frequency to tune to (in Hz)", 0, G_MAXULONG, 0, G_PARAM_READWRITE));
-
+ "Frequency",
+ "Frequency to tune to (in Hz)", 0, G_MAXULONG, 0, G_PARAM_READWRITE));
}
GstV4l2Object *
@@ -275,13 +271,11 @@ gst_v4l2_object_new (GstElement * element,
GstV4l2SetInOutFunction set_in_out_func,
GstV4l2UpdateFpsFunction update_fps_func)
{
-
GstV4l2Object *v4l2object;
/*
* some default values
*/
-
v4l2object = g_new0 (GstV4l2Object, 1);
v4l2object->element = element;
@@ -300,16 +294,12 @@ gst_v4l2_object_new (GstElement * element,
v4l2object->xwindow_id = 0;
return v4l2object;
-
}
-
void
gst_v4l2_object_destroy (GstV4l2Object ** v4l2object)
{
-
if (*v4l2object) {
-
if ((*v4l2object)->videodev) {
g_free ((*v4l2object)->videodev);
(*v4l2object)->videodev = NULL;
@@ -317,29 +307,24 @@ gst_v4l2_object_destroy (GstV4l2Object ** v4l2object)
g_free (*v4l2object);
*v4l2object = NULL;
-
}
-
}
-
gboolean
gst_v4l2_object_set_property_helper (GstV4l2Object * v4l2object,
guint prop_id, const GValue * value, GParamSpec * pspec)
{
-
switch (prop_id) {
case PROP_DEVICE:
if (v4l2object->videodev)
g_free (v4l2object->videodev);
- v4l2object->videodev = g_strdup (g_value_get_string (value));
+ v4l2object->videodev = g_value_dup_string (value);
break;
case PROP_STD:
if (GST_V4L2_IS_OPEN (v4l2object)) {
GstTuner *tuner = GST_TUNER (v4l2object->element);
GstTunerNorm *norm = gst_tuner_find_norm_by_name (tuner,
- (gchar *)
- g_value_get_string (value));
+ (gchar *) g_value_get_string (value));
if (norm) {
/* like gst_tuner_set_norm (tuner, norm)
@@ -355,8 +340,7 @@ gst_v4l2_object_set_property_helper (GstV4l2Object * v4l2object,
if (GST_V4L2_IS_OPEN (v4l2object)) {
GstTuner *tuner = GST_TUNER (v4l2object->element);
GstTunerChannel *channel = gst_tuner_find_channel_by_name (tuner,
- (gchar *)
- g_value_get_string (value));
+ (gchar *) g_value_get_string (value));
if (channel) {
/* like gst_tuner_set_channel (tuner, channel)
@@ -389,9 +373,7 @@ gst_v4l2_object_set_property_helper (GstV4l2Object * v4l2object,
return FALSE;
break;
}
-
return TRUE;
-
}
@@ -405,15 +387,15 @@ gst_v4l2_object_get_property_helper (GstV4l2Object * v4l2object,
break;
case PROP_DEVICE_NAME:
{
- gchar *new = NULL;
+ const guchar *new = NULL;
if (GST_V4L2_IS_OPEN (v4l2object)) {
- new = (gchar *) v4l2object->vcap.card;
+ new = v4l2object->vcap.card;
} else if (gst_v4l2_open (v4l2object)) {
- new = (gchar *) v4l2object->vcap.card;
+ new = v4l2object->vcap.card;
gst_v4l2_close (v4l2object);
}
- g_value_set_string (value, new);
+ g_value_set_string (value, (gchar *) new);
break;
}
case PROP_FLAGS:
@@ -425,6 +407,8 @@ gst_v4l2_object_get_property_helper (GstV4l2Object * v4l2object,
(V4L2_CAP_VIDEO_CAPTURE |
V4L2_CAP_VIDEO_OUTPUT |
V4L2_CAP_VIDEO_OVERLAY | V4L2_CAP_TUNER | V4L2_CAP_AUDIO);
+ /* FIXME. if there is something with AUDIO we add something with
+ * video? this needs some explanation.. */
if (v4l2object->vcap.capabilities & V4L2_CAP_AUDIO)
flags |= V4L2_FBUF_CAP_CHROMAKEY;
}
@@ -444,9 +428,7 @@ gst_v4l2_object_get_property_helper (GstV4l2Object * v4l2object,
return FALSE;
break;
}
-
return TRUE;
-
}
static void
@@ -464,6 +446,7 @@ gst_v4l2_set_defaults (GstV4l2Object * v4l2object)
norm =
GST_TUNER_NORM (gst_tuner_get_norm (GST_TUNER (v4l2object->element)));
if (norm) {
+ /* FIXME, free old? */
v4l2object->std = g_strdup (norm->label);
gst_tuner_norm_changed (tuner, norm);
g_object_notify (G_OBJECT (v4l2object->element), "std");
@@ -478,6 +461,7 @@ gst_v4l2_set_defaults (GstV4l2Object * v4l2object)
channel =
GST_TUNER_CHANNEL (gst_tuner_get_channel (GST_TUNER (v4l2object->
element)));
+ /* FIXME, free old? */
v4l2object->input = g_strdup (channel->label);
gst_tuner_channel_changed (tuner, channel);
g_object_notify (G_OBJECT (v4l2object->element), "input");
@@ -498,7 +482,6 @@ gst_v4l2_set_defaults (GstV4l2Object * v4l2object)
}
}
-
gboolean
gst_v4l2_object_start (GstV4l2Object * v4l2object)
{
@@ -507,7 +490,6 @@ gst_v4l2_object_start (GstV4l2Object * v4l2object)
else
return FALSE;
-
#ifdef HAVE_XVIDEO
gst_v4l2_xoverlay_start (v4l2object);
#endif
@@ -518,7 +500,6 @@ gst_v4l2_object_start (GstV4l2Object * v4l2object)
gboolean
gst_v4l2_object_stop (GstV4l2Object * v4l2object)
{
-
#ifdef HAVE_XVIDEO
gst_v4l2_xoverlay_stop (v4l2object);
#endif