|
From: <mo...@us...> - 2007-08-29 13:29:32
|
Revision: 837
http://gmyth.svn.sourceforge.net/gmyth/?rev=837&view=rev
Author: morphbr
Date: 2007-08-29 06:29:24 -0700 (Wed, 29 Aug 2007)
Log Message:
-----------
- Deleted old code
- Bug fix on gmencoder by Renato Filho
- Restored Renato's version of monitor_handler to work with gmencoder
Modified Paths:
--------------
trunk/gmyth/src/gmyth_monitor_handler.c
trunk/gmyth/src/gmyth_monitor_handler.h
trunk/gmyth-stream/gmemcoder/src/gmencoder.c
Removed Paths:
-------------
trunk/gmyth-stream/libgnomevfs2/
Modified: trunk/gmyth/src/gmyth_monitor_handler.c
===================================================================
--- trunk/gmyth/src/gmyth_monitor_handler.c 2007-08-29 09:00:25 UTC (rev 836)
+++ trunk/gmyth/src/gmyth_monitor_handler.c 2007-08-29 13:29:24 UTC (rev 837)
@@ -70,7 +70,9 @@
#define GMYTHTV_ENABLE_DEBUG 1
#endif
-gpointer gmyth_monitor_handler_listener(gpointer data);
+static gboolean gmyth_monitor_handler_listener (GIOChannel *io_channel,
+ GIOCondition condition,
+ gpointer data);
static void gmyth_monitor_handler_default_listener(GMythMonitorHandler
* monitor,
@@ -92,51 +94,10 @@
void gmyth_monitor_handler_close(GMythMonitorHandler * monitor);
-G_DEFINE_TYPE(GMythMonitorHandler, gmyth_monitor_handler, G_TYPE_OBJECT)
- static void
+G_DEFINE_TYPE(GMythMonitorHandler, gmyth_monitor_handler, G_TYPE_OBJECT);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- gmyth_monitor_handler_class_init(GMythMonitorHandlerClass * klass)
+static void
+gmyth_monitor_handler_class_init(GMythMonitorHandlerClass * klass)
{
GObjectClass *gobject_class;
GMythMonitorHandlerClass *gmonitor_class;
@@ -169,23 +130,11 @@
monitor->hostname = NULL;
monitor->port = 0;
monitor->actual_index = 0;
-
monitor->allow_msgs_listener = FALSE;
-
/*
- * monitor->backend_msgs = g_hash_table_new( g_int_hash, g_int_equal
- * );
- */
-
- /*
* it is used for signalizing the event socket consumer thread
*/
monitor->mutex = g_mutex_new();
-
- monitor->th = NULL;
-
- monitor->gmyth_monitor_handler_listener =
- gmyth_monitor_handler_listener;
}
static void
@@ -197,14 +146,9 @@
monitor->allow_msgs_listener = FALSE;
- if (monitor->th != NULL) {
- gboolean *ret = (gboolean *) g_thread_join(monitor->th);
-
- if (*ret == FALSE)
- gmyth_debug("Error closing GThread listener socket!");
- else
- gmyth_debug("Closed GThread listener socket.");
- // g_object_unref( monitor->th );
+ if (monitor->io_source != 0) {
+ g_source_remove (monitor->io_source);
+ monitor->io_source = 0;
}
/*
@@ -226,6 +170,7 @@
monitor->hostname = NULL;
}
+
if (monitor->backend_msgs != NULL) {
g_hash_table_destroy(monitor->backend_msgs);
monitor->backend_msgs = NULL;
@@ -236,6 +181,7 @@
* io_watcher_cond = NULL; }
*/
+
G_OBJECT_CLASS(gmyth_monitor_handler_parent_class)->dispose(object);
}
@@ -353,30 +299,22 @@
gmyth_debug("Monitor event socket --- hostname: %s, port %d\n",
monitor->hostname, monitor->port);
- if (NULL != monitor->event_sock) {
+ if (monitor->event_sock != NULL) {
g_object_unref(monitor->event_sock);
monitor->event_sock = NULL;
}
/*
- * configure the event socket
+ * configure the event socket
*/
- if (NULL == monitor->event_sock) {
- if (!gmyth_connect_to_backend_monitor(monitor)) {
- gmyth_debug("Connection to backend failed (Event Socket)!");
- ret = FALSE;
- } else {
- gmyth_debug
- ("Remote monitor event socket had been succesfully created. (io_fd == %d)\n",
- g_io_channel_unix_get_fd(monitor->event_sock->sd_io_ch));
- }
+ if (!gmyth_connect_to_backend_monitor(monitor)) {
+ gmyth_debug("Connection to backend failed (Event Socket)!");
+ ret = FALSE;
} else {
- gmyth_debug
- ("ASSERT ERROR: Remote monitor event socket is not NULL at the setup...\n");
+ gmyth_debug ("Remote monitor event socket had been succesfully create");
}
return ret;
-
}
/**
@@ -493,122 +431,73 @@
* @return Pointer to a gboolean <code>true</code> value, if the data was
* successfully read.
*/
-gpointer
-gmyth_monitor_handler_listener(gpointer data)
+static gboolean
+gmyth_monitor_handler_listener (GIOChannel *io_channel,
+ GIOCondition io_cond,
+ gpointer data)
{
- GMythMonitorHandler *monitor = (GMythMonitorHandler *) data;
+ GMythMonitorHandler *monitor;
guint recv = 0;
- gboolean *ret = g_new0(gboolean, 1);
gsize len = 0;
- GIOChannel *io_channel = monitor->event_sock->sd_io_ch;
- GIOCondition io_cond =
- g_io_channel_get_buffer_condition(io_channel);
- static guint count = 0;
+ GMythStringList *strlist = NULL;
+ gint bytes_sent = 0;
- *ret = TRUE;
+ monitor = (GMythMonitorHandler *) data;
gmyth_debug("Entering MONITOR handler listener...");
myth_control_acquire_context(monitor, TRUE);
- if ((io_cond & G_IO_HUP) != 0) {
- *ret = FALSE;
+ if (((io_cond & G_IO_HUP) != 0) ||
+ ((io_cond & G_IO_ERR) != 0)) {
goto clean_up;
}
- GMythStringList *strlist = NULL;
- if (NULL == io_channel) {
- gmyth_debug("Monitor socket is NULL! (GIOChannel)");
- *ret = FALSE;
- goto clean_up;
- }
+ gmyth_debug("Listening on Monitor socket...!\n");
+ strlist = gmyth_string_list_new();
- while (monitor->allow_msgs_listener) {
- ++count;
+ len = gmyth_socket_read_stringlist(monitor->event_sock, strlist);
+ if ((len > 0) && strlist != NULL && gmyth_string_list_length(strlist) > 0) {
+ gchar *back_msg_action;
+ gint msg_type;
- gmyth_debug("%d - Listening on Monitor socket...!\n", count);
+ bytes_sent = gmyth_string_list_get_int(strlist, 0);
+ // on backend error
+ gmyth_debug ("received data buffer from IO event channel... %d strings gone!\n", len);
+ recv += len;
- do {
+ /*
+ * debug purpose: prints out all the string list
+ * elements
+ */
+ g_list_foreach(strlist->glist,
+ (GFunc) gmyth_monitor_handler_print,
+ NULL);
- gint bytes_sent = 0;
+ back_msg_action = g_new0(gchar, 1);
+ msg_type = gmyth_monitor_handler_is_backend_message(monitor,
+ strlist,
+ &back_msg_action);
- strlist = gmyth_string_list_new();
-
- if (monitor->event_sock != NULL) {
-
- len =
- gmyth_socket_read_stringlist(monitor->event_sock,
- strlist);
-
- if ((len > 0) && strlist != NULL
- && gmyth_string_list_length(strlist) > 0) {
- bytes_sent = gmyth_string_list_get_int(strlist, 0); // -1
- //
- //
- // on
- // backend
- // error
-
- gmyth_debug
- ("[%s] MONITOR: received data buffer from IO event channel... %d strings gone!\n",
- __FUNCTION__, len);
-
- recv += len;
-
- /*
- * debug purpose: prints out all the string list
- * elements
- */
- g_list_foreach(strlist->glist,
- (GFunc) gmyth_monitor_handler_print,
- NULL);
-
- gchar *back_msg_action = g_new0(gchar, 1);
- gint msg_type =
- gmyth_monitor_handler_is_backend_message(monitor,
- strlist,
- &back_msg_action);
-
- if (monitor != NULL
- && msg_type != GMYTH_BACKEND_NO_MESSAGE)
- g_signal_emit(monitor, GMYTH_MONITOR_HANDLER_GET_CLASS(monitor)->backend_events_handler_signal_id, 0, /* details
- */
- msg_type, back_msg_action);
-
- if (back_msg_action != NULL)
- g_free(back_msg_action);
-
- }
-
- }
-
- if (strlist != NULL) {
- g_object_unref(strlist);
- strlist = NULL;
- }
-
- io_cond = g_io_channel_get_buffer_condition(io_channel);
-
- g_usleep(500);
-
+ if (msg_type != GMYTH_BACKEND_NO_MESSAGE) {
+ g_signal_emit(monitor,
+ GMYTH_MONITOR_HANDLER_GET_CLASS(monitor)->backend_events_handler_signal_id,
+ 0, msg_type, back_msg_action);
}
- while (recv <= 0 && ((io_cond & G_IO_HUP) == 0));
- gmyth_debug("\tMONITOR EVENT: Read %d bytes\n", recv);
+ if (back_msg_action != NULL)
+ g_free(back_msg_action);
- } /* main GThread while */
+ g_object_unref(strlist);
+ }
- clean_up:
+clean_up:
myth_control_release_context(monitor);
-
- g_thread_exit(ret);
-
- return (gpointer) ret;
-
+ return TRUE;
}
-/**
+/**
* Opens connection events' socket the the Monitor socket on
* MythTV backend server.
*
@@ -616,7 +505,7 @@
*
* @return <code>true</code>, if the socket was successfully opened.
*/
-static gboolean
+static gboolean
gmyth_connect_to_backend_monitor(GMythMonitorHandler * monitor)
{
gboolean ret = TRUE;
@@ -625,7 +514,7 @@
/*
* Connects the socket, send Mythtv ANN Monitor and verify Mythtv
- * protocol version
+ * protocol version
*/
if (!gmyth_socket_connect_to_backend_events(monitor->event_sock,
monitor->hostname,
@@ -638,52 +527,38 @@
return ret;
}
-/**
+/**
* Opens connection the the Monitor socket on MythTV backend server,
* where all status messages are notified to the client.
- *
+ *
* @param monitor The GMythMonitorHandler instance.
* @param channel The GIOChannel instance to the Monitor socket.
- *
+ *
* @return Pointer to the boolean value, and it is <code>true</code> only if the
- * GMythMonitorHandler could be configured.
+ * GMythMonitorHandler could be configured.
*/
-static gboolean
+static gboolean
gmyth_monitor_handler_setup(GMythMonitorHandler * monitor,
GIOChannel * channel)
{
- gboolean ret = TRUE;
+ gboolean ret = TRUE;
if (channel != NULL) {
monitor->allow_msgs_listener = TRUE;
-
- monitor->th =
- g_thread_create((GThreadFunc) gmyth_monitor_handler_listener,
- monitor, TRUE, NULL);
- gmyth_debug("MONITOR GThread created!");
+ monitor->io_source = g_io_add_watch (channel, G_IO_IN | G_IO_ERR | G_IO_HUP,
+ gmyth_monitor_handler_listener,
+ monitor);
} else {
ret = FALSE;
- goto cleanup;
}
-
- if (NULL == monitor->th) {
- gmyth_debug
- ("[%s] Error adding GThread listener function to the IO control channel!\n",
- __FUNCTION__);
- ret = FALSE;
- goto cleanup;
- }
-
- cleanup:
-
return ret;
}
-/**
+/**
* Starts the MonitorHandler thread to the GIOWatcher.
- *
+ *
* @param monitor The GMythMonitorHandler instance.
- *
+ *
* @return <code>true</code>, if the MonitorHandler was started.
*/
gboolean
Modified: trunk/gmyth/src/gmyth_monitor_handler.h
===================================================================
--- trunk/gmyth/src/gmyth_monitor_handler.h 2007-08-29 09:00:25 UTC (rev 836)
+++ trunk/gmyth/src/gmyth_monitor_handler.h 2007-08-29 13:29:24 UTC (rev 837)
@@ -63,12 +63,12 @@
GObjectClass parent_class;
/*
- * callbacks
+ * callbacks
*/
guint backend_events_handler_signal_id;
/*
- * signal default handlers
+ * signal default handlers
*/
void (*backend_events_handler) (GMythMonitorHandler *
monitor, gint msg_code,
@@ -88,14 +88,8 @@
*/
GMythSocket *event_sock;
+ //gpointer(*gmyth_monitor_handler_listener) (gpointer data);
-
-
-
-
-
- gpointer(*gmyth_monitor_handler_listener) (gpointer data);
-
gchar *hostname;
gint port;
@@ -109,9 +103,7 @@
GHashTable *backend_msgs;
GMutex *mutex;
-
- GThread *th;
-
+ guint io_source;
};
GType gmyth_monitor_handler_get_type(void);
Modified: trunk/gmyth-stream/gmemcoder/src/gmencoder.c
===================================================================
--- trunk/gmyth-stream/gmemcoder/src/gmencoder.c 2007-08-29 09:00:25 UTC (rev 836)
+++ trunk/gmyth-stream/gmemcoder/src/gmencoder.c 2007-08-29 13:29:24 UTC (rev 837)
@@ -866,7 +866,6 @@
GstElement *bsrc = NULL;
GstElement *src = NULL;
- GstElement *queue = NULL;
GstElement *aqueue = NULL;
GstElement *vqueue = NULL;
GstElement *decode = NULL;
@@ -888,11 +887,10 @@
if (src == NULL)
goto error;
- decode = gst_element_factory_make("decodebin", "decode");
+ decode = gst_element_factory_make("decodebin2", "decode");
if (decode == NULL)
goto error;
- queue = gst_element_factory_make("queue", "queue_src");
aqueue = gst_element_factory_make("queue", "aqueue");
if (aqueue == NULL)
goto error;
@@ -901,9 +899,9 @@
if (vqueue == NULL)
goto error;
- gst_bin_add_many(GST_BIN(bsrc), src, queue, decode, aqueue, vqueue,
+ gst_bin_add_many(GST_BIN(bsrc), src, decode, aqueue, vqueue,
NULL);
- gst_element_link_many(src, queue, decode, NULL);
+ gst_element_link (src, decode);
g_signal_connect(G_OBJECT(decode),
"new-decoded-pad",
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|