changeset 591:8be45c22b20a trunk

[svn] - aosd: simplify the thread semaphores logic
author giacomo
date Wed, 31 Jan 2007 12:09:03 -0800
parents 6584e697e6da
children 546e779aba64
files ChangeLog src/aosd/aosd_osd.c
diffstat 2 files changed, 21 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Jan 31 11:50:36 2007 -0800
+++ b/ChangeLog	Wed Jan 31 12:09:03 2007 -0800
@@ -1,3 +1,13 @@
+2007-01-31 19:50:36 +0000  Giacomo Lozito <james@develia.org>
+  revision [1266]
+  - aosd: extended ghosd source with ghosd_set_event_button_cb to capture and handle button events in osd
+  trunk/src/aosd/ghosd-internal.h |    9 +++++++++
+  trunk/src/aosd/ghosd-main.c     |   19 +++++++++++++++++++
+  trunk/src/aosd/ghosd.c          |   13 ++++++++++++-
+  trunk/src/aosd/ghosd.h          |   17 +++++++++++++++++
+  4 files changed, 57 insertions(+), 1 deletion(-)
+
+
 2007-01-31 17:39:22 +0000  Giacomo Lozito <james@develia.org>
   revision [1264]
   - aosd: added 'none' decoration, just displays text and optional shadow
--- a/src/aosd/aosd_osd.c	Wed Jan 31 11:50:36 2007 -0800
+++ b/src/aosd/aosd_osd.c	Wed Jan 31 12:09:03 2007 -0800
@@ -34,14 +34,13 @@
 #include "ghosd-text.h"
 
 
-#define AOSD_STATUS_HIDDEN 0
-#define AOSD_STATUS_SHOWN  1
-#define AOSD_STATUS_UPDATE 2
+#define AOSD_STATUS_HIDDEN    0
+#define AOSD_STATUS_SHOWN     1
+#define AOSD_STATUS_INTERRUPT 2
 
 
 static pthread_t * aosd_thread = NULL;
 static pthread_mutex_t aosd_status_mutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t aosd_status_cond = PTHREAD_COND_INITIALIZER;
 static gboolean aosd_status = AOSD_STATUS_HIDDEN;
 
 
@@ -227,7 +226,7 @@
     for ( fade_data.alpha = 0 ; fade_data.alpha < 1.0 ; fade_data.alpha += dalpha_in )
     {
       pthread_mutex_lock( &aosd_status_mutex );
-      if ( aosd_status == AOSD_STATUS_UPDATE )
+      if ( aosd_status == AOSD_STATUS_INTERRUPT )
         { pthread_mutex_unlock( &aosd_status_mutex ); stop_now = TRUE; break; }
       pthread_mutex_unlock( &aosd_status_mutex );
 
@@ -250,7 +249,7 @@
     while ( time_iter_ms < cfg_osd->animation.timing_display )
     {
       pthread_mutex_lock( &aosd_status_mutex );
-      if ( aosd_status == AOSD_STATUS_UPDATE )
+      if ( aosd_status == AOSD_STATUS_INTERRUPT )
         { pthread_mutex_unlock( &aosd_status_mutex ); stop_now = TRUE; break; }
       pthread_mutex_unlock( &aosd_status_mutex );
 
@@ -267,7 +266,7 @@
     for ( fade_data.alpha = 1 ; fade_data.alpha > 0.0 ; fade_data.alpha -= dalpha_out )
     {
       pthread_mutex_lock( &aosd_status_mutex );
-      if ( aosd_status == AOSD_STATUS_UPDATE )
+      if ( aosd_status == AOSD_STATUS_INTERRUPT )
         { pthread_mutex_unlock( &aosd_status_mutex ); stop_now = TRUE; break; }
       pthread_mutex_unlock( &aosd_status_mutex );
 
@@ -289,17 +288,8 @@
     cairo_surface_destroy( fade_data.surface );
 
   pthread_mutex_lock( &aosd_status_mutex );
-  if ( aosd_status == AOSD_STATUS_UPDATE )
-  {
-    aosd_status = AOSD_STATUS_SHOWN;
-    pthread_mutex_unlock( &aosd_status_mutex );
-    pthread_cond_signal( &aosd_status_cond );
-  }
-  else
-  {
-    aosd_status = AOSD_STATUS_HIDDEN;
-    pthread_mutex_unlock( &aosd_status_mutex );
-  }
+  aosd_status = AOSD_STATUS_HIDDEN;
+  pthread_mutex_unlock( &aosd_status_mutex );
 
   g_free( markup_string );
   if ( thread_data->cfg_is_copied == TRUE )
@@ -333,8 +323,7 @@
   {
     /* a message is already being shown in osd, stop the
        display of that message cause there is a new one */
-    aosd_status = AOSD_STATUS_UPDATE;
-    pthread_cond_wait( &aosd_status_cond , &aosd_status_mutex );
+    aosd_status = AOSD_STATUS_INTERRUPT;
   }
   else
   {
@@ -348,6 +337,7 @@
   else
     aosd_thread = g_malloc(sizeof(pthread_t));
 
+  aosd_status = AOSD_STATUS_SHOWN; /* aosd_thread joined, no need to mutex this */
   pthread_create( aosd_thread , NULL , aosd_thread_func , thread_data );
   return 0;
 }
@@ -363,8 +353,7 @@
     {
       /* a message is being shown in osd,
          stop the display of that message */
-      aosd_status = AOSD_STATUS_UPDATE;
-      pthread_cond_wait( &aosd_status_cond , &aosd_status_mutex );
+      aosd_status = AOSD_STATUS_INTERRUPT;
     }
     pthread_mutex_unlock( &aosd_status_mutex );
     pthread_join( *aosd_thread , NULL );