| @@ -53,7 +53,7 @@ void cb( t_CKSAMPLE * in, t_CKSAMPLE * out, t_CKUINT numFrames, · 52 unmodified lines |
| 53 | | 53 | |
| 54 | // C functions | 54 | // C functions |
| 55 | extern "C" void signal_int( int sig_num ); | 55 | extern "C" void signal_int( int sig_num ); |
| 56 | | 56 | extern "C" void signal_pipe( int sig_num ); |
| 57 | | 57 | |
| 58 | | 58 | |
| 59 | | 59 | |
| @@ -67,7 +67,7 @@ CHUCK_THREAD g_tid_shell = 0; · 7 unmodified lines |
| 67 | // default destination host name | 67 | // default destination host name |
| 68 | char g_otf_dest[256] = "127.0.0.1"; | 68 | char g_otf_dest[256] = "127.0.0.1"; |
| 69 | // otf listener port | 69 | // otf listener port |
| 70 | t_CKUINT g_otf_port = 8888; | 70 | t_CKINT g_otf_port = 8888; |
| 71 | | 71 | |
| 72 | // the shell | 72 | // the shell |
| 73 | Chuck_Shell * g_shell = NULL; | 73 | Chuck_Shell * g_shell = NULL; |
| @@ -254,6 +254,27 @@ extern "C" void signal_int( int sig_num ) · 180 unmodified lines |
| 254 | | 254 | |
| 255 | | 255 | |
| 256 | | 256 | |
| | 257 | |
| | 258 | |
| | 259 | |
| | 260 | |
| | 261 | //----------------------------------------------------------------------------- |
| | 262 | // name: signal_pipe() |
| | 263 | // desc: ... |
| | 264 | //----------------------------------------------------------------------------- |
| | 265 | extern "C" void signal_pipe( int sig_num ) |
| | 266 | { |
| | 267 | fprintf( stderr, "[chuck]: sigpipe handled - broken pipe (no connection)...\n" ); |
| | 268 | if( g_sigpipe_mode ) |
| | 269 | { |
| | 270 | all_detach(); |
| | 271 | // exit( 2 ); |
| | 272 | } |
| | 273 | } |
| | 274 | |
| | 275 | |
| | 276 | |
| | 277 | |
| 257 | //----------------------------------------------------------------------------- | 278 | //----------------------------------------------------------------------------- |
| 258 | // name: global_cleanup() | 279 | // name: global_cleanup() |
| 259 | // desc: ... | 280 | // desc: ... |
| @@ -364,6 +385,8 @@ bool go( int argc, const char ** argv ) · 104 unmodified lines |
| 364 | t_CKBOOL update_otf_vm = TRUE; | 385 | t_CKBOOL update_otf_vm = TRUE; |
| 365 | string filename = ""; | 386 | string filename = ""; |
| 366 | vector<string> args; | 387 | vector<string> args; |
| | 388 | Chuck_VM_Code * code = NULL; |
| | 389 | Chuck_VM_Shred * shred = NULL; |
| 367 | | 390 | |
| 368 | // list of search pathes (added 1.3.0.0) | 391 | // list of search pathes (added 1.3.0.0) |
| 369 | std::list<std::string> dl_search_path; | 392 | std::list<std::string> dl_search_path; |
| @@ -791,132 +814,52 @@ bool go( int argc, const char ** argv ) · 421 unmodified lines |
| 791 | the_chuck->setParam( CHUCK_PARAM_VM_ADAPTIVE, adaptive_size ); | 814 | the_chuck->setParam( CHUCK_PARAM_VM_ADAPTIVE, adaptive_size ); |
| 792 | the_chuck->setParam( CHUCK_PARAM_VM_HALT, (t_CKINT)(vm_halt) ); | 815 | the_chuck->setParam( CHUCK_PARAM_VM_HALT, (t_CKINT)(vm_halt) ); |
| 793 | the_chuck->setParam( CHUCK_PARAM_OTF_PORT, g_otf_port ); | 816 | the_chuck->setParam( CHUCK_PARAM_OTF_PORT, g_otf_port ); |
| 794 | the_chuck->setParam( CHUCK_PARAM_LOG_LEVEL, g_loglevel ); | 817 | the_chuck->setParam( CHUCK_PARAM_DUMP_INSTRUCTIONS, (t_CKINT)dump ); |
| 795 | the_chuck->setParam( CHUCK_PARAM_, ); | 818 | the_chuck->setParam( CHUCK_PARAM_AUTO_DEPEND, (t_CKINT)auto_depend ); |
| 796 | the_chuck->setParam( CHUCK_PARAM_, ); | 819 | the_chuck->setParam( CHUCK_PARAM_DEPRECATE_LEVEL, deprecate_level ); |
| 797 | the_chuck->setParam( CHUCK_PARAM_, ); | 820 | the_chuck->setLogLevel( log_level ); |
| 798 | the_chuck->setParam( CHUCK_PARAM_, ); | | |
| 799 | | 821 | |
| 800 | // initialize | 822 | // initialize |
| 801 | | 823 | the_chuck->init(); |
| 802 | | | |
| 803 | | | |
| 804 | //------------------------- VIRTUAL MACHINE SETUP ----------------------------- | | |
| 805 | | | |
| 806 | // allocate the vm - needs the type system | | |
| 807 | vm = m_carrier.vm = m_vmRef = new Chuck_VM; | | |
| 808 | m_carrier.vm->setCarrier( &m_carrier ); | | |
| 809 | | | |
| 810 | // ge: refactor 2015: initialize VM | | |
| 811 | if( !vm->initialize( srate, dac_chans, adc_chans, adaptive_size, vm_halt ) ) | | |
| 812 | { | | |
| 813 | CK_FPRINTF_STDERR( "[chuck]: %s\n", vm->last_error() ); | | |
| 814 | exit( 1 ); | | |
| 815 | } | | |
| 816 | | | |
| 817 | if( update_otf_vm ) | | |
| 818 | { | | |
| 819 | set_otf_vm( vm ); | | |
| 820 | } | | |
| 821 | | | |
| 822 | | 824 | |
| 823 | //--------------------------- AUDIO I/O SETUP --------------------------------- | 825 | //--------------------------- AUDIO I/O SETUP --------------------------------- |
| | 826 | // log |
| | 827 | EM_log( CK_LOG_SYSTEM, "initializing audio I/O..." ); |
| | 828 | // push |
| | 829 | EM_pushlog(); |
| | 830 | // log |
| | 831 | EM_log( CK_LOG_SYSTEM, "probing '%s' audio subsystem...", g_enable_realtime_audio ? "real-time" : "fake-time" ); |
| | 832 | |
| 824 | // initialize audio system | 833 | // initialize audio system |
| 825 | t_CKBOOL retval = ChuckAudio::initialize( numInChannels, numOutChannels, | 834 | t_CKBOOL retval = ChuckAudio::initialize( adc_chans, dac_chans, |
| 826 | srate, bufferSize, numBuffers, cb, NULL, FALSE ); | 835 | srate, buffer_size, num_buffers, cb, (void *)the_chuck, force_srate ); |
| 827 | // check | 836 | // check |
| 828 | if( !retval ) | 837 | if( !retval ) |
| 829 | { | 838 | { |
| 830 | // BADDDD | 839 | EM_log( CK_LOG_SYSTEM, |
| 831 | } | 840 | "cannot initialize audio device (use --silent/-s for non-realtime)" ); |
| 832 | | | |
| 833 | // ge: 1.3.5.3 | | |
| 834 | if( g_bbq == NULL ) { | | |
| 835 | bbq = g_bbq = new BBQ; | | |
| 836 | // set some parameters | | |
| 837 | bbq->set_srate( srate ); | | |
| 838 | bbq->set_bufsize( buffer_size ); | | |
| 839 | bbq->set_numbufs( num_buffers ); | | |
| 840 | bbq->set_inouts( adc, dac ); | | |
| 841 | bbq->set_chans( adc_chans, dac_chans ); | | |
| 842 | | | |
| 843 | // log | | |
| 844 | EM_log( CK_LOG_SYSTEM, "initializing audio I/O..." ); | | |
| 845 | // push | | |
| 846 | EM_pushlog(); | | |
| 847 | // log | | |
| 848 | EM_log( CK_LOG_SYSTEM, "probing '%s' audio subsystem...", g_enable_realtime_audio ? "real-time" : "fake-time" ); | | |
| 849 | | | |
| 850 | // probe / init (this shouldn't start audio yet... | | |
| 851 | // moved here 1.3.1.2; to main ge: 1.3.5.3) | | |
| 852 | if( !bbq->initialize( dac_chans, adc_chans, srate, 16, buffer_size, num_buffers, | | |
| 853 | dac, adc, block, vm, g_enable_realtime_audio, NULL, NULL, force_srate ) ) | | |
| 854 | { | | |
| 855 | EM_log( CK_LOG_SYSTEM, | | |
| 856 | "cannot initialize audio device (use --silent/-s for non-realtime)" ); | | |
| 857 | // pop | | |
| 858 | EM_poplog(); | | |
| 859 | // done | | |
| 860 | exit( 1 ); | | |
| 861 | } | | |
| 862 | | | |
| 863 | // log | | |
| 864 | EM_log( CK_LOG_SYSTEM, "real-time audio: %s", g_enable_realtime_audio ? "YES" : "NO" ); | | |
| 865 | EM_log( CK_LOG_SYSTEM, "mode: %s", block ? "BLOCKING" : "CALLBACK" ); | | |
| 866 | EM_log( CK_LOG_SYSTEM, "sample rate: %ld", srate ); | | |
| 867 | EM_log( CK_LOG_SYSTEM, "buffer size: %ld", buffer_size ); | | |
| 868 | if( g_enable_realtime_audio ) | | |
| 869 | { | | |
| 870 | EM_log( CK_LOG_SYSTEM, "num buffers: %ld", num_buffers ); | | |
| 871 | EM_log( CK_LOG_SYSTEM, "adc: %ld dac: %d", adc, dac ); | | |
| 872 | EM_log( CK_LOG_SYSTEM, "adaptive block processing: %ld", adaptive_size > 1 ? adaptive_size : 0 ); | | |
| 873 | } | | |
| 874 | EM_log( CK_LOG_SYSTEM, "channels in: %ld out: %ld", adc_chans, dac_chans ); | | |
| 875 | | | |
| 876 | // pop | 841 | // pop |
| 877 | EM_poplog(); | 842 | EM_poplog(); |
| 878 | } else { | 843 | // done |
| 879 | bbq = g_bbq; | | |
| 880 | } | | |
| 881 | | | |
| 882 | //------------------------- CHUCK COMPILER SETUP ----------------------------- | | |
| 883 | | | |
| 884 | // if chugin load is off, then clear the lists (added 1.3.0.0 -- TODO: refactor) | | |
| 885 | if( chugin_load == 0 ) | | |
| 886 | { | | |
| 887 | // turn off chugin load | | |
| 888 | dl_search_path.clear(); | | |
| 889 | named_dls.clear(); | | |
| 890 | } | | |
| 891 | | | |
| 892 | // allocate the compiler | | |
| 893 | compiler = m_carrier.compiler = m_compilerRef = new Chuck_Compiler; | | |
| 894 | m_carrier.compiler->setCarrier( &m_carrier ); | | |
| 895 | | | |
| 896 | // initialize the compiler (search_apth and named_dls added 1.3.0.0 -- TODO: refactor) | | |
| 897 | if( !compiler->initialize( dl_search_path, named_dls ) ) | | |
| 898 | { | | |
| 899 | CK_FPRINTF_STDERR( "[chuck]: error initializing compiler...\n" ); | | |
| 900 | exit( 1 ); | 844 | exit( 1 ); |
| 901 | } | 845 | } |
| 902 | // enable dump | | |
| 903 | compiler->emitter->dump = dump; | | |
| 904 | // set auto depend | | |
| 905 | compiler->set_auto_depend( auto_depend ); | | |
| 906 | | 846 | |
| 907 | if( update_otf_vm ) | 847 | // log |
| 908 | { | 848 | EM_log( CK_LOG_SYSTEM, "real-time audio: %s", g_enable_realtime_audio ? "YES" : "NO" ); |
| 909 | // also update otf compiler | 849 | EM_log( CK_LOG_SYSTEM, "mode: %s", block ? "BLOCKING" : "CALLBACK" ); |
| 910 | set_otf_compiler( compiler ); | 850 | EM_log( CK_LOG_SYSTEM, "sample rate: %ld", srate ); |
| 911 | } | 851 | EM_log( CK_LOG_SYSTEM, "buffer size: %ld", buffer_size ); |
| 912 | | 852 | if( g_enable_realtime_audio ) |
| 913 | // vm synthesis subsystem - needs the type system | | |
| 914 | if( !vm->initialize_synthesis( ) ) | | |
| 915 | { | 853 | { |
| 916 | CK_FPRINTF_STDERR( "[chuck]: %s\n", vm->last_error() ); | 854 | EM_log( CK_LOG_SYSTEM, "num buffers: %ld", num_buffers ); |
| 917 | exit( 1 ); | 855 | EM_log( CK_LOG_SYSTEM, "adc: %ld dac: %d", adc, dac ); |
| | 856 | EM_log( CK_LOG_SYSTEM, "adaptive block processing: %ld", adaptive_size > 1 ? adaptive_size : 0 ); |
| 918 | } | 857 | } |
| | 858 | EM_log( CK_LOG_SYSTEM, "channels in: %ld out: %ld", adc_chans, dac_chans ); |
| 919 | | 859 | |
| | 860 | // pop |
| | 861 | EM_poplog(); |
| | 862 | |
| 920 | #ifndef __ALTER_HID__ | 863 | #ifndef __ALTER_HID__ |
| 921 | // pre-load hid | 864 | // pre-load hid |
| 922 | if( load_hid ) HidInManager::init(); | 865 | if( load_hid ) HidInManager::init(); |
| @@ -935,82 +878,13 @@ bool go( int argc, const char ** argv ) · 12 unmodified lines |
| 935 | // instantiate | 878 | // instantiate |
| 936 | g_shell = new Chuck_Shell; | 879 | g_shell = new Chuck_Shell; |
| 937 | // initialize | 880 | // initialize |
| 938 | if( !init_shell( g_shell, new Chuck_Console, vm ) ) | 881 | if( !init_shell( g_shell, new Chuck_Console(), the_chuck->vm() ) ) |
| 939 | exit( 1 ); | 882 | exit( 1 ); |
| 940 | } | 883 | } |
| 941 | | 884 | |
| 942 | // set deprecate | | |
| 943 | compiler->env()->deprecate_level = deprecate_level; | | |
| 944 | | | |
| 945 | // reset count | 885 | // reset count |
| 946 | count = 1; | 886 | count = 1; |
| 947 | | 887 | |
| 948 | // figure out current working directory (added 1.3.0.0) | | |
| 949 | std::string cwd; | | |
| 950 | { | | |
| 951 | char cstr_cwd[MAXPATHLEN]; | | |
| 952 | if( getcwd(cstr_cwd, MAXPATHLEN) == NULL ) | | |
| 953 | { | | |
| 954 | // uh... | | |
| 955 | EM_log( CK_LOG_SEVERE, "error: unable to determine current working directory!" ); | | |
| 956 | } | | |
| 957 | else | | |
| 958 | { | | |
| 959 | cwd = std::string(cstr_cwd); | | |
| 960 | cwd = normalize_directory_separator(cwd) + "/"; | | |
| 961 | } | | |
| 962 | } | | |
| 963 | | | |
| 964 | // whether or not chug should be enabled (added 1.3.0.0) | | |
| 965 | if( chugin_load ) | | |
| 966 | { | | |
| 967 | // log | | |
| 968 | EM_log( CK_LOG_SEVERE, "pre-loading ChucK libs..." ); | | |
| 969 | EM_pushlog(); | | |
| 970 | | | |
| 971 | // iterate over list of ck files that the compiler found | | |
| 972 | for( std::list<std::string>::iterator j = compiler->m_cklibs_to_preload.begin(); | | |
| 973 | j != compiler->m_cklibs_to_preload.end(); j++) | | |
| 974 | { | | |
| 975 | // the filename | | |
| 976 | std::string filename = *j; | | |
| 977 | | | |
| 978 | // log | | |
| 979 | EM_log( CK_LOG_SEVERE, "preloading '%s'...", filename.c_str() ); | | |
| 980 | // push indent | | |
| 981 | EM_pushlog(); | | |
| 982 | | | |
| 983 | // SPENCERTODO: what to do for full path | | |
| 984 | std::string full_path = filename; | | |
| 985 | | | |
| 986 | // parse, type-check, and emit | | |
| 987 | if( compiler->go( filename, NULL, NULL, full_path ) ) | | |
| 988 | { | | |
| 989 | // TODO: how to compilation handle? | | |
| 990 | //return 1; | | |
| 991 | | | |
| 992 | // get the code | | |
| 993 | code = compiler->output(); | | |
| 994 | // name it - TODO? | | |
| 995 | // code->name += string(argv[i]); | | |
| 996 | | | |
| 997 | // spork it | | |
| 998 | shred = vm->spork( code, NULL, TRUE ); | | |
| 999 | } | | |
| 1000 | | | |
| 1001 | // pop indent | | |
| 1002 | EM_poplog(); | | |
| 1003 | } | | |
| 1004 | | | |
| 1005 | // clear the list of chuck files to preload | | |
| 1006 | compiler->m_cklibs_to_preload.clear(); | | |
| 1007 | | | |
| 1008 | // pop log | | |
| 1009 | EM_poplog(); | | |
| 1010 | } | | |
| 1011 | | | |
| 1012 | compiler->env()->load_user_namespace(); | | |
| 1013 | | | |
| 1014 | // log | 888 | // log |
| 1015 | EM_log( CK_LOG_SEVERE, "starting compilation..." ); | 889 | EM_log( CK_LOG_SEVERE, "starting compilation..." ); |
| 1016 | // push indent | 890 | // push indent |
| @@ -1026,9 +900,9 @@ bool go( int argc, const char ** argv ) · 9 unmodified lines |
| 1026 | if( argv[i][0] == '-' || argv[i][0] == '+' ) | 900 | if( argv[i][0] == '-' || argv[i][0] == '+' ) |
| 1027 | { | 901 | { |
| 1028 | if( !strcmp(argv[i], "--dump") || !strcmp(argv[i], "+d" ) ) | 902 | if( !strcmp(argv[i], "--dump") || !strcmp(argv[i], "+d" ) ) |
| 1029 | compiler->emitter->dump = TRUE; | 903 | the_chuck->compiler()->emitter->dump = TRUE; |
| 1030 | else if( !strcmp(argv[i], "--nodump") || !strcmp(argv[i], "-d" ) ) | 904 | else if( !strcmp(argv[i], "--nodump") || !strcmp(argv[i], "-d" ) ) |
| 1031 | compiler->emitter->dump = FALSE; | 905 | the_chuck->compiler()->emitter->dump = FALSE; |
| 1032 | else | 906 | else |
| 1033 | get_count( argv[i], &count ); | 907 | get_count( argv[i], &count ); |
| 1034 | | 908 | |
| @@ -1036,7 +910,7 @@ bool go( int argc, const char ** argv ) · 1 unmodified line |
| 1036 | } | 910 | } |
| 1037 | | 911 | |
| 1038 | // compile it! | 912 | // compile it! |
| 1039 | compileFile( argv[i], "", count ); | 913 | the_chuck->compileFile( argv[i], "", count ); |
| 1040 | | 914 | |
| 1041 | // reset count | 915 | // reset count |
| 1042 | count = 1; | 916 | count = 1; |
| @@ -1045,56 +919,22 @@ bool go( int argc, const char ** argv ) · 2 unmodified lines |
| 1045 | // pop indent | 919 | // pop indent |
| 1046 | EM_poplog(); | 920 | EM_poplog(); |
| 1047 | | 921 | |
| 1048 | // reset the parser | | |
| 1049 | reset_parse(); | | |
| 1050 | | | |
| 1051 | // boost priority | 922 | // boost priority |
| 1052 | if( Chuck_VM::our_priority != 0x7fffffff ) | 923 | if( XThreadUtil::our_priority != 0x7fffffff ) |
| 1053 | { | 924 | { |
| 1054 | // try | 925 | // try |
| 1055 | if( !Chuck_VM::set_priority( Chuck_VM::our_priority, vm ) ) | 926 | if( !XThreadUtil::set_priority( XThreadUtil::our_priority ) ) |
| 1056 | { | 927 | { |
| 1057 | // error | 928 | // error |
| 1058 | CK_FPRINTF_STDERR( "[chuck]: %s\n", vm->last_error() ); | 929 | CK_FPRINTF_STDERR( "[chuck]: error setting thread priority...\n" ); |
| 1059 | exit( 1 ); | 930 | exit( 1 ); |
| 1060 | } | 931 | } |
| 1061 | } | 932 | } |
| 1062 | | 933 | |
| 1063 | | 934 | |
| 1064 | //----------------------- ON-THE-FLY SERVER SETUP ----------------------------- | 935 | //----------------------- SHELL SETUP ----------------------------- |
| 1065 | | | |
| 1066 | // server | | |
| 1067 | if( enable_server ) | | |
| 1068 | { | | |
| 1069 | #ifndef __DISABLE_OTF_SERVER__ | | |
| 1070 | // log | | |
| 1071 | EM_log( CK_LOG_SYSTEM, "starting listener on port: %d...", g_port ); | | |
| 1072 | | | |
| 1073 | // start tcp server | | |
| 1074 | g_sock = ck_tcp_create( 1 ); | | |
| 1075 | if( !g_sock || !ck_bind( g_sock, g_port ) || !ck_listen( g_sock, 10 ) ) | | |
| 1076 | { | | |
| 1077 | CK_FPRINTF_STDERR( "[chuck]: cannot bind to tcp port %li...\n", g_port ); | | |
| 1078 | ck_close( g_sock ); | | |
| 1079 | g_sock = NULL; | | |
| 1080 | } | | |
| 1081 | else | | |
| 1082 | { | | |
| 1083 | #if !defined(__PLATFORM_WIN32__) || defined(__WINDOWS_PTHREAD__) | | |
| 1084 | pthread_create( &g_tid_otf, NULL, otf_cb, NULL ); | | |
| 1085 | #else | | |
| 1086 | g_tid_otf = CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)otf_cb, NULL, 0, 0 ); | | |
| 1087 | #endif | | |
| 1088 | } | | |
| 1089 | #endif // __DISABLE_OTF_SERVER__ | | |
| 1090 | } | | |
| 1091 | else | | |
| 1092 | { | | |
| 1093 | // log | | |
| 1094 | EM_log( CK_LOG_SYSTEM, "OTF server/listener: OFF" ); | | |
| 1095 | } | | |
| 1096 | | 936 | |
| 1097 | // start shell on separate thread | 937 | // start shell on separate thread | REFACTOR-2017: per-VM?!? |
| 1098 | if( g_enable_shell ) | 938 | if( g_enable_shell ) |
| 1099 | { | 939 | { |
| 1100 | #if !defined(__PLATFORM_WIN32__) || defined(__WINDOWS_PTHREAD__) | 940 | #if !defined(__PLATFORM_WIN32__) || defined(__WINDOWS_PTHREAD__) |
| @@ -1104,7 +944,6 @@ bool go( int argc, const char ** argv ) · 3 unmodified lines |
| 1104 | #endif | 944 | #endif |
| 1105 | } | 945 | } |
| 1106 | | 946 | |
| 1107 | | | |
| 1108 | //-------------------------- MAIN CHUCK LOOP!!! ----------------------------- | 947 | //-------------------------- MAIN CHUCK LOOP!!! ----------------------------- |
| 1109 | | 948 | |
| 1110 | // log | 949 | // log |
| @@ -1112,65 +951,14 @@ bool go( int argc, const char ** argv ) · 1 unmodified line |
| 1112 | // push indent | 951 | // push indent |
| 1113 | EM_pushlog(); | 952 | EM_pushlog(); |
| 1114 | | 953 | |
| 1115 | // set run state | 954 | // start it! |
| 1116 | vm->start(); | 955 | the_chuck->start(); |
| 1117 | | | |
| 1118 | EM_log( CK_LOG_SEVERE, "initializing audio buffers..." ); | | |
| 1119 | if( !bbq->digi_out()->initialize( ) ) | | |
| 1120 | { | | |
| 1121 | EM_log( CK_LOG_SYSTEM, | | |
| 1122 | "cannot open audio output (use --silent/-s)" ); | | |
| 1123 | exit(1); | | |
| 1124 | } | | |
| 1125 | | | |
| 1126 | // initialize input | | |
| 1127 | bbq->digi_in()->initialize( ); | | |
| 1128 | | 956 | |
| 1129 | // log | 957 | // log |
| 1130 | EM_log( CK_LOG_SEVERE, "virtual machine running..." ); | 958 | EM_log( CK_LOG_SEVERE, "virtual machine running..." ); |
| 1131 | // pop indent | 959 | // pop indent |
| 1132 | EM_poplog(); | 960 | EM_poplog(); |
| 1133 | | 961 | |
| 1134 | // NOTE: non-blocking callback only, ge: 1.3.5.3 | | |
| 1135 | | | |
| 1136 | // compute shreds before first sample | | |
| 1137 | if( !vm->compute() ) | | |
| 1138 | { | | |
| 1139 | // done, 1.3.5.3 | | |
| 1140 | vm->stop(); | | |
| 1141 | // log | | |
| 1142 | EM_log( CK_LOG_SYSTEM, "virtual machine stopped..." ); | | |
| 1143 | } | | |
| 1144 | | | |
| 1145 | // check client mode | | |
| 1146 | if( clientMode ) | | |
| 1147 | { | | |
| 1148 | // done! | | |
| 1149 | return TRUE; | | |
| 1150 | } | | |
| 1151 | | | |
| 1152 | // start audio | | |
| 1153 | if( !audio_started ) | | |
| 1154 | { | | |
| 1155 | // audio | | |
| 1156 | if( !audio_started && g_enable_realtime_audio ) | | |
| 1157 | { | | |
| 1158 | EM_log( CK_LOG_SEVERE, "starting real-time audio..." ); | | |
| 1159 | bbq->digi_out()->start(); | | |
| 1160 | bbq->digi_in()->start(); | | |
| 1161 | } | | |
| 1162 | | | |
| 1163 | // set the flag to true to avoid entering this function | | |
| 1164 | audio_started = TRUE; | | |
| 1165 | } | | |
| 1166 | | | |
| 1167 | | | |
| 1168 | // Don't run audio callback and shut down if we only wanted to init here | | |
| 1169 | if( m_initOnly ) { | | |
| 1170 | return TRUE; | | |
| 1171 | } | | |
| 1172 | | | |
| 1173 | | | |
| 1174 | // silent mode buffers | 962 | // silent mode buffers |
| 1175 | SAMPLE * input = new SAMPLE[buffer_size*adc_chans]; | 963 | SAMPLE * input = new SAMPLE[buffer_size*adc_chans]; |
| 1176 | SAMPLE * output = new SAMPLE[buffer_size*dac_chans]; | 964 | SAMPLE * output = new SAMPLE[buffer_size*dac_chans]; |
| @@ -1179,25 +967,20 @@ bool go( int argc, const char ** argv ) · 2 unmodified lines |
| 1179 | memset( output, 0, sizeof(SAMPLE)*buffer_size*dac_chans ); | 967 | memset( output, 0, sizeof(SAMPLE)*buffer_size*dac_chans ); |
| 1180 | | 968 | |
| 1181 | // wait | 969 | // wait |
| 1182 | while( vm->running() ) | 970 | while( the_chuck->vm()->running() ) |
| 1183 | { | 971 | { |
| 1184 | // real-time audio | 972 | // real-time audio |
| 1185 | if( g_enable_realtime_audio ) | 973 | if( g_enable_realtime_audio ) |
| 1186 | { | 974 | { |
| 1187 | if( g_main_thread_hook && g_main_thread_quit ) | 975 | usleep( 10000 ); |
| 1188 | g_main_thread_hook( g_main_thread_bindle ); | | |
| 1189 | else | | |
| 1190 | usleep( 1000 ); | | |
| 1191 | } | 976 | } |
| 1192 | else // silent mode | 977 | else // silent mode |
| 1193 | { | 978 | { |
| 1194 | // keep running as fast as possible | 979 | // keep running as fast as possible |
| 1195 | this->run( input, output, buffer_size ); | 980 | the_chuck->run( input, output, buffer_size ); |
| 1196 | } | 981 | } |
| 1197 | } | 982 | } |
| 1198 | | 983 | |
| 1199 | // shutdown | | |
| 1200 | clientShutdown(); | | |
| 1201 | | | |
| 1202 | return TRUE; | 984 | return TRUE; |
| 1203 | } | 985 | } |
| | 986 | |