1 /*****************************************************************************
\r
2 * osd.c - The OSD Menu core code.
\r
3 *****************************************************************************
\r
4 * Copyright (C) 2005 M2X
\r
5 * $Id: osd.c 9451 2004-12-01 01:07:08Z jpsaman $
\r
7 * Authors: Jean-Paul Saman <jpsaman #_at_# m2x dot nl>
\r
9 * This program is free software; you can redistribute it and/or modify
\r
10 * it under the terms of the GNU General Public License as published by
\r
11 * the Free Software Foundation; either version 2 of the License, or
\r
12 * (at your option) any later version.
\r
14 * This program is distributed in the hope that it will be useful,
\r
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
17 * GNU General Public License for more details.
\r
19 * You should have received a copy of the GNU General Public License
\r
20 * along with this program; if not, write to the Free Software
\r
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
\r
22 *****************************************************************************/
\r
24 /*****************************************************************************
\r
26 *****************************************************************************/
\r
30 #include <vlc/vlc.h>
\r
31 #include <vlc_keys.h>
\r
32 #include <vlc_osd.h>
\r
34 #undef OSD_MENU_DEBUG
\r
36 /*****************************************************************************
\r
38 *****************************************************************************/
\r
40 static void osd_UpdateState( osd_menu_state_t *, int, int, int, int, picture_t * );
\r
41 static inline osd_state_t *osd_VolumeStateChange( osd_state_t *, int );
\r
43 osd_menu_t *__osd_MenuCreate( vlc_object_t *p_this, const char *psz_file )
\r
45 osd_menu_t *p_osd = NULL;
\r
46 vlc_value_t lockval;
\r
50 /* to be sure to avoid multiple creation */
\r
51 var_Create( p_this->p_libvlc, "osd_mutex", VLC_VAR_MUTEX );
\r
52 var_Get( p_this->p_libvlc, "osd_mutex", &lockval );
\r
53 vlc_mutex_lock( lockval.p_address );
\r
55 if( ( p_osd = vlc_object_find( p_this, VLC_OBJECT_OSDMENU, FIND_ANYWHERE ) ) == NULL )
\r
59 msg_Dbg( p_this, "creating osd menu object" );
\r
60 if( ( p_osd = vlc_object_create( p_this, VLC_OBJECT_OSDMENU ) ) == NULL )
\r
62 msg_Err( p_this, "out of memory" );
\r
63 vlc_mutex_unlock( lockval.p_address );
\r
67 /* Parse configuration file */
\r
68 if( osd_ConfigLoader( p_this, psz_file, &p_osd ) )
\r
71 /* Setup default button (first button) */
\r
72 p_osd->p_state->p_visible = p_osd->p_button;
\r
73 p_osd->p_state->p_visible->p_current_state =
\r
74 osd_StateChange( p_osd->p_state->p_visible->p_states, OSD_BUTTON_SELECT );
\r
75 p_osd->i_width = p_osd->p_state->p_visible->p_current_state->p_pic->p[Y_PLANE].i_visible_pitch;
\r
76 p_osd->i_height = p_osd->p_state->p_visible->p_current_state->p_pic->p[Y_PLANE].i_visible_lines;
\r
78 /* Update the volume state images to match the current volume */
\r
79 i_volume = config_GetInt( p_this, "volume" );
\r
80 i_steps = (i_volume / AOUT_VOLUME_STEP / 3); /* 3 is a magic number for 32 volume decrease steps */
\r
81 p_osd->p_state->p_volume->p_current_state = osd_VolumeStateChange( p_osd->p_state->p_volume->p_states, i_steps );
\r
83 /* Initialize OSD state */
\r
84 osd_UpdateState( p_osd->p_state, p_osd->i_x, p_osd->i_y,
\r
85 p_osd->i_width, p_osd->i_height, NULL );
\r
87 vlc_object_yield( p_osd );
\r
88 vlc_object_attach( p_osd, p_this->p_vlc );
\r
90 /* Signal when an update of OSD menu is needed */
\r
91 var_Create( p_osd, "osd-menu-update", VLC_VAR_BOOL );
\r
92 var_Create( p_osd, "osd-menu-visible", VLC_VAR_BOOL );
\r
94 val.b_bool = VLC_FALSE;
\r
95 var_Set( p_osd, "osd-menu-update", val );
\r
96 var_Set( p_osd, "osd-menu-visible", val );
\r
98 vlc_mutex_unlock( lockval.p_address );
\r
102 msg_Err( p_this, "creating osd menu object failed" );
\r
103 vlc_mutex_unlock( lockval.p_address );
\r
104 vlc_object_destroy( p_osd );
\r
108 void __osd_MenuDelete( vlc_object_t *p_this, osd_menu_t *p_osd )
\r
110 vlc_value_t lockval;
\r
112 if( !p_osd || !p_this ) return;
\r
114 var_Get( p_this->p_libvlc, "osd_mutex", &lockval );
\r
115 vlc_mutex_lock( lockval.p_address );
\r
117 vlc_object_release( p_osd );
\r
118 if( p_osd->i_refcount > 0 )
\r
120 vlc_mutex_unlock( lockval.p_address );
\r
124 var_Destroy( p_osd, "osd-menu-visible" );
\r
125 var_Destroy( p_osd, "osd-menu-update" );
\r
127 osd_ConfigUnload( p_this, &p_osd );
\r
128 vlc_object_detach( p_osd );
\r
129 vlc_object_destroy( p_osd );
\r
132 vlc_mutex_unlock( lockval.p_address );
\r
135 osd_state_t *__osd_StateChange( osd_state_t *p_states, const int i_state )
\r
137 osd_state_t *p_current = p_states;
\r
138 osd_state_t *p_temp = NULL;
\r
141 for( i=0; p_current != NULL; i++ )
\r
143 if( p_current->i_state == i_state )
\r
145 p_temp = p_current->p_next;
\r
146 p_current = p_temp;
\r
151 /* The volume can be modified in another interface while the OSD Menu
\r
152 * has not been instantiated yet. This routines updates the "volume OSD menu item"
\r
153 * to reflect the current state of the GUI.
\r
155 static inline osd_state_t *osd_VolumeStateChange( osd_state_t *p_current, int i_steps )
\r
157 osd_state_t *p_temp = NULL;
\r
160 for( i=0; (i < i_steps) && (p_current != NULL); i++ )
\r
162 p_temp = p_current->p_next;
\r
163 if( !p_temp ) return p_current;
\r
164 p_current = p_temp;
\r
166 return (!p_temp) ? p_current : p_temp;
\r
169 /* Update the state of the OSD Menu */
\r
170 static void osd_UpdateState( osd_menu_state_t *p_state, int i_x, int i_y,
\r
171 int i_width, int i_height, picture_t *p_pic )
\r
173 p_state->i_x = i_x;
\r
174 p_state->i_y = i_y;
\r
175 p_state->i_width = i_width;
\r
176 p_state->i_height = i_height;
\r
177 p_state->p_pic = p_pic;
\r
180 void __osd_MenuShow( vlc_object_t *p_this )
\r
182 osd_menu_t *p_osd = NULL;
\r
183 osd_button_t *p_button = NULL;
\r
184 vlc_value_t lockval;
\r
186 if( ( p_osd = vlc_object_find( p_this, VLC_OBJECT_OSDMENU, FIND_ANYWHERE ) ) == NULL )
\r
188 msg_Err( p_this, "osd_MenuNext failed" );
\r
192 var_Get( p_this->p_libvlc, "osd_mutex", &lockval );
\r
193 vlc_mutex_lock( lockval.p_address );
\r
195 #if defined(OSD_MENU_DEBUG)
\r
196 msg_Dbg( p_osd, "menu on" );
\r
198 p_button = p_osd->p_state->p_visible;
\r
201 if( !p_button->b_range )
\r
202 p_button->p_current_state = osd_StateChange( p_button->p_states, OSD_BUTTON_UNSELECT );
\r
203 p_osd->p_state->p_visible = p_osd->p_button;
\r
205 if( !p_osd->p_state->p_visible->b_range )
\r
206 p_osd->p_state->p_visible->p_current_state =
\r
207 osd_StateChange( p_osd->p_state->p_visible->p_states, OSD_BUTTON_SELECT );
\r
209 osd_UpdateState( p_osd->p_state,
\r
210 p_osd->p_state->p_visible->i_x, p_osd->p_state->p_visible->i_y,
\r
211 p_osd->p_state->p_visible->p_current_state->p_pic->p[Y_PLANE].i_visible_pitch,
\r
212 p_osd->p_state->p_visible->p_current_state->p_pic->p[Y_PLANE].i_visible_lines,
\r
213 p_osd->p_state->p_visible->p_current_state->p_pic );
\r
214 osd_SetMenuUpdate( p_osd, VLC_TRUE );
\r
216 osd_SetMenuVisible( p_osd, VLC_TRUE );
\r
218 vlc_object_release( (vlc_object_t*) p_osd );
\r
219 vlc_mutex_unlock( lockval.p_address );
\r
222 void __osd_MenuHide( vlc_object_t *p_this )
\r
224 osd_menu_t *p_osd = NULL;
\r
225 vlc_value_t lockval;
\r
227 if( ( p_osd = vlc_object_find( p_this, VLC_OBJECT_OSDMENU, FIND_ANYWHERE ) ) == NULL )
\r
229 msg_Err( p_this, "osd_MenuNext failed" );
\r
233 var_Get( p_this->p_libvlc, "osd_mutex", &lockval );
\r
234 vlc_mutex_lock( lockval.p_address );
\r
236 #if defined(OSD_MENU_DEBUG)
\r
237 msg_Dbg( p_osd, "menu off" );
\r
239 osd_UpdateState( p_osd->p_state,
\r
240 p_osd->p_state->i_x, p_osd->p_state->i_y,
\r
241 p_osd->p_state->p_visible->p_current_state->p_pic->p[Y_PLANE].i_visible_pitch,
\r
242 p_osd->p_state->p_visible->p_current_state->p_pic->p[Y_PLANE].i_visible_lines,
\r
244 osd_SetMenuUpdate( p_osd, VLC_TRUE );
\r
246 vlc_object_release( (vlc_object_t*) p_osd );
\r
247 vlc_mutex_unlock( lockval.p_address );
\r
250 void __osd_MenuActivate( vlc_object_t *p_this )
\r
252 osd_menu_t *p_osd = NULL;
\r
253 osd_button_t *p_button = NULL;
\r
254 vlc_value_t lockval;
\r
256 if( ( p_osd = vlc_object_find( p_this, VLC_OBJECT_OSDMENU, FIND_ANYWHERE ) ) == NULL )
\r
258 msg_Err( p_this, "osd_MenuNext failed" );
\r
262 var_Get( p_this->p_libvlc, "osd_mutex", &lockval );
\r
263 vlc_mutex_lock( lockval.p_address );
\r
265 #if defined(OSD_MENU_DEBUG)
\r
266 msg_Dbg( p_osd, "select" );
\r
268 p_button = p_osd->p_state->p_visible;
\r
270 * Is there a menu item above or below? If so, then select it.
\r
272 if( p_button && p_button->p_up)
\r
274 vlc_object_release( (vlc_object_t*) p_osd );
\r
275 vlc_mutex_unlock( lockval.p_address );
\r
276 __osd_MenuUp( p_this ); /* "menu select" means go to menu item above. */
\r
279 if( p_button && p_button->p_down)
\r
281 vlc_object_release( (vlc_object_t*) p_osd );
\r
282 vlc_mutex_unlock( lockval.p_address );
\r
283 __osd_MenuDown( p_this ); /* "menu select" means go to menu item below. */
\r
287 if( p_button && !p_button->b_range )
\r
289 p_button->p_current_state = osd_StateChange( p_button->p_states, OSD_BUTTON_PRESSED );
\r
290 osd_UpdateState( p_osd->p_state,
\r
291 p_button->i_x, p_button->i_y,
\r
292 p_osd->p_state->p_visible->p_current_state->p_pic->p[Y_PLANE].i_visible_pitch,
\r
293 p_osd->p_state->p_visible->p_current_state->p_pic->p[Y_PLANE].i_visible_lines,
\r
294 p_button->p_current_state->p_pic );
\r
295 osd_SetMenuUpdate( p_osd, VLC_TRUE );
\r
296 osd_SetMenuVisible( p_osd, VLC_TRUE );
\r
297 osd_SetKeyPressed( VLC_OBJECT(p_osd->p_vlc), config_GetInt( p_osd, p_button->psz_action ) );
\r
298 #if defined(OSD_MENU_DEBUG)
\r
299 msg_Dbg( p_osd, "select (%d, %s)", config_GetInt( p_osd, p_button->psz_action ), p_button->psz_action );
\r
302 vlc_object_release( (vlc_object_t*) p_osd );
\r
303 vlc_mutex_unlock( lockval.p_address );
\r
306 void __osd_MenuNext( vlc_object_t *p_this )
\r
308 osd_menu_t *p_osd = NULL;
\r
309 osd_button_t *p_button = NULL;
\r
310 vlc_value_t lockval;
\r
312 if( ( p_osd = vlc_object_find( p_this, VLC_OBJECT_OSDMENU, FIND_ANYWHERE ) ) == NULL )
\r
314 msg_Err( p_this, "osd_MenuNext failed" );
\r
318 var_Get( p_this->p_libvlc, "osd_mutex", &lockval );
\r
319 vlc_mutex_lock( lockval.p_address );
\r
321 p_button = p_osd->p_state->p_visible;
\r
324 if( !p_button->b_range )
\r
325 p_button->p_current_state = osd_StateChange( p_button->p_states, OSD_BUTTON_UNSELECT );
\r
326 if( p_button->p_next )
\r
327 p_osd->p_state->p_visible = p_button->p_next;
\r
329 p_osd->p_state->p_visible = p_osd->p_button;
\r
331 if( !p_osd->p_state->p_visible->b_range )
\r
332 p_osd->p_state->p_visible->p_current_state =
\r
333 osd_StateChange( p_osd->p_state->p_visible->p_states, OSD_BUTTON_SELECT );
\r
335 osd_UpdateState( p_osd->p_state,
\r
336 p_osd->p_state->p_visible->i_x, p_osd->p_state->p_visible->i_y,
\r
337 p_osd->p_state->p_visible->p_current_state->p_pic->p[Y_PLANE].i_visible_pitch,
\r
338 p_osd->p_state->p_visible->p_current_state->p_pic->p[Y_PLANE].i_visible_lines,
\r
339 p_osd->p_state->p_visible->p_current_state->p_pic );
\r
340 osd_SetMenuUpdate( p_osd, VLC_TRUE );
\r
342 #if defined(OSD_MENU_DEBUG)
\r
343 msg_Dbg( p_osd, "direction right [button %s]", p_osd->p_state->p_visible->psz_action );
\r
346 vlc_object_release( (vlc_object_t*) p_osd );
\r
347 vlc_mutex_unlock( lockval.p_address );
\r
350 void __osd_MenuPrev( vlc_object_t *p_this )
\r
352 osd_menu_t *p_osd = NULL;
\r
353 osd_button_t *p_button = NULL;
\r
354 vlc_value_t lockval;
\r
356 if( ( p_osd = vlc_object_find( p_this, VLC_OBJECT_OSDMENU, FIND_ANYWHERE ) ) == NULL )
\r
358 msg_Err( p_this, "osd_MenuPrev failed" );
\r
362 var_Get( p_this->p_libvlc, "osd_mutex", &lockval );
\r
363 vlc_mutex_lock( lockval.p_address );
\r
365 p_button = p_osd->p_state->p_visible;
\r
368 if( !p_button->b_range )
\r
369 p_button->p_current_state = osd_StateChange( p_button->p_states, OSD_BUTTON_UNSELECT );
\r
370 if( p_button->p_prev )
\r
371 p_osd->p_state->p_visible = p_button->p_prev;
\r
373 p_osd->p_state->p_visible = p_osd->p_last_button;
\r
375 if( !p_osd->p_state->p_visible->b_range )
\r
376 p_osd->p_state->p_visible->p_current_state =
\r
377 osd_StateChange( p_osd->p_state->p_visible->p_states, OSD_BUTTON_SELECT );
\r
379 osd_UpdateState( p_osd->p_state,
\r
380 p_osd->p_state->p_visible->i_x, p_osd->p_state->p_visible->i_y,
\r
381 p_osd->p_state->p_visible->p_current_state->p_pic->p[Y_PLANE].i_visible_pitch,
\r
382 p_osd->p_state->p_visible->p_current_state->p_pic->p[Y_PLANE].i_visible_lines,
\r
383 p_osd->p_state->p_visible->p_current_state->p_pic );
\r
384 osd_SetMenuUpdate( p_osd, VLC_TRUE );
\r
386 #if defined(OSD_MENU_DEBUG)
\r
387 msg_Dbg( p_osd, "direction left [button %s]", p_osd->p_state->p_visible->psz_action );
\r
390 vlc_object_release( (vlc_object_t*) p_osd );
\r
391 vlc_mutex_unlock( lockval.p_address );
\r
394 void __osd_MenuUp( vlc_object_t *p_this )
\r
396 osd_menu_t *p_osd = NULL;
\r
397 osd_button_t *p_button = NULL;
\r
398 vlc_value_t lockval;
\r
399 #if defined(OSD_MENU_DEBUG)
\r
403 if( ( p_osd = vlc_object_find( p_this, VLC_OBJECT_OSDMENU, FIND_ANYWHERE ) ) == NULL )
\r
405 msg_Err( p_this, "osd_MenuDown failed" );
\r
409 var_Get( p_this->p_libvlc, "osd_mutex", &lockval );
\r
410 vlc_mutex_lock( lockval.p_address );
\r
412 p_button = p_osd->p_state->p_visible;
\r
415 if( !p_button->b_range )
\r
417 p_button->p_current_state = osd_StateChange( p_button->p_states, OSD_BUTTON_SELECT );
\r
418 if( p_button->p_up )
\r
419 p_osd->p_state->p_visible = p_button->p_up;
\r
422 if( p_button->b_range && p_osd->p_state->p_visible->b_range )
\r
424 osd_state_t *p_temp = p_osd->p_state->p_visible->p_current_state;
\r
425 if( p_temp && p_temp->p_next )
\r
426 p_osd->p_state->p_visible->p_current_state = p_temp->p_next;
\r
428 else if( !p_osd->p_state->p_visible->b_range )
\r
430 p_osd->p_state->p_visible->p_current_state =
\r
431 osd_StateChange( p_osd->p_state->p_visible->p_states, OSD_BUTTON_SELECT );
\r
434 osd_UpdateState( p_osd->p_state,
\r
435 p_osd->p_state->p_visible->i_x, p_osd->p_state->p_visible->i_y,
\r
436 p_osd->p_state->p_visible->p_current_state->p_pic->p[Y_PLANE].i_visible_pitch,
\r
437 p_osd->p_state->p_visible->p_current_state->p_pic->p[Y_PLANE].i_visible_lines,
\r
438 p_osd->p_state->p_visible->p_current_state->p_pic );
\r
439 osd_SetMenuUpdate( p_osd, VLC_TRUE );
\r
440 /* If this is a range style action with associated images of only one state,
\r
441 * then perform "menu select" on every menu navigation
\r
443 if( p_button->b_range )
\r
445 osd_SetKeyPressed( VLC_OBJECT(p_osd->p_vlc), config_GetInt(p_osd, p_button->psz_action) );
\r
446 #if defined(OSD_MENU_DEBUG)
\r
447 msg_Dbg( p_osd, "select (%d, %s)", val.i_int, p_button->psz_action );
\r
451 #if defined(OSD_MENU_DEBUG)
\r
452 msg_Dbg( p_osd, "direction up [button %s]", p_osd->p_state->p_visible->psz_action );
\r
455 vlc_object_release( (vlc_object_t*) p_osd );
\r
456 vlc_mutex_unlock( lockval.p_address );
\r
459 void __osd_MenuDown( vlc_object_t *p_this )
\r
461 osd_menu_t *p_osd = NULL;
\r
462 osd_button_t *p_button = NULL;
\r
463 vlc_value_t lockval;
\r
464 #if defined(OSD_MENU_DEBUG)
\r
468 if( ( p_osd = vlc_object_find( p_this, VLC_OBJECT_OSDMENU, FIND_ANYWHERE ) ) == NULL )
\r
470 msg_Err( p_this, "osd_MenuDown failed" );
\r
474 var_Get( p_this->p_libvlc, "osd_mutex", &lockval );
\r
475 vlc_mutex_lock( lockval.p_address );
\r
477 p_button = p_osd->p_state->p_visible;
\r
480 if( !p_button->b_range )
\r
482 p_button->p_current_state = osd_StateChange( p_button->p_states, OSD_BUTTON_SELECT );
\r
483 if( p_button->p_down )
\r
484 p_osd->p_state->p_visible = p_button->p_down;
\r
487 if( p_button->b_range && p_osd->p_state->p_visible->b_range )
\r
489 osd_state_t *p_temp = p_osd->p_state->p_visible->p_current_state;
\r
490 if( p_temp && p_temp->p_prev )
\r
491 p_osd->p_state->p_visible->p_current_state = p_temp->p_prev;
\r
493 else if( !p_osd->p_state->p_visible->b_range )
\r
495 p_osd->p_state->p_visible->p_current_state =
\r
496 osd_StateChange( p_osd->p_state->p_visible->p_states, OSD_BUTTON_SELECT );
\r
499 osd_UpdateState( p_osd->p_state,
\r
500 p_osd->p_state->p_visible->i_x, p_osd->p_state->p_visible->i_y,
\r
501 p_osd->p_state->p_visible->p_current_state->p_pic->p[Y_PLANE].i_visible_pitch,
\r
502 p_osd->p_state->p_visible->p_current_state->p_pic->p[Y_PLANE].i_visible_lines,
\r
503 p_osd->p_state->p_visible->p_current_state->p_pic );
\r
504 osd_SetMenuUpdate( p_osd, VLC_TRUE );
\r
505 /* If this is a range style action with associated images of only one state,
\r
506 * then perform "menu select" on every menu navigation
\r
508 if( p_button->b_range )
\r
510 osd_SetKeyPressed( VLC_OBJECT(p_osd->p_vlc), config_GetInt(p_osd, p_button->psz_action_down) );
\r
511 #if defined(OSD_MENU_DEBUG)
\r
512 msg_Dbg( p_osd, "select (%d, %s)", val.i_int, p_button->psz_action_down );
\r
516 #if defined(OSD_MENU_DEBUG)
\r
517 msg_Dbg( p_osd, "direction down [button %s]", p_osd->p_state->p_visible->psz_action );
\r
520 vlc_object_release( (vlc_object_t*) p_osd );
\r
521 vlc_mutex_unlock( lockval.p_address );
\r
527 * The OSD Menu audio volume bar is updated to reflect the new audio volume. Call this function
\r
528 * when the audio volume is updated outside the OSD menu command "menu up".
\r
530 void __osd_VolumeUp( vlc_object_t *p_this )
\r
532 osd_menu_t *p_osd = NULL;
\r
533 osd_button_t *p_button = NULL;
\r
534 vlc_value_t lockval;
\r
538 if( ( p_osd = vlc_object_find( p_this, VLC_OBJECT_OSDMENU, FIND_ANYWHERE ) ) == NULL )
\r
540 msg_Err( p_this, "osd_VolumeUp failed" );
\r
544 var_Get( p_this->p_libvlc, "osd_mutex", &lockval );
\r
545 vlc_mutex_lock( lockval.p_address );
\r
547 /* Update the volume state images to match the current volume */
\r
548 i_volume = config_GetInt( p_this, "volume" );
\r
549 i_steps = (i_volume / AOUT_VOLUME_STEP / 3); /* 3 is a magic number for 32 volume decrease steps */
\r
550 p_osd->p_state->p_volume->p_current_state = osd_VolumeStateChange( p_osd->p_state->p_volume->p_states, i_steps );
\r
552 p_button = p_osd->p_state->p_volume;
\r
553 if( p_osd->p_state->p_volume )
\r
554 p_osd->p_state->p_visible = p_osd->p_state->p_volume;
\r
555 if( p_button && p_button->b_range )
\r
557 osd_state_t *p_temp = p_button->p_current_state;
\r
558 if( p_temp->p_next )
\r
559 p_button->p_current_state = p_temp->p_next;
\r
561 osd_UpdateState( p_osd->p_state,
\r
562 p_button->i_x, p_button->i_y,
\r
563 p_button->p_current_state->p_pic->p[Y_PLANE].i_visible_pitch,
\r
564 p_button->p_current_state->p_pic->p[Y_PLANE].i_visible_lines,
\r
565 p_button->p_current_state->p_pic );
\r
566 osd_SetMenuUpdate( p_osd, VLC_TRUE );
\r
567 osd_SetMenuVisible( p_osd, VLC_TRUE );
\r
569 vlc_object_release( (vlc_object_t*) p_osd );
\r
570 vlc_mutex_unlock( lockval.p_address );
\r
574 * Audio volume down
\r
576 * The OSD Menu audio volume bar is updated to reflect the new audio volume. Call this function
\r
577 * when the audio volume is updated outside the OSD menu command "menu down".
\r
579 void __osd_VolumeDown( vlc_object_t *p_this )
\r
581 osd_menu_t *p_osd = NULL;
\r
582 osd_button_t *p_button = NULL;
\r
583 vlc_value_t lockval;
\r
587 if( ( p_osd = vlc_object_find( p_this, VLC_OBJECT_OSDMENU, FIND_ANYWHERE ) ) == NULL )
\r
589 msg_Err( p_this, "osd_VolumeDown failed" );
\r
593 var_Get( p_this->p_libvlc, "osd_mutex", &lockval );
\r
594 vlc_mutex_lock( lockval.p_address );
\r
596 /* Update the volume state images to match the current volume */
\r
597 i_volume = config_GetInt( p_this, "volume" );
\r
598 i_steps = (i_volume / AOUT_VOLUME_STEP / 3); /* 3 is a magic number for 32 volume decrease steps */
\r
599 p_osd->p_state->p_volume->p_current_state = osd_VolumeStateChange( p_osd->p_state->p_volume->p_states, i_steps );
\r
601 p_button = p_osd->p_state->p_volume;
\r
602 if( p_osd->p_state->p_volume )
\r
603 p_osd->p_state->p_visible = p_osd->p_state->p_volume;
\r
604 if( p_button && p_button->b_range )
\r
606 osd_state_t *p_temp = p_button->p_current_state;
\r
607 if( p_temp && p_temp->p_prev )
\r
608 p_button->p_current_state = p_temp->p_prev;
\r
610 osd_UpdateState( p_osd->p_state,
\r
611 p_button->i_x, p_button->i_y,
\r
612 p_button->p_current_state->p_pic->p[Y_PLANE].i_visible_pitch,
\r
613 p_button->p_current_state->p_pic->p[Y_PLANE].i_visible_lines,
\r
614 p_button->p_current_state->p_pic );
\r
615 osd_SetMenuUpdate( p_osd, VLC_TRUE );
\r
616 osd_SetMenuVisible( p_osd, VLC_TRUE );
\r
618 vlc_object_release( (vlc_object_t*) p_osd );
\r
619 vlc_mutex_unlock( lockval.p_address );
\r