bool app_draw(int id) { VSX_UNUSED(id); if (first) { printf("INFO: app_draw first\n"); first = false; // create a new manager manager = manager_factory(); manager->set_option_preload_all(option_preload_all); // init manager with the shared path and sound input type. // manual sound injection: manager->init( path.c_str() , "media_player"); std::string path = PLATFORM_SHARED_FILES_STLSTRING; manager->init( path.c_str(), ""); // create a new text overlay overlay = new vsx_overlay; overlay->set_manager(manager); // create a new intro (Luna logo) object if (disable_randomizer) manager->set_randomizer(false); printf("INFO: app_draw first done\n"); } /* uncomment for manual sound injection for (unsigned long i = 0; i < 512; i++) { sound_wave_test[i] = (float)(rand()%65535-32768)*(1.0f/32768.0f); } for (unsigned long i = 0; i < 512; i++) { sound_freq_test[i] = (float)(rand()%65535)*(1.0f/65535.0f); } manager->set_sound_freq(&sound_freq_test[0]); manager->set_sound_wave(&sound_wave_test[0]); */ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); if (manager) manager->render(); if (overlay && !no_overlay) overlay->render(); return true; }
virtual bool Start(int channels, int samplesPerSec, int bitsPerSample, std::string songName) override { std::string path = kodi::GetAddonPath("resources"); // create a new manager m_manager = manager_factory(); m_manager->set_option_preload_all(false); m_manager->init("/usr/share/vsxu", "media_player"); m_manager->add_visual_path(path.c_str()); m_presets = m_manager->get_visual_filenames(); // strip off dir names - if there are duped presets this will misbehave. for (size_t i=0;i<m_presets.size();++i) { size_t sit = m_presets[i].rfind('/'); size_t dit = m_presets[i].rfind('.'); m_presets[i] = m_presets[i].substr(sit+1,dit-sit-1); } vsx_gl_state::get_instance()->viewport_set(0,0,Width(),Height()); }
/** * 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; }
/** * 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; }