Example #1
0
t_CKBOOL server_handle_update_info( AudiclePak * pack )
{
    EM_log( CK_LOG_INFO, "server about to handle update info for user %d", pack->user );

    CoCoServer * server = &(CoAudicle::instance()->coco_server); 
    CoCoSession * session = server->get( pack->user );
    if( session != NULL )
    {
        EM_log( CK_LOG_INFO, "server handled update info for user %d", pack->user );
        session->m_update_socket = pack->sender;
        
        // inform user of other users for that server
        AudiclePak packet;
        packet.type = HEY_USER_ADD;
        packet.alloc( 100 );
        packet.length = 100;
        packet.user = session->m_user_id;
        map <t_CKUINT, CoCoSession *>::iterator it;
        for( it = server->m_sessions.begin(); it != server->m_sessions.end(); it++ )
        {
            *(t_CKUINT *)packet.data = (*it).first;
            strcpy( packet.data + 4, (*it).second->m_user_name.c_str() );
            strcpy( packet.data + 36, (*it).second->m_host_name.c_str() );
            session->m_update_socket->send( &packet );
        }

        // set state
        packet.type = UPDATE_DUDE;
        CoCoUserState state;
        state.m_location = Point3D( ( 2.0 * ::rand() / (t_CKFLOAT)RAND_MAX - 1.0 ), 0,
                                    ( 2.0 * ::rand() / (t_CKFLOAT)RAND_MAX - 1.0 ) );
        state.m_orientation = Vec3D( 0, 0, -1 );
        state.m_color = Color4D( (::rand() / (t_CKFLOAT)RAND_MAX), (::rand() / (t_CKFLOAT)RAND_MAX), (::rand() / (t_CKFLOAT)RAND_MAX), 1.0 );
        state.m_home = Point3D( 0, 0, 0 );
        strcpy( state.m_msg, "hey" );
        packet.alloc( sizeof(state) );
        packet.length = sizeof(state);
        memcpy( packet.data, &state, sizeof(state) );
        
        CoAudicle::instance()->coco_server.broadcast( &packet );
        
        // start audio
        CoAudicle::instance()->audio_server.add( session->m_ip.c_str(), CO_AUDIO_PORT );
    }
    else
    {
        EM_log( CK_LOG_INFO, "server not coping well" );
        return FALSE;
    }

    return TRUE;
}
Example #2
0
void ConsoleWindow::addAlert ( std::string mesg, Color4D col , double b , double e )
{ 
    // log
    EM_log( CK_LOG_INFO, "(audicle) add alert box..." );
    EM_pushlog();
    EM_log( CK_LOG_INFO, "(audicle) text: %s", mesg.c_str() );
    EM_log( CK_LOG_INFO, "(audicle) time: %.3f, %.3f", b, e );
    EM_poplog();

    AlertBox * a = new AlertBox(mesg);
    a->setColor( col );
    a->setTime( b, e );
    _alerts.push_back( a ) ;
}
Example #3
0
void
CodeWindow::reshape() { 

    DisplayWindow::reshape();
    
    EM_log( CK_LOG_FINE, "(audicle) CodeWindow::reshape..." );
    
    //test button
    _testButton.moveto( _titleBox.right() + _marginSize, _titleBox.top()  );
    _testButton.resize( _titleBox.h(), _titleBox.h());

    //compile button
    _compileButton.moveto( _testButton.right() + _marginSize, _testButton.top() );
    _compileButton.resize( _titleBox.h(), _titleBox.h());

    //spork button
    _sporkButton.moveto( _compileButton.right() + _marginSize, _compileButton.top() );
    _sporkButton.resize( _titleBox.h(), _titleBox.h());
    
    UIRectangle bW = _baseWindow;

    _revisionBox.moveto( bW.w() , - _titleBox.h() * 0.5 );
    _revisionBox.resize( _titleBox.h(), bW.h() - _titleBox.h() * 0.5 );
    

}
Example #4
0
//-----------------------------------------------------------------------------
// name: stop_vm()
// desc: ...
//-----------------------------------------------------------------------------
t_CKBOOL miniAudicle::stop_vm()
{
    if( status_bufs )
    {
        for( size_t i = 0; i < num_status_bufs; i++ )
        {
            if( status_bufs[i] )
            {
                delete status_bufs[i];
                status_bufs[i] = NULL;
            }
        }

        delete[] status_bufs;
        status_bufs = NULL;
    }
    
    // if it's there
    if( m_chuck )
    {
        EM_log( CK_LOG_SYSTEM, "stopping chuck virtual machine..." );
        
        ChuckAudio::stop();
        ChuckAudio::shutdown();
        
        ChucK::globalCleanup();
        
        SAFE_DELETE(m_chuck);
        
        compiler = NULL;
        vm = NULL;
    }

    return TRUE;
}
Example #5
0
//-----------------------------------------------------------------------------
// name: init_class_groove()
// desc: ...
//-----------------------------------------------------------------------------
t_CKBOOL init_class_groove( Chuck_Env * env )
{
    Chuck_DL_Func * func = NULL;
    Chuck_Value * value = NULL;

    // log
    EM_log( CK_LOG_INFO, "class 'AudicleGroove'" );

    // import
    if( !type_engine_import_class_begin( env, "AudicleGroove", "Object",
                                         env->global(), groove_ctor ) )
        return FALSE;

    // add pane()
    func = make_new_sfun( "AudiclePane", "pane", groove_pane );
    if( !type_engine_import_sfun( env, func ) ) goto error;

    // wrap up
    type_engine_import_class_end( env );

    return TRUE;

error:

    // wrap up
    type_engine_import_class_end( env );

    return FALSE;
}
Example #6
0
//-----------------------------------------------------------------------------
// name: render_view()
// desc: ...
//-----------------------------------------------------------------------------
void AudicleFaceTnT::render_view( )
{
    EM_log( CK_LOG_FINEST, "AudicleFaceTNT: rendering view..." );

    // set the matrix mode to project
    glMatrixMode( GL_PROJECTION );
    // load the identity matrix
    // load the identity matrix XXX
    // this is handled by AudicleWindow, in order to set up pick matrices...
    // you can assume that LoadIdentity has been called already
    //glLoadIdentity( ); 
    // create the viewing frustum
    AudicleWindow * aW = AudicleWindow::main();    
    m_aspt = aW->m_hsize / aW->m_vsize;

    glOrtho(-m_aspt, m_aspt, -1.0, 1.0 , -10, 10 );
    // set the matrix mode to modelview
    glMatrixMode( GL_MODELVIEW );
    // load the identity matrix
    glLoadIdentity( );
    // position the view point

    gluLookAt( 0.0f, 3.5f * sin( m_eye_y ), 3.5f * cos( m_eye_y ), 
               0.0f, 0.0f, 0.0f, 
               0.0f, ( cos( m_eye_y ) < 0 ? -1.0f : 1.0f ), 0.0f );

    // set the position of the lights
    glLightfv( GL_LIGHT0, GL_POSITION, m_light0_pos );
    glLightfv( GL_LIGHT1, GL_POSITION, m_light1_pos );
}
Example #7
0
//-----------------------------------------------------------------------------
// name: all_detach()
// desc: called during cleanup to close all open file handles
//-----------------------------------------------------------------------------
extern "C" void all_detach()
{
    // log
    EM_log( CK_LOG_INFO, "detaching all resources..." );
    // push
    EM_pushlog();
    // close stk file handles
    stk_detach( 0, NULL );
#ifndef __DISABLE_MIDI__
    // close midi file handles
    midirw_detach();
#endif // __DISABLE_MIDI__
#ifndef __DISABLE_KBHIT__
    // shutdown kb loop
    KBHitManager::shutdown();
#endif // __DISABLE_KBHIT__
#ifndef __ALTER_HID__
    // shutdown HID
    HidInManager::cleanup();
#endif // __ALTER_HID__
    
    Chuck_IO_Serial::shutdown();
    // pop
    EM_poplog();
}
Example #8
0
TextContent::TextContent() :
    WindowContent(),
    _leading(0.06),
    _fontScale(0.04),
    _fontAspect(1.0),
    _fontWeight(1),
    _windowLinePos(0),
    _windowLineSpan(0),
    _magicCharPos(0),
    _title("buffer:"),
    _canvasDirty(true),
    _parsed(NULL),
    _parse_tree(NULL),
    _parse_edit_point(0),
    _viewportDirty(true)
{ 
    EM_log( CK_LOG_FINER, "(audicle) TextContent ctor..." );
    _loc.line = 0;
    _loc.chr = 0;
    _markLoc = _loc;
    _wSpace  = bufferFont->length("m");
    _wTab    = _wSpace * 4;
    _viewport.setScale( 1.1, 1.1 );
    _fontColor = Color4D ( 0,0,0,0.95 );
    _buf = new_buffer();
    
    //should be in CodeRevision
}
Example #9
0
//-----------------------------------------------------------------------------
// name: render_pre()
// desc: ...
//-----------------------------------------------------------------------------
void AudicleFaceTnT::render_pre()
{
    // log
    EM_log( CK_LOG_FINEST, "AudicleFaceTNT: pre-render..." );
    glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );

    AudicleFace::render_pre();

    glPushAttrib( GL_LIGHTING_BIT | GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT
                  | GL_POINT_BIT  | GL_LINE_BIT ); 

    // enable depth
    glDisable( GL_DEPTH_TEST );

    glEnable( GL_BLEND ) ;

    glBlendFunc ( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );

    if ( AudicleWindow::main()->m_antialiased ) { 
        glHint   (GL_POINT_SMOOTH_HINT, GL_NICEST );
        glHint   (GL_LINE_SMOOTH_HINT, GL_NICEST);
        glEnable (GL_POINT_SMOOTH);
        glEnable (GL_LINE_SMOOTH);
    }
    else { 
        glDisable (GL_POINT_SMOOTH);
        glDisable (GL_LINE_SMOOTH);
    }
}
Example #10
0
bool
CodeWindowHandler::handleKey(const InputEvent &e) { 
    CodeWindow * d = NULL;
    DisplayWindow * dd = NULL;
    //wm set the event before this was called. 
    InputState * wimp = _wm->wimp();

    bool ret = false;

    if (wimp->ctrlDown ) {

        ret = true;
        switch ( wimp->lastKey ) { 

        case KEY_CTRL_U:
            _wm->arrangeWindows();
            break;
        case KEY_CTRL_N:
            d = (CodeWindow*)new_window();
            d->current()->setBuffer( d->getTextContent()->getBuf() );
            d->moveto(wimp->lastPos[0], wimp->lastPos[1] );
            _wm->addWindow(d);
            _wm->setTopWindow(d);
            
            break;
        case KEY_CTRL_F:
        case KEY_CTRL_O:    //create new window and pass the call down...
            if ( !_wm->top()) { 
                DirScanner dr;
                fileData * f = dr.openFileDialog();
                fileData * nf = f;
                int c = 0;
                while ( nf ) { 
                    EM_log( CK_LOG_INFO, "(audicle) opening file %d : %s", c, nf->fileName.c_str() );

                    d = (CodeWindow*)new_window(); //new codewindow, new textwindow, empty buffer
                    d->getTextContent()->open( (char*)nf->fileName.c_str());
                    d->current()->setBuffer( d->getTextContent()->getBuf() );

                    Point2D np = wimp->lastPos + Point2D(0.03, -0.03 ) * (double)c;
                    d->moveto(np[0], np[1] );
                    d->resize( max ( 2.25, d->base()->w() ) , max ( 2.5, d->base()->h() )  );
                    _wm->addWindow(d);
                    _wm->setTopWindow(d);

                    c++;
                    nf = nf->next;
                }

            }
            else ret = false;
            break;
        default:
            ret = false;
        }
    }
    return ret;

}
Example #11
0
//-----------------------------------------------------------------------------
// name: render_post()
// desc: ...
//-----------------------------------------------------------------------------
void AudicleFaceTnT::render_post()
{
    EM_log( CK_LOG_FINEST, "AudicleFaceTNT: post-render..." );

    glPopAttrib();

    AudicleFace::render_post();
}
Example #12
0
ClientCodingWindow::ClientCodingWindow( ) :
window_id(0) 
{ 
    initShapes();
    EM_log(CK_LOG_SYSTEM, "client code win constructor" );
    _content = _textcontent = new ClientTextContent();
    _content->containerDirty() = true;
}
Example #13
0
bool
TextWindowHandler::handleKey(const InputEvent &e) { 

    DisplayWindow * d;

    e.fprint( stderr );
    InputState * wimp = _wm->wimp();
    wimp->setEvent(e);

    bool ret = false; 
    if (wimp->ctrlDown ) {

        bool ret = true;
        switch ( wimp->lastKey ) {
        case KEY_CTRL_N:
            fprintf(stderr,"Make new window\n");
            d = new DisplayWindow();
            d->setContent(new TextContent());
            _wm->addWindow(d);
            d->moveto(wimp->lastPos[0], wimp->lastPos[1] );
            break;
        case KEY_CTRL_F:
        case KEY_CTRL_O:    //create new window and pass the call down...
            if ( !_wm->top()) { 
                DirScanner dr;
                fileData * f = dr.openFileDialog();
                fileData * nf = f;
                int c = 0;
                while ( nf ) { 
                    EM_log( CK_LOG_INFO, "(audicle) opening file %d : %s", c, nf->fileName.c_str());

                    d = new DisplayWindow();

                    TextContent * ntext = new TextContent();
                    ntext->open((char*)nf->fileName.c_str());
                    d->setContent(ntext);

                    Point2D np = wimp->lastPos + Point2D(0.03, -0.03 ) * (double)c; 
                    d->moveto(np[0], np[1] );
                    _wm->addWindow(d);
                    _wm->setTopWindow(d);

                    c++;
                    nf = nf->next;
                }

            }
            break;
        default:
            ret = false;
        }
    }

    return ret;

}
Example #14
0
//-----------------------------------------------------------------------------
// name: ~miniAudicle()
// desc: ...
//-----------------------------------------------------------------------------
miniAudicle::~miniAudicle()
{
    if( vm_on )
        stop_vm();

    delete class_names;
    
    // log
    EM_log( CK_LOG_INFO, "miniAudicle instance destroyed..." );
}
Example #15
0
void
CodeRevision::removeShred( int procid ) { 
    int ind = findShred ( procid );
    if ( ind >= 0 ) { 
        _shreds.erase (_shreds.begin() + ind );
    }
	else { 
		EM_log( CK_LOG_WARNING, "CodeRevision::removeShred: attempting to remove proc (%d) not found!", procid ); 
	}
}
Example #16
0
//-----------------------------------------------------------------------------
// name: init_class_dude()
// desc: ...
//-----------------------------------------------------------------------------
t_CKBOOL init_class_dude( Chuck_Env * env )
{
    Chuck_DL_Func * func = NULL;
    Chuck_Value * value = NULL;

    // log
    EM_log( CK_LOG_INFO, "class 'AudicleDude'" );

    // import
    if( !type_engine_import_class_begin( env, "AudicleDude", "Object",
                                         env->global(), dude_ctor ) )
        return FALSE;

    // add member
    dude_offset_data = type_engine_import_mvar( env, "int", "@data", FALSE );
    if( dude_offset_data == CK_INVALID_OFFSET ) goto error;

    // add jump()
    func = make_new_mfun( "void", "jump", dude_jump );
    if( !type_engine_import_mfun( env, func ) ) goto error;

    // add headbang()
    func = make_new_mfun( "void", "headbang", dude_headbang );
    if( !type_engine_import_mfun( env, func ) ) goto error;

    // add leanback()
    func = make_new_mfun( "void", "leanback", dude_leanback );
    if( !type_engine_import_mfun( env, func ) ) goto error;

    // add armsup()
    func = make_new_mfun( "int", "armsup", dude_armsup );
    if( !type_engine_import_mfun( env, func ) ) goto error;

    // add setpos()
    func = make_new_mfun( "void", "pos", dude_pos );
    func->add_arg( "float", "x" );
    func->add_arg( "float", "y" );
    func->add_arg( "float", "z" );
    if( !type_engine_import_mfun( env, func ) ) goto error;

    // end the class import
    type_engine_import_class_end( env );

    // keep the type around
    g_dude_type = type_engine_find_type( env, new_id_list("AudicleDude", 0 ) );

    return TRUE;

error:

    // end the class import
    type_engine_import_class_end( env );

    return FALSE;
}
Example #17
0
//-----------------------------------------------------------------------------
// name: render()
// desc: ...
//-----------------------------------------------------------------------------
t_CKUINT AudicleFaceTnT::render( void * d )
{
    EM_log( CK_LOG_FINEST, "AudicleFaceTNT: rendering objects..." );
    EM_pushlog();

    int i;
    map<Shred_Stat *, Shred_Stat *>::iterator iter;

    Chuck_Stats::instance()->get_shreds( m_shreds, m_done );
    Shred_Stat * stat = NULL;    

    m_now = the()->shreduler()->now_system;
    m_earliest = m_now - m_window; // set a now time for the check_active test

    // log
    EM_log( CK_LOG_FINEST, "num shreds: %d", m_shreds.size() );

    // get activations
    m_drawing_active_set = true; //hack
    for( i = 0; i < m_shreds.size(); i++ )
        fetch_shred_activations ( m_shreds[i] );

    m_drawing_active_set = false; //hack
    for( iter = m_done.begin(); iter != m_done.end(); iter++ )
    {
        stat = (*iter).second;
        fetch_shred_activations ( stat );
    }

    m_now = the()->shreduler()->now_system; 
    m_earliest = m_now - m_window; 

    EM_poplog();

    if ( m_show_mode == SHOW_TIMING_HISTORY )
        return render_timing_history();
    else
        return render_cycle_heatmap ();
        

    return 0;
}
Example #18
0
CodeWindow::CodeWindow() :
    DisplayWindow(), 
    _current(NULL),
    _textcontent(new TextContent())
    { 
        EM_log( CK_LOG_FINER, "(audicle) CodeWindow base ctor...");
        initShapes();
        //a new window
        _content = _textcontent;
        setRevision(new CodeRevision());
    }
Example #19
0
t_CKBOOL client_send_update_info( AudicleClient * source, t_CKUINT user )
{
    AudiclePak packit;

    // log
    EM_log( CK_LOG_INFO, "preparing update info packet (follow up to join request)..." );
    // push indent
    EM_pushlog();

    // set type
    //packit.type = ?;
    // set user to appropriate value
    packit.user = user;
    // set server to ""
    strcpy( packit.server, "" );

    // allocate payload
    packit.alloc( sizeof( t_CKUINT ) );
    
    // log
    EM_log( CK_LOG_INFO, "user id: %d", packit.user );

    // set length
    packit.length = 0;
    // log
    EM_log( CK_LOG_INFO, "packet length: %d", packit.length );

    // pop indent
    EM_poplog();

    EM_log( CK_LOG_INFO, "sending update packet..." );

    // send the request
    if( !source->m_update_socket.send( &packit ) )
    {
        EM_error3( "cannot send update packet! oh no!" );
        return FALSE;
    }

    return TRUE;    
}
Example #20
0
ClientCodingWindow::ClientCodingWindow ( ClientCodeBuffer * b ) : 
CodeWindow(b),
window_id(0) 
{
    EM_log(CK_LOG_SYSTEM, "client win w buffer constructor" );
    initShapes();
    //need a TextContent constructor with buf arguments
    _content = _textcontent = new ClientTextContent();
    _content->containerDirty() = true;
    //create for existing revision
    setClientCodeBuffer(b);
}
Example #21
0
//-----------------------------------------------------------------------------
// name: init_class_pane()
// desc: ...
//-----------------------------------------------------------------------------
t_CKBOOL init_class_pane( Chuck_Env * env )
{
    Chuck_DL_Func * func = NULL;
    Chuck_Value * value = NULL;

    // log
    EM_log( CK_LOG_INFO, "class 'AudiclePane'" );

    // import
    if( !type_engine_import_class_begin( env, "AudiclePane", "Object",
                                         env->global(), pane_ctor ) )
        return FALSE;

    // add member
    pane_offset_data = type_engine_import_mvar( env, "int", "@data", FALSE );
    if( pane_offset_data == CK_INVALID_OFFSET ) goto error;

    // add width()
    func = make_new_mfun( "int", "width", pane_get_width );
    if( !type_engine_import_mfun( env, func ) ) goto error;

    // add height()
    func = make_new_mfun( "int", "height", pane_get_height );
    if( !type_engine_import_mfun( env, func ) ) goto error;

    // add setglow()
    func = make_new_mfun( "void", "setglow", pane_set_glow );
    func->add_arg( "int", "x" );
    func->add_arg( "int", "y" );
    func->add_arg( "float", "val" );
    if( !type_engine_import_mfun( env, func ) ) goto error;

    // add getvalue()
    func = make_new_mfun( "int", "getvalue", pane_get_value );
    func->add_arg( "int", "x" );
    func->add_arg( "int", "y" );
    if( !type_engine_import_mfun( env, func ) ) goto error;

    // end the class import
    type_engine_import_class_end( env );

    // keep the type around
    g_pane_type = type_engine_find_type( env, new_id_list("AudiclePane", 0 ) );

    return TRUE;

error:

    // end the class import
    type_engine_import_class_end( env );

    return FALSE;
}
Example #22
0
//-----------------------------------------------------------------------------
// name: shutdown()
// desc: ...
//-----------------------------------------------------------------------------
t_CKBOOL Audicle::shutdown( )
{
    if( !m_init )
        return TRUE;

    // log
    EM_log( CK_LOG_SYSTEM, "(audicle) shutting down face manager..." );

    m_init = FALSE;
    
    return TRUE;
}
Example #23
0
//-----------------------------------------------------------------------------
// name: init()
// desc: ...
//-----------------------------------------------------------------------------
t_CKBOOL Audicle::init( )
{
    if( m_init )
        return TRUE;

    // log
    EM_log( CK_LOG_SYSTEM, "(audicle) initializing face manager..." );

    m_init = TRUE;
    
    return TRUE;
}
Example #24
0
// on entering mode
t_CKBOOL kb_initscr()
{
    if( g_init ) return FALSE;

#ifndef __PLATFORM_WIN32__

#ifdef __PLATFORM_MACOSX__
    struct termios term;
    if( ioctl( 0, TIOCGETA, &term ) == -1 )
#else
    struct termio term;
    if( ioctl( 0, TCGETA, &term ) == -1 )
#endif
    {
        EM_log( CK_LOG_SEVERE, "(kbhit disabled): standard input not a tty!");
        return FALSE;
    }

    // log
    EM_log( CK_LOG_INFO, "starting kb hit immediate mode..." );

    g_save = term;

    term.c_lflag &= ~ICANON;
    term.c_lflag &= ~ECHO;

    term.c_cc[VMIN] = 0;
    term.c_cc[VTIME]=0;

#ifdef __PLATFORM_MACOSX__
    ioctl( 0, TIOCSETA, &term );
#else
    ioctl( 0, TCSETA, &term );
#endif

#endif

    g_init = TRUE;
    return TRUE;
}
Example #25
0
CodeRevision * 
CodeRevision::splitModified() {
    if ( _status == rev_NEED_SPLIT || (  _buffer->modified() && _status >= rev_COMPILED ) ) {
        EM_log( CK_LOG_INFO, "(audicle) splitting modified branch..." );
        CodeRevision * branch = new CodeRevision( this );
        if ( _status != rev_NEED_SPLIT ) { 
            branch->getBuffer()->setFileName( name_branch() );
        }
        *_buffer = *_original; //repair our copy
        return branch;
    }
    else return NULL;
}
Example #26
0
void CoAudicle::getip()
{
    // get our hostname
    char hostname[256];
    gethostname( hostname, 256 );
    // get the hostend
    struct hostent * host = gethostbyname( hostname );
    // print it
    sprintf( hostname, "%i.%i.%i.%i", (host->h_addr_list[0][0]+256)%256, (host->h_addr_list[0][1]+256)%256, (host->h_addr_list[0][2]+256)%256, (host->h_addr_list[0][3]+256)%256 );
    // log
    EM_log( CK_LOG_SYSTEM, "ip %s", hostname );
    the_ip = hostname;
}
Example #27
0
void
ShellContent::start_shell() { 

    _console = NULL;

    // instantiate
    _shell = new Chuck_Shell();
    // instantiate shell UI
    _console = new Audicle_Shell_UI();

    // initialize shell UI
    if( !_console->init() )
    {
		
        EM_log( CK_LOG_SYSTEM, "(audicle) error starting shell UI..." );
		return;
    }
    
    // initialize
    if( !_shell->init( the() , _console ) )
    {
        EM_log( CK_LOG_SYSTEM, "(audicle) error starting shell..." );
		return;
    }

	EM_log( CK_LOG_SYSTEM, "(audicle) shell started..." );	

	//start shell thread
//    g_shell = _shell;

//	_shell->run();
#ifndef __PLATFORM_WIN32__
        pthread_create( &_shell_tid, NULL, shell_cb, _shell );
#else
        _shell_tid = CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)shell_cb, _shell, 0, 0 );
#endif


}
Example #28
0
//-----------------------------------------------------------------------------
// name: stop_vm()
// desc: ...
//-----------------------------------------------------------------------------
t_CKBOOL miniAudicle::stop_vm()
{
    if( status_bufs )
    {
        for( size_t i = 0; i < num_status_bufs; i++ )
        {
            if( status_bufs[i] )
            {
                delete status_bufs[i];
                status_bufs[i] = NULL;
            }
        }

        delete[] status_bufs;
        status_bufs = NULL;
    }
    
    // if it's there
    if( vm )
    {
        EM_log( CK_LOG_SYSTEM, "stopping chuck virtual machine..." );
        // get vm
        Chuck_VM * the_vm = g_vm;
        // flag the global one
        vm = g_vm = NULL;
        // if not NULL
        if( the_vm && vm_on )
        {
            // flag
            vm_on = FALSE;

            // stop
            the_vm->stop();
        
            // wait a bit
            usleep( 100000 );

            // detach
            // all_detach();

#if !defined(__PLATFORM_WIN32__) && !defined(__WINDOWS_PTHREAD__)
            SAFE_DELETE( the_vm );
#endif
        }

        SAFE_DELETE( compiler );
        g_compiler = compiler = NULL;
    }

    return TRUE;
}
Example #29
0
//-----------------------------------------------------------------------------
// name: set_priority()
// desc: ...
//-----------------------------------------------------------------------------
static t_CKBOOL set_priority( CHUCK_THREAD tid, t_CKINT priority )
{
    // if priority is 0 then done
    if( !priority ) return TRUE;

    // log
    EM_log( CK_LOG_FINE, "setting thread priority to: %ld...", priority );

    // set the priority the thread
    if( !SetThreadPriority( tid, priority ) )
        return FALSE;

    return TRUE;
}
Example #30
0
void
CodeRevision::removeShred( ShredInstance * s ) { 
	bool removed = false;
	for ( int i = _shreds.size() - 1 ; i >= 0 ; i-- ) { 
		if ( _shreds[i] == s ) { 
			_shreds.erase ( _shreds.begin() + i ); 
			removed = true;
		}
	}

	if ( !removed ) { 
		EM_log( CK_LOG_WARNING, "CodeRevision::removeShred: attempting to remove proc (ptr) not found!" ); 
	}
}