/** * Open the module * @param p_this: the filter object * @return VLC_SUCCESS or vlc error codes */ static int Open( vlc_object_t * p_this ) { filter_t *p_filter = (filter_t *)p_this; filter_sys_t *p_sys; p_sys = p_filter->p_sys = (filter_sys_t*)malloc( sizeof( *p_sys ) ); if( unlikely( !p_sys ) ) { return VLC_ENOMEM; } /* Create the object for the thread */ p_sys->b_quit = false; p_sys->i_channels = aout_FormatNbChannels( &p_filter->fmt_in.audio ); vlc_mutex_init( &p_sys->lock ); vlc_mutex_init( &p_sys->cyclic_block_mutex ); p_sys->vsxu_cyclic_buffer = new cyclic_block_queue(); /* Create the openGL provider */ vout_window_cfg_t cfg; memset( &cfg, 0, sizeof(cfg) ); cfg.width = var_InheritInteger( p_filter, "vsxu-width" ); cfg.height = var_InheritInteger( p_filter, "vsxu-height" ); p_sys->gl = vlc_gl_surface_Create( VLC_OBJECT(p_filter), &cfg, NULL ); if( p_sys->gl == NULL ) goto error; /* Create the thread */ if( vlc_clone( &p_sys->thread, Thread, p_filter, VLC_THREAD_PRIORITY_LOW ) ) { vlc_gl_surface_Destroy( p_sys->gl ); goto error; } p_filter->fmt_in.audio.i_format = VLC_CODEC_FL32; p_filter->fmt_out.audio = p_filter->fmt_in.audio; p_filter->pf_audio_filter = DoWork; return VLC_SUCCESS; error: vlc_mutex_destroy( &p_sys->cyclic_block_mutex ); vlc_mutex_destroy( &p_sys->lock ); free( p_sys ); return VLC_EGENERIC; }
/** * Close the module * @param p_this: the filter object */ static void Close( vlc_object_t *p_this ) { filter_t *p_filter = (filter_t *)p_this; filter_sys_t *p_sys = p_filter->p_sys; vlc_mutex_lock( &p_sys->lock ); p_sys->b_quit = true; vlc_mutex_unlock( &p_sys->lock ); vlc_join( p_sys->thread, NULL ); /* Free the ressources */ vlc_gl_surface_Destroy( p_sys->gl ); vlc_mutex_destroy( &p_sys->cyclic_block_mutex ); vlc_mutex_destroy( &p_sys->lock ); delete p_sys->vsxu_cyclic_buffer; free( p_sys ); }
/** * Close the module * @param p_this: the filter object */ static void Close( vlc_object_t *p_this ) { filter_t *p_filter = (filter_t *)p_this; filter_sys_t *p_sys = p_filter->p_sys; /* Stop the thread * XXX vlc_cleanup_push does not seems to work with C++ so no * vlc_cancel()... */ vlc_mutex_lock( &p_sys->lock ); p_sys->b_quit = true; vlc_mutex_unlock( &p_sys->lock ); vlc_join( p_sys->thread, NULL ); /* Free the ressources */ vlc_gl_surface_Destroy( p_sys->gl ); vlc_mutex_destroy( &p_sys->lock ); free( p_sys->p_buffer ); free( p_sys ); }