VLC_EXPORT( void, intf_StopThread, ( intf_thread_t * ) );
VLC_EXPORT( void, intf_Destroy, ( intf_thread_t * ) );
+/* If the interface is in the main thread, it should listen both to
+ * p_intf->b_die and p_libvlc->b_die */
+#define intf_ShouldDie( p_intf ) (p_intf->b_die || (p_intf->b_block && p_intf->p_libvlc->b_die ) )
+
/*@}*/
/*****************************************************************************
msg_Err( p_intf, "Exception in CORBA events check loop" );
return FALSE;
}
-
+
vlc_mutex_lock( &p_intf->change_lock );
if( b_work_pending )
CORBA_ORB_perform_work( p_intf->p_sys->orb, ev );
-
- if( p_intf->b_die )
+
+ if( intf_ShouldDie( p_intf ) )
{
vlc_mutex_unlock( &p_intf->change_lock );
CORBA_ORB_shutdown( p_intf->p_sys->orb, TRUE, ev );
msg_Dbg( p_intf, "interface thread initialized" );
/* Main loop */
- while( !p_intf->b_die )
+ while( !intf_ShouldDie( p_intf ) )
{
vlc_mutex_lock( &p_intf->change_lock );
{
char *psz_button;
/* we might need some locking here */
- if( !p_intf->b_die )
+ if( !intf_ShouldDie( p_intf ) )
{
input_thread_t * p_input;
var_Set( p_intf->p_libvlc, p_hotkeys[i].psz_action, val );
}
- while( !p_intf->b_die )
+ while( !intf_ShouldDie( p_intf ) )
{
int i_key, i_action;
int i_times = 0;
{
intf_sys_t *p_sys = p_intf->p_sys;
- while( !p_intf->b_die )
+ while( !intf_ShouldDie( p_intf ) )
{
/* get the playlist */
if( p_sys->p_playlist == NULL )
{
char *code, *c;
- while( !p_intf->b_die )
+ while( !intf_ShouldDie( p_intf ) )
{
/* Sleep a bit */
msleep( INTF_IDLE_SLEEP );
continue;
}
- while( !p_intf->b_die
+ while( !intf_ShouldDie( p_intf )
&& lirc_code2char( p_intf->p_sys->config, code, &c ) == 0
&& c != NULL )
{
{
int i_x, i_oldx = 0;
- while( !p_intf->b_die )
+ while( !intf_ShouldDie( p_intf ) )
{
#define LOW_THRESHOLD 80
#define HIGH_THRESHOLD 100
/* High priority thread */
vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_INPUT );
- while( !p_intf->b_die )
+ while( !intf_ShouldDie( p_intf ) )
{
struct timeval timeout;
fd_set fds_r;
}
#endif
- while( !p_intf->b_die )
+ while( !intf_ShouldDie( p_intf ) )
{
char *psz_cmd, *psz_arg;
vlc_bool_t b_complete;
while( WaitForSingleObject( p_intf->p_sys->hConsoleIn,
INTF_IDLE_SLEEP/1000 ) == WAIT_OBJECT_0 )
{
- while( !p_intf->b_die && *pi_size < MAX_LINE_LENGTH &&
+ while( !intf_ShouldDie( p_intf ) && *pi_size < MAX_LINE_LENGTH &&
ReadConsoleInput( p_intf->p_sys->hConsoleIn, &input_record,
1, &i_dw ) )
{
}
#endif
- while( !p_intf->b_die && *pi_size < MAX_LINE_LENGTH &&
+ while( !intf_ShouldDie( p_intf ) && *pi_size < MAX_LINE_LENGTH &&
(i_read = net_ReadNonBlock( p_intf, p_intf->p_sys->i_socket == -1 ?
0 /*STDIN_FILENO*/ : p_intf->p_sys->i_socket, NULL,
(uint8_t *)p_buffer + *pi_size, 1, INTF_IDLE_SLEEP ) ) > 0 )
}
/* Main loop */
- while( !p_intf->b_die )
+ while( !intf_ShouldDie( p_intf ) )
{
vlc_mutex_lock( &p_intf->change_lock );
*****************************************************************************/
static int InitThread( intf_thread_t * p_intf )
{
- if( !p_intf->b_die )
+ if( !intf_ShouldDie( p_intf ) )
{
vlc_mutex_lock( &p_intf->change_lock );
psz_password = config_GetPsz( p_intf, "telnet-password" );
- while( !p_intf->b_die )
+ while( !intf_ShouldDie( p_intf ) )
{
fd_set fds_read, fds_write;
int i_handle_max = 0;
*****************************************************************************/
static void Run( intf_thread_t *p_intf )
{
- while( !p_intf->b_die )
+ while( !intf_ShouldDie( p_intf ) )
{
p_intf->p_sys->p_window->UpdateInterface();
msleep( INTF_IDLE_SLEEP );
vlc_object_release( p_playlist );
- while( !p_intf->b_die )
+ while( !intf_ShouldDie( p_intf ) )
{
vlc_mutex_lock( &p_intf->change_lock );
*/
t_last_refresh = ( time( 0 ) - 1);
- while( !p_intf->b_die )
+ while( !intf_ShouldDie( p_intf ) )
{
msleep( INTF_IDLE_SLEEP );
#ifdef NEED_GTK2_MAIN
msg_Dbg( p_intf, "Manage GTK keyboard events using threads" );
- while( !p_intf->b_die )
+ while( !intf_ShouldDie( p_intf ) )
{
Manage( p_intf );
}
vlc_mutex_unlock( &p_input->object_lock );
}
- else if( p_intf->p_sys->b_playing && !p_intf->b_die )
+ else if( p_intf->p_sys->b_playing && !intf_ShouldDie( p_intf ) )
{
E_(GtkModeManage)( p_intf );
p_intf->p_sys->b_playing = 0;
}
#ifndef NEED_GTK2_MAIN
- if( p_intf->b_die )
+ if( intf_ShouldDie( p_intf ) )
{
vlc_mutex_unlock( &p_intf->change_lock );
advControls->enableInput( THEMIM->getIM()->hasInput() );
advControls->enableVideo( THEMIM->getIM()->hasVideo() );
- if( p_intf->b_die )
+ if( intf_ShouldDie( p_intf ) )
{
QApplication::closeAllWindows();
QApplication::quit();
void VlcProc::manage()
{
// Did the user request to quit vlc ?
- if( getIntf()->b_die || getIntf()->p_libvlc->b_die )
+ if( intf_ShouldDie( getIntf() ) )
{
CmdQuit *pCmd = new CmdQuit( getIntf() );
AsyncQueue *pQueue = AsyncQueue::instance( getIntf() );
}
}
}
- else if( p_intf->p_sys->b_playing && !p_intf->b_die )
+ else if( p_intf->p_sys->b_playing && !intf_ShouldDie( p_intf ) )
{
p_intf->p_sys->b_playing = 0;
p_main_interface->TogglePlayButton( PAUSE_S );
i_old_playing_status = PAUSE_S;
}
- if( p_intf->b_die )
+ if( intf_ShouldDie( p_intf ) )
{
vlc_mutex_unlock( &p_intf->change_lock );
p_intf->p_sys->b_intf_show = VLC_FALSE;
}
- if( p_intf->b_die )
+ if( intf_ShouldDie( p_intf ) )
{
vlc_mutex_unlock( &p_intf->change_lock );
msg_Info( p_intf, "using the dummy interface module..." );
- p_intf->pf_run = Run;
+ p_intf->pf_run = NULL;
return VLC_SUCCESS;
}
-
-/*****************************************************************************
- * Run: main loop
- *****************************************************************************/
-static void Run( intf_thread_t *p_intf )
-{
- while( !p_intf->b_die )
- {
- /* Wait a bit */
- msleep( INTF_IDLE_SLEEP );
- }
-}
-
/*****************************************************************************
* Local prototypes
*****************************************************************************/
-static void Manager( intf_thread_t *p_intf );
static void RunInterface( intf_thread_t *p_intf );
static int SwitchIntfCallback( vlc_object_t *, char const *,
vlc_value_t , vlc_value_t , void * );
#ifdef __APPLE__
+static void Manager( intf_thread_t *p_intf );
/*****************************************************************************
* VLCApplication interface
*****************************************************************************/
{
/* This interface doesn't need to be run */
if( !p_intf->pf_run )
- {
return VLC_SUCCESS;
- }
+
/* Run the interface in a separate thread */
if( !strcmp( p_intf->p_module->psz_object_name, "macosx" ) )
{
#else
if( p_intf->b_block )
{
- /* Run a manager thread, launch the interface, kill the manager */
- if( vlc_thread_create( p_intf, "manager", Manager,
- VLC_THREAD_PRIORITY_LOW, VLC_FALSE ) )
+ /* If the main interface does not have a run function,
+ * implement a waiting loop ourselves
+ */
+ if( p_intf->pf_run )
+ RunInterface( p_intf );
+ else
{
- msg_Err( p_intf, "cannot spawn manager thread" );
- return VLC_EGENERIC;
+ while( !intf_ShouldDie( p_intf ) )
+ msleep( INTF_IDLE_SLEEP * 2);
}
-
- RunInterface( p_intf );
-
p_intf->b_die = VLC_TRUE;
/* Do not join the thread... intf_StopThread will do it for us */
}
if( !p_intf->b_block )
{
p_intf->b_die = VLC_TRUE;
+ if( p_intf->pf_run )
+ vlc_thread_join( p_intf );
}
-
- /* Wait for the thread to exit */
- if( p_intf->pf_run )
- vlc_thread_join( p_intf );
}
/**
/* Following functions are local */
/*****************************************************************************
- * Manager: helper thread for blocking interfaces
- *****************************************************************************
- * If the interface is launched in the main thread, it will not listen to
- * p_vlc->b_die events because it is only supposed to listen to p_intf->b_die.
- * This thread takes care of the matter.
+ * Manager: helper thread for blocking OS X
*****************************************************************************/
-/**
- * \brief Helper thread for blocking interfaces.
- * \ingroup vlc_interface
- *
- * This is a local function
- * If the interface is launched in the main thread, it will not listen to
- * p_vlc->b_die events because it is only supposed to listen to p_intf->b_die.
- * This thread takes care of the matter.
- * \see intf_RunThread
- * \param p_intf an interface thread
- * \return nothing
- */
+#ifdef __APPLE__
static void Manager( intf_thread_t *p_intf )
{
while( !p_intf->b_die )
if( p_intf->p_libvlc->b_die )
{
p_intf->b_die = VLC_TRUE;
-#ifdef __APPLE__
- if( strncmp( p_intf->p_libvlc->psz_object_name, "clivlc", 6 ) )
- {
- [NSApp stop: NULL];
- }
-#endif
+ if( strncmp( p_intf->p_libvlc->psz_object_name, "clivlc", 6 ) )
+ {
+ [NSApp stop: NULL];
+ }
return;
}
}
}
+#endif
/*****************************************************************************
* RunInterface: setups necessary data and give control to the interface