# HG changeset patch # User rosfran # Date 1171408655 0 # Node ID 06009f72d65741aba05e90e39618aeeb09a25464 # Parent 194c44ef8da4327d0405992d9448dbb5ca106296 [svn r360] Removed a lot of GStaticMutex references. diff -r 194c44ef8da4 -r 06009f72d657 gmyth/src/gmyth_livetv.c --- a/gmyth/src/gmyth_livetv.c Tue Feb 13 23:15:54 2007 +0000 +++ b/gmyth/src/gmyth_livetv.c Tue Feb 13 23:17:35 2007 +0000 @@ -47,7 +47,7 @@ static gint tvchain_curr_index = -1; -static GStaticMutex lock = G_STATIC_MUTEX_INIT; +/*static GStaticMutex lock = G_STATIC_MUTEX_INIT;*/ #define GMYTHTV_TRANSFER_MAX_WAITS 100 @@ -77,6 +77,8 @@ livetv->tvchain = NULL; livetv->proginfo = NULL; livetv->uri = NULL; + + livetv->mutex = NULL; } @@ -91,6 +93,7 @@ } if ( livetv->recorder != NULL ) { + //gmyth_livetv_stop_playing( g_object_unref (livetv->recorder); livetv->recorder = NULL; } @@ -126,6 +129,12 @@ livetv->uri = NULL; } + if ( livetv->mutex != NULL ) + { + g_mutex_free (livetv->mutex); + livetv->mutex = NULL; + } + G_OBJECT_CLASS (gmyth_livetv_parent_class)->dispose (object); } @@ -141,7 +150,9 @@ gmyth_livetv_new () { GMythLiveTV *livetv = GMYTH_LIVETV ( g_object_new( GMYTH_LIVETV_TYPE, NULL ) ); - + + livetv->mutex = g_mutex_new(); + return livetv; } @@ -309,7 +320,7 @@ } } - g_static_mutex_lock( &lock ); + g_mutex_lock( livetv->mutex ); livetv->is_livetv = TRUE; @@ -327,14 +338,10 @@ } if ( gmyth_remote_util_get_free_recorder_count (livetv->socket) <= 0 ) { - gmyth_debug ("No free remote encoder available. Trying to close the actual recording..."); + gmyth_debug ("No free remote encoder available."); - //res = FALSE; - //goto error; - if ( livetv->recorder != NULL ) { - g_object_unref( livetv->recorder ); - livetv->recorder = NULL; - } + res = FALSE; + goto error; } /* Gets the recorder num */ @@ -445,8 +452,7 @@ /* gmyth_debug( "Old ProgramInfo...\n" ); gmyth_program_info_print( livetv->proginfo ); - */ - + */ /* GMythProgramInfo* prog_inf = gmyth_recorder_get_next_program_info( livetv->recorder, BROWSE_DIRECTION_UP ); @@ -457,6 +463,7 @@ /* check if the program chain could be obtained from the MythTV protocol message */ if ( prog_info != NULL ) { + g_debug( "Program Info: %s\n", gmyth_program_info_to_string( prog_info ) ); livetv->proginfo = prog_info; /* testing change channel */ //gmyth_recorder_spawntv_no_tvchain( livetv->recorder ); @@ -488,7 +495,7 @@ livetv->uri = (GMythURI*)gmyth_backend_info_get_uri( backend_info ); - g_static_mutex_unlock( &lock ); + g_mutex_unlock( livetv->mutex ); if ( !gmyth_livetv_monitor_handler_start( livetv ) ) { @@ -646,7 +653,7 @@ else gmyth_debug( "URI path (from URI) = %s.\n", livetv->uri->uri->str ); - g_static_mutex_lock( &lock ); + g_mutex_lock( livetv->mutex ); if ( livetv->file_transfer != NULL ) { @@ -686,7 +693,7 @@ goto done; } - g_static_mutex_unlock( &lock ); + g_mutex_unlock( livetv->mutex ); done: /* @@ -709,11 +716,11 @@ if (livetv->is_livetv) { if ( !gmyth_recorder_stop_livetv (livetv->recorder) ) { - g_warning ("[%s] Error while stoping remote encoder", __FUNCTION__); + g_debug ("[%s] Error while stoping remote encoder", __FUNCTION__); } if ( !gmyth_recorder_finish_recording(livetv->recorder) ) { - g_warning ("[%s] Error while finishing recording on remote encoder", __FUNCTION__); + g_debug ("[%s] Error while finishing recording on remote encoder", __FUNCTION__); } } } diff -r 194c44ef8da4 -r 06009f72d657 gmyth/src/gmyth_livetv.h --- a/gmyth/src/gmyth_livetv.h Tue Feb 13 23:15:54 2007 +0000 +++ b/gmyth/src/gmyth_livetv.h Tue Feb 13 23:17:35 2007 +0000 @@ -78,6 +78,8 @@ gboolean is_livetv; gboolean setup_done; + + GMutex *mutex; }; diff -r 194c44ef8da4 -r 06009f72d657 gmyth/src/gmyth_monitor_handler.c --- a/gmyth/src/gmyth_monitor_handler.c Tue Feb 13 23:15:54 2007 +0000 +++ b/gmyth/src/gmyth_monitor_handler.c Tue Feb 13 23:17:35 2007 +0000 @@ -70,8 +70,6 @@ #define GMYTHTV_ENABLE_DEBUG 1 #endif -//GMainContext *io_watcher_context = NULL; - //GThread *monitor_th = NULL; //static gboolean* myth_control_sock_listener( GIOChannel *io_channel ); @@ -84,7 +82,7 @@ static void gmyth_monitor_handler_default_listener( GMythMonitorHandler *monitor, gint msg_code, gchar* message ); -static GStaticMutex mutex = G_STATIC_MUTEX_INIT; +/* static GStaticMutex mutex = G_STATIC_MUTEX_INIT; */ //static GCond* io_watcher_cond = NULL; @@ -146,9 +144,6 @@ /* it is used for signalizing the event socket consumer thread */ //io_watcher_cond = g_cond_new(); - /* mutex to control access to the event socket consumer thread */ - /*monitor->mutex = g_mutex_new();*/ - monitor->monitor_th = NULL; monitor->gmyth_monitor_handler_listener = gmyth_monitor_handler_listener; @@ -163,6 +158,15 @@ monitor->allow_msgs_listener = FALSE; + /* + if ( monitor->mutex != NULL ) + { + g_mutex_unlock( monitor->mutex ); + g_mutex_free( monitor->mutex ); + monitor->mutex = NULL; + } + */ + if ( monitor->monitor_th != NULL ) { g_thread_pool_free( monitor->monitor_th, TRUE, FALSE ); @@ -190,15 +194,7 @@ g_hash_table_destroy ( monitor->backend_msgs ); monitor->backend_msgs = NULL; } - - /* - if ( monitor->mutex != NULL ) - { - g_mutex_free( monitor->mutex ); - monitor->mutex = NULL; - } - */ - + /* if ( io_watcher_cond != NULL ) { @@ -224,7 +220,10 @@ { GMythMonitorHandler *monitor = GMYTH_MONITOR_HANDLER ( g_object_new ( GMYTH_MONITOR_HANDLER_TYPE, FALSE ) ); - + + /* mutex to control access to the event socket consumer thread */ + //monitor->mutex = g_mutex_new(); + return monitor; } @@ -249,7 +248,7 @@ ret = FALSE; */ - g_static_mutex_lock( &mutex ); + //g_mutex_lock( monitor->mutex ); return ret; @@ -261,7 +260,7 @@ gboolean ret = TRUE; - g_static_mutex_unlock( &mutex ); + //g_mutex_unlock( monitor->mutex ); //g_main_context_release( io_watcher_context ); @@ -283,7 +282,7 @@ monitor->allow_msgs_listener = FALSE; #if 0 - if ( monitor->monitor_th != NULL ) + if ( monitor->monitor_th != NULL ) { g_thread_pool_free( monitor->monitor_th, TRUE, FALSE ); //g_thread_exit( monitor->monitor_th ); @@ -320,7 +319,7 @@ /* configure the event socket */ //if ( NULL == monitor->event_sock ) { if (!gmyth_connect_to_backend_monitor (monitor)) { - g_printerr( "Connection to backend failed (Event Socket).\n" ); + gmyth_debug( "Connection to backend failed (Event Socket)." ); ret = FALSE; } else { @@ -416,6 +415,12 @@ static guint count = 0; + if ( ( io_cond & G_IO_HUP ) != 0 ) + { + *ret = FALSE; + goto clean_up; + } + //GIOChannel *io_channel = monitor->event_sock->sd_io_ch; //GIOCondition condition = g_io_channel_get_buffer_condition( io_channel ); @@ -482,14 +487,14 @@ g_object_unref( strlist ); strlist = NULL; } - + io_cond = g_io_channel_get_buffer_condition( io_channel ); - } while ( recv <= 0 /* && ( io_cond & G_IO_IN ) != 0 */); + } while ( recv <= 0 && ( ( io_cond & G_IO_HUP ) == 0 ) ); gmyth_debug ("\tMONITOR EVENT: Read %d bytes\n", recv ); - g_usleep( 300 ); + //g_usleep( 300 ); } /* main GThread while */ diff -r 194c44ef8da4 -r 06009f72d657 gmyth/src/gmyth_monitor_handler.h --- a/gmyth/src/gmyth_monitor_handler.h Tue Feb 13 23:15:54 2007 +0000 +++ b/gmyth/src/gmyth_monitor_handler.h Tue Feb 13 23:17:35 2007 +0000 @@ -102,7 +102,7 @@ /* stores the messages coming from the backend */ GHashTable *backend_msgs; - /*GMutex *mutex;*/ + //GMutex *mutex; }; diff -r 194c44ef8da4 -r 06009f72d657 gmyth/src/gmyth_socket.c --- a/gmyth/src/gmyth_socket.c Tue Feb 13 23:15:54 2007 +0000 +++ b/gmyth/src/gmyth_socket.c Tue Feb 13 23:17:35 2007 +0000 @@ -1053,7 +1053,7 @@ * @return TRUE if command was sent, FALSE if any error happens. */ gboolean -gmyth_socket_write_stringlist(GMythSocket *gmyth_socket, GMythStringList* str_list) +gmyth_socket_write_stringlist( GMythSocket *gmyth_socket, GMythStringList* str_list ) { GList *tmp_list = NULL;