# HG changeset patch
# User rosfran
# Date 1171491879 0
# Node ID 6d7b5baf170b076b9764ea2c01ee90d14955d839
# Parent  7140b2c2e63cfd431cf7a99b5c67bb3b106dd129
[svn r364] Fixed a mutual exclusion bug on the Monitor Handler GIOChannel read callback.

diff -r 7140b2c2e63c -r 6d7b5baf170b gmyth/src/gmyth_livetv.c
--- a/gmyth/src/gmyth_livetv.c	Wed Feb 14 21:35:23 2007 +0000
+++ b/gmyth/src/gmyth_livetv.c	Wed Feb 14 22:24:39 2007 +0000
@@ -386,11 +386,8 @@
 
     while (wait_to_transfer++ < GMYTHTV_TRANSFER_MAX_WAITS &&
         (gmyth_recorder_is_recording (livetv->recorder) == FALSE))
-      g_usleep (500);
+      g_usleep (50);
 
-    /* IS_RECORDING again, just like the MythTV backend does... */
-    gmyth_recorder_is_recording (livetv->recorder);
-    
 		if ( channel != NULL ) 
 		{
 			/* Pauses remote encoder. */
@@ -411,7 +408,7 @@
 	
 		} /* if - changes the channel number */
 		
-    sleep (8);                  /* FIXME: this is evil (tpm) */
+    sleep (4);                  /* FIXME: this is evil (tpm) */
   }
   
   /* DEBUG message */  
diff -r 7140b2c2e63c -r 6d7b5baf170b gmyth/src/gmyth_monitor_handler.c
--- a/gmyth/src/gmyth_monitor_handler.c	Wed Feb 14 21:35:23 2007 +0000
+++ b/gmyth/src/gmyth_monitor_handler.c	Wed Feb 14 22:24:39 2007 +0000
@@ -418,6 +418,8 @@
   gsize len = 0;
   
   static guint count = 0;
+
+  myth_control_acquire_context ( monitor, TRUE );
   
   if ( ( io_cond & G_IO_HUP ) != 0 )
   {
@@ -430,10 +432,6 @@
   
   GMythStringList *strlist = NULL;
   
-  //GMythMonitorHandler *monitor = (GMythMonitorHandler*)data;
-  
-  myth_control_acquire_context (monitor, TRUE);
-  
   if ( NULL == io_channel ) {
   	g_debug ("Monitor socket is NULL!\n");
   	*ret = FALSE;
@@ -500,8 +498,6 @@
 
   } /* main GThread while */
   
-  myth_control_release_context (monitor);
-  
   if ( io_status == G_IO_STATUS_ERROR ) {
     //gmyth_debug ("[%s] Error reading: %s\n", __FUNCTION__, error != NULL ? error->message : "" );
     gmyth_debug ("Error reading MONITOR event socket.\n");
@@ -510,6 +506,7 @@
   }
   
 clean_up:
+  myth_control_release_context (monitor);
   	
  	return *ret;