Showing the changes to src/host/chuck_main.cpp (1 of 3 files). Show all
Unified · Split
| @@ -39,7 +39,9 @@ · 38 unmodified lines | ||
| 39 | 39 | |
| 40 | 40 | // function prototypes |
| 41 | 41 | t_CKBOOL init_shell( Chuck_Shell * shell, Chuck_Shell_UI * ui, Chuck_VM * vm ); |
| 42 | +bool go( int argc, const char ** argv ); | |
| 42 | 43 | void global_cleanup(); |
| 44 | +void all_stop(); | |
| 43 | 45 | void usage(); |
| 44 | 46 | void uh(); |
| 45 | 47 | t_CKBOOL get_count( const char * arg, t_CKUINT * out ); |
| @@ -73,8 +75,6 @@ t_CKUINT g_watchdog_countermeasure_priority = 0; · 27 unmodified lines | ||
| 73 | 75 | #endif |
| 74 | 76 | // watchdog timeout |
| 75 | 77 | t_CKFLOAT g_watchdog_timeout = 0.5; |
| 76 | −// thread id for whatever | |
| 77 | −CHUCK_THREAD g_tid_whatever = 0; | |
| 78 | 78 | // flag for Std.system( string ) |
| 79 | 79 | t_CKBOOL g_enable_system_cmd = FALSE; |
| 80 | 80 | // flag for enabling shell, ge: 1.3.5.3 |
| @@ -170,7 +170,7 @@ static void version() · 89 unmodified lines | ||
| 170 | 170 | // name: usage() |
| 171 | 171 | // desc: ... |
| 172 | 172 | //----------------------------------------------------------------------------- |
| 173 | −static void usage() | |
| 173 | +void usage() | |
| 174 | 174 | { |
| 175 | 175 | // (note: optional colon added 1.3.0.0) |
| 176 | 176 | CK_FPRINTF_STDERR( "usage: chuck --[options|commands] [+-=^] file1 file2 file3 ...\n" ); |
| @@ -192,7 +192,7 @@ static void usage() · 15 unmodified lines | ||
| 192 | 192 | // name: get_count() |
| 193 | 193 | // desc: get the thing after -- or - as number |
| 194 | 194 | //----------------------------------------------------------------------------- |
| 195 | −static t_CKBOOL get_count( const char * arg, t_CKUINT * out ) | |
| 195 | +t_CKBOOL get_count( const char * arg, t_CKUINT * out ) | |
| 196 | 196 | { |
| 197 | 197 | // no comment |
| 198 | 198 | if( !strncmp( arg, "--", 2 ) ) arg += 2; |
| @@ -236,41 +236,15 @@ extern "C" void signal_int( int sig_num ) · 37 unmodified lines | ||
| 236 | 236 | //----------------------------------------------------------------------------- |
| 237 | 237 | void global_cleanup() |
| 238 | 238 | { |
| 239 | − // if any Chuck_Systems are left, delete them | |
| 240 | − while( !g_systems.empty() ) | |
| 241 | − { | |
| 242 | − Chuck_System * next_chuck = g_systems.front(); | |
| 243 | − // delete Chuck_System causes a g_systems.remove which modifies the list | |
| 244 | − // and thus g_systems.front() will be different next time | |
| 245 | − delete next_chuck; | |
| 246 | − } | |
| 239 | + SAFE_DELETE( the_chuck ); | |
| 247 | 240 | |
| 248 | 241 | // request bbq shutdown |
| 242 | + // REFACTOR-2017 TODO: Shut down audio system | |
| 249 | 243 | all_stop(); |
| 250 | 244 | |
| 251 | 245 | // request MIDI, etc. files open be closed |
| 252 | 246 | all_detach(); |
| 253 | 247 | |
| 254 | − // shutdown audio | |
| 255 | − if( g_enable_realtime_audio ) | |
| 256 | − { | |
| 257 | − // log | |
| 258 | − EM_log( CK_LOG_SYSTEM, "shutting down real-time audio..." ); | |
| 259 | − | |
| 260 | − g_bbq->digi_out()->cleanup(); | |
| 261 | − g_bbq->digi_in()->cleanup(); | |
| 262 | − g_bbq->shutdown(); | |
| 263 | − // m_audio = FALSE; | |
| 264 | − } | |
| 265 | − // log | |
| 266 | − EM_log( CK_LOG_SYSTEM, "freeing bbq subsystem..." ); | |
| 267 | − // clean up | |
| 268 | − SAFE_DELETE( g_bbq ); | |
| 269 | − | |
| 270 | − if( g_main_thread_quit ) | |
| 271 | − g_main_thread_quit( g_main_thread_bindle ); | |
| 272 | − clear_main_thread_hook(); | |
| 273 | − | |
| 274 | 248 | // wait for the shell, if it is running |
| 275 | 249 | // does the VM reset its priority to normal before exiting? |
| 276 | 250 | if( g_enable_shell ) |
| @@ -279,30 +253,37 @@ void global_cleanup() · 2 unmodified lines | ||
| 279 | 253 | |
| 280 | 254 | // things don't work so good on windows... |
| 281 | 255 | #if !defined(__PLATFORM_WIN32__) || defined(__WINDOWS_PTHREAD__) |
| 282 | − // pthread_kill( g_tid_otf, 2 ); | |
| 283 | − if( g_tid_otf ) pthread_cancel( g_tid_otf ); | |
| 284 | − if( g_tid_whatever ) pthread_cancel( g_tid_whatever ); | |
| 285 | − // if( g_tid_otf ) usleep( 50000 ); | |
| 256 | + // REFACTOR-2017 TODO: Cancel otf, le_cb threads? Does this happen in ~ChucK()? | |
| 257 | +// if( g_tid_otf ) pthread_cancel( g_tid_otf ); | |
| 258 | +// if( g_tid_whatever ) pthread_cancel( g_tid_whatever ); | |
| 286 | 259 | #else |
| 287 | 260 | // close handle |
| 288 | 261 | if( g_tid_otf ) CloseHandle( g_tid_otf ); |
| 289 | 262 | #endif |
| 290 | − | |
| 291 | − // ck_close( g_sock ); | |
| 292 | − | |
| 293 | −#if !defined(__PLATFORM_WIN32__) || defined(__WINDOWS_PTHREAD__) | |
| 294 | − // pthread_join( g_tid_otf, NULL ); | |
| 295 | −#endif | |
| 296 | 263 | } |
| 297 | 264 | |
| 298 | 265 | |
| 299 | 266 | |
| 300 | 267 | |
| 268 | + | |
| 269 | +//----------------------------------------------------------------------------- | |
| 270 | +// name: all_stop() | |
| 271 | +// desc: ... | |
| 272 | +//----------------------------------------------------------------------------- | |
| 273 | +void all_stop() | |
| 274 | +{ | |
| 275 | + // TODO: | |
| 276 | +} | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 301 | 282 | //----------------------------------------------------------------------------- |
| 302 | 283 | // name: init_shell() |
| 303 | 284 | // desc: ... |
| 304 | 285 | //----------------------------------------------------------------------------- |
| 305 | −static t_CKBOOL init_shell( Chuck_Shell * shell, Chuck_Shell_UI * ui, Chuck_VM * vm ) | |
| 286 | +t_CKBOOL init_shell( Chuck_Shell * shell, Chuck_Shell_UI * ui, Chuck_VM * vm ) | |
| 306 | 287 | { |
| 307 | 288 | // initialize shell UI |
| 308 | 289 | if( !ui->init() ) |
| @@ -428,17 +409,6 @@ bool go( int argc, const char ** argv ) · 119 unmodified lines | ||
| 428 | 409 | enable_server = FALSE; |
| 429 | 410 | else if( !strcmp(argv[i], "--callback") ) |
| 430 | 411 | block = FALSE; |
| 431 | − else if( !strcmp( argv[i], "--external-callback" ) ) | |
| 432 | − { | |
| 433 | − // caller will call the Chuck_System->run itself | |
| 434 | − m_initOnly = TRUE; | |
| 435 | − // --external-callback implies --loop: wait for incoming shreds | |
| 436 | − // (don't enable server, which waits on TCP8888) | |
| 437 | − vm_halt = FALSE; | |
| 438 | − enable_server = FALSE; | |
| 439 | − // --external-callback implies --silent: don't engage the main thread hook | |
| 440 | − g_enable_realtime_audio = FALSE; | |
| 441 | − } | |
| 442 | 412 | // blocking removed, ge: 1.3.5.3 |
| 443 | 413 | // else if( !strcmp(argv[i], "--blocking") ) |
| 444 | 414 | // block = TRUE; |