From: Jean-Paul Saman Date: Sun, 15 Jun 2008 16:46:33 +0000 (+0200) Subject: Replace vlc_object_find() and vlc_object_release() of VLC_OBJECT_PLAYLIST with pl_Yie... X-Git-Tag: 0.9.0-test1~247 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=a2174f04844383afce9277afc1fda717f24f714e;p=vlc Replace vlc_object_find() and vlc_object_release() of VLC_OBJECT_PLAYLIST with pl_Yield() and pl_Release() --- diff --git a/modules/gui/wxwidgets/dialogs.cpp b/modules/gui/wxwidgets/dialogs.cpp index 5bd482a41a..2204abf445 100644 --- a/modules/gui/wxwidgets/dialogs.cpp +++ b/modules/gui/wxwidgets/dialogs.cpp @@ -435,9 +435,7 @@ void DialogsProvider::OnOpenFileGeneric( wxCommandEvent& event ) void DialogsProvider::OnOpenFileSimple( wxCommandEvent& event ) { - playlist_t *p_playlist = - (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, - FIND_ANYWHERE ); + playlist_t *p_playlist = pl_Yield( p_intf ); if( p_playlist == NULL ) { return; @@ -473,15 +471,12 @@ void DialogsProvider::OnOpenFileSimple( wxCommandEvent& event ) wxLocaleFree( psz_utf8 ); } } - - vlc_object_release( p_playlist ); + pl_Release( p_playlist ); } void DialogsProvider::OnOpenDirectory( wxCommandEvent& event ) { - playlist_t *p_playlist = - (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, - FIND_ANYWHERE ); + playlist_t *p_playlist = pl_Yield( p_intf ); if( p_playlist == NULL ) { return; @@ -499,8 +494,7 @@ void DialogsProvider::OnOpenDirectory( wxCommandEvent& event ) PLAYLIST_END, true, false ); wxLocaleFree( psz_utf8 ); } - - vlc_object_release( p_playlist ); + pl_Release( p_playlist ); } void DialogsProvider::OnOpenFile( wxCommandEvent& event ) diff --git a/modules/gui/wxwidgets/dialogs/bookmarks.cpp b/modules/gui/wxwidgets/dialogs/bookmarks.cpp index e2f138c4e8..13dfa1d45d 100644 --- a/modules/gui/wxwidgets/dialogs/bookmarks.cpp +++ b/modules/gui/wxwidgets/dialogs/bookmarks.cpp @@ -204,28 +204,24 @@ BookmarksDialog::BookmarksDialog( intf_thread_t *_p_intf, wxWindow *p_parent ) main_sizer->Add( main_panel, 1, wxEXPAND ); SetSizer( main_sizer ); - playlist_t *p_playlist = - (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, - FIND_ANYWHERE ); + playlist_t *p_playlist = pl_Yield( p_intf ); if( p_playlist ) { /* Some global changes happened -> Rebuild all */ var_AddCallback( p_playlist, "playlist-current", PlaylistChanged, this ); - vlc_object_release( p_playlist ); + pl_Release( p_playlist ); } } BookmarksDialog::~BookmarksDialog() { - playlist_t *p_playlist = - (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, - FIND_ANYWHERE ); + playlist_t *p_playlist = pl_Yield( p_intf ); if( p_playlist ) { var_DelCallback( p_playlist, "playlist-current", PlaylistChanged, this ); - vlc_object_release( p_playlist ); + pl_Release( p_playlist ); } } diff --git a/modules/gui/wxwidgets/dialogs/fileinfo.cpp b/modules/gui/wxwidgets/dialogs/fileinfo.cpp index 76f697eba6..df06c633c3 100644 --- a/modules/gui/wxwidgets/dialogs/fileinfo.cpp +++ b/modules/gui/wxwidgets/dialogs/fileinfo.cpp @@ -55,9 +55,8 @@ FileInfo::FileInfo( intf_thread_t *_p_intf, wxWindow *p_parent ): wxDefaultSize, wxDEFAULT_FRAME_STYLE ) { p_intf = _p_intf; - playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf, - VLC_OBJECT_PLAYLIST, - FIND_ANYWHERE ); + playlist_t *p_playlist = pl_Yield( p_intf ); + b_stats = config_GetInt(p_intf, "stats"); /* Initializations */ SetIcon( *p_intf->p_sys->p_icon ); @@ -102,7 +101,7 @@ FileInfo::FileInfo( intf_thread_t *_p_intf, wxWindow *p_parent ): if( p_playlist ) { var_AddCallback( p_playlist, "item-change", ItemChanged, this ); - vlc_object_release( p_playlist ); + pl_Release( p_playlist ); } last_update = 0L; @@ -115,22 +114,20 @@ void FileInfo::Update() if( mdate() - last_update < 400000L ) return; last_update = mdate(); - playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf, - VLC_OBJECT_PLAYLIST, - FIND_ANYWHERE ); + playlist_t *p_playlist = pl_Yield( p_intf ); if( !p_playlist ) return; input_thread_t *p_input = p_playlist->p_input ; - if( !p_input || p_input->b_dead || !input_GetItem(p_input)->psz_name ) { item_info->Clear(); advanced_info->Clear(); if( b_stats ) stats_info->Clear(); - vlc_object_release( p_playlist ); + pl_Release( p_playlist ); return; } + pl_Release( p_playlist ); vlc_object_yield( p_input ); vlc_mutex_lock( &input_GetItem(p_input)->lock ); @@ -146,7 +143,7 @@ void FileInfo::Update() vlc_mutex_unlock( &input_GetItem(p_input)->lock ); vlc_object_release(p_input); - vlc_object_release( p_playlist ); + pl_Release( p_playlist ); b_need_update = false; panel_sizer->Layout(); diff --git a/modules/gui/wxwidgets/dialogs/open.cpp b/modules/gui/wxwidgets/dialogs/open.cpp index 715bcc72c7..562f81f62b 100644 --- a/modules/gui/wxwidgets/dialogs/open.cpp +++ b/modules/gui/wxwidgets/dialogs/open.cpp @@ -1158,9 +1158,7 @@ void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) ) } /* Update the playlist */ - playlist_t *p_playlist = - (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, - FIND_ANYWHERE ); + playlist_t *p_playlist = pl_Yield( p_intf ); if( p_playlist == NULL ) return; for( int i = 0; i < (int)mrl.GetCount(); i++ ) @@ -1209,10 +1207,9 @@ void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) ) playlist_AddInput( p_playlist, p_input, PLAYLIST_APPEND | ( b_start ? PLAYLIST_GO : PLAYLIST_PREPARSE ), PLAYLIST_END, true, false ); - vlc_gc_decref( p_input ); + vlc_gc_decref( p_input ); } - - vlc_object_release( p_playlist ); + pl_Release( p_playlist ); Hide(); diff --git a/modules/gui/wxwidgets/dialogs/playlist.cpp b/modules/gui/wxwidgets/dialogs/playlist.cpp index 17d0022d10..4faf317afd 100644 --- a/modules/gui/wxwidgets/dialogs/playlist.cpp +++ b/modules/gui/wxwidgets/dialogs/playlist.cpp @@ -217,8 +217,7 @@ Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ): i_sort_mode = MODE_NONE; b_need_update = false; i_items_to_append = 0; - p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, - FIND_ANYWHERE ); + p_playlist = pl_Yield( p_intf ); if( p_playlist == NULL ) return; SetIcon( *p_intf->p_sys->p_icon ); @@ -425,7 +424,7 @@ Playlist::~Playlist() var_DelCallback( p_playlist, "intf-change", PlaylistChanged, this ); var_DelCallback( p_playlist, "item-append", ItemAppended, this ); var_DelCallback( p_playlist, "item-deleted", ItemDeleted, this ); - vlc_object_release( p_playlist ); + pl_Release( p_playlist ); } /********************************************************************** diff --git a/modules/gui/wxwidgets/dialogs/wizard.cpp b/modules/gui/wxwidgets/dialogs/wizard.cpp index 792a24e7c2..95921b7cb3 100644 --- a/modules/gui/wxwidgets/dialogs/wizard.cpp +++ b/modules/gui/wxwidgets/dialogs/wizard.cpp @@ -577,9 +577,7 @@ wizInputPage::wizInputPage( wxWizard *parent, wxWizardPage *prev, intf_thread_t openSizer->Fit(open_panel); mainSizer->Add( open_panel ); - playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf, - VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); - + playlist_t *p_playlist = pl_Yield( p_intf ); if( p_playlist ) { if( !playlist_IsEmpty( p_playlist ) ) @@ -601,7 +599,7 @@ wizInputPage::wizInputPage( wxWizard *parent, wxWizardPage *prev, intf_thread_t { input_radios[1]->Disable(); } - vlc_object_release( p_playlist ); + pl_Release( p_playlist ); } else { @@ -717,11 +715,10 @@ void wizInputPage::OnWizardPageChanging(wxWizardEvent& event) if( i != -1 ) { long data = listview->GetItemData( i ); - playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf, - VLC_OBJECT_PLAYLIST, FIND_ANYWHERE); + playlist_t *p_playlist = pl_Yield( p_intf ); if( p_playlist ) { - playlist_item_t * p_item = playlist_ItemGetById( p_playlist, (int)data, false ); + playlist_item_t * p_item = playlist_ItemGetById( p_playlist, (int)data, false ); if( p_item ) { const char *psz_uri = input_item_GetURI( p_item->p_input ); @@ -730,6 +727,7 @@ void wizInputPage::OnWizardPageChanging(wxWizardEvent& event) } else event.Veto(); + pl_Release( p_playlist ); } else event.Veto(); @@ -1608,8 +1606,7 @@ void WizardDialog::Run() free( psz_sap_option ); } - playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf, - VLC_OBJECT_PLAYLIST, FIND_ANYWHERE); + playlist_t *p_playlist = pl_Yield( p_intf ); if( p_playlist ) { input_item_t *p_input = input_ItemNew( p_playlist, mrl, @@ -1636,7 +1633,7 @@ void WizardDialog::Run() playlist_AddInput( p_playlist, p_input, PLAYLIST_GO, PLAYLIST_END, true, false ); vlc_gc_decref( p_input ); - vlc_object_release(p_playlist); + pl_Release( p_playlist ); } else { diff --git a/modules/gui/wxwidgets/input_manager.cpp b/modules/gui/wxwidgets/input_manager.cpp index ed79ec9d9c..9419e2ef07 100644 --- a/modules/gui/wxwidgets/input_manager.cpp +++ b/modules/gui/wxwidgets/input_manager.cpp @@ -194,9 +194,7 @@ bool InputManager::IsPlaying() *****************************************************************************/ void InputManager::UpdateInput() { - playlist_t *p_playlist = - (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, - FIND_ANYWHERE ); + playlist_t *p_playlist = pl_Yield( p_intf ); if( p_playlist != NULL ) { LockPlaylist( p_intf->p_sys, p_playlist ); @@ -204,7 +202,7 @@ void InputManager::UpdateInput() if( p_intf->p_sys->p_input ) vlc_object_yield( p_intf->p_sys->p_input ); UnlockPlaylist( p_intf->p_sys, p_playlist ); - vlc_object_release( p_playlist ); + pl_Release( p_playlist ); } } diff --git a/modules/gui/wxwidgets/interface.cpp b/modules/gui/wxwidgets/interface.cpp index 256cf2a8bf..60b1973bfe 100644 --- a/modules/gui/wxwidgets/interface.cpp +++ b/modules/gui/wxwidgets/interface.cpp @@ -1075,9 +1075,7 @@ void Interface::OnPlayStream( wxCommandEvent& WXUNUSED(event) ) void Interface::PlayStream() { wxCommandEvent dummy; - playlist_t *p_playlist = - (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, - FIND_ANYWHERE ); + playlist_t *p_playlist = pl_Yield( p_intf ); if( p_playlist == NULL ) return; if( !playlist_IsEmpty(p_playlist) ) @@ -1091,7 +1089,7 @@ void Interface::PlayStream() { /* No stream was playing, start one */ playlist_Play( p_playlist ); - vlc_object_release( p_playlist ); + pl_Release( p_playlist ); input_manager->Update(); return; } @@ -1110,13 +1108,13 @@ void Interface::PlayStream() var_Set( p_input, "state", state ); vlc_object_release( p_input ); - vlc_object_release( p_playlist ); + pl_Release( p_playlist ); input_manager->Update(); } else { /* If the playlist is empty, open a file requester instead */ - vlc_object_release( p_playlist ); + pl_Release( p_playlist ); OnShowDialog( dummy ); GetToolBar()->ToggleTool( PlayStream_Event, false ); } @@ -1128,16 +1126,14 @@ void Interface::OnStopStream( wxCommandEvent& WXUNUSED(event) ) } void Interface::StopStream() { - playlist_t * p_playlist = - (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, - FIND_ANYWHERE ); + playlist_t * p_playlist = pl_Yield( p_intf ); if( p_playlist == NULL ) { return; } playlist_Stop( p_playlist ); - vlc_object_release( p_playlist ); + pl_Release( p_playlist ); input_manager->Update(); } @@ -1148,16 +1144,14 @@ void Interface::OnPrevStream( wxCommandEvent& WXUNUSED(event) ) void Interface::PrevStream() { - playlist_t * p_playlist = - (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, - FIND_ANYWHERE ); + playlist_t * p_playlist = pl_Yield( p_intf ); if( p_playlist == NULL ) { return; } playlist_Prev( p_playlist ); - vlc_object_release( p_playlist ); + pl_Release( p_playlist ); } void Interface::OnNextStream( wxCommandEvent& WXUNUSED(event) ) @@ -1167,15 +1161,13 @@ void Interface::OnNextStream( wxCommandEvent& WXUNUSED(event) ) void Interface::NextStream() { - playlist_t * p_playlist = - (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, - FIND_ANYWHERE ); + playlist_t * p_playlist = pl_Yield( p_intf ); if( p_playlist == NULL ) { return; } playlist_Next( p_playlist ); - vlc_object_release( p_playlist ); + pl_Release( p_playlist ); } void Interface::OnSlowStream( wxCommandEvent& WXUNUSED(event) ) @@ -1323,10 +1315,7 @@ bool DragAndDrop::OnDropFiles( wxCoord, wxCoord, const wxArrayString& filenames ) { /* Add dropped files to the playlist */ - - playlist_t *p_playlist = - (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, - FIND_ANYWHERE ); + playlist_t *p_playlist = pl_Yield( p_intf ); if( p_playlist == NULL ) { return FALSE; @@ -1344,7 +1333,7 @@ bool DragAndDrop::OnDropFiles( wxCoord, wxCoord, { vlc_object_release( p_input ); wxDnDLocaleFree( psz_utf8 ); - vlc_object_release( p_playlist ); + pl_Release( p_playlist ); return TRUE; } vlc_object_release( p_input ); @@ -1362,8 +1351,7 @@ bool DragAndDrop::OnDropFiles( wxCoord, wxCoord, wxDnDLocaleFree( psz_utf8 ); } - - vlc_object_release( p_playlist ); + pl_Release( p_playlist ); return TRUE; } diff --git a/modules/gui/wxwidgets/menus.cpp b/modules/gui/wxwidgets/menus.cpp index 7d681b7700..9d02544e3c 100644 --- a/modules/gui/wxwidgets/menus.cpp +++ b/modules/gui/wxwidgets/menus.cpp @@ -229,8 +229,7 @@ int IntfAutoMenuBuilder( intf_thread_t *p_intf, ArrayOfInts &ri_objects, unsigned int i_last_separator = 0; \ ArrayOfInts ai_objects; \ ArrayOfStrings as_varnames; \ - playlist_t *p_playlist = (playlist_t *) vlc_object_find( p_intf, \ - VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );\ + playlist_t *p_playlist = pl_Yield( p_intf ); \ if( !p_playlist ) \ return; \ input_thread_t *p_input = p_playlist->p_input @@ -270,7 +269,7 @@ int IntfAutoMenuBuilder( intf_thread_t *p_intf, ArrayOfInts &ri_objects, popupmenu.InsertSeparator( 0 ); \ popupmenu.Insert( 0, Play_Event, wxU(_("Play")) ); \ } \ - if( p_playlist ) vlc_object_release( p_playlist ); \ + if( p_playlist ) pl_Release( p_playlist ); \ } \ \ popupmenu.Append( MenuDummy_Event, wxU(_("Miscellaneous")), \ @@ -297,7 +296,7 @@ void VideoPopupMenu( intf_thread_t *p_intf, wxWindow *p_parent, } vlc_object_release( p_input ); } - vlc_object_release( p_playlist ); + pl_Release( p_playlist ); CREATE_POPUP; } @@ -319,7 +318,7 @@ void AudioPopupMenu( intf_thread_t *p_intf, wxWindow *p_parent, } vlc_object_release( p_input ); } - vlc_object_release( p_playlist ); + pl_Release( p_playlist ); CREATE_POPUP; } @@ -348,7 +347,7 @@ void MiscPopupMenu( intf_thread_t *p_intf, wxWindow *p_parent, p_intf->p_sys->p_popup_menu = &popupmenu; p_parent->PopupMenu( &popupmenu, pos.x, pos.y ); p_intf->p_sys->p_popup_menu = NULL; - vlc_object_release( p_playlist ); + pl_Release( p_playlist ); } void PopupMenu( intf_thread_t *p_intf, wxWindow *p_parent, @@ -404,7 +403,7 @@ void PopupMenu( intf_thread_t *p_intf, wxWindow *p_parent, p_intf->p_sys->p_popup_menu = &popupmenu; p_parent->PopupMenu( &popupmenu, pos.x, pos.y ); p_intf->p_sys->p_popup_menu = NULL; - vlc_object_release( p_playlist ); + pl_Release( p_playlist ); } /***************************************************************************** @@ -937,9 +936,7 @@ void MenuEvtHandler::OnMenuEvent( wxCommandEvent& event ) if( event.GetId() >= Play_Event && event.GetId() <= Stop_Event ) { input_thread_t *p_input; - playlist_t * p_playlist = - (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, - FIND_ANYWHERE ); + playlist_t * p_playlist = pl_Yield( p_intf ); if( !p_playlist ) return; switch( event.GetId() ) @@ -970,8 +967,7 @@ void MenuEvtHandler::OnMenuEvent( wxCommandEvent& event ) playlist_Next( p_playlist ); break; } - - vlc_object_release( p_playlist ); + pl_Release( p_playlist ); return; } diff --git a/modules/gui/wxwidgets/playlist_manager.cpp b/modules/gui/wxwidgets/playlist_manager.cpp index d8d77e982a..d853bf9b7e 100644 --- a/modules/gui/wxwidgets/playlist_manager.cpp +++ b/modules/gui/wxwidgets/playlist_manager.cpp @@ -111,8 +111,7 @@ PlaylistManager::PlaylistManager( intf_thread_t *_p_intf, wxWindow *p_parent ): i_cached_item_id = -1; i_update_counter = 0; - p_playlist = (playlist_t *) - vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); + p_playlist = pl_Yield( p_intf ); if( p_playlist == NULL ) return; var_Create( p_intf, "random", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); @@ -188,7 +187,7 @@ PlaylistManager::~PlaylistManager() var_DelCallback( p_playlist, "intf-change", PlaylistChanged, this ); var_DelCallback( p_playlist, "item-append", ItemAppended, this ); var_DelCallback( p_playlist, "item-deleted", ItemDeleted, this ); - vlc_object_release( p_playlist ); + pl_Release( p_playlist ); } /***************************************************************************** diff --git a/modules/gui/wxwidgets/timer.cpp b/modules/gui/wxwidgets/timer.cpp index 897476536f..b9f4e0e0ad 100644 --- a/modules/gui/wxwidgets/timer.cpp +++ b/modules/gui/wxwidgets/timer.cpp @@ -49,13 +49,11 @@ Timer::Timer( intf_thread_t *_p_intf, Interface *_p_main_interface ) var_AddCallback( p_intf->p_libvlc, "intf-show", IntfShowCB, p_intf ); /* Register callback for the intf-popupmenu variable */ - playlist_t *p_playlist = - (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, - FIND_ANYWHERE ); + playlist_t *p_playlist = pl_Yield( p_intf ); if( p_playlist != NULL ) { var_AddCallback( p_playlist, "intf-popupmenu", PopupMenuCB, p_intf ); - vlc_object_release( p_playlist ); + pl_Release( p_playlist ); } Start( 100 /*milliseconds*/, wxTIMER_CONTINUOUS ); @@ -66,13 +64,11 @@ Timer::~Timer() var_DelCallback( p_intf->p_libvlc, "intf-show", IntfShowCB, p_intf ); /* Unregister callback */ - playlist_t *p_playlist = - (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, - FIND_ANYWHERE ); + playlist_t *p_playlist = pl_Yield( p_intf ); if( p_playlist != NULL ) { var_DelCallback( p_playlist, "intf-popupmenu", PopupMenuCB, p_intf ); - vlc_object_release( p_playlist ); + pl_Release( p_playlist ); } }