Fixed... The problem is that the GStreamer pipeline don't free properly when the window's exit button was pressed: it can be fixed using a quit function that frees the pipeline prior to close the GTK main loop.
GstElement *pipeline; // global now // prototype void destroy (GtkWidget *, gpointer); { void destroy (GtkWidget *widget, gpointer data) { gst_element_set_state(pipeline, GST_STATE_NULL); gst_object_unref(pipeline); gtk_main_quit(); } // adding action to window's events gtk_signal_connect(GTK_OBJECT(window), "delete_event", GTK_SIGNAL_FUNC(destroy), // previous: gtk_main_quit NULL); Quoting [EMAIL PROTECTED]: > Hi everybody. I wrote a little application combining GTK and GStreamer > functions to view the camera input on the window's screen and > to take photo (not yet implemented, this is experimental code...). > When I launch the application I obtain the following error: > > "The program 'test2' received an X Window System error. > This probably reflects a bug in the program. > The error was 'BadDrawable (invalid Pixmap or Window parameter)'. > (Details: serial 1362 error_code 9 request_code 140 minor_code 9)" > > Sometimes BadDrawable is substituted with BadWindow or others... I really > don't know why this occur: the application runs properly, I also manage > the "delete" and "destroy" event on the main window, but... Can anyone > help me? > > Here is the launching command line to compile: > > gcc base.c `pkg-config --cflags --libs gtk+-2.0 gstreamer-0.10 \ > gstreamer-interfaces-0.8 gdk-2.0` -o test2 > > > And here is the source code: > > #include <gtk/gtk.h> > #include <gst/gst.h> > #include <gst/interfaces/xoverlay.h> > #include <gdk/gdkx.h> > #include <gdk/gdk.h> > > static gboolean expose( GtkWidget * widget, GdkEventExpose * event, > gpointer data ); > > int main( int argc, char *argv[] ) > { > GtkWidget *window, *screen; > > GstElement *pipeline, *src, *sink, *csp; > GstElement *tee, *csp2, *fakesink; > GstElement *queue; > GstCaps *filter; > gboolean link_ok; > > > > gtk_init (&argc, &argv); > > gst_init(&argc, &argv); > > > window = gtk_window_new (GTK_WINDOW_TOPLEVEL); > > gtk_signal_connect(GTK_OBJECT(window), > "delete_event", > GTK_SIGNAL_FUNC(gtk_main_quit), > NULL); > > gtk_signal_connect(GTK_OBJECT(window), > "destroy", > GTK_SIGNAL_FUNC(gtk_main_quit), > NULL); > > screen = gtk_drawing_area_new(); > > gtk_window_set_title(GTK_WINDOW(window), "Camera app"); > gtk_container_set_border_width (GTK_CONTAINER (window), 5); > gtk_widget_set_size_request(window, 640, 480); > > gtk_widget_set_size_request(screen, 320, 240); > gtk_widget_show(screen); > > > gtk_container_add(GTK_CONTAINER(window), screen); > > > pipeline = gst_pipeline_new("camera"); > src = gst_element_factory_make("videotestsrc", "src"); > // src = gst_element_factory_make("gconfv4l2src", "src"); > > sink = gst_element_factory_make("xvimagesink", "sink"); > csp = gst_element_factory_make("ffmpegcolorspace", "csp"); > tee = gst_element_factory_make("tee", "tee"); > fakesink = gst_element_factory_make("fakesink", "fakesink"); > csp2 = gst_element_factory_make("ffmpegcolorspace", "csp2"); > queue = gst_element_factory_make("queue", "queue"); > > > gst_bin_add(GST_BIN(pipeline), src); > gst_bin_add(GST_BIN(pipeline), csp); > gst_bin_add(GST_BIN(pipeline), tee); > gst_bin_add(GST_BIN(pipeline), csp2); > gst_bin_add(GST_BIN(pipeline), sink); > gst_bin_add(GST_BIN(pipeline), queue); > gst_bin_add(GST_BIN(pipeline), fakesink); > > > filter = gst_caps_new_simple("video/x-raw-yuv", > "width", G_TYPE_INT, 320, > "height", G_TYPE_INT, 240, > "framerate", GST_TYPE_FRACTION, 11, 1, > NULL); > > > link_ok = gst_element_link_filtered(src, tee, filter); > if (!link_ok) > g_warning("Failed to link elements\n"); > gst_element_link(tee, csp); > gst_element_link(csp, sink); > gst_element_link(tee, queue); > gst_element_link(queue, csp2); > gst_element_link(csp2, fakesink); > > /* now connect the video source to the desired widget */ > g_signal_connect(screen, "expose-event", G_CALLBACK(expose), sink); > > > /* set current pipeline state to PLAY */ > gst_element_set_state(pipeline, GST_STATE_PLAYING); > > > gtk_widget_show(window); > > /* entering main loop */ > gtk_main (); > > /* stop the pipeline */ > gst_element_set_state(pipeline, GST_STATE_NULL); > /* frees the pipeline */ > gst_object_unref(pipeline); > > return 0; > } > > > static gboolean expose > ( GtkWidget * widget, GdkEventExpose * event, gpointer data ) > { > > gst_x_overlay_set_xwindow_id(GST_X_OVERLAY(data), > GDK_WINDOW_XWINDOW(widget->window)); > return FALSE; > } > > > ---------------------------------------------------------------- > This message was sent using IMP, the Internet Messaging Program. > _______________________________________________ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > > ---------------------------------------------------------------- This message was sent using IMP, the Internet Messaging Program. _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list