# HG changeset patch # User rosfran # Date 1166576618 0 # Node ID 1cf29cf20fb376ce3e5f008e2bb054c5f4e8ee67 # Parent 00b55a87f1ba0a09bd5fdad3c631a86fa1a964d0 [svn r234] Do a better the signal emission, when changing from the program chain. diff -r 00b55a87f1ba -r 1cf29cf20fb3 gmyth/src/gmyth_file_transfer.c --- a/gmyth/src/gmyth_file_transfer.c Tue Dec 19 23:28:32 2006 +0000 +++ b/gmyth/src/gmyth_file_transfer.c Wed Dec 20 01:03:38 2006 +0000 @@ -129,8 +129,10 @@ g_type_class_add_private (gobject_class, sizeof (GMythFileTransferPrivate)); + gtransfer_class->program_info_changed_handler = gmyth_file_transfer_program_info_changed; + gtransfer_class->program_info_changed_handler_signal_id = - g_signal_new ("program-info-changed", + g_signal_new ( "program-info-changed", G_TYPE_FROM_CLASS (gtransfer_class), G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, 0, @@ -140,9 +142,7 @@ G_TYPE_NONE, 2, G_TYPE_INT, - G_TYPE_POINTER); - - gtransfer_class->program_info_changed_handler = gmyth_file_transfer_program_info_changed; + G_TYPE_POINTER ); } @@ -164,6 +164,10 @@ transfer->mutex = g_mutex_new(); + g_signal_connect ( G_OBJECT (transfer), "program-info-changed", + (GCallback)(GMYTH_FILE_TRANSFER_GET_CLASS(transfer)->program_info_changed_handler), + NULL ); + } static void @@ -340,6 +344,25 @@ return ret; } +void +gmyth_file_transfer_emit_program_info_changed_signal ( GMythFileTransfer *transfer, gint msg_code, + gpointer live_tv ) +{ + /* + g_signal_emit_by_name ( G_OBJECT(transfer), + "program-info-changed", + msg_code, live_tv ); + */ + + gmyth_debug( "Calling signal handler... [FILE_TRANSFER]" ); + + g_signal_emit ( transfer, + GMYTH_FILE_TRANSFER_GET_CLASS (transfer)->program_info_changed_handler_signal_id, + 0, /* details */ + msg_code, live_tv ); + +} + gboolean gmyth_file_transfer_is_open (GMythFileTransfer *transfer) { @@ -633,7 +656,7 @@ gmyth_file_transfer_program_info_changed( GMythFileTransfer *transfer, gint msg_code, gpointer livetv_transfer ) { - GMythLiveTV *livetv = (GMythLiveTV*)livetv_transfer; + GMythLiveTV *livetv = GMYTH_LIVETV( livetv_transfer ); gmyth_debug( "Program info changed! ( file transfer orig. = %p, ptr. = [%s], user data = [%s] )", transfer, livetv_transfer != NULL ? "[NOT NULL]" : "[NULL]", livetv != NULL ? "[NOT NULL]" : "[NULL]" ); diff -r 00b55a87f1ba -r 1cf29cf20fb3 gmyth/src/gmyth_file_transfer.h --- a/gmyth/src/gmyth_file_transfer.h Tue Dec 19 23:28:32 2006 +0000 +++ b/gmyth/src/gmyth_file_transfer.h Wed Dec 20 01:03:38 2006 +0000 @@ -113,6 +113,10 @@ gboolean gmyth_file_transfer_settimeout (GMythFileTransfer *transfer, gboolean fast); guint64 gmyth_file_transfer_get_filesize (GMythFileTransfer *transfer); +void gmyth_file_transfer_emit_program_info_changed_signal ( GMythFileTransfer *transfer, + gint msg_code, + gpointer live_tv ); + G_END_DECLS #endif /* __GMYTH_FILE_TRANSFER_H__ */ diff -r 00b55a87f1ba -r 1cf29cf20fb3 gmyth/src/gmyth_livetv.c --- a/gmyth/src/gmyth_livetv.c Tue Dec 19 23:28:32 2006 +0000 +++ b/gmyth/src/gmyth_livetv.c Wed Dec 20 01:03:38 2006 +0000 @@ -140,8 +140,8 @@ gmyth_livetv_monitor_signal_handler( GMythMonitorHandler *monitor, gint msg_code, gchar* message, gpointer user_data ) { - GMythLiveTV *live_tv = (GMythLiveTV*) user_data; - g_object_ref( live_tv ); + GMythLiveTV *live_tv = GMYTH_LIVETV ( user_data ); + //g_object_ref( live_tv ); gmyth_debug( "LIVETV Signal handler ( msg = %s, code = %d, live_tv param = %s, user_data = %s )\n", message, msg_code, live_tv != NULL ? "" : "NULL", user_data != NULL ? "" : "NULL" ); @@ -163,12 +163,12 @@ /* advertises the FileTransfer about the program info changed */ if ( live_tv->file_transfer != NULL ) { - g_signal_emit_by_name ( G_OBJECT(live_tv->file_transfer), - "program-info-changed", - 0, /* details */ - msg_code, live_tv ); + gmyth_debug( "Emitting signal to the FileTransfer... [ \"program-info-changed \" ]" ); + + gmyth_file_transfer_emit_program_info_changed_signal( live_tv->file_transfer, + msg_code, (gpointer)live_tv ); - gmyth_livetv_monitor_handler_stop( live_tv ); + //gmyth_livetv_monitor_handler_stop( live_tv ); } else gmyth_debug( "LIVETV file_transfer is NULL!!! Cannot move to the next program chain event received.\n"); /*}*/ diff -r 00b55a87f1ba -r 1cf29cf20fb3 gmyth/src/gmyth_monitor_handler.c --- a/gmyth/src/gmyth_monitor_handler.c Tue Dec 19 23:28:32 2006 +0000 +++ b/gmyth/src/gmyth_monitor_handler.c Wed Dec 20 01:03:38 2006 +0000 @@ -139,6 +139,8 @@ monitor->port = 0; monitor->actual_index = 0; + monitor->allow_msgs_listener = TRUE; + //monitor->backend_msgs = g_hash_table_new( g_int_hash, g_int_equal ); /* it is used for signalizing the event socket consumer thread */ @@ -158,14 +160,14 @@ GMythMonitorHandler *monitor = GMYTH_MONITOR_HANDLER (object); + monitor->allow_msgs_listener = FALSE; + if ( monitor->monitor_th != NULL ) { g_thread_pool_free( monitor->monitor_th, TRUE, FALSE ); - /* - g_thread_exit( monitor->monitor_th ); + //g_thread_exit( monitor->monitor_th ); if ( monitor->monitor_th != NULL ) g_object_unref( monitor->monitor_th ); - */ monitor->monitor_th = NULL; } @@ -313,25 +315,23 @@ if ( back_msg != NULL && back_msg->str != NULL && strstr( back_msg->str, "BACKEND" ) != NULL ) { - if ( monitor->backend_msgs != NULL ) - { - *back_msg_action = gmyth_string_list_get_char_array( strlist, 1 ); - - if ( back_msg_action != NULL ) - { - - if ( g_strstr_len( *back_msg_action, strlen( *back_msg_action ), "LIVETV_CHAIN" ) || - g_strstr_len( *back_msg_action, strlen( *back_msg_action ), "RECORDING_LIST_CHANGE" ) || - g_strstr_len( *back_msg_action, strlen( *back_msg_action ), "LIVETV_WATCH" ) ) - { - gmyth_debug( "MONITOR: message type == GMYTH_BACKEND_PROGRAM_INFO_CHANGED, msg = %s", *back_msg_action ); - msg_type = GMYTH_BACKEND_PROGRAM_INFO_CHANGED; - } - - //g_hash_table_insert ( monitor->backend_msgs, - // &(monitor->actual_index), *back_msg_action ); - - } // if + gmyth_debug( "MONITOR HANDLER - Received backend message = %s", back_msg->str ); + *back_msg_action = gmyth_string_list_get_char_array( strlist, 1 ); + + if ( back_msg_action != NULL ) + { + + if ( g_strstr_len( *back_msg_action, strlen( *back_msg_action ), "LIVETV_CHAIN" ) || + g_strstr_len( *back_msg_action, strlen( *back_msg_action ), "RECORDING_LIST_CHANGE" ) || + g_strstr_len( *back_msg_action, strlen( *back_msg_action ), "SCHEDULE_CHANGE" ) || + g_strstr_len( *back_msg_action, strlen( *back_msg_action ), "LIVETV_WATCH" ) ) + { + gmyth_debug( "MONITOR: message type == GMYTH_BACKEND_PROGRAM_INFO_CHANGED, msg = %s", *back_msg_action ); + msg_type = GMYTH_BACKEND_PROGRAM_INFO_CHANGED; + } + + //g_hash_table_insert ( monitor->backend_msgs, + // &(monitor->actual_index), *back_msg_action ); } // if } @@ -394,7 +394,7 @@ goto clean_up; } - while (TRUE) { + while (monitor->allow_msgs_listener) { ++count; gmyth_debug ("%d - Listening on Monitor socket...!\n", count); diff -r 00b55a87f1ba -r 1cf29cf20fb3 gmyth/src/gmyth_monitor_handler.h --- a/gmyth/src/gmyth_monitor_handler.h Tue Dec 19 23:28:32 2006 +0000 +++ b/gmyth/src/gmyth_monitor_handler.h Wed Dec 20 01:03:38 2006 +0000 @@ -94,6 +94,8 @@ gint64 actual_index; + gboolean allow_msgs_listener; + /* stores the messages coming from the backend */ GHashTable *backend_msgs;