[svn r234] Do a better the signal emission, when changing from the program chain. trunk
authorrosfran
Wed Dec 20 01:03:38 2006 +0000 (2006-12-20)
branchtrunk
changeset 2331cf29cf20fb3
parent 232 00b55a87f1ba
child 234 803a006ca678
[svn r234] Do a better the signal emission, when changing from the program chain.
gmyth/src/gmyth_file_transfer.c
gmyth/src/gmyth_file_transfer.h
gmyth/src/gmyth_livetv.c
gmyth/src/gmyth_monitor_handler.c
gmyth/src/gmyth_monitor_handler.h
     1.1 --- a/gmyth/src/gmyth_file_transfer.c	Tue Dec 19 23:28:32 2006 +0000
     1.2 +++ b/gmyth/src/gmyth_file_transfer.c	Wed Dec 20 01:03:38 2006 +0000
     1.3 @@ -129,8 +129,10 @@
     1.4    
     1.5    g_type_class_add_private (gobject_class, sizeof (GMythFileTransferPrivate));
     1.6    
     1.7 +	gtransfer_class->program_info_changed_handler = gmyth_file_transfer_program_info_changed;
     1.8 +  
     1.9  	gtransfer_class->program_info_changed_handler_signal_id = 
    1.10 -		  g_signal_new ("program-info-changed",
    1.11 +		  g_signal_new ( "program-info-changed",
    1.12  		                 G_TYPE_FROM_CLASS (gtransfer_class),
    1.13  		                 G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
    1.14  		                 0,
    1.15 @@ -140,9 +142,7 @@
    1.16  										 G_TYPE_NONE,
    1.17  										 2,
    1.18  										 G_TYPE_INT,
    1.19 -										 G_TYPE_POINTER);
    1.20 -										 
    1.21 -	gtransfer_class->program_info_changed_handler = gmyth_file_transfer_program_info_changed; 
    1.22 +										 G_TYPE_POINTER );
    1.23  
    1.24  }
    1.25  
    1.26 @@ -164,6 +164,10 @@
    1.27    
    1.28    transfer->mutex = g_mutex_new();
    1.29    
    1.30 +	g_signal_connect ( G_OBJECT (transfer), "program-info-changed",
    1.31 +              (GCallback)(GMYTH_FILE_TRANSFER_GET_CLASS(transfer)->program_info_changed_handler),
    1.32 +              NULL );
    1.33 +
    1.34  }
    1.35  
    1.36  static void
    1.37 @@ -340,6 +344,25 @@
    1.38    return ret;
    1.39  }    
    1.40  
    1.41 +void
    1.42 +gmyth_file_transfer_emit_program_info_changed_signal ( GMythFileTransfer *transfer, gint msg_code,
    1.43 +			gpointer live_tv ) 
    1.44 +{
    1.45 +				/*
    1.46 +	g_signal_emit_by_name ( G_OBJECT(transfer),
    1.47 +         "program-info-changed",
    1.48 +         msg_code, live_tv );
    1.49 +         */
    1.50 +         
    1.51 +  gmyth_debug( "Calling signal handler... [FILE_TRANSFER]" );
    1.52 +
    1.53 +  g_signal_emit ( transfer,
    1.54 +         GMYTH_FILE_TRANSFER_GET_CLASS (transfer)->program_info_changed_handler_signal_id,
    1.55 +         0, /* details */
    1.56 +         msg_code, live_tv );
    1.57 +
    1.58 +}
    1.59 +
    1.60  gboolean
    1.61  gmyth_file_transfer_is_open (GMythFileTransfer *transfer)
    1.62  {
    1.63 @@ -633,7 +656,7 @@
    1.64  gmyth_file_transfer_program_info_changed( GMythFileTransfer *transfer, 
    1.65  										gint msg_code, gpointer livetv_transfer )
    1.66  {
    1.67 -	GMythLiveTV *livetv = (GMythLiveTV*)livetv_transfer;
    1.68 +	GMythLiveTV *livetv = GMYTH_LIVETV( livetv_transfer );
    1.69  	
    1.70  	gmyth_debug( "Program info changed! ( file transfer orig. = %p, ptr. = [%s], user data = [%s] )", transfer, 
    1.71  		livetv_transfer != NULL ? "[NOT NULL]" : "[NULL]", livetv != NULL ? "[NOT NULL]" : "[NULL]" );
     2.1 --- a/gmyth/src/gmyth_file_transfer.h	Tue Dec 19 23:28:32 2006 +0000
     2.2 +++ b/gmyth/src/gmyth_file_transfer.h	Wed Dec 20 01:03:38 2006 +0000
     2.3 @@ -113,6 +113,10 @@
     2.4  gboolean            gmyth_file_transfer_settimeout      (GMythFileTransfer *transfer, gboolean fast);
     2.5  guint64             gmyth_file_transfer_get_filesize    (GMythFileTransfer *transfer);
     2.6  
     2.7 +void								gmyth_file_transfer_emit_program_info_changed_signal ( GMythFileTransfer *transfer, 
     2.8 +																																					 gint msg_code,
     2.9 +																																					 gpointer live_tv );
    2.10 +
    2.11  G_END_DECLS
    2.12  
    2.13  #endif /* __GMYTH_FILE_TRANSFER_H__ */
     3.1 --- a/gmyth/src/gmyth_livetv.c	Tue Dec 19 23:28:32 2006 +0000
     3.2 +++ b/gmyth/src/gmyth_livetv.c	Wed Dec 20 01:03:38 2006 +0000
     3.3 @@ -140,8 +140,8 @@
     3.4  gmyth_livetv_monitor_signal_handler( GMythMonitorHandler *monitor, gint msg_code, 
     3.5  							gchar* message, gpointer user_data )
     3.6  {
     3.7 -	GMythLiveTV *live_tv = (GMythLiveTV*) user_data;
     3.8 -	g_object_ref( live_tv );
     3.9 +	GMythLiveTV *live_tv = GMYTH_LIVETV ( user_data );
    3.10 +	//g_object_ref( live_tv );
    3.11  	
    3.12  	gmyth_debug( "LIVETV Signal handler ( msg = %s, code = %d, live_tv param = %s, user_data = %s )\n", message, msg_code, live_tv != NULL ? "" : 
    3.13  					"NULL", user_data != NULL ? "" : "NULL" );
    3.14 @@ -163,12 +163,12 @@
    3.15  			/* advertises the FileTransfer about the program info changed */
    3.16  			if ( live_tv->file_transfer != NULL )
    3.17  			{
    3.18 -				g_signal_emit_by_name ( G_OBJECT(live_tv->file_transfer),
    3.19 -	             "program-info-changed",
    3.20 -	             0, /* details */
    3.21 -	             msg_code, live_tv );
    3.22 +				gmyth_debug( "Emitting signal to the FileTransfer... [ \"program-info-changed \" ]" );
    3.23 +				
    3.24 +				gmyth_file_transfer_emit_program_info_changed_signal( live_tv->file_transfer,
    3.25 +	             msg_code, (gpointer)live_tv );
    3.26  	             
    3.27 -	      gmyth_livetv_monitor_handler_stop( live_tv );	      
    3.28 +	      //gmyth_livetv_monitor_handler_stop( live_tv );	      
    3.29  			} else
    3.30  				gmyth_debug( "LIVETV file_transfer is NULL!!! Cannot move to the next program chain event received.\n");
    3.31  			/*}*/
     4.1 --- a/gmyth/src/gmyth_monitor_handler.c	Tue Dec 19 23:28:32 2006 +0000
     4.2 +++ b/gmyth/src/gmyth_monitor_handler.c	Wed Dec 20 01:03:38 2006 +0000
     4.3 @@ -139,6 +139,8 @@
     4.4    monitor->port = 0;
     4.5    monitor->actual_index = 0;
     4.6    
     4.7 +  monitor->allow_msgs_listener = TRUE;
     4.8 +  
     4.9    //monitor->backend_msgs = g_hash_table_new( g_int_hash, g_int_equal );
    4.10      
    4.11    /* it is used for signalizing the event socket consumer thread */
    4.12 @@ -158,14 +160,14 @@
    4.13  	
    4.14  	GMythMonitorHandler *monitor = GMYTH_MONITOR_HANDLER (object);
    4.15  	
    4.16 +	monitor->allow_msgs_listener = FALSE;
    4.17 +	
    4.18  	if ( monitor->monitor_th != NULL )  
    4.19    {
    4.20    	g_thread_pool_free( monitor->monitor_th, TRUE, FALSE );
    4.21 -  	/*
    4.22 -  	g_thread_exit( monitor->monitor_th );
    4.23 +  	//g_thread_exit( monitor->monitor_th );
    4.24    	if ( monitor->monitor_th != NULL )
    4.25    		g_object_unref( monitor->monitor_th );
    4.26 -  	*/
    4.27    	monitor->monitor_th = NULL;
    4.28    }
    4.29  	
    4.30 @@ -313,25 +315,23 @@
    4.31  	if ( back_msg != NULL && back_msg->str != NULL &&
    4.32  	                                strstr( back_msg->str, "BACKEND" ) != NULL )
    4.33  	{
    4.34 -	  if ( monitor->backend_msgs != NULL )
    4.35 -	  {
    4.36 -	  	*back_msg_action = gmyth_string_list_get_char_array( strlist, 1 );	        	
    4.37 -	  	
    4.38 -	  	if ( back_msg_action != NULL )
    4.39 -	  	{	        	
    4.40 -	  	
    4.41 -	    	if ( g_strstr_len( *back_msg_action, strlen( *back_msg_action ), "LIVETV_CHAIN" ) ||
    4.42 -	    			g_strstr_len( *back_msg_action, strlen( *back_msg_action ), "RECORDING_LIST_CHANGE" ) ||
    4.43 -	    			g_strstr_len( *back_msg_action, strlen( *back_msg_action ), "LIVETV_WATCH" ) )
    4.44 -	    	{
    4.45 -	    		gmyth_debug( "MONITOR: message type == GMYTH_BACKEND_PROGRAM_INFO_CHANGED, msg = %s", *back_msg_action );
    4.46 -	    		msg_type = GMYTH_BACKEND_PROGRAM_INFO_CHANGED;
    4.47 -	    	}  	
    4.48 -	
    4.49 -	      //g_hash_table_insert ( monitor->backend_msgs,
    4.50 -	      //                       &(monitor->actual_index), *back_msg_action );
    4.51 -	                              
    4.52 -	  	} // if
    4.53 +		gmyth_debug( "MONITOR HANDLER - Received backend message = %s", back_msg->str );
    4.54 +  	*back_msg_action = gmyth_string_list_get_char_array( strlist, 1 );
    4.55 +  	
    4.56 +  	if ( back_msg_action != NULL )
    4.57 +  	{	        	
    4.58 +  	
    4.59 +    	if ( g_strstr_len( *back_msg_action, strlen( *back_msg_action ), "LIVETV_CHAIN" ) ||
    4.60 +    			g_strstr_len( *back_msg_action, strlen( *back_msg_action ), "RECORDING_LIST_CHANGE" ) ||
    4.61 +    			g_strstr_len( *back_msg_action, strlen( *back_msg_action ), "SCHEDULE_CHANGE" ) ||
    4.62 +    			g_strstr_len( *back_msg_action, strlen( *back_msg_action ), "LIVETV_WATCH" ) )
    4.63 +    	{
    4.64 +    		gmyth_debug( "MONITOR: message type == GMYTH_BACKEND_PROGRAM_INFO_CHANGED, msg = %s", *back_msg_action );
    4.65 +    		msg_type = GMYTH_BACKEND_PROGRAM_INFO_CHANGED;
    4.66 +    	}  	
    4.67 +
    4.68 +      //g_hash_table_insert ( monitor->backend_msgs,
    4.69 +      //                       &(monitor->actual_index), *back_msg_action );
    4.70  	    
    4.71  	  } // if
    4.72  	}
    4.73 @@ -394,7 +394,7 @@
    4.74    	goto clean_up;
    4.75    }
    4.76      
    4.77 -  while (TRUE) {
    4.78 +  while (monitor->allow_msgs_listener) {
    4.79    	++count;
    4.80    	
    4.81    	gmyth_debug ("%d - Listening on Monitor socket...!\n", count);
     5.1 --- a/gmyth/src/gmyth_monitor_handler.h	Tue Dec 19 23:28:32 2006 +0000
     5.2 +++ b/gmyth/src/gmyth_monitor_handler.h	Wed Dec 20 01:03:38 2006 +0000
     5.3 @@ -94,6 +94,8 @@
     5.4  	
     5.5  	gint64 actual_index;
     5.6  	
     5.7 +	gboolean allow_msgs_listener;
     5.8 +	
     5.9  	/* stores the messages coming from the backend */
    5.10  	GHashTable *backend_msgs;	
    5.11