changeset 637:a1687bd302ce trunk

[svn] - aosd: completed volume change trigger, works now
author giacomo
date Mon, 12 Feb 2007 07:20:56 -0800
parents 23160f66bc49
children 7c569af3f656
files ChangeLog src/aosd/aosd_trigger.c
diffstat 2 files changed, 55 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Feb 12 01:39:53 2007 -0800
+++ b/ChangeLog	Mon Feb 12 07:20:56 2007 -0800
@@ -1,3 +1,11 @@
+2007-02-12 09:39:53 +0000  William Pitcock <nenolod@sacredspiral.co.uk>
+  revision [1358]
+  - update Welsh translation: ~75% completed
+  
+  trunk/po/cy.po |  248 +++++++++++++++++++++++++++++++--------------------------
+  1 file changed, 135 insertions(+), 113 deletions(-)
+
+
 2007-02-11 14:22:20 +0000  Yoshiki Yazawa <yaz@cc.rim.or.jp>
   revision [1356]
   - add rpath to make sure that plugins pick libid3tag up from libdir.
--- a/src/aosd/aosd_trigger.c	Mon Feb 12 01:39:53 2007 -0800
+++ b/src/aosd/aosd_trigger.c	Mon Feb 12 07:20:56 2007 -0800
@@ -67,14 +67,14 @@
                               aosd_trigger_func_pb_start_cb },
 
   [AOSD_TRIGGER_PB_TITLECHANGE] = { N_("Title Change") ,
-                                    N_("Trigger OSD when, during playback, the song title changes "
+                                    N_("Triggers OSD when, during playback, the song title changes "
                                        "but the filename is the same. This is mostly useful to display "
                                        "title changes in internet streams.") ,
                                     aosd_trigger_func_pb_titlechange_onoff ,
                                     aosd_trigger_func_pb_titlechange_cb },
 
   [AOSD_TRIGGER_VOL_CHANGE] = { N_("Volume Change") ,
-                                N_("Volume blah blah.") ,
+                                N_("Triggers OSD when volume is changed.") ,
                                 aosd_trigger_func_vol_change_onoff ,
                                 aosd_trigger_func_vol_change_cb }
 };
@@ -263,11 +263,55 @@
 static void
 aosd_trigger_func_vol_change_onoff ( gboolean turn_on )
 {
+  if ( turn_on == TRUE )
+    hook_associate( "volume set" , aosd_trigger_func_vol_change_cb , NULL );
+  else
+    hook_dissociate( "volume set" , aosd_trigger_func_vol_change_cb );
   return;
 }
 
+typedef struct
+{
+  gint h_vol[2];
+  gint sid;
+}
+aosd_vol_change_bucket_t;
+
+static gboolean
+aosd_trigger_func_vol_change_timeout ( gpointer bucket_gp )
+{
+  aosd_vol_change_bucket_t *bucket = bucket_gp;
+  gchar *utf8_title_markup = g_markup_printf_escaped(
+    "<span font_desc='%s'>Volume Change - L: %i , R: %i</span>" ,
+    global_config->osd->text.fonts_name[0] , bucket->h_vol[0] , bucket->h_vol[1] );
+  aosd_display( utf8_title_markup , global_config->osd , FALSE );
+  g_free( utf8_title_markup );
+  bucket->sid = 0; /* reset source id value */
+  return FALSE;
+}
+
 static void
-aosd_trigger_func_vol_change_cb ( gpointer plentry_gp , gpointer prevs_gp )
+aosd_trigger_func_vol_change_cb ( gpointer h_vol_gp , gpointer unused )
 {
+  gint *h_vol = h_vol_gp;
+  static aosd_vol_change_bucket_t bucket = { { 0 , 0 } , 0 };
+  
+  bucket.h_vol[0] = h_vol[0];
+  bucket.h_vol[1] = h_vol[1];
+  
+  /* in order to avoid repeated display of osd for each volume variation, use a
+     timer to prevent it from appearing more than once when multiple volume
+     changes are performed in a short time interval (500 msec) */
+  if ( bucket.sid == 0 )
+  {
+    /* first call in the time interval */
+    bucket.sid = g_timeout_add( 500 , aosd_trigger_func_vol_change_timeout , &bucket );
+  }
+  else
+  {
+    /* another call in the same interval, reset the interval */
+    g_source_remove( bucket.sid );
+    bucket.sid = g_timeout_add( 500 , aosd_trigger_func_vol_change_timeout , &bucket );
+  }
   return;
 }