rem: (void) gst_element_get_state (video_sink, NULL, NULL, GST_CLOCK_TIME_NONE);
add: ret = gst_element_get_state (video_sink, NULL, NULL, 5 * GST_SECOND); if (ret != GST_STATE_CHANGE_SUCCESS) { GST_WARNING ("Timeout setting videosink to READY"); g_set_error (err, BVW_ERROR, BVW_ERROR_VIDEO_PLUGIN, _("Failed to open video output. It may not be available. " "Please select another video output in the Multimedia Systems Selector.")); return NULL; }
context: bacon_video_widget_new (int width, int height,			BvwUseType type, GError ** err){  GConfValue *confvalue;  BaconVideoWidget *bvw;  GstElement *audio_sink = NULL, *video_sink = NULL;  GstBus *bus;  bvw = BACON_VIDEO_WIDGET (g_object_new                            (bacon_video_widget_get_type (), NULL));    bvw->priv->play = gst_element_factory_make ("playbin", "play");  if (!bvw->priv->play) {    g_set_error (err, BVW_ERROR, BVW_ERROR_PLUGIN_LOAD,		 _("Failed to create a GStreamer play object. "		   "Please check your GStreamer installation."));    g_object_unref (bvw);    return NULL;  }  bus = gst_pipeline_get_bus (GST_PIPELINE (bvw->priv->play));  gst_bus_add_signal_watch (bus);  g_signal_connect (bus, "message",                     G_CALLBACK (bvw_bus_message_cb),                    bvw);  bvw->priv->vis_capsfilter = gst_element_factory_make ("capsfilter",							"vis-capsfilter");  bvw->priv->speakersetup = BVW_AUDIO_SOUND_STEREO;  bvw->priv->media_device = g_strdup ("/dev/dvd");  bvw->priv->init_width = 240;  bvw->priv->init_height = 180;  bvw->priv->visq = VISUAL_SMALL;  bvw->priv->show_vfx = FALSE;  bvw->priv->vis_element = NULL;  bvw->priv->tv_out_type = TV_OUT_NONE;  bvw->priv->connection_speed = 0;  bvw->priv->ratio_type = BVW_RATIO_AUTO;  bvw->priv->cursor_shown = TRUE;  bvw->priv->logo_mode = TRUE;  bvw->priv->auto_resize = TRUE;  /* gconf setting in backend */  bvw->priv->gc = gconf_client_get_default ();  gconf_client_notify_add (bvw->priv->gc, "/apps/totem",      cb_gconf, bvw, NULL, NULL);  if (type == BVW_USE_TYPE_VIDEO || type == BVW_USE_TYPE_AUDIO) {    audio_sink = gst_element_factory_make ("gconfaudiosink", "audio-sink");    if (audio_sink) {      gst_element_set_bus (audio_sink, bus); /* FIXME: WHY THIS? */    } else {      g_warning ("Could not create element 'gconfaudiosink'");    }  } else {    audio_sink = gst_element_factory_make ("fakesink", "audio-fake-sink");  }  if (type == BVW_USE_TYPE_VIDEO) {    video_sink = gst_element_factory_make ("gconfvideosink", "video-sink");    if (video_sink) {      gst_element_set_bus (video_sink, bus); /* FIXME: WHY THIS? */    } else {      g_warning ("Could not create element 'gconfvideosink'");    }/* FIXME: April fool's day puzzle */#if 0    if (video_sink) {      GDate d;      g_date_clear (&d, 1);      g_date_set_time (&d, time (NULL));      if (g_date_day (&d) == 1 && g_date_month (&d) == G_DATE_APRIL) {        confvalue = gconf_client_get_without_default (bvw->priv->gc,            GCONF_PREFIX"/puzzle_year", NULL);        if (!confvalue ||            gconf_value_get_int (confvalue) != g_date_year (&d)) {          GstElement *puzzle;          gconf_client_set_int (bvw->priv->gc, GCONF_PREFIX"/puzzle_year",              g_date_year (&d), NULL);          puzzle = gst_element_factory_make ("puzzle", NULL);          if (puzzle) {            GstElement *bin = gst_bin_new ("videosinkbin");            GstPad *pad;            gst_bin_add_many (GST_BIN (bin), puzzle, video_sink, NULL);            gst_element_link_pads (puzzle, "src", video_sink, "sink");            pad = gst_element_get_pad (puzzle, "sink");            gst_element_add_pad (bin, gst_ghost_pad_new ("sink", pad));            gst_object_unref (pad);            video_sink = bin;          }        }        if (confvalue)          gconf_value_free (confvalue);      }    }#endif  } else {    video_sink = gst_element_factory_make ("fakesink", "video-fake-sink");  }  if (video_sink) {    gboolean success;    gst_element_set_state (video_sink, GST_STATE_READY);    success = poll_for_state_change (bvw, video_sink, GST_STATE_READY, err);    if (!success) {      if (err && !*err) {	g_warning ("Should have gotten an error message, please file a bug.");	g_set_error (err, BVW_ERROR, BVW_ERROR_VIDEO_PLUGIN,		     _("Failed to open video output. It may not be available. "		       "Please select another video output in the Multimedia "		       "Systems Selector."));      }      goto sink_error;    }  } else {    g_set_error (err, BVW_ERROR, BVW_ERROR_VIDEO_PLUGIN,		 _("Could not find the video output. "		   "You may need to install additional GStreamer plugins, "		   "or select another video output in the Multimedia Systems "		   "Selector."));    goto sink_error;  }  if (audio_sink) {    gboolean success;    gst_element_set_state (audio_sink, GST_STATE_READY);    success = poll_for_state_change (bvw, audio_sink, GST_STATE_READY, err);    if (!success) {      if (err && !*err) {	g_warning ("Should have gotten an error message, please file a bug.");	g_set_error (err, BVW_ERROR, BVW_ERROR_VIDEO_PLUGIN,		     _("Failed to open audio output. You may not have "		       "permission to open the sound device, or the sound "		       "server may not be running. "		       "Please select another audio output in the Multimedia "		       "Systems Selector."));      }      goto sink_error;    }  } else {    g_set_error (err, BVW_ERROR, BVW_ERROR_VIDEO_PLUGIN,		 _("Could not find the audio output. "		   "You may need to install additional GStreamer plugins, or "		   "select another audio output in the Multimedia Systems "		   "Selector."));    goto sink_error;  }  do {    GstElement *bin;    GstPad *pad;    bvw->priv->audio_capsfilter =        gst_element_factory_make ("capsfilter", "audiofilter");    bin = gst_bin_new ("audiosinkbin");    gst_bin_add_many (GST_BIN (bin),	bvw->priv->audio_capsfilter, audio_sink, NULL);    gst_element_link_pads (bvw->priv->audio_capsfilter, "src",	audio_sink, "sink");    pad = gst_element_get_pad (bvw->priv->audio_capsfilter, "sink");    gst_element_add_pad (bin, gst_ghost_pad_new ("sink", pad));    gst_object_unref (pad);    audio_sink = bin;  } while (0);  /* now tell playbin */  g_object_set (bvw->priv->play, "video-sink", video_sink, NULL);  g_object_set (bvw->priv->play, "audio-sink", audio_sink, NULL);  bvw->priv->vis_plugins_list = NULL;  g_signal_connect (bvw->priv->play, "notify::source",		    G_CALLBACK (got_source), bvw);  g_signal_connect (bvw->priv->play, "notify::stream-info",		    G_CALLBACK (stream_info_set), bvw);  if (type == BVW_USE_TYPE_VIDEO) {    /* wait for video sink to finish changing to READY state,      * otherwise we won't be able to detect the colorbalance interface */    (void) gst_element_get_state (video_sink, NULL, NULL, GST_CLOCK_TIME_NONE);    bvw_update_interface_implementations (bvw);  }  if (GST_IS_BIN (video_sink)) {    /* video sink bins like gconfvideosink might remove their children and     * create new ones when set to NULL state, and they are currently set     * to NULL state whenever playbin re-creates its internal video bin     * (it sets all elements to NULL state before gst_bin_remove()ing them) */    g_signal_connect (video_sink, "element-added",                      G_CALLBACK (got_new_video_sink_bin_element), bvw);    gst_bus_set_sync_handler (bus, gst_bus_sync_signal_handler, bvw);    g_signal_connect (bus, "sync-message::state-changed",                      G_CALLBACK (bvw_changed_state_msg_sync), bvw);  }  gst_object_unref (bus);  /* audio out, if any */  confvalue = gconf_client_get_without_default (bvw->priv->gc,      GCONF_PREFIX"/audio_output_type", NULL);  if (confvalue != NULL &&      (type != BVW_USE_TYPE_METADATA && type != BVW_USE_TYPE_CAPTURE)) {    bvw->priv->speakersetup = gconf_value_get_int (confvalue);    bvw->priv->speakersetup = gconf_value_get_int (confvalue) - 1;    bacon_video_widget_set_audio_out_type (bvw, bvw->priv->speakersetup + 1);    gconf_value_free (confvalue);  } else {    bvw->priv->speakersetup = -1;    bacon_video_widget_set_audio_out_type (bvw, BVW_AUDIO_SOUND_STEREO);  }  /* visualization */  confvalue = gconf_client_get_without_default (bvw->priv->gc,      GCONF_PREFIX "/show_vfx", NULL);  if (confvalue != NULL) {    bvw->priv->show_vfx = gconf_value_get_bool (confvalue);    gconf_value_free (confvalue);  }  confvalue = gconf_client_get_without_default (bvw->priv->gc,      GCONF_PREFIX "/visual_quality", NULL);  if (confvalue != NULL) {    bvw->priv->visq = gconf_value_get_int (confvalue);    gconf_value_free (confvalue);  }#if 0  confvalue = gconf_client_get_without_default (bvw->priv->gc,      GCONF_PREFIX "/visual", NULL);  if (confvalue != NULL) {    bvw->priv->vis_element =         gst_element_factory_make (gconf_value_get_string (confvalue), NULL);    gconf_value_free (confvalue);  }  setup_vis ();#endif  /* tv/conn (not used yet) */  confvalue = gconf_client_get_without_default (bvw->priv->gc,      GCONF_PREFIX "/tv_out_type", NULL);  if (confvalue != NULL) {    bvw->priv->tv_out_type = gconf_value_get_int (confvalue);    gconf_value_free (confvalue);  }  confvalue = gconf_client_get_without_default (bvw->priv->gc,      GCONF_PREFIX "/connection_speed", NULL);  if (confvalue != NULL) {    bvw->priv->connection_speed = gconf_value_get_int (confvalue);    gconf_value_free (confvalue);  }  /* those are private to us, i.e. not Xine-compatible */  confvalue = gconf_client_get_without_default (bvw->priv->gc,      GCONF_PREFIX "/buffer-size", NULL);  if (confvalue != NULL) {    g_object_set (bvw->priv->play, "queue-size",        (guint64) GST_SECOND * gconf_value_get_float (confvalue), NULL);    gconf_value_free (confvalue);  }  confvalue = gconf_client_get_without_default (bvw->priv->gc,      GCONF_PREFIX "/network-buffer-threshold", NULL);  if (confvalue != NULL) {    g_object_set (bvw->priv->play, "queue-threshold",        (guint64) GST_SECOND * gconf_value_get_float (confvalue), NULL);    gconf_value_free (confvalue);  }  return GTK_WIDGET (bvw);  /* errors */sink_error:  {    if (video_sink)      gst_object_unref (video_sink);    if (audio_sink)      gst_object_unref (audio_sink);    g_free (bvw);    return NULL;  }}