vlc_linux/vlc-3.0.16/modules/visualization/projectm.cpp
/**
 * Open the module
 * @param p_this: the filter object
 * @return VLC_SUCCESS or vlc error codes
 */
Open the module
@param p_this: the filter object
@return VLC_SUCCESS or vlc error codes
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( !p_sys )
        return VLC_ENOMEM;
    p_sys->b_quit        = false;
    p_sys->i_channels    = aout_FormatNbChannels( &p_filter->fmt_in.audio );
    vlc_mutex_init( &p_sys->lock );
    p_sys->p_buffer      = NULL;
    p_sys->i_buffer_size = 0;
    p_sys->i_nb_samples  = 0;
    vout_window_cfg_t cfg;
    memset(&cfg, 0, sizeof (cfg));
    cfg.width = var_CreateGetInteger( p_filter, "projectm-width" );
    cfg.height = var_CreateGetInteger( p_filter, "projectm-height" );
    p_sys->gl = vlc_gl_surface_Create( VLC_OBJECT(p_filter), &cfg, NULL );
    if( p_sys->gl == NULL )
        goto error;
    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->lock );
    free (p_sys );
    return VLC_EGENERIC;
}
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 ( ! p_sys ) return VLC_ENOMEM ; p_sys -> b_quit = false ; p_sys -> i_channels = aout_FormatNbChannels ( & p_filter -> fmt_in . audio ) ; vlc_mutex_init ( & p_sys -> lock ) ; p_sys -> p_buffer = NULL ; p_sys -> i_buffer_size = 0 ; p_sys -> i_nb_samples = 0 ; vout_window_cfg_t cfg ; memset ( & cfg , 0 , sizeof ( cfg ) ) ; cfg . width = var_CreateGetInteger ( p_filter , " " ) ; cfg . height = var_CreateGetInteger ( p_filter , " " ) ; p_sys -> gl = vlc_gl_surface_Create ( VLC_OBJECT ( p_filter ) , & cfg , NULL ) ; if ( p_sys -> gl == NULL ) goto error ; 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 -> lock ) ; free ( p_sys ) ; return VLC_EGENERIC ; }
Open the module
 @param p_this: the filter object
 @return VLC_SUCCESS or vlc error codes
Open the module @param p_this : the filter object @return VLC_SUCCESS or vlc error codes
/* Create the object for the thread */ /* Create the OpenGL context */ /* Create the thread */