comparison src/aosd/aosd_trigger.c @ 637:a1687bd302ce trunk

[svn] - aosd: completed volume change trigger, works now
author giacomo
date Mon, 12 Feb 2007 07:20:56 -0800
parents 443de962d0a0
children 40fb4189fa88
comparison
equal deleted inserted replaced
636:23160f66bc49 637:a1687bd302ce
65 N_("Triggers OSD when a playlist entry is played.") , 65 N_("Triggers OSD when a playlist entry is played.") ,
66 aosd_trigger_func_pb_start_onoff , 66 aosd_trigger_func_pb_start_onoff ,
67 aosd_trigger_func_pb_start_cb }, 67 aosd_trigger_func_pb_start_cb },
68 68
69 [AOSD_TRIGGER_PB_TITLECHANGE] = { N_("Title Change") , 69 [AOSD_TRIGGER_PB_TITLECHANGE] = { N_("Title Change") ,
70 N_("Trigger OSD when, during playback, the song title changes " 70 N_("Triggers OSD when, during playback, the song title changes "
71 "but the filename is the same. This is mostly useful to display " 71 "but the filename is the same. This is mostly useful to display "
72 "title changes in internet streams.") , 72 "title changes in internet streams.") ,
73 aosd_trigger_func_pb_titlechange_onoff , 73 aosd_trigger_func_pb_titlechange_onoff ,
74 aosd_trigger_func_pb_titlechange_cb }, 74 aosd_trigger_func_pb_titlechange_cb },
75 75
76 [AOSD_TRIGGER_VOL_CHANGE] = { N_("Volume Change") , 76 [AOSD_TRIGGER_VOL_CHANGE] = { N_("Volume Change") ,
77 N_("Volume blah blah.") , 77 N_("Triggers OSD when volume is changed.") ,
78 aosd_trigger_func_vol_change_onoff , 78 aosd_trigger_func_vol_change_onoff ,
79 aosd_trigger_func_vol_change_cb } 79 aosd_trigger_func_vol_change_cb }
80 }; 80 };
81 81
82 82
261 261
262 262
263 static void 263 static void
264 aosd_trigger_func_vol_change_onoff ( gboolean turn_on ) 264 aosd_trigger_func_vol_change_onoff ( gboolean turn_on )
265 { 265 {
266 return; 266 if ( turn_on == TRUE )
267 } 267 hook_associate( "volume set" , aosd_trigger_func_vol_change_cb , NULL );
268 268 else
269 static void 269 hook_dissociate( "volume set" , aosd_trigger_func_vol_change_cb );
270 aosd_trigger_func_vol_change_cb ( gpointer plentry_gp , gpointer prevs_gp ) 270 return;
271 { 271 }
272 return; 272
273 } 273 typedef struct
274 {
275 gint h_vol[2];
276 gint sid;
277 }
278 aosd_vol_change_bucket_t;
279
280 static gboolean
281 aosd_trigger_func_vol_change_timeout ( gpointer bucket_gp )
282 {
283 aosd_vol_change_bucket_t *bucket = bucket_gp;
284 gchar *utf8_title_markup = g_markup_printf_escaped(
285 "<span font_desc='%s'>Volume Change - L: %i , R: %i</span>" ,
286 global_config->osd->text.fonts_name[0] , bucket->h_vol[0] , bucket->h_vol[1] );
287 aosd_display( utf8_title_markup , global_config->osd , FALSE );
288 g_free( utf8_title_markup );
289 bucket->sid = 0; /* reset source id value */
290 return FALSE;
291 }
292
293 static void
294 aosd_trigger_func_vol_change_cb ( gpointer h_vol_gp , gpointer unused )
295 {
296 gint *h_vol = h_vol_gp;
297 static aosd_vol_change_bucket_t bucket = { { 0 , 0 } , 0 };
298
299 bucket.h_vol[0] = h_vol[0];
300 bucket.h_vol[1] = h_vol[1];
301
302 /* in order to avoid repeated display of osd for each volume variation, use a
303 timer to prevent it from appearing more than once when multiple volume
304 changes are performed in a short time interval (500 msec) */
305 if ( bucket.sid == 0 )
306 {
307 /* first call in the time interval */
308 bucket.sid = g_timeout_add( 500 , aosd_trigger_func_vol_change_timeout , &bucket );
309 }
310 else
311 {
312 /* another call in the same interval, reset the interval */
313 g_source_remove( bucket.sid );
314 bucket.sid = g_timeout_add( 500 , aosd_trigger_func_vol_change_timeout , &bucket );
315 }
316 return;
317 }