Exemple #1
0
int main(int argc, char **argv)
{
    int i;
    perfmanagerhandle_t *p;
    perf_counter *data;
    int size;
    int enabled;

    perfhandle_t *dummyperf = perf_event_create("");
    p = manager_init( " );

    assert( p != 0 );

    for(i = 0; i < 10; ++i)
    {
        perf_get_r(p, &data, &size);
        enabled = perf_enabled(p);
        printf("Perf enabled = %d\n", enabled);
        sleep(1);
    }

    manager_destroy(p);

    perf_event_destroy(dummyperf);

    return 0;
}
  virtual ~CVisualizationVSXU()
  {
    // stop vsxu nicely (unloads textures and frees memory)
    if (m_manager)
    {
      m_manager->stop();
      manager_destroy(m_manager);
    }

    m_manager = nullptr;
  }
Exemple #3
0
void app_key_down(long key)
{
  switch (key)
  {
    case GLFW_KEY_ESC:
      if (manager) manager_destroy(manager);
      exit(0);
    case GLFW_KEY_PAGEUP:
      manager->inc_speed();
      break;
    case GLFW_KEY_PAGEDOWN:
      manager->dec_speed();
      break;
    case GLFW_KEY_UP:
      manager->inc_fx_level(); overlay->show_fx_graph();
      break;
    case GLFW_KEY_DOWN:
      manager->dec_fx_level(); overlay->show_fx_graph();
      break;
    case GLFW_KEY_LEFT:
      manager->prev_visual();
      break;
    case GLFW_KEY_RIGHT:
      manager->next_visual();
      break;
    case GLFW_KEY_F1:
      overlay->set_help(1);
      break;
    // "F" key:
    case 'f':
    case 'F':
      overlay->set_help(2);
      break;
    // "R" key:
    case 'r':
    case 'R':
      if (app_ctrl)
      {
        manager->pick_random_visual();
      }
      else
      {
        manager->toggle_randomizer();
        overlay->show_randomizer_status();
      }
      break;
  }
}
Exemple #4
0
/**
 * VSXu update thread which do the rendering
 * @param p_this: the p_thread object
 */
static void *Thread( void *p_data )
{
    filter_t  *p_filter = (filter_t*)p_data;
    filter_sys_t *p_sys = p_filter->p_sys;
    vlc_gl_t *gl = p_sys->gl;

    // our abstract manager holder
    vsx_manager_abs* manager = 0;

    // temp audio buffer for sending to vsxu through manager
    float f_sample_buf[512];

    // vsxu logo intro
    vsx_logo_intro* intro = 0;

    bool first = true;
    bool run = true;

    // tell main thread we are ready
    vlc_gl_MakeCurrent( gl );

    while ( run )
    {
        /* Manage the events */
        unsigned width, height;

        if( vlc_gl_surface_CheckSize( p_sys->gl, &width, &height ) )
        {
            /* ??? */
        }

        // look for control commands from outside the thread
        vlc_mutex_lock( &p_sys->lock );
            if( p_sys->b_quit )
            {
                run = false;
            }
        vlc_mutex_unlock( &p_sys->lock );

        if (first)
        {
            // only run this once
            first = false;

            // create a new manager
            manager = manager_factory();

            // init manager with the shared path and sound input type.
            manager->init( 0, "media_player" );

            // only show logo once
            // keep track of iterations
            static int i_iterations = 0;
            if ( i_iterations++ < 1 )
            {
                intro = new vsx_logo_intro();
                intro->set_destroy_textures( false );
            }
        }

        // lock cyclic buffer mutex and copy floats
        vlc_mutex_lock( &p_sys->cyclic_block_mutex );
            block_holder* bh = p_sys->vsxu_cyclic_buffer->consume();
            memcpy( &f_sample_buf[0], (void*)(&bh->data[0]), sizeof(float) * 512 );
        vlc_mutex_unlock( &p_sys->cyclic_block_mutex );

        // send sound pointer to vsxu
        manager->set_sound_wave( &f_sample_buf[0] );

        // render vsxu engine
        if (manager) manager->render();

        // render intro
        if (intro) intro->draw();

        // swap buffers etc.
        if( !vlc_gl_Lock(gl) )
        {
            vlc_gl_Swap( gl );
            vlc_gl_Unlock( gl );
        }
    }

    // stop vsxu nicely (unloads textures and frees memory)
    if (manager) manager->stop();

    // call manager factory to destruct our manager object
    if (manager) manager_destroy( manager );

    // delete the intro (if ever allocated)
    if (intro) delete intro;

    vlc_gl_ReleaseCurrent( gl );

    // clean up the cyclic buffer
    vlc_mutex_lock( &p_sys->cyclic_block_mutex );
        p_sys->vsxu_cyclic_buffer->reset();
    vlc_mutex_unlock( &p_sys->cyclic_block_mutex );

    // die
    return NULL;
}
Exemple #5
0
/**
 * VSXu update thread which do the rendering
 * @param p_this: the p_thread object
 */
static void *Thread( void *p_data )
{
    filter_t  *p_filter = (filter_t*)p_data;
    filter_sys_t *p_sys = p_filter->p_sys;

    // our abstract manager holder
    vsx_manager_abs* manager = 0;

    // temp audio buffer for sending to vsxu through manager
    float f_sample_buf[512];

    // vsxu logo intro
    vsx_logo_intro* intro = 0;

    vout_display_t *p_vd;

    video_format_t fmt;
    vlc_gl_t *gl;

    unsigned int i_last_width  = 0;
    unsigned int i_last_height = 0;
    bool first = true;
    bool run = true;

    /* Create the openGL provider */
    vout_thread_t  *p_vout;

    p_vout = (vout_thread_t *)vlc_object_create( p_filter, sizeof(vout_thread_t) );
    if( !p_vout )
        goto error;

    video_format_Init( &fmt, 0 );
    video_format_Setup( &fmt, VLC_CODEC_RGB32,
                        p_sys->i_width, p_sys->i_height, 0, 1 );
    fmt.i_sar_num = 1;
    fmt.i_sar_den = 1;

    vout_display_state_t state;
    memset( &state, 0, sizeof(state) );
    state.cfg.display.sar.num = 1;
    state.cfg.display.sar.den = 1;
    state.cfg.is_display_filled = true;
    state.cfg.zoom.num = 1;
    state.cfg.zoom.den = 1;
    state.sar.num = 1;
    state.sar.den = 1;

    p_vd = vout_NewDisplay( p_vout, &fmt, &state, "opengl", 300000, 1000000 );
    if( !p_vd )
    {
        vlc_object_release( p_vout );
        goto error;
    }
    var_Create( p_vout, "fullscreen", VLC_VAR_BOOL );
    var_AddCallback( p_vout, "fullscreen", VoutCallback, p_vd );

    gl = vout_GetDisplayOpengl( p_vd );
    if( !gl )
    {
        var_DelCallback( p_vout, "fullscreen", VoutCallback, p_vd );
        vout_DeleteDisplay( p_vd, NULL );
        vlc_object_release( p_vout );
        goto error;
    }

    // tell main thread we are ready
    vlc_sem_post( &p_sys->ready );

    while ( run )
    {
        /* Manage the events */
        vout_ManageDisplay( p_vd, true );
        if( p_vd->cfg->display.width  != i_last_width ||
            p_vd->cfg->display.height != i_last_height )
        {
            /* FIXME it is not perfect as we will have black bands */
            vout_display_place_t place;
            vout_display_PlacePicture( &place, &p_vd->source, p_vd->cfg, false );

            i_last_width  = p_vd->cfg->display.width;
            i_last_height = p_vd->cfg->display.height;
        }

        // look for control commands from outside the thread
        vlc_mutex_lock( &p_sys->lock );
            if( p_sys->b_quit )
            {
                run = false;
            }
        vlc_mutex_unlock( &p_sys->lock );

        if (first)
        {
            // only run this once
            first = false;

            // create a new manager
            manager = manager_factory();

            // init manager with the shared path and sound input type.
            manager->init( 0, "media_player" );

            // only show logo once
            // keep track of iterations
            static int i_iterations = 0;
            if ( i_iterations++ < 1 )
            {
                intro = new vsx_logo_intro();
                intro->set_destroy_textures( false );
            }
        }

        // lock cyclic buffer mutex and copy floats
        vlc_mutex_lock( &p_sys->cyclic_block_mutex );
            block_holder* bh = p_sys->vsxu_cyclic_buffer->consume();
            memcpy( &f_sample_buf[0], (void*)(&bh->data[0]), sizeof(float) * 512 );
        vlc_mutex_unlock( &p_sys->cyclic_block_mutex );

        // send sound pointer to vsxu
        manager->set_sound_wave( &f_sample_buf[0] );

        // render vsxu engine
        if (manager) manager->render();

        // render intro
        if (intro) intro->draw();

        // swap buffers etc.
        if( !vlc_gl_Lock(gl) )
        {
            vlc_gl_Swap( gl );
            vlc_gl_Unlock( gl );
        }
    }

    // stop vsxu nicely (unloads textures and frees memory)
    if (manager) manager->stop();

    // call manager factory to destruct our manager object
    if (manager) manager_destroy( manager );

    // delete the intro (if ever allocated)
    if (intro) delete intro;

    var_DelCallback( p_vout, "fullscreen", VoutCallback, p_vd );

    // clean out vlc opengl stuff
    vout_DeleteDisplay( p_vd, NULL );
    vlc_object_release( p_vout );

    // clean up the cyclic buffer
    vlc_mutex_lock( &p_sys->cyclic_block_mutex );
        p_sys->vsxu_cyclic_buffer->reset();
    vlc_mutex_unlock( &p_sys->cyclic_block_mutex );

    // die
    return NULL;

error:
    p_sys->b_error = true;
    vlc_sem_post( &p_sys->ready );
    return NULL;
}