diff -r 7feaeeed26d5 -r f635d7c4f789 gmyth-stream/gmemcoder/src/gmencoder.c --- a/gmyth-stream/gmemcoder/src/gmencoder.c Wed Jul 04 15:25:52 2007 +0100 +++ b/gmyth-stream/gmemcoder/src/gmencoder.c Wed Jul 04 21:51:42 2007 +0100 @@ -18,7 +18,6 @@ // #define SUPPORT_MULT_INPUT 0 #define USE_MANUAL_SINK -#define BUFFER_SIZE (1024 * 64) typedef struct _GMencoderPrivate GMencoderPrivate; typedef struct _SetupInfo SetupInfo; @@ -52,9 +51,6 @@ gint tick_id; gint64 duration; gboolean send_chunked; -#ifdef USE_MANUAL_SINK - GByteArray *queue; -#endif }; enum { @@ -172,9 +168,6 @@ { GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self); priv->info = g_new0(SetupInfo, 1); -#ifdef USE_MANUAL_SINK - priv->queue = g_byte_array_new (); -#endif } static void @@ -190,9 +183,6 @@ // TODO: clear vars g_mencoder_close_stream(G_MENCODER(object)); g_free (priv->info); -#ifdef USE_MANUAL_SINK - g_byte_array_free (priv->queue, TRUE); -#endif } GMencoder * @@ -267,7 +257,7 @@ if (prop != NULL) { for (i = 0; i < g_strv_length(prop); i++) { if (prop[i] != NULL) { - char **v = g_strsplit(prop[i], "=", 2); + char **v = g_strsplit(prop[i], "=", 2); if (g_strv_length(v) == 2) { _obj_set_prop(G_OBJECT(ret), v[0], v[1]); } @@ -946,8 +936,6 @@ i = g_strsplit(uri, "://", 0); if (strcmp(i[0], "fd") == 0) { priv->fd = atoi(i[1]); - if (priv->send_chunked) - fcntl (priv->fd, F_SETFL, O_ASYNC); } else if (strcmp(i[0], "file") == 0) { if (g_file_test (i[1], G_FILE_TEST_EXISTS)) { if (unlink (i[1]) != 0) { @@ -1034,7 +1022,7 @@ case GST_MESSAGE_EOS: priv->ready = FALSE; #ifdef USE_MANUAL_SINK - _flush_queue (G_MENCODER (user_data)); + _flush_queue (G_MENCODER (user_data)); #endif g_signal_emit(user_data, g_mencoder_signals[EOS], 0); break; @@ -1147,21 +1135,14 @@ static void _flush_queue (GMencoder *self) { - gchar *end_msg; GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(self); - if (BUFFER_SIZE == 0) - return; - - if (priv->queue->len > 0) { - _send_buffer (priv->fd, priv->queue->data, priv->queue->len); - priv->queue = g_byte_array_remove_range (priv->queue, 0, priv->queue->len); + if (priv->send_chunked) { + gchar *end_msg; + end_msg = g_strdup ("0\r\n\r\n"); + write (priv->fd, (const guint8*) end_msg, strlen(end_msg) * sizeof(gchar)); + g_free (end_msg); } - - end_msg = g_strdup ("0\r\n\r\n"); - write (priv->fd, (const guint8*) end_msg, strlen(end_msg) * sizeof(gchar)); - g_free (end_msg); - return; } static void _buffer_arrive_cb (GstElement* object, @@ -1171,26 +1152,14 @@ { GMencoderPrivate *priv = G_MENCODER_GET_PRIVATE(user_data); - if (GST_BUFFER_SIZE (buff) == 0) - return; - - if (BUFFER_SIZE == 0) { - if (_send_buffer (priv->fd, GST_BUFFER_DATA (buff), GST_BUFFER_SIZE (buff)) == FALSE) - goto error; - return; + if (priv->send_chunked) { + if (_send_buffer (priv->fd, GST_BUFFER_DATA (buff), GST_BUFFER_SIZE (buff)) == FALSE) + goto error; + } else { + if (write (priv->fd, GST_BUFFER_DATA (buff), GST_BUFFER_SIZE (buff)) < 0) + goto error; } - priv->queue = g_byte_array_append (priv->queue, GST_BUFFER_DATA (buff), GST_BUFFER_SIZE (buff)); - while (priv->queue->len >= BUFFER_SIZE) { - if (priv->send_chunked) { - if (_send_buffer (priv->fd, priv->queue->data, BUFFER_SIZE) == FALSE) - goto error; - } else { - if (write (priv->fd, priv->queue->data, BUFFER_SIZE) == -1) - goto error; - } - priv->queue = g_byte_array_remove_range (priv->queue, 0, BUFFER_SIZE); - } return; error: @@ -1198,7 +1167,6 @@ g_source_remove(priv->tick_id); priv->tick_id = 0; } - priv->queue = g_byte_array_remove_range (priv->queue, 0, priv->queue->len); g_signal_emit(user_data, g_mencoder_signals[ERROR], 0, "Error on socket"); } #endif