Fix segfault when oppening a radio device.

Original commit message from CVS:
Fix segfault when oppening a radio device.
This commit is contained in:
Edgard Lima 2007-02-22 17:53:26 +00:00
parent 5c1b116dc8
commit fff672f930
4 changed files with 40 additions and 25 deletions

View file

@ -1,3 +1,10 @@
2007-02-22 Edgard Lima <edgard.lima@indt.org.br>
* sys/v4l2/gstv4l2object.c:
* sys/v4l2/gstv4l2tuner.c:
* sys/v4l2/v4l2_calls.c:
Fix segfault when oppening a radio device.
2007-02-22 Stefan Kost <ensonic@users.sf.net>
* gst/level/gstlevel.c: (gst_level_set_caps),

View file

@ -431,12 +431,15 @@ gst_v4l2_set_defaults (GstV4l2Object * v4l2object)
channel =
GST_TUNER_CHANNEL (gst_tuner_get_channel (GST_TUNER (v4l2object->
element)));
g_free (v4l2object->channel);
v4l2object->channel = g_strdup (channel->label);
gst_tuner_channel_changed (tuner, channel);
if (channel) {
g_free (v4l2object->channel);
v4l2object->channel = g_strdup (channel->label);
gst_tuner_channel_changed (tuner, channel);
}
}
if (GST_TUNER_CHANNEL_HAS_FLAG (channel, GST_TUNER_CHANNEL_FREQUENCY)) {
if (channel
&& GST_TUNER_CHANNEL_HAS_FLAG (channel, GST_TUNER_CHANNEL_FREQUENCY)) {
if (v4l2object->frequency != 0) {
gst_tuner_set_frequency (tuner, channel, v4l2object->frequency);
} else {

View file

@ -171,11 +171,13 @@ gst_v4l2_tuner_get_channel (GstV4l2Object * v4l2object)
/* assert that we're opened and that we're using a known item */
g_return_val_if_fail (GST_V4L2_IS_OPEN (v4l2object), NULL);
v4l2object->get_in_out_func (v4l2object, &channel);
if (v4l2object->get_in_out_func (v4l2object, &channel)) {
for (item = v4l2object->channels; item != NULL; item = item->next) {
if (channel == GST_V4L2_TUNER_CHANNEL (item->data)->index)
return (GstTunerChannel *) item->data;
}
for (item = v4l2object->channels; item != NULL; item = item->next) {
if (channel == GST_V4L2_TUNER_CHANNEL (item->data)->index)
return (GstTunerChannel *) item->data;
}
return NULL;
@ -271,15 +273,17 @@ gst_v4l2_tuner_set_frequency (GstV4l2Object * v4l2object,
g_return_val_if_fail (gst_v4l2_tuner_contains_channel (v4l2object,
v4l2channel), FALSE);
v4l2object->get_in_out_func (v4l2object, &chan);
if (chan == GST_V4L2_TUNER_CHANNEL (channel)->index &&
GST_TUNER_CHANNEL_HAS_FLAG (channel, GST_TUNER_CHANNEL_FREQUENCY)) {
if (gst_v4l2_set_frequency (v4l2object, v4l2channel->tuner, frequency)) {
gst_tuner_frequency_changed (GST_TUNER (v4l2object->element), channel,
frequency);
return TRUE;
if (v4l2object->get_in_out_func (v4l2object, &chan)) {
if (chan == GST_V4L2_TUNER_CHANNEL (channel)->index &&
GST_TUNER_CHANNEL_HAS_FLAG (channel, GST_TUNER_CHANNEL_FREQUENCY)) {
if (gst_v4l2_set_frequency (v4l2object, v4l2channel->tuner, frequency)) {
gst_tuner_frequency_changed (GST_TUNER (v4l2object->element), channel,
frequency);
return TRUE;
}
}
}
return FALSE;
}
@ -298,10 +302,11 @@ gst_v4l2_tuner_get_frequency (GstV4l2Object * v4l2object,
g_return_val_if_fail (gst_v4l2_tuner_contains_channel (v4l2object,
v4l2channel), 0);
v4l2object->get_in_out_func (v4l2object, &chan);
if (chan == GST_V4L2_TUNER_CHANNEL (channel)->index &&
GST_TUNER_CHANNEL_HAS_FLAG (channel, GST_TUNER_CHANNEL_FREQUENCY)) {
gst_v4l2_get_frequency (v4l2object, v4l2channel->tuner, &frequency);
if (v4l2object->get_in_out_func (v4l2object, &chan)) {
if (chan == GST_V4L2_TUNER_CHANNEL (channel)->index &&
GST_TUNER_CHANNEL_HAS_FLAG (channel, GST_TUNER_CHANNEL_FREQUENCY)) {
gst_v4l2_get_frequency (v4l2object, v4l2channel->tuner, &frequency);
}
}
return frequency;
@ -322,10 +327,11 @@ gst_v4l2_tuner_signal_strength (GstV4l2Object * v4l2object,
g_return_val_if_fail (gst_v4l2_tuner_contains_channel (v4l2object,
v4l2channel), 0);
v4l2object->get_in_out_func (v4l2object, &chan);
if (chan == GST_V4L2_TUNER_CHANNEL (channel)->index &&
GST_TUNER_CHANNEL_HAS_FLAG (channel, GST_TUNER_CHANNEL_FREQUENCY)) {
gst_v4l2_signal_strength (v4l2object, v4l2channel->tuner, &signal);
if (v4l2object->get_in_out_func (v4l2object, &chan)) {
if (chan == GST_V4L2_TUNER_CHANNEL (channel)->index &&
GST_TUNER_CHANNEL_HAS_FLAG (channel, GST_TUNER_CHANNEL_FREQUENCY)) {
gst_v4l2_signal_strength (v4l2object, v4l2channel->tuner, &signal);
}
}
return signal;

View file

@ -726,8 +726,7 @@ gst_v4l2_get_input (GstV4l2Object * v4l2object, gint * input)
input_failed:
{
GST_ELEMENT_WARNING (v4l2object->element, RESOURCE, SETTINGS,
(_("Failed to get current input on device '%s'."),
v4l2object->videodev), GST_ERROR_SYSTEM);
(_("Failed to get current input on device '%s'. May be it is a radio device"), v4l2object->videodev), GST_ERROR_SYSTEM);
return FALSE;
}
}