static int SoundMuteChanged( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * );
-static int RandomChanged( vlc_object_t *, const char *,
- vlc_value_t, vlc_value_t, void * );
-static int LoopChanged( vlc_object_t *, const char *,
- vlc_value_t, vlc_value_t, void * );
-static int RepeatChanged( vlc_object_t *, const char *,
- vlc_value_t, vlc_value_t, void * );
-
-
static int InputEvent( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * );
static int VbiEvent( vlc_object_t *, const char *,
if( val.i_int > 0 )
{
- emit titleChanged( true );
- msg_Dbg( p_intf, "Title %"PRId64, val.i_int );
/* p_input != NULL since val.i_int != 0 */
var_Change( p_input, "chapter", VLC_VAR_CHOICESCOUNT, &val2, NULL );
- emit chapterChanged( (val2.i_int > 1) || ( val2.i_int > 0 && val.i_int > 1 ) );
- msg_Dbg( p_intf, "Chapter: %"PRId64, val2.i_int );
+
+ emit titleChanged( val.i_int > 1 );
+ emit chapterChanged( val2.i_int > 1 );
}
else
- emit titleChanged( false );
+ emit chapterChanged( false );
}
void InputManager::UpdateStatus()
void InputManager::UpdateName()
{
+ assert( p_input );
+
/* Update text, name and nowplaying */
QString name;
free( formated );
/* If we have Nothing */
- if( name.isEmpty() )
+ if( name.simplified().isEmpty() )
{
char *uri = input_item_GetURI( input_GetItem( p_input ) );
char *file = uri ? strrchr( uri, '/' ) : NULL;
inline void InputManager::UpdateStats()
{
+ assert( p_input );
emit statisticsUpdated( input_GetItem( p_input ) );
}
-inline void InputManager::UpdateMeta( input_item_t *p_item )
+inline void InputManager::UpdateMeta( input_item_t *p_item_ )
{
- emit metaChanged( p_item );
+ emit metaChanged( p_item_ );
}
inline void InputManager::UpdateMeta()
{
+ assert( p_input );
emit currentMetaChanged( input_GetItem( p_input ) );
}
inline void InputManager::UpdateInfo()
{
+ assert( p_input );
emit infoChanged( input_GetItem( p_input ) );
}
emit seekRequested( new_pos );
}
-/* User togglePlayPause */
-void InputManager::togglePlayPause()
-{
- if( hasInput() )
- {
- int state = var_GetInteger( p_input, "state" );
- state = ( state != PLAYING_S ) ? PLAYING_S : PAUSE_S;
- var_SetInteger( p_input, "state", state );
- }
-}
-
void InputManager::sectionPrev()
{
if( hasInput() )
{
if( hasInput() )
{
- float f_rate = var_GetFloat( p_input, "rate" );
- var_SetFloat( p_input, "rate", -f_rate );
+ float f_rate_ = var_GetFloat( p_input, "rate" );
+ var_SetFloat( p_input, "rate", -f_rate_ );
}
}
void InputManager::jumpFwd()
{
int i_interval = var_InheritInteger( p_input, "short-jump-size" );
- if( i_interval > 0 )
+ if( i_interval > 0 && hasInput() )
{
mtime_t val = CLOCK_FREQ * i_interval;
var_SetTime( p_input, "time-offset", val );
void InputManager::jumpBwd()
{
int i_interval = var_InheritInteger( p_input, "short-jump-size" );
- if( i_interval > 0 )
+ if( i_interval > 0 && hasInput() )
{
mtime_t val = -CLOCK_FREQ * i_interval;
var_SetTime( p_input, "time-offset", val );
**********************************************************************/
MainInputManager::MainInputManager( intf_thread_t *_p_intf )
- : QObject(NULL), p_intf( _p_intf )
+ : QObject(NULL), p_intf( _p_intf ),
+ random( VLC_OBJECT(THEPL), "random" ),
+ repeat( VLC_OBJECT(THEPL), "repeat" ), loop( VLC_OBJECT(THEPL), "loop" )
{
p_input = NULL;
im = new InputManager( this, p_intf );
var_AddCallback( THEPL, "leaf-to-parent", LeafToParent, this );
var_AddCallback( THEPL, "playlist-item-append", PLItemAppended, this );
var_AddCallback( THEPL, "playlist-item-deleted", PLItemRemoved, this );
- var_AddCallback( THEPL, "random", RandomChanged, this );
- var_AddCallback( THEPL, "repeat", RepeatChanged, this );
- var_AddCallback( THEPL, "loop", LoopChanged, this );
+ random.addCallback( this, SLOT(notifyRandom(bool)) );
+ repeat.addCallback( this, SLOT(notifyRepeatLoop(bool)) );
+ loop.addCallback( this, SLOT(notifyRepeatLoop(bool)) );
var_AddCallback( THEPL, "volume", VolumeChanged, this );
var_AddCallback( THEPL, "mute", SoundMuteChanged, this );
DCONNECT( this, inputChanged( input_thread_t * ),
im, setInput( input_thread_t * ) );
+ /* initialize p_input (an input can already be running) */
+ p_input = playlist_CurrentInput( pl_Get(p_intf) );
+ if( p_input )
+ {
+ if( !p_intf->p_sys->b_isDialogProvider )
+ var_AddCallback( p_input, "state", PLItemChanged, this );
+ emit inputChanged( p_input );
+ }
}
MainInputManager::~MainInputManager()
var_DelCallback( THEPL, "item-current", PLItemChanged, this );
var_DelCallback( THEPL, "playlist-item-append", PLItemAppended, this );
var_DelCallback( THEPL, "playlist-item-deleted", PLItemRemoved, this );
- var_DelCallback( THEPL, "random", RandomChanged, this );
- var_DelCallback( THEPL, "repeat", RepeatChanged, this );
- var_DelCallback( THEPL, "loop", LoopChanged, this );
-
- /* Save some interface state in configuration, at module quit */
- config_PutInt( p_intf, "random", var_GetBool( THEPL, "random" ) );
- config_PutInt( p_intf, "loop", var_GetBool( THEPL, "loop" ) );
- config_PutInt( p_intf, "repeat", var_GetBool( THEPL, "repeat" ) );
-
- if( var_InheritBool( p_intf, "qt-autosave-volume" ) )
- config_PutInt( p_intf, "volume", aout_VolumeGet( THEPL ) );
}
vout_thread_t* MainInputManager::getVout()
plEv = static_cast<PLEvent*>( event );
emit playlistItemRemoved( plEv->i_item );
return;
- case RandomChanged_Type:
- emit randomChanged( var_GetBool( THEPL, "random" ) );
- return;
- case LoopChanged_Type:
- case RepeatChanged_Type:
- notifyRepeatLoop();
+ case PLEmpty_Type:
+ plEv = static_cast<PLEvent*>( event );
+ emit playlistNotEmpty( plEv->i_item >= 0 );
return;
case LeafToParent_Type:
plEv = static_cast<PLEvent*>( event );
if( !p_input )
playlist_Play( THEPL );
else
- getIM()->togglePlayPause();
+ playlist_Pause( THEPL );
}
void MainInputManager::play()
{
if( PLAYING_S != var_GetInteger( p_input, "state" ) )
{
- getIM()->togglePlayPause();
+ playlist_Pause( THEPL );
}
}
}
{
if(p_input && PLAYING_S == var_GetInteger( p_input, "state" ) )
{
- getIM()->togglePlayPause();
+ playlist_Pause( THEPL );
}
}
void MainInputManager::toggleRandom()
{
- var_ToggleBool( THEPL, "random" );
+ config_PutInt( p_intf, "random", var_ToggleBool( THEPL, "random" ) );
}
-void MainInputManager::notifyRepeatLoop()
+void MainInputManager::notifyRandom(bool value)
+{
+ emit randomChanged(value);
+}
+
+void MainInputManager::notifyRepeatLoop(bool)
{
int i_value = var_GetBool( THEPL, "loop" ) * REPEAT_ALL
+ var_GetBool( THEPL, "repeat" ) * REPEAT_ONE;
void MainInputManager::loopRepeatLoopStatus()
{
/* Toggle Normal -> Loop -> Repeat -> Normal ... */
- if( var_GetBool( THEPL, "repeat" ) )
- var_SetBool( THEPL, "repeat", false );
- else if( var_GetBool( THEPL, "loop" ) )
+ bool loop = var_GetBool( THEPL, "loop" );
+ bool repeat = var_GetBool( THEPL, "repeat" );
+
+ if( repeat )
{
- var_SetBool( THEPL, "loop", false );
- var_SetBool( THEPL, "repeat", true );
+ loop = false;
+ repeat = false;
+ }
+ else if( loop )
+ {
+ loop = false;
+ repeat = true;
}
else
- var_SetBool( THEPL, "loop", true );
+ {
+ loop = true;
+ //repeat = false;
+ }
+
+ var_SetBool( THEPL, "loop", loop );
+ var_SetBool( THEPL, "repeat", repeat );
+ config_PutInt( p_intf, "loop", loop );
+ config_PutInt( p_intf, "repeat", repeat );
}
void MainInputManager::activatePlayQuit( bool b_exit )
return var_GetBool( THEPL, "play-and-exit" );
}
+bool MainInputManager::hasEmptyPlaylist()
+{
+ playlist_Lock( THEPL );
+ bool b_empty = playlist_IsEmpty( THEPL );
+ playlist_Unlock( THEPL );
+ return b_empty;
+}
+
/****************************
* Static callbacks for MIM *
****************************/
( vlc_object_t * obj, const char *var, vlc_value_t old, vlc_value_t cur, void *data )
{
VLC_UNUSED( obj ); VLC_UNUSED( var ); VLC_UNUSED( old );
-
MainInputManager *mim = static_cast<MainInputManager*>(data);
playlist_add_t *p_add = static_cast<playlist_add_t*>( cur.p_address );
PLEvent *event = new PLEvent( PLItemAppended_Type, p_add->i_item, p_add->i_node );
QApplication::postEvent( mim, event );
+ event = new PLEvent( PLEmpty_Type, p_add->i_item, 0 );
+ QApplication::postEvent( mim, event );
return VLC_SUCCESS;
}
static int PLItemRemoved
( vlc_object_t * obj, const char *var, vlc_value_t old, vlc_value_t cur, void *data )
{
- VLC_UNUSED( obj ); VLC_UNUSED( var ); VLC_UNUSED( old );
+ VLC_UNUSED( var ); VLC_UNUSED( old );
+ playlist_t *pl = (playlist_t *) obj;
MainInputManager *mim = static_cast<MainInputManager*>(data);
PLEvent *event = new PLEvent( PLItemRemoved_Type, cur.i_int, 0 );
QApplication::postEvent( mim, event );
- return VLC_SUCCESS;
-}
-
-static int RandomChanged
-( vlc_object_t * obj, const char *var, vlc_value_t old, vlc_value_t cur, void *data )
-{
- VLC_UNUSED( obj ); VLC_UNUSED( var ); VLC_UNUSED( old ); VLC_UNUSED( cur );
-
- MainInputManager *mim = static_cast<MainInputManager*>(data);
-
- IMEvent *event = new IMEvent( RandomChanged_Type );
- QApplication::postEvent( mim, event );
- return VLC_SUCCESS;
-}
-
-/* Probably could be merged with next callback */
-static int LoopChanged
-( vlc_object_t * obj, const char *var, vlc_value_t old, vlc_value_t cur, void *data )
-{
- VLC_UNUSED( obj ); VLC_UNUSED( var ); VLC_UNUSED( old ); VLC_UNUSED( cur );
-
- MainInputManager *mim = static_cast<MainInputManager*>(data);
-
- IMEvent *event = new IMEvent( LoopChanged_Type );
- QApplication::postEvent( mim, event );
- return VLC_SUCCESS;
-}
-
-static int RepeatChanged
-( vlc_object_t * obj, const char *var, vlc_value_t old, vlc_value_t cur, void *data )
-{
- VLC_UNUSED( obj ); VLC_UNUSED( var ); VLC_UNUSED( old ); VLC_UNUSED( cur );
-
- MainInputManager *mim = static_cast<MainInputManager*>(data);
-
- IMEvent *event = new IMEvent( RepeatChanged_Type );
- QApplication::postEvent( mim, event );
+ // can't use playlist_IsEmpty( ) as it isn't true yet
+ if ( pl->items.i_size == 1 ) // lock is held
+ {
+ event = new PLEvent( PLEmpty_Type, -1, 0 );
+ QApplication::postEvent( mim, event );
+ }
return VLC_SUCCESS;
}