Browse Source

skins2: remove playlist pointer copy and simplify

pull/51/head
Rémi Denis-Courmont 10 years ago
parent
commit
6acc10eb1c
  1. 4
      modules/gui/skins2/commands/cmd_add_item.cpp
  2. 4
      modules/gui/skins2/commands/cmd_audio.cpp
  3. 15
      modules/gui/skins2/commands/cmd_dvd.cpp
  4. 38
      modules/gui/skins2/commands/cmd_input.cpp
  5. 54
      modules/gui/skins2/commands/cmd_playlist.cpp
  6. 2
      modules/gui/skins2/commands/cmd_playtree.cpp
  7. 2
      modules/gui/skins2/commands/cmd_vars.cpp
  8. 4
      modules/gui/skins2/src/skin_common.hpp
  9. 3
      modules/gui/skins2/src/skin_main.cpp
  10. 59
      modules/gui/skins2/src/vlcproc.cpp
  11. 6
      modules/gui/skins2/vars/equalizer.cpp
  12. 2
      modules/gui/skins2/vars/playtree.cpp
  13. 6
      modules/gui/skins2/vars/volume.cpp

4
modules/gui/skins2/commands/cmd_add_item.cpp

@ -33,9 +33,7 @@
void CmdAddItem::execute()
{
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
if( !pPlaylist )
return;
playlist_t *pPlaylist = getPL();
if( strstr( m_name.c_str(), "://" ) == NULL )
{

4
modules/gui/skins2/commands/cmd_audio.cpp

@ -29,9 +29,7 @@
void CmdSetEqualizer::execute()
{
playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
playlist_EnableAudioFilter( pPlaylist, "equalizer", m_enable );
playlist_EnableAudioFilter( getPL(), "equalizer", m_enable );
}

15
modules/gui/skins2/commands/cmd_dvd.cpp

@ -27,8 +27,7 @@
void CmdDvdNextTitle::execute()
{
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
input_thread_t *p_input = playlist_CurrentInput( pPlaylist );
input_thread_t *p_input = playlist_CurrentInput( getPL() );
if( p_input )
{
@ -40,8 +39,7 @@ void CmdDvdNextTitle::execute()
void CmdDvdPreviousTitle::execute()
{
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
input_thread_t *p_input = playlist_CurrentInput( pPlaylist );
input_thread_t *p_input = playlist_CurrentInput( getPL() );
if( p_input )
{
@ -53,8 +51,7 @@ void CmdDvdPreviousTitle::execute()
void CmdDvdNextChapter::execute()
{
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
input_thread_t *p_input = playlist_CurrentInput( pPlaylist );
input_thread_t *p_input = playlist_CurrentInput( getPL() );
if( p_input )
{
@ -66,8 +63,7 @@ void CmdDvdNextChapter::execute()
void CmdDvdPreviousChapter::execute()
{
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
input_thread_t *p_input = playlist_CurrentInput( pPlaylist );
input_thread_t *p_input = playlist_CurrentInput( getPL() );
if( p_input )
{
@ -79,8 +75,7 @@ void CmdDvdPreviousChapter::execute()
void CmdDvdRootMenu::execute()
{
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
input_thread_t *p_input = playlist_CurrentInput( pPlaylist );
input_thread_t *p_input = playlist_CurrentInput( getPL() );
if( p_input )
{

38
modules/gui/skins2/commands/cmd_input.cpp

@ -29,15 +29,13 @@
void CmdPlay::execute()
{
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
if( pPlaylist == NULL )
return;
playlist_t *pPlaylist = getPL();
// if already playing an input, reset rate to normal speed
input_thread_t *pInput = playlist_CurrentInput( pPlaylist );
if( pInput )
{
var_SetFloat( pPlaylist, "rate", 1.0 );
var_SetFloat( getPL(), "rate", 1.0 );
vlc_object_release( pInput );
}
@ -59,60 +57,42 @@ void CmdPlay::execute()
void CmdPause::execute()
{
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
if( pPlaylist != NULL )
playlist_TogglePause( pPlaylist );
playlist_TogglePause( getPL() );
}
void CmdStop::execute()
{
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
if( pPlaylist != NULL )
playlist_Stop( pPlaylist );
playlist_Stop( getPL() );
}
void CmdSlower::execute()
{
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
input_thread_t *pInput = playlist_CurrentInput( pPlaylist );
if( pInput )
{
var_TriggerCallback( pPlaylist, "rate-slower" );
vlc_object_release( pInput );
}
var_TriggerCallback( getPL(), "rate-slower" );
}
void CmdFaster::execute()
{
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
input_thread_t *pInput = playlist_CurrentInput( pPlaylist );
if( pInput )
{
var_TriggerCallback( pPlaylist, "rate-faster" );
vlc_object_release( pInput );
}
var_TriggerCallback( getPL(), "rate-faster" );
}
void CmdMute::execute()
{
playlist_MuteToggle( getIntf()->p_sys->p_playlist );
playlist_MuteToggle( getPL() );
}
void CmdVolumeUp::execute()
{
playlist_VolumeUp( getIntf()->p_sys->p_playlist, 1, NULL );
playlist_VolumeUp( getPL(), 1, NULL );
}
void CmdVolumeDown::execute()
{
playlist_VolumeDown( getIntf()->p_sys->p_playlist, 1, NULL );
playlist_VolumeDown( getPL(), 1, NULL );
}

54
modules/gui/skins2/commands/cmd_playlist.cpp

@ -34,75 +34,59 @@ void CmdPlaylistDel::execute()
void CmdPlaylistNext::execute()
{
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
if( pPlaylist != NULL )
playlist_Next( pPlaylist );
playlist_Next( getPL() );
}
void CmdPlaylistPrevious::execute()
{
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
if( pPlaylist != NULL )
playlist_Prev( pPlaylist );
playlist_Prev( getPL() );
}
void CmdPlaylistRandom::execute()
{
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
if( pPlaylist != NULL )
var_SetBool( pPlaylist , "random", m_value );
var_SetBool( getPL(), "random", m_value );
}
void CmdPlaylistLoop::execute()
{
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
if( pPlaylist != NULL )
var_SetBool( pPlaylist , "loop", m_value );
var_SetBool( getPL(), "loop", m_value );
}
void CmdPlaylistRepeat::execute()
{
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
if( pPlaylist != NULL )
var_SetBool( pPlaylist , "repeat", m_value );
var_SetBool( getPL(), "repeat", m_value );
}
void CmdPlaylistLoad::execute()
{
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
if( pPlaylist != NULL )
playlist_Import( pPlaylist, m_file.c_str() );
playlist_Import( getPL(), m_file.c_str() );
}
void CmdPlaylistSave::execute()
{
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
if( pPlaylist != NULL )
const char *psz_module;
if( m_file.find( ".xsp", 0 ) != std::string::npos )
psz_module = "export-xspf";
else if( m_file.find( "m3u", 0 ) != std::string::npos )
psz_module = "export-m3u";
else if( m_file.find( "html", 0 ) != std::string::npos )
psz_module = "export-html";
else
{
const char *psz_module;
if( m_file.find( ".xsp", 0 ) != std::string::npos )
psz_module = "export-xspf";
else if( m_file.find( "m3u", 0 ) != std::string::npos )
psz_module = "export-m3u";
else if( m_file.find( "html", 0 ) != std::string::npos )
psz_module = "export-html";
else
{
msg_Err(getIntf(),"Did not recognise playlist export file type");
return;
}
playlist_Export( pPlaylist, m_file.c_str(), true, psz_module );
msg_Err(getIntf(),"Did not recognise playlist export file type");
return;
}
playlist_Export( getPL(), m_file.c_str(), true, psz_module );
}
void CmdPlaylistFirst::execute()
{
playlist_Control(getIntf()->p_sys->p_playlist,PLAYLIST_PLAY,pl_Unlocked);
playlist_Control(getPL(), PLAYLIST_PLAY, pl_Unlocked);
}

2
modules/gui/skins2/commands/cmd_playtree.cpp

@ -36,7 +36,7 @@ void CmdPlaytreeSort::execute()
{
/// \todo Choose sort method/order - Need more commands
/// \todo Choose the correct view
playlist_t *p_playlist = getIntf()->p_sys->p_playlist;
playlist_t *p_playlist = getPL();
PL_LOCK;
playlist_RecursiveNodeSort( p_playlist, p_playlist->p_root,
SORT_TITLE, ORDER_NORMAL );

2
modules/gui/skins2/commands/cmd_vars.cpp

@ -34,7 +34,7 @@ void CmdItemUpdate::execute()
return;
// update playtree
playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
playlist_t* pPlaylist = getPL();
playlist_Lock( pPlaylist );
playlist_item_t* p_plItem = playlist_ItemGetByInput( pPlaylist, m_pItem );
int id = p_plItem ? p_plItem->i_id : 0;

4
modules/gui/skins2/src/skin_common.hpp

@ -94,9 +94,6 @@ struct intf_sys_t
/// The input thread
input_thread_t *p_input;
/// The playlist thread
playlist_t *p_playlist;
// "Singleton" objects: MUST be initialized to NULL !
/// Logger
Logger *p_logger;
@ -143,6 +140,7 @@ public:
/// Getter (public because it is used in C callbacks in the win32
/// interface)
intf_thread_t *getIntf() const { return m_pIntf; }
playlist_t *getPL() const { return pl_Get(m_pIntf); }
private:
intf_thread_t *m_pIntf;

3
modules/gui/skins2/src/skin_main.cpp

@ -83,7 +83,6 @@ static int Open( vlc_object_t *p_this )
return VLC_ENOMEM;
p_intf->p_sys->p_input = NULL;
p_intf->p_sys->p_playlist = pl_Get( p_intf );
// Initialize "singleton" objects
p_intf->p_sys->p_logger = NULL;
@ -150,7 +149,7 @@ static void Close( vlc_object_t *p_this )
msg_Dbg( p_intf, "closing skins2 module" );
/* Terminate input to ensure that our window provider is released. */
playlist_Deactivate( p_intf->p_sys->p_playlist );
playlist_Deactivate( pl_Get(p_intf) );
vlc_mutex_lock( &skin_load.mutex );
skin_load.intf = NULL;

59
modules/gui/skins2/src/vlcproc.cpp

@ -154,29 +154,25 @@ VlcProc::VlcProc( intf_thread_t *pIntf ): SkinObject( pIntf ),
#define ADD_CALLBACK( p_object, var ) \
var_AddCallback( p_object, var, onGenericCallback, this );
ADD_CALLBACK( pIntf->p_sys->p_playlist, "volume" )
ADD_CALLBACK( pIntf->p_sys->p_playlist, "mute" )
ADD_CALLBACK( getPL(), "volume" )
ADD_CALLBACK( getPL(), "mute" )
ADD_CALLBACK( pIntf->obj.libvlc, "intf-toggle-fscontrol" )
ADD_CALLBACK( pIntf->p_sys->p_playlist, "random" )
ADD_CALLBACK( pIntf->p_sys->p_playlist, "loop" )
ADD_CALLBACK( pIntf->p_sys->p_playlist, "repeat" )
ADD_CALLBACK( getPL(), "random" )
ADD_CALLBACK( getPL(), "loop" )
ADD_CALLBACK( getPL(), "repeat" )
#undef ADD_CALLBACK
// Called when a playlist item is added
var_AddCallback( pIntf->p_sys->p_playlist, "playlist-item-append",
onItemAppend, this );
var_AddCallback( getPL(), "playlist-item-append", onItemAppend, this );
// Called when a playlist item is deleted
// TODO: properly handle item-deleted
var_AddCallback( pIntf->p_sys->p_playlist, "playlist-item-deleted",
onItemDelete, this );
var_AddCallback( getPL(), "playlist-item-deleted", onItemDelete, this );
// Called when the current input changes
var_AddCallback( pIntf->p_sys->p_playlist, "input-current",
onInputNew, this );
var_AddCallback( getPL(), "input-current", onInputNew, this );
// Called when a playlist item changed
var_AddCallback( pIntf->p_sys->p_playlist, "item-change",
onItemChange, this );
var_AddCallback( getPL(), "item-change", onItemChange, this );
// Called when we have an interaction dialog to display
var_Create( pIntf, "interaction", VLC_VAR_ADDRESS );
@ -195,29 +191,20 @@ VlcProc::~VlcProc()
m_pVout = NULL;
}
var_DelCallback( getIntf()->p_sys->p_playlist, "volume",
onGenericCallback, this );
var_DelCallback( getIntf()->p_sys->p_playlist, "mute",
onGenericCallback, this );
var_DelCallback( getPL(), "volume", onGenericCallback, this );
var_DelCallback( getPL(), "mute",onGenericCallback, this );
var_DelCallback( getIntf()->obj.libvlc, "intf-toggle-fscontrol",
onGenericCallback, this );
var_DelCallback( getIntf()->p_sys->p_playlist, "random",
onGenericCallback, this );
var_DelCallback( getIntf()->p_sys->p_playlist, "loop",
onGenericCallback, this );
var_DelCallback( getIntf()->p_sys->p_playlist, "repeat",
onGenericCallback, this );
var_DelCallback( getPL(), "random", onGenericCallback, this );
var_DelCallback( getPL(), "loop", onGenericCallback, this );
var_DelCallback( getPL(), "repeat", onGenericCallback, this );
var_DelCallback( getIntf()->p_sys->p_playlist, "playlist-item-append",
onItemAppend, this );
var_DelCallback( getIntf()->p_sys->p_playlist, "playlist-item-deleted",
onItemDelete, this );
var_DelCallback( getIntf()->p_sys->p_playlist, "input-current",
onInputNew, this );
var_DelCallback( getIntf()->p_sys->p_playlist, "item-change",
onItemChange, this );
var_DelCallback( getIntf(), "interaction", onInteraction, this );
var_DelCallback( getPL(), "playlist-item-append", onItemAppend, this );
var_DelCallback( getPL(), "playlist-item-deleted", onItemDelete, this );
var_DelCallback( getPL(), "input-current", onInputNew, this );
var_DelCallback( getPL(), "item-change", onItemChange, this );
var_DelCallback( getPL(), "interaction", onInteraction, this );
}
int VlcProc::onInputNew( vlc_object_t *pObj, const char *pVariable,
@ -620,9 +607,8 @@ void VlcProc::on_repeat_changed( vlc_object_t* p_obj, vlc_value_t newVal )
void VlcProc::on_volume_changed( vlc_object_t* p_obj, vlc_value_t newVal )
{
(void)p_obj; (void)newVal;
playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
SET_VOLUME( m_cVarVolume, var_GetFloat( pPlaylist, "volume" ), false );
SET_VOLUME( m_cVarVolume, var_GetFloat( getPL(), "volume" ), false );
}
void VlcProc::on_mute_changed( vlc_object_t* p_obj, vlc_value_t newVal )
@ -715,7 +701,7 @@ void VlcProc::reset_input()
void VlcProc::init_variables()
{
playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
playlist_t* pPlaylist = getPL();
SET_BOOL( m_cVarRandom, var_GetBool( pPlaylist, "random" ) );
SET_BOOL( m_cVarLoop, var_GetBool( pPlaylist, "loop" ) );
@ -769,8 +755,7 @@ void VlcProc::update_current_input()
void VlcProc::init_equalizer()
{
playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
audio_output_t* pAout = playlist_GetAout( pPlaylist );
audio_output_t* pAout = playlist_GetAout( getPL() );
if( pAout )
{
if( !var_Type( pAout, "equalizer-bands" ) )

6
modules/gui/skins2/vars/equalizer.cpp

@ -84,8 +84,7 @@ VariablePtr EqualizerBands::getBand( int band )
void EqualizerBands::onUpdate( Subject<VarPercent> &rBand, void *arg )
{
(void)rBand; (void)arg;
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
audio_output_t *pAout = playlist_GetAout( pPlaylist );
audio_output_t *pAout = playlist_GetAout( getPL() );
// Make sure we are not called from set()
if (!m_isUpdating)
@ -128,8 +127,7 @@ EqualizerPreamp::EqualizerPreamp( intf_thread_t *pIntf ): VarPercent( pIntf )
void EqualizerPreamp::set( float percentage, bool updateVLC )
{
playlist_t *pPlaylist = getIntf()->p_sys->p_playlist;
audio_output_t *pAout = playlist_GetAout( pPlaylist );
audio_output_t *pAout = playlist_GetAout( getPL() );
VarPercent::set( percentage );

2
modules/gui/skins2/vars/playtree.cpp

@ -36,7 +36,7 @@
#include "../utils/ustring.hpp"
Playtree::Playtree( intf_thread_t *pIntf )
: VarTree( pIntf ), m_pPlaylist( pIntf->p_sys->p_playlist )
: VarTree( pIntf ), m_pPlaylist( pl_Get(pIntf) )
{
getPositionVar().addObserver( this );
buildTree();

6
modules/gui/skins2/vars/volume.cpp

@ -39,8 +39,7 @@ Volume::Volume( intf_thread_t *pIntf ): VarPercent( pIntf )
/ (float)AOUT_VOLUME_MAX;
// set current volume from the playlist
playlist_t* pPlaylist = pIntf->p_sys->p_playlist;
setVolume( var_GetFloat( pPlaylist, "volume" ), false );
setVolume( var_GetFloat( getPL(), "volume" ), false );
}
@ -49,8 +48,7 @@ void Volume::set( float percentage, bool updateVLC )
VarPercent::set( percentage );
if( updateVLC )
{
playlist_t* pPlaylist = getIntf()->p_sys->p_playlist;
playlist_VolumeSet( pPlaylist, getVolume() );
playlist_VolumeSet( getPL(), getVolume() );
}
}

Loading…
Cancel
Save