sound-juicer r2136 - in trunk: . src
- From: tpm svn gnome org
- To: svn-commits-list gnome org
- Subject: sound-juicer r2136 - in trunk: . src
- Date: Fri, 14 Mar 2008 13:51:23 +0000 (GMT)
Author: tpm
Date: Fri Mar 14 13:51:22 2008
New Revision: 2136
URL: http://svn.gnome.org/viewvc/sound-juicer?rev=2136&view=rev
Log:
* src/sj-play.c: (select_track), (cb_error):
Fix error handling: when the state change fails immediately
(e.g. because the audio device can't be opened), return FALSE
to the caller, so that the caller doesn't try to go into
playing state a second time, which would result in two error
dialogs being shown. Also set pipeline to NULL state when we
get an error, so any other (generic) error messages on the
pipeline's bus are flushed - we only want to show the first
error message. Fixes #520370.
Also fix up seeking in select_track: state changs to PAUSED or
PLAYING state are usually async, so a seek right after will
usually fail.
Modified:
trunk/ChangeLog
trunk/src/sj-play.c
Modified: trunk/src/sj-play.c
==============================================================================
--- trunk/src/sj-play.c (original)
+++ trunk/src/sj-play.c Fri Mar 14 13:51:22 2008
@@ -55,6 +55,7 @@
static gboolean
select_track (void)
{
+ GstStateChangeReturn ret;
GstElement *cd;
if (!gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (track_store),
@@ -64,9 +65,23 @@
}
cd = gst_bin_get_by_name_recurse_up (GST_BIN (pipeline), "cd-source");
- gst_element_set_state (pipeline, GST_STATE_PAUSED);
- gst_element_seek (pipeline, 1.0, gst_format_get_by_nick ("track"), GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET, seek_to_track, GST_SEEK_TYPE_NONE, -1);
- current_track = seek_to_track;
+
+ ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);
+ if (ret == GST_STATE_CHANGE_FAILURE) {
+ return FALSE;
+ } else if (ret == GST_STATE_CHANGE_SUCCESS) {
+ /* state change was instant, we can seek right away */
+ if (gst_element_seek_simple (pipeline, gst_format_get_by_nick ("track"),
+ GST_SEEK_FLAG_FLUSH, seek_to_track)) {
+ current_track = seek_to_track;
+ } else {
+ /* seek failed - what now? */
+ return FALSE;
+ }
+ } else if (ret == GST_STATE_CHANGE_ASYNC) {
+ /* do nothing, seek will hopefully be done later?! */
+ }
+
return TRUE;
}
@@ -186,6 +201,11 @@
gtk_widget_destroy (dialog);
g_error_free (error);
+
+ /* There may be other (more generic) error messages on the bus; set pipeline
+ * to NULL state so these messages are flushed from the bus and we don't get
+ * called again for those */
+ stop ();
}
static gchar *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]