Commit a2174f04 authored by Jean-Paul Saman's avatar Jean-Paul Saman

Replace vlc_object_find() and vlc_object_release() of VLC_OBJECT_PLAYLIST with...

Replace vlc_object_find() and vlc_object_release() of VLC_OBJECT_PLAYLIST with pl_Yield() and pl_Release()
parent 9bddd7d3
......@@ -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 )
......
......@@ -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 );
}
}
......
......@@ -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();
......
......@@ -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++ )
......@@ -1211,8 +1209,7 @@ void OpenDialog::OnOk( wxCommandEvent& WXUNUSED(event) )
PLAYLIST_END, true, false );
vlc_gc_decref( p_input );
}
vlc_object_release( p_playlist );
pl_Release( p_playlist );
Hide();
......
......@@ -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 );
}
/**********************************************************************
......
......@@ -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,8 +715,7 @@ 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 );
......@@ -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
{
......
......@@ -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 );
}
}
......
......@@ -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;
}
......
......@@ -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;
}
......
......@@ -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 );
}
/*****************************************************************************
......
......@@ -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 );
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment