diff -r 59623bb25c17 -r 6620b7037407 gmyth-stream/gmemcoder/src/gmencoder.c --- a/gmyth-stream/gmemcoder/src/gmencoder.c Fri Jun 22 16:14:21 2007 +0100 +++ b/gmyth-stream/gmemcoder/src/gmencoder.c Tue Jun 26 14:32:33 2007 +0100 @@ -82,7 +82,7 @@ gpointer user_data); static void _close_output(GMencoder * self); -static void _open_output(GMencoder * self, const gchar * uri); +static gboolean _open_output(GMencoder * self, const gchar * uri); static GstElement *_create_source(const gchar * uri); static GstElement *_create_pipeline(GMencoder * self, @@ -437,7 +437,7 @@ -void +gboolean g_mencoder_setup_stream(GMencoder * self, const gchar * mux_name, const gchar * video_encode, @@ -454,11 +454,12 @@ if (priv->ready == TRUE) { g_warning ("Stream already configured. You need close stream first."); - return; + return FALSE; } _close_output(self); - _open_output(self, out_uri); + if (_open_output(self, out_uri) == FALSE) + return FALSE; priv->sources = 0; priv->pipe = _create_pipeline(self, @@ -472,6 +473,7 @@ audio_encode, audio_encode_prop, audio_rate); + return (priv->pipe != NULL); } @@ -856,9 +858,10 @@ return NULL; } -static void +static gboolean _open_output(GMencoder * self, const gchar * uri) { + gboolean ret = TRUE; gchar **i; GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self); @@ -867,15 +870,27 @@ priv->fd = atoi(i[1]); } else if (strcmp(i[0], "file") == 0) { if (g_file_test (i[1], G_FILE_TEST_EXISTS)) { - g_assert (unlink (i[1]) == 0); + if (unlink (i[1]) != 0) { + g_warning ("Fail to write in : %s", uri); + ret = FALSE; + goto done; + } } priv->fd = open(i[1], O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + + if (priv->fd == -1) { + g_warning ("Fail to open : %s", uri); + ret = FALSE; + } } else { g_warning("Output uri not supported"); + ret = FALSE; } +done: g_strfreev(i); + return ret; } static gboolean