Changeset a06213d7f406c886dba790418ef8cca43d7ad140
- Timestamp:
- 09/24/06 11:34:57
(2 years ago)
- Author:
- Clément Stenac <zorglub@videolan.org>
- git-committer:
- Clément Stenac <zorglub@videolan.org> 1159090497 +0000
- git-parent:
[ade29e262f65904c0b95d2849680efd8d105dd43]
- git-author:
- Clément Stenac <zorglub@videolan.org> 1159090497 +0000
- Message:
* Get rid of the Manager thread by making blocking interfaces listen to
p_libvlc->b_die
Not implemented for OS X as I am not sure, please check if it is feasible.
* Don't run the dummy interface
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r19f019c |
ra06213d |
|
| 120 | 120 | VLC_EXPORT( void, intf_Destroy, ( intf_thread_t * ) ); |
|---|
| 121 | 121 | |
|---|
| | 122 | /* If the interface is in the main thread, it should listen both to |
|---|
| | 123 | * p_intf->b_die and p_libvlc->b_die */ |
|---|
| | 124 | #define intf_ShouldDie( p_intf ) (p_intf->b_die || (p_intf->b_block && p_intf->p_libvlc->b_die ) ) |
|---|
| | 125 | |
|---|
| 122 | 126 | /*@}*/ |
|---|
| 123 | 127 | |
|---|
| rb5243c8 |
ra06213d |
|
| 758 | 758 | return FALSE; |
|---|
| 759 | 759 | } |
|---|
| 760 | | |
|---|
| | 760 | |
|---|
| 761 | 761 | vlc_mutex_lock( &p_intf->change_lock ); |
|---|
| 762 | 762 | |
|---|
| 763 | 763 | if( b_work_pending ) |
|---|
| 764 | 764 | CORBA_ORB_perform_work( p_intf->p_sys->orb, ev ); |
|---|
| 765 | | |
|---|
| 766 | | if( p_intf->b_die ) |
|---|
| | 765 | |
|---|
| | 766 | if( intf_ShouldDie( p_intf ) ) |
|---|
| 767 | 767 | { |
|---|
| 768 | 768 | vlc_mutex_unlock( &p_intf->change_lock ); |
|---|
| rf485214 |
ra06213d |
|
| 156 | 156 | |
|---|
| 157 | 157 | /* Main loop */ |
|---|
| 158 | | while( !p_intf->b_die ) |
|---|
| | 158 | while( !intf_ShouldDie( p_intf ) ) |
|---|
| 159 | 159 | { |
|---|
| 160 | 160 | vlc_mutex_lock( &p_intf->change_lock ); |
|---|
| … | … | |
| 262 | 262 | char *psz_button; |
|---|
| 263 | 263 | /* we might need some locking here */ |
|---|
| 264 | | if( !p_intf->b_die ) |
|---|
| | 264 | if( !intf_ShouldDie( p_intf ) ) |
|---|
| 265 | 265 | { |
|---|
| 266 | 266 | input_thread_t * p_input; |
|---|
| r360b392 |
ra06213d |
|
| 165 | 165 | } |
|---|
| 166 | 166 | |
|---|
| 167 | | while( !p_intf->b_die ) |
|---|
| | 167 | while( !intf_ShouldDie( p_intf ) ) |
|---|
| 168 | 168 | { |
|---|
| 169 | 169 | int i_key, i_action; |
|---|
| rf485214 |
ra06213d |
|
| 432 | 432 | intf_sys_t *p_sys = p_intf->p_sys; |
|---|
| 433 | 433 | |
|---|
| 434 | | while( !p_intf->b_die ) |
|---|
| | 434 | while( !intf_ShouldDie( p_intf ) ) |
|---|
| 435 | 435 | { |
|---|
| 436 | 436 | /* get the playlist */ |
|---|
| rf485214 |
ra06213d |
|
| 121 | 121 | char *code, *c; |
|---|
| 122 | 122 | |
|---|
| 123 | | while( !p_intf->b_die ) |
|---|
| | 123 | while( !intf_ShouldDie( p_intf ) ) |
|---|
| 124 | 124 | { |
|---|
| 125 | 125 | /* Sleep a bit */ |
|---|
| … | … | |
| 137 | 137 | } |
|---|
| 138 | 138 | |
|---|
| 139 | | while( !p_intf->b_die |
|---|
| | 139 | while( !intf_ShouldDie( p_intf ) |
|---|
| 140 | 140 | && lirc_code2char( p_intf->p_sys->config, code, &c ) == 0 |
|---|
| 141 | 141 | && c != NULL ) |
|---|
| r2cda7c1 |
ra06213d |
|
| 133 | 133 | int i_x, i_oldx = 0; |
|---|
| 134 | 134 | |
|---|
| 135 | | while( !p_intf->b_die ) |
|---|
| | 135 | while( !intf_ShouldDie( p_intf ) ) |
|---|
| 136 | 136 | { |
|---|
| 137 | 137 | #define LOW_THRESHOLD 80 |
|---|
| rb0639d9 |
ra06213d |
|
| 160 | 160 | vlc_thread_set_priority( p_intf, VLC_THREAD_PRIORITY_INPUT ); |
|---|
| 161 | 161 | |
|---|
| 162 | | while( !p_intf->b_die ) |
|---|
| | 162 | while( !intf_ShouldDie( p_intf ) ) |
|---|
| 163 | 163 | { |
|---|
| 164 | 164 | struct timeval timeout; |
|---|
| r415749b |
ra06213d |
|
| 561 | 561 | #endif |
|---|
| 562 | 562 | |
|---|
| 563 | | while( !p_intf->b_die ) |
|---|
| | 563 | while( !intf_ShouldDie( p_intf ) ) |
|---|
| 564 | 564 | { |
|---|
| 565 | 565 | char *psz_cmd, *psz_arg; |
|---|
| … | … | |
| 2202 | 2202 | INTF_IDLE_SLEEP/1000 ) == WAIT_OBJECT_0 ) |
|---|
| 2203 | 2203 | { |
|---|
| 2204 | | while( !p_intf->b_die && *pi_size < MAX_LINE_LENGTH && |
|---|
| | 2204 | while( !intf_ShouldDie( p_intf ) && *pi_size < MAX_LINE_LENGTH && |
|---|
| 2205 | 2205 | ReadConsoleInput( p_intf->p_sys->hConsoleIn, &input_record, |
|---|
| 2206 | 2206 | 1, &i_dw ) ) |
|---|
| … | … | |
| 2272 | 2272 | #endif |
|---|
| 2273 | 2273 | |
|---|
| 2274 | | while( !p_intf->b_die && *pi_size < MAX_LINE_LENGTH && |
|---|
| | 2274 | while( !intf_ShouldDie( p_intf ) && *pi_size < MAX_LINE_LENGTH && |
|---|
| 2275 | 2275 | (i_read = net_ReadNonBlock( p_intf, p_intf->p_sys->i_socket == -1 ? |
|---|
| 2276 | 2276 | 0 /*STDIN_FILENO*/ : p_intf->p_sys->i_socket, NULL, |
|---|
| r415749b |
ra06213d |
|
| 117 | 117 | |
|---|
| 118 | 118 | /* Main loop */ |
|---|
| 119 | | while( !p_intf->b_die ) |
|---|
| | 119 | while( !intf_ShouldDie( p_intf ) ) |
|---|
| 120 | 120 | { |
|---|
| 121 | 121 | vlc_mutex_lock( &p_intf->change_lock ); |
|---|
| … | … | |
| 176 | 176 | static int InitThread( intf_thread_t * p_intf ) |
|---|
| 177 | 177 | { |
|---|
| 178 | | if( !p_intf->b_die ) |
|---|
| | 178 | if( !intf_ShouldDie( p_intf ) ) |
|---|
| 179 | 179 | { |
|---|
| 180 | 180 | vlc_mutex_lock( &p_intf->change_lock ); |
|---|
| rf485214 |
ra06213d |
|
| 246 | 246 | psz_password = config_GetPsz( p_intf, "telnet-password" ); |
|---|
| 247 | 247 | |
|---|
| 248 | | while( !p_intf->b_die ) |
|---|
| | 248 | while( !intf_ShouldDie( p_intf ) ) |
|---|
| 249 | 249 | { |
|---|
| 250 | 250 | fd_set fds_read, fds_write; |
|---|
| r2cb472d |
ra06213d |
|
| 120 | 120 | static void Run( intf_thread_t *p_intf ) |
|---|
| 121 | 121 | { |
|---|
| 122 | | while( !p_intf->b_die ) |
|---|
| | 122 | while( !intf_ShouldDie( p_intf ) ) |
|---|
| 123 | 123 | { |
|---|
| 124 | 124 | p_intf->p_sys->p_window->UpdateInterface(); |
|---|
| r0b66060 |
ra06213d |
|
| 1007 | 1007 | vlc_object_release( p_playlist ); |
|---|
| 1008 | 1008 | |
|---|
| 1009 | | while( !p_intf->b_die ) |
|---|
| | 1009 | while( !intf_ShouldDie( p_intf ) ) |
|---|
| 1010 | 1010 | { |
|---|
| 1011 | 1011 | vlc_mutex_lock( &p_intf->change_lock ); |
|---|
| rf485214 |
ra06213d |
|
| 337 | 337 | t_last_refresh = ( time( 0 ) - 1); |
|---|
| 338 | 338 | |
|---|
| 339 | | while( !p_intf->b_die ) |
|---|
| | 339 | while( !intf_ShouldDie( p_intf ) ) |
|---|
| 340 | 340 | { |
|---|
| 341 | 341 | msleep( INTF_IDLE_SLEEP ); |
|---|
| rf485214 |
ra06213d |
|
| 320 | 320 | #ifdef NEED_GTK2_MAIN |
|---|
| 321 | 321 | msg_Dbg( p_intf, "Manage GTK keyboard events using threads" ); |
|---|
| 322 | | while( !p_intf->b_die ) |
|---|
| | 322 | while( !intf_ShouldDie( p_intf ) ) |
|---|
| 323 | 323 | { |
|---|
| 324 | 324 | Manage( p_intf ); |
|---|
| … | … | |
| 519 | 519 | vlc_mutex_unlock( &p_input->object_lock ); |
|---|
| 520 | 520 | } |
|---|
| 521 | | else if( p_intf->p_sys->b_playing && !p_intf->b_die ) |
|---|
| | 521 | else if( p_intf->p_sys->b_playing && !intf_ShouldDie( p_intf ) ) |
|---|
| 522 | 522 | { |
|---|
| 523 | 523 | E_(GtkModeManage)( p_intf ); |
|---|
| … | … | |
| 526 | 526 | |
|---|
| 527 | 527 | #ifndef NEED_GTK2_MAIN |
|---|
| 528 | | if( p_intf->b_die ) |
|---|
| | 528 | if( intf_ShouldDie( p_intf ) ) |
|---|
| 529 | 529 | { |
|---|
| 530 | 530 | vlc_mutex_unlock( &p_intf->change_lock ); |
|---|
| r18efcf5 |
ra06213d |
|
| 622 | 622 | advControls->enableVideo( THEMIM->getIM()->hasVideo() ); |
|---|
| 623 | 623 | |
|---|
| 624 | | if( p_intf->b_die ) |
|---|
| | 624 | if( intf_ShouldDie( p_intf ) ) |
|---|
| 625 | 625 | { |
|---|
| 626 | 626 | QApplication::closeAllWindows(); |
|---|
| rf485214 |
ra06213d |
|
| 231 | 231 | { |
|---|
| 232 | 232 | // Did the user request to quit vlc ? |
|---|
| 233 | | if( getIntf()->b_die || getIntf()->p_libvlc->b_die ) |
|---|
| | 233 | if( intf_ShouldDie( getIntf() ) ) |
|---|
| 234 | 234 | { |
|---|
| 235 | 235 | CmdQuit *pCmd = new CmdQuit( getIntf() ); |
|---|
| r2cb472d |
ra06213d |
|
| 211 | 211 | } |
|---|
| 212 | 212 | } |
|---|
| 213 | | else if( p_intf->p_sys->b_playing && !p_intf->b_die ) |
|---|
| | 213 | else if( p_intf->p_sys->b_playing && !intf_ShouldDie( p_intf ) ) |
|---|
| 214 | 214 | { |
|---|
| 215 | 215 | p_intf->p_sys->b_playing = 0; |
|---|
| … | … | |
| 218 | 218 | } |
|---|
| 219 | 219 | |
|---|
| 220 | | if( p_intf->b_die ) |
|---|
| | 220 | if( intf_ShouldDie( p_intf ) ) |
|---|
| 221 | 221 | { |
|---|
| 222 | 222 | vlc_mutex_unlock( &p_intf->change_lock ); |
|---|
| r2cb472d |
ra06213d |
|
| 108 | 108 | } |
|---|
| 109 | 109 | |
|---|
| 110 | | if( p_intf->b_die ) |
|---|
| | 110 | if( intf_ShouldDie( p_intf ) ) |
|---|
| 111 | 111 | { |
|---|
| 112 | 112 | vlc_mutex_unlock( &p_intf->change_lock ); |
|---|
| r07b1471 |
ra06213d |
|
| 52 | 52 | msg_Info( p_intf, "using the dummy interface module..." ); |
|---|
| 53 | 53 | |
|---|
| 54 | | p_intf->pf_run = Run; |
|---|
| | 54 | p_intf->pf_run = NULL; |
|---|
| 55 | 55 | |
|---|
| 56 | 56 | return VLC_SUCCESS; |
|---|
| 57 | 57 | } |
|---|
| 58 | | |
|---|
| 59 | | /***************************************************************************** |
|---|
| 60 | | * Run: main loop |
|---|
| 61 | | *****************************************************************************/ |
|---|
| 62 | | static void Run( intf_thread_t *p_intf ) |
|---|
| 63 | | { |
|---|
| 64 | | while( !p_intf->b_die ) |
|---|
| 65 | | { |
|---|
| 66 | | /* Wait a bit */ |
|---|
| 67 | | msleep( INTF_IDLE_SLEEP ); |
|---|
| 68 | | } |
|---|
| 69 | | } |
|---|
| 70 | | |
|---|
| r187a6ea |
ra06213d |
|
| 53 | 53 | * Local prototypes |
|---|
| 54 | 54 | *****************************************************************************/ |
|---|
| 55 | | static void Manager( intf_thread_t *p_intf ); |
|---|
| 56 | 55 | static void RunInterface( intf_thread_t *p_intf ); |
|---|
| 57 | 56 | |
|---|
| … | … | |
| 62 | 61 | |
|---|
| 63 | 62 | #ifdef __APPLE__ |
|---|
| | 63 | static void Manager( intf_thread_t *p_intf ); |
|---|
| 64 | 64 | /***************************************************************************** |
|---|
| 65 | 65 | * VLCApplication interface |
|---|
| … | … | |
| 189 | 189 | /* This interface doesn't need to be run */ |
|---|
| 190 | 190 | if( !p_intf->pf_run ) |
|---|
| 191 | | { |
|---|
| 192 | 191 | return VLC_SUCCESS; |
|---|
| 193 | | } |
|---|
| | 192 | |
|---|
| 194 | 193 | /* Run the interface in a separate thread */ |
|---|
| 195 | 194 | if( !strcmp( p_intf->p_module->psz_object_name, "macosx" ) ) |
|---|
| … | … | |
| 217 | 216 | if( p_intf->b_block ) |
|---|
| 218 | 217 | { |
|---|
| 219 | | /* Run a manager thread, launch the interface, kill the manager */ |
|---|
| 220 | | if( vlc_thread_create( p_intf, "manager", Manager, |
|---|
| 221 | | VLC_THREAD_PRIORITY_LOW, VLC_FALSE ) ) |
|---|
| 222 | | { |
|---|
| 223 | | msg_Err( p_intf, "cannot spawn manager thread" ); |
|---|
| 224 | | return VLC_EGENERIC; |
|---|
| 225 | | } |
|---|
| 226 | | |
|---|
| 227 | | RunInterface( p_intf ); |
|---|
| 228 | | |
|---|
| | 218 | /* If the main interface does not have a run function, |
|---|
| | 219 | * implement a waiting loop ourselves |
|---|
| | 220 | */ |
|---|
| | 221 | if( p_intf->pf_run ) |
|---|
| | 222 | RunInterface( p_intf ); |
|---|
| | 223 | else |
|---|
| | 224 | { |
|---|
| | 225 | while( !intf_ShouldDie( p_intf ) ) |
|---|
| | 226 | msleep( INTF_IDLE_SLEEP * 2); |
|---|
| | 227 | } |
|---|
| 229 | 228 | p_intf->b_die = VLC_TRUE; |
|---|
| 230 | 229 | /* Do not join the thread... intf_StopThread will do it for us */ |
|---|
| … | … | |
| 262 | 261 | { |
|---|
| 263 | 262 | p_intf->b_die = VLC_TRUE; |
|---|
| 264 | | } |
|---|
| 265 | | |
|---|
| 266 | | /* Wait for the thread to exit */ |
|---|
| 267 | | if( p_intf->pf_run ) |
|---|
| 268 | | vlc_thread_join( p_intf ); |
|---|
| | 263 | if( p_intf->pf_run ) |
|---|
| | 264 | vlc_thread_join( p_intf ); |
|---|
| | 265 | } |
|---|
| 269 | 266 | } |
|---|
| 270 | 267 | |
|---|
| … | … | |
| 294 | 291 | |
|---|
| 295 | 292 | /***************************************************************************** |
|---|
| 296 | | * Manager: helper thread for blocking interfaces |
|---|
| 297 | | ***************************************************************************** |
|---|
| 298 | | * If the interface is launched in the main thread, it will not listen to |
|---|
| 299 | | * p_vlc->b_die events because it is only supposed to listen to p_intf->b_die. |
|---|
| 300 | | * This thread takes care of the matter. |
|---|
| 301 | | *****************************************************************************/ |
|---|
| 302 | | /** |
|---|
| 303 | | * \brief Helper thread for blocking interfaces. |
|---|
| 304 | | * \ingroup vlc_interface |
|---|
| 305 | | * |
|---|
| 306 | | * This is a local function |
|---|
| 307 | | * If the interface is launched in the main thread, it will not listen to |
|---|
| 308 | | * p_vlc->b_die events because it is only supposed to listen to p_intf->b_die. |
|---|
| 309 | | * This thread takes care of the matter. |
|---|
| 310 | | * \see intf_RunThread |
|---|
| 311 | | * \param p_intf an interface thread |
|---|
| 312 | | * \return nothing |
|---|
| 313 | | */ |
|---|
| | 293 | * Manager: helper thread for blocking OS X |
|---|
| | 294 | *****************************************************************************/ |
|---|
| | 295 | #ifdef __APPLE__ |
|---|
| 314 | 296 | static void Manager( intf_thread_t *p_intf ) |
|---|
| 315 | 297 | { |
|---|
| … | … | |
| 321 | 303 | { |
|---|
| 322 | 304 | p_intf->b_die = VLC_TRUE; |
|---|
| 323 | | #ifdef __APPLE__ |
|---|
| 324 | | if( strncmp( p_intf->p_libvlc->psz_object_name, "clivlc", 6 ) ) |
|---|
| 325 | | { |
|---|
| 326 | | [NSApp stop: NULL]; |
|---|
| 327 | | } |
|---|
| 328 | | #endif |
|---|
| | 305 | if( strncmp( p_intf->p_libvlc->psz_object_name, "clivlc", 6 ) ) |
|---|
| | 306 | { |
|---|
| | 307 | [NSApp stop: NULL]; |
|---|
| | 308 | } |
|---|
| 329 | 309 | return; |
|---|
| 330 | 310 | } |
|---|
| 331 | 311 | } |
|---|
| 332 | 312 | } |
|---|
| | 313 | #endif |
|---|
| 333 | 314 | |
|---|
| 334 | 315 | /***************************************************************************** |
|---|