From 34e462b49342bf7b3dd0dbd06462ee0b61862428 Mon Sep 17 00:00:00 2001 From: Gildas Bazin Date: Mon, 26 May 2003 19:06:47 +0000 Subject: [PATCH] * modules/audio_output/alsa.c: the aout-device obj var wasn't destroyed properly on probe() failure, preventing other audio plugins from working afterwards. * modules/gui/skins/src/skin_main.cpp: got rid of the skins shortcut. * modules/gui/wxwindows/*: the popupmenu is not created inside the timer anymore so the slider will still be active when the popup is triggered. * modules/video_output/directx/events.c, modules/video_output/x11/xcommon.c, src/playlist/playlist.c: new intf-popupmenu obj var to handle popup context menu requests from the vouts. --- modules/audio_output/alsa.c | 12 ++++++- modules/gui/skins/src/skin_main.cpp | 3 +- modules/gui/wxwindows/interface.cpp | 4 ++- modules/gui/wxwindows/menus.cpp | 3 +- modules/gui/wxwindows/timer.cpp | 51 +++++++++++++++++++++++---- modules/gui/wxwindows/wxwindows.h | 3 +- modules/video_output/directx/events.c | 28 ++++++++------- modules/video_output/x11/xcommon.c | 22 +++++++++++- src/playlist/playlist.c | 4 ++- 9 files changed, 103 insertions(+), 27 deletions(-) diff --git a/modules/audio_output/alsa.c b/modules/audio_output/alsa.c index 572e33cc65..bead5dbbbe 100644 --- a/modules/audio_output/alsa.c +++ b/modules/audio_output/alsa.c @@ -2,7 +2,7 @@ * alsa.c : alsa plugin for vlc ***************************************************************************** * Copyright (C) 2000-2001 VideoLAN - * $Id: alsa.c,v 1.27 2003/05/19 23:36:44 gbazin Exp $ + * $Id: alsa.c,v 1.28 2003/05/26 19:06:47 gbazin Exp $ * * Authors: Henri Fallon - Original Author * Jeffrey Baker - Port to ALSA 1.0 API @@ -123,6 +123,7 @@ static void Probe( aout_instance_t * p_aout, msg_Warn( p_aout, "unable to retrieve initial hardware parameters" ", disabling linear PCM audio" ); snd_pcm_close( p_sys->p_snd_pcm ); + var_Destroy( p_aout, "audio-device" ); return; } @@ -135,6 +136,7 @@ static void Probe( aout_instance_t * p_aout, msg_Warn( p_aout, "unable to set stream sample size and word order" ", disabling linear PCM audio" ); snd_pcm_close( p_sys->p_snd_pcm ); + var_Destroy( p_aout, "audio-device" ); return; } @@ -208,6 +210,14 @@ static void Probe( aout_instance_t * p_aout, } } + var_Change( p_aout, "audio-device", VLC_VAR_CHOICESCOUNT, &val, NULL ); + if( val.i_int <= 0 ) + { + /* Probe() has failed. */ + var_Destroy( p_aout, "audio-device" ); + return; + } + /* Add final settings to the variable */ var_AddCallback( p_aout, "audio-device", aout_ChannelsRestart, NULL ); val.b_bool = VLC_TRUE; diff --git a/modules/gui/skins/src/skin_main.cpp b/modules/gui/skins/src/skin_main.cpp index 1423bc795a..71f4c60129 100644 --- a/modules/gui/skins/src/skin_main.cpp +++ b/modules/gui/skins/src/skin_main.cpp @@ -2,7 +2,7 @@ * skin-main.cpp: skins plugin for VLC ***************************************************************************** * Copyright (C) 2003 VideoLAN - * $Id: skin_main.cpp,v 1.27 2003/05/26 02:09:27 gbazin Exp $ + * $Id: skin_main.cpp,v 1.28 2003/05/26 19:06:47 gbazin Exp $ * * Authors: Olivier Teulière * Emmanuel Puig @@ -298,7 +298,6 @@ vlc_module_begin(); set_description( _("Skinnable Interface") ); set_capability( "interface", 30 ); set_callbacks( Open, Close ); - add_shortcut( "skins" ); vlc_module_end(); diff --git a/modules/gui/wxwindows/interface.cpp b/modules/gui/wxwindows/interface.cpp index 83fa426fd4..cad7e9365c 100644 --- a/modules/gui/wxwindows/interface.cpp +++ b/modules/gui/wxwindows/interface.cpp @@ -2,7 +2,7 @@ * interface.cpp : wxWindows plugin for vlc ***************************************************************************** * Copyright (C) 2000-2001 VideoLAN - * $Id: interface.cpp,v 1.34 2003/05/26 16:06:13 gbazin Exp $ + * $Id: interface.cpp,v 1.35 2003/05/26 19:06:47 gbazin Exp $ * * Authors: Gildas Bazin * @@ -172,6 +172,8 @@ Interface::Interface( intf_thread_t *_p_intf ): p_prefs_dialog = NULL; i_old_playing_status = PAUSE_S; p_open_dialog = NULL; + p_popup_menu = NULL; + b_popup_change = VLC_FALSE; /* Give our interface a nice little icon */ p_intf->p_sys->p_icon = new wxIcon( vlc_xpm ); diff --git a/modules/gui/wxwindows/menus.cpp b/modules/gui/wxwindows/menus.cpp index c5501d42b1..d2865a2a85 100644 --- a/modules/gui/wxwindows/menus.cpp +++ b/modules/gui/wxwindows/menus.cpp @@ -2,7 +2,7 @@ * menus.cpp : wxWindows plugin for vlc ***************************************************************************** * Copyright (C) 2000-2001 VideoLAN - * $Id: menus.cpp,v 1.13 2003/05/24 20:54:27 gbazin Exp $ + * $Id: menus.cpp,v 1.14 2003/05/26 19:06:47 gbazin Exp $ * * Authors: Gildas Bazin * @@ -174,6 +174,7 @@ void PopupMenu( intf_thread_t *_p_intf, Interface *_p_main_interface, _p_main_interface->p_popup_menu = &popupmenu; _p_main_interface->PopupMenu( &popupmenu, pos.x, pos.y ); + _p_main_interface->p_popup_menu = NULL; } wxMenu *AudioMenu( intf_thread_t *_p_intf, Interface *_p_main_interface ) diff --git a/modules/gui/wxwindows/timer.cpp b/modules/gui/wxwindows/timer.cpp index 7e8e559135..4b75af8d41 100644 --- a/modules/gui/wxwindows/timer.cpp +++ b/modules/gui/wxwindows/timer.cpp @@ -2,7 +2,7 @@ * timer.cpp : wxWindows plugin for vlc ***************************************************************************** * Copyright (C) 2000-2001 VideoLAN - * $Id: timer.cpp,v 1.18 2003/05/18 19:46:35 gbazin Exp $ + * $Id: timer.cpp,v 1.19 2003/05/26 19:06:47 gbazin Exp $ * * Authors: Gildas Bazin * @@ -49,6 +49,10 @@ void DisplayStreamDate( wxControl *, intf_thread_t *, int ); +/* Callback prototype */ +int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable, + vlc_value_t old_val, vlc_value_t new_val, void *param ); + /***************************************************************************** * Constructor. *****************************************************************************/ @@ -59,6 +63,17 @@ Timer::Timer( intf_thread_t *_p_intf, Interface *_p_main_interface ) i_old_playing_status = PAUSE_S; i_old_rate = DEFAULT_RATE; + /* Register callback for the intf-popupmenu variable */ + playlist_t *p_playlist = + (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, + FIND_ANYWHERE ); + if( p_playlist != NULL ) + { + var_AddCallback( p_playlist, "intf-popupmenu", PopupMenuCB, + p_main_interface ); + vlc_object_release( p_playlist ); + } + Start( 100 /*milliseconds*/, wxTIMER_CONTINUOUS ); } @@ -104,12 +119,21 @@ void Timer::Notify() vlc_mutex_lock( &p_intf->change_lock ); /* If the "display popup" flag has changed */ - if( p_intf->b_menu_change ) + if( p_main_interface->b_popup_change ) { wxPoint mousepos = wxGetMousePosition(); - PopupMenu( p_intf, p_main_interface, - p_main_interface->ScreenToClient(mousepos) ); - p_intf->b_menu_change = 0; + +#if defined( __WXMSW__ ) || defined( __WXMAC__ ) + wxContextMenuEvent event = + wxContextMenuEvent( wxEVT_NULL, 0, mousepos ); +#else + wxMouseEvent event = wxMouseEvent( wxEVT_RIGHT_UP ); + event.m_x = p_main_interface->ScreenToClient(mousepos).x; + event.m_y = p_main_interface->ScreenToClient(mousepos).y; +#endif + p_main_interface->AddPendingEvent(event); + + p_main_interface->b_popup_change = VLC_FALSE; } /* Update the log window */ @@ -120,7 +144,7 @@ void Timer::Notify() /* Update the fileinfo windows */ p_intf->p_sys->p_fileinfo_window->UpdateFileInfo(); - + /* Update the input */ if( p_intf->p_sys->p_input == NULL ) { @@ -296,3 +320,18 @@ void DisplayStreamDate( wxControl *p_slider_frame, intf_thread_t * p_intf , #undef p_area } } + +/***************************************************************************** + * PlaylistChanged: callback triggered by the intf-change playlist variable + * We don't rebuild the playlist directly here because we don't want the + * caller to block for a too long time. + *****************************************************************************/ +int PopupMenuCB( vlc_object_t *p_this, const char *psz_variable, + vlc_value_t old_val, vlc_value_t new_val, void *param ) +{ + Interface *p_main_interface = (Interface *)param; + + p_main_interface->b_popup_change = VLC_TRUE; + + return VLC_SUCCESS; +} diff --git a/modules/gui/wxwindows/wxwindows.h b/modules/gui/wxwindows/wxwindows.h index 9d9e92d750..7881b592e7 100644 --- a/modules/gui/wxwindows/wxwindows.h +++ b/modules/gui/wxwindows/wxwindows.h @@ -2,7 +2,7 @@ * wxwindows.h: private wxWindows interface description ***************************************************************************** * Copyright (C) 1999, 2000 VideoLAN - * $Id: wxwindows.h,v 1.31 2003/05/24 17:52:49 gbazin Exp $ + * $Id: wxwindows.h,v 1.32 2003/05/26 19:06:47 gbazin Exp $ * * Authors: Gildas Bazin * @@ -140,6 +140,7 @@ public: OpenDialog *p_open_dialog; wxMenu *p_popup_menu; + vlc_bool_t b_popup_change; private: void CreateOurMenuBar(); diff --git a/modules/video_output/directx/events.c b/modules/video_output/directx/events.c index 38cf06d898..8e02693e39 100644 --- a/modules/video_output/directx/events.c +++ b/modules/video_output/directx/events.c @@ -2,7 +2,7 @@ * events.c: Windows DirectX video output events handler ***************************************************************************** * Copyright (C) 2001 VideoLAN - * $Id: events.c,v 1.15 2003/05/17 14:36:19 gbazin Exp $ + * $Id: events.c,v 1.16 2003/05/26 19:06:47 gbazin Exp $ * * Authors: Gildas Bazin * @@ -170,13 +170,14 @@ void DirectXEventThread( event_thread_t *p_event ) val.i_int &= ~4; var_Set( p_event->p_vout, "mouse-button-down", val ); { - intf_thread_t *p_intf; - p_intf = vlc_object_find( p_event, VLC_OBJECT_INTF, - FIND_ANYWHERE ); - if( p_intf ) + playlist_t *p_playlist = + vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, + FIND_ANYWHERE ); + if( p_playlist != NULL ) { - p_intf->b_menu_change = 1; - vlc_object_release( p_intf ); + vlc_value_t val; + var_Set( p_playlist, "intf-popupmenu", val ); + vlc_object_release( p_playlist ); } } break; @@ -202,13 +203,14 @@ void DirectXEventThread( event_thread_t *p_event ) case VK_MENU: { - intf_thread_t *p_intf; - p_intf = vlc_object_find( p_event->p_vout, VLC_OBJECT_INTF, - FIND_ANYWHERE ); - if( p_intf ) + playlist_t *p_playlist = + vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, + FIND_ANYWHERE ); + if( p_playlist != NULL ) { - p_intf->b_menu_change = 1; - vlc_object_release( p_intf ); + vlc_value_t val; + var_Set( p_playlist, "intf-popupmenu", val ); + vlc_object_release( p_playlist ); } } break; diff --git a/modules/video_output/x11/xcommon.c b/modules/video_output/x11/xcommon.c index f5f74f0ac3..e1c8947773 100644 --- a/modules/video_output/x11/xcommon.c +++ b/modules/video_output/x11/xcommon.c @@ -2,7 +2,7 @@ * xcommon.c: Functions common to the X11 and XVideo plugins ***************************************************************************** * Copyright (C) 1998-2001 VideoLAN - * $Id: xcommon.c,v 1.18 2003/05/25 20:16:26 gbazin Exp $ + * $Id: xcommon.c,v 1.19 2003/05/26 19:06:47 gbazin Exp $ * * Authors: Vincent Seguin * Samuel Hocevar @@ -539,6 +539,16 @@ static int ManageVideo( vout_thread_t *p_vout ) p_intf->b_menu_change = 1; vlc_object_release( p_intf ); } + + playlist_t *p_playlist = + vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, + FIND_ANYWHERE ); + if( p_playlist != NULL ) + { + vlc_value_t val; + var_Set( p_playlist, "intf-popupmenu", val ); + vlc_object_release( p_playlist ); + } } break; case XK_Left: @@ -676,6 +686,16 @@ static int ManageVideo( vout_thread_t *p_vout ) p_intf->b_menu_change = 1; vlc_object_release( p_intf ); } + + playlist_t *p_playlist = + vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, + FIND_ANYWHERE ); + if( p_playlist != NULL ) + { + vlc_value_t val; + var_Set( p_playlist, "intf-popupmenu", val ); + vlc_object_release( p_playlist ); + } } break; diff --git a/src/playlist/playlist.c b/src/playlist/playlist.c index 207bd15df0..384a91f67e 100644 --- a/src/playlist/playlist.c +++ b/src/playlist/playlist.c @@ -2,7 +2,7 @@ * playlist.c : Playlist management functions ***************************************************************************** * Copyright (C) 1999-2001 VideoLAN - * $Id: playlist.c,v 1.35 2003/05/12 17:33:20 gbazin Exp $ + * $Id: playlist.c,v 1.36 2003/05/26 19:06:47 gbazin Exp $ * * Authors: Samuel Hocevar * @@ -64,6 +64,8 @@ playlist_t * __playlist_Create ( vlc_object_t *p_parent ) val.b_bool = VLC_TRUE; var_Set( p_playlist, "intf-change", val ); + var_Create( p_playlist, "intf-popupmenu", VLC_VAR_VOID ); + p_playlist->p_input = NULL; p_playlist->i_status = PLAYLIST_STOPPED; p_playlist->i_index = -1; -- 2.39.2