[svn r684] fixed bug on destructor trunk
authorrenatofilho
Wed May 16 23:52:37 2007 +0100 (2007-05-16)
branchtrunk
changeset 67889bdaa9e72bf
parent 677 1b7b4d7f714c
child 679 c9757033ccc6
[svn r684] fixed bug on destructor
gmyth-stream/gmemcoder/src/gmencoder.c
gmyth-stream/gmemcoder/src/main.c
     1.1 --- a/gmyth-stream/gmemcoder/src/gmencoder.c	Wed May 16 23:21:58 2007 +0100
     1.2 +++ b/gmyth-stream/gmemcoder/src/gmencoder.c	Wed May 16 23:52:37 2007 +0100
     1.3 @@ -162,7 +162,7 @@
     1.4      g_mencoder_signals[ERROR] =
     1.5          g_signal_new ("error",
     1.6      		  G_OBJECT_CLASS_TYPE (object_class),
     1.7 -    		  G_SIGNAL_RUN_FIRST,
     1.8 +    		  G_SIGNAL_RUN_LAST,
     1.9      		  0, NULL, NULL,
    1.10      		  g_cclosure_marshal_VOID__STRING,
    1.11      		  G_TYPE_NONE, 1, G_TYPE_STRING);	
    1.12 @@ -246,11 +246,13 @@
    1.13  
    1.14      if (prop != NULL) {
    1.15          for (i=0; i < g_strv_length (prop); i++) {
    1.16 -            char** v = g_strsplit(prop[i], "=", 2);
    1.17 -            if (g_strv_length (v) == 2) {
    1.18 -                _obj_set_prop (G_OBJECT (ret), v[0], v[1]);
    1.19 -            }
    1.20 -            g_strfreev (v);
    1.21 +			if (prop[i] != NULL) {
    1.22 +            	char** v = g_strsplit(prop[i], "=", 2);
    1.23 +            	if (g_strv_length (v) == 2) {
    1.24 +                	_obj_set_prop (G_OBJECT (ret), v[0], v[1]);
    1.25 +            	}	
    1.26 +            	g_strfreev (v);
    1.27 +			}
    1.28          }
    1.29      }
    1.30  
    1.31 @@ -635,16 +637,18 @@
    1.32  	}
    1.33  
    1.34      if (priv->pipe != NULL) { 
    1.35 -        gst_element_set_state (priv->pipe, GST_STATE_NULL);
    1.36 -        gst_object_unref (priv->pipe);
    1.37 +		GstState state;
    1.38 +		GstState pending;		
    1.39 +        //gst_element_set_state (priv->pipe, GST_STATE_NULL);
    1.40 +        //gst_object_unref (priv->pipe);
    1.41 +        gst_object_unref (priv->src);
    1.42 +		priv->src = NULL;
    1.43          priv->pipe = NULL;
    1.44          priv->abin = NULL;
    1.45          priv->vbin = NULL;
    1.46          priv->sink = NULL;
    1.47      }
    1.48      priv->ready = FALSE;
    1.49 -
    1.50 -
    1.51  }
    1.52  
    1.53  static GstElement*
    1.54 @@ -934,16 +938,23 @@
    1.55  		    GError *error;
    1.56  		    gchar *debug;
    1.57  		    gchar *err_str;
    1.58 +
    1.59 +			if (priv->tick_id != 0) {			
    1.60 +				g_source_remove (priv->tick_id);
    1.61 +				priv->tick_id = 0;
    1.62 +			}
    1.63  		    
    1.64  		    gst_message_parse_error (msg, &error, &debug);
    1.65  		    err_str = g_strdup_printf ("Error [%d] %s (%s)", error->code,
    1.66  		        error->message,
    1.67  		        debug);
    1.68 +			g_debug ("%s", err_str);
    1.69 +            priv->ready = FALSE;
    1.70  		    g_signal_emit (user_data, g_mencoder_signals[ERROR], 0, err_str);
    1.71 -            priv->ready = FALSE;
    1.72  		    g_free (err_str);
    1.73  		    g_clear_error (&error);
    1.74  		    g_free (debug);
    1.75 +			g_debug ("ERROR DONE");
    1.76  		    break;
    1.77  		}
    1.78  		
     2.1 --- a/gmyth-stream/gmemcoder/src/main.c	Wed May 16 23:21:58 2007 +0100
     2.2 +++ b/gmyth-stream/gmemcoder/src/main.c	Wed May 16 23:52:37 2007 +0100
     2.3 @@ -26,19 +26,29 @@
     2.4  static gchar*   output_uri      = NULL;
     2.5  
     2.6  
     2.7 +
     2.8 +static gboolean
     2.9 +_quit (gpointer data)
    2.10 +{
    2.11 +	g_debug ("Quit");
    2.12 +	g_object_unref (data);
    2.13 +	g_main_loop_quit (mainloop);
    2.14 +	return FALSE;
    2.15 +}
    2.16 +
    2.17  static void
    2.18  _mencoder_eos_cb (GMencoder *mencoder, gpointer data)
    2.19 -{
    2.20 +{		
    2.21      g_print ("EOS\n");
    2.22 -    g_main_loop_quit ((GMainLoop *) data);
    2.23 +	g_idle_add (_quit, mencoder);
    2.24  }
    2.25  
    2.26 +
    2.27  static void
    2.28  _mencoder_error_cb (GMencoder *mencoder, const gchar* msg, gpointer data)
    2.29  {
    2.30      g_print ("Error: %s\n", msg);
    2.31 -	g_mencoder_close_stream (mencoder);
    2.32 -    g_main_loop_quit ((GMainLoop *) data);
    2.33 +	g_idle_add (_quit, mencoder);
    2.34  }
    2.35  
    2.36  static gboolean