[gst-devel] Crash in v4l2src when device is busy

4ernov 4ernov at gmail.com
Fri Aug 27 09:24:07 CEST 2010


Hello,

I've faced some strange behavior of v4l2src when capture device is
busy and I try to set it to READY state. The program crashes in some
of GStreamer routines with the following error message:

ERROR!  Error:  Device '/dev/video0' cannot capture at 640x480
DEBUG   Error:  gstv4l2object.c(1920): gst_v4l2_object_set_format ():
/GstPipeline:camera/GstV4l2Src:v4l2src0:
Call to S_FMT failed for YUYV @ 640x480: Device or resource busy

Backtrace is like this:

#1  0x02581e1e in gst_v4l2src_create (src=0x8353000, buf=0xb50fd1cc)
at gstv4l2src.c:914
#2  0x025c3765 in gst_push_src_create (bsrc=0x8353000,
offset=18446744073709551615, length=4096, ret=0xb50fd1cc) at
gstpushsrc.c:117
#3  0x025b0881 in gst_base_src_get_range (src=<value optimised out>,
offset=18446744073709551615, length=4096, buf=0xb50fd1cc) at
gstbasesrc.c:2081
#4  0x025b3327 in gst_base_src_loop (pad=0x8354010) at gstbasesrc.c:2334
#5  0x0024ed6b in gst_task_func (task=0x83bd0c0) at gsttask.c:238
#6  0x00250377 in default_func (tdata=0x809b7c0, pool=0x8076810) at
gsttaskpool.c:70

My code is just plain as in tutorial I think:

    GstElement *v4l2src, *deinterlace, *videoscale, *tee,
*ffmpegcolorspace, *queue, *xvideoscale, *ximagesink;

    GstBus* bus;

    GstCaps* caps = gst_caps_new_simple ("video/x-raw-yuv", "width",
G_TYPE_INT, 400,
                                                            "height",
G_TYPE_INT, 300, NULL);

    /* Create gstreamer elements */

    _pipeline      = gst_pipeline_new("camera");

    v4l2src      = gst_element_factory_make("v4l2src",  NULL);

    deinterlace = gst_element_factory_make("deinterlace",  NULL);

    videoscale  = gst_element_factory_make("videoscale",  NULL);

    tee      = gst_element_factory_make("tee",  NULL);

    queue   = gst_element_factory_make("queue", NULL);

    xvideoscale = gst_element_factory_make("videoscale",  NULL);

    ffmpegcolorspace = gst_element_factory_make("ffmpegcolorspace",  NULL);

    ximagesink   = gst_element_factory_make("ximagesink", NULL);

    if (!_pipeline || !v4l2src || !videoscale || !tee || !queue ||
!ffmpegcolorspace || !xvideoscale || !ximagesink)
    {
            qDebug()<<"Elements could not be created. Exiting.";
    }

    gst_bin_add_many (GST_BIN (_pipeline), v4l2src, deinterlace,
videoscale, tee, queue, ffmpegcolorspace, xvideoscale, ximagesink,
NULL);

    gst_element_link_many(v4l2src, deinterlace, videoscale, NULL);

    gst_element_link_filtered(videoscale, tee, caps);

    gst_caps_unref(caps);


    gst_element_link_many(tee, queue, ffmpegcolorspace, xvideoscale,
ximagesink, NULL);


    g_object_set(G_OBJECT (ximagesink), "force-aspect-ratio", true, NULL);

    g_object_set(G_OBJECT (deinterlace), "mode", 0, NULL);

    if (_winid)
    {
        gst_x_overlay_set_xwindow_id ((GstXOverlay*)ximagesink, _winid);
    }

    bus = gst_pipeline_get_bus (GST_PIPELINE (_pipeline));
    gst_bus_add_watch (bus, bus_call, this);
    gst_object_unref (bus);

    /* Set the pipeline to "playing" state*/
//    gst_element_set_state (_pipeline, GST_STATE_READY);

    /* Iterate */
    g_print ("Running...\n");

    g_object_set(G_OBJECT (_v4l2src), "device", str.c_str(), NULL);

    gst_element_set_state (_pipeline, GST_STATE_READY);

Is it a bug and so I should post it or perhaps I did something unsafe?




More information about the gstreamer-devel mailing list