#include <vlc_plugin.h>
#include <vlc_aout.h>
#include <vlc_vout.h>
+#include <vlc_filter.h>
#include <libprojectM/projectM.hpp>
vlc_module_begin ()
set_shortname( N_("projectM"))
set_description( N_("libprojectM effect") )
- set_capability( "visualization", 0 )
+ set_capability( "visualization2", 0 )
set_category( CAT_AUDIO )
set_subcategory( SUBCAT_AUDIO_VISUAL )
add_file( "projectm-config", "/usr/share/projectM/config.inp", NULL,
{
VLC_COMMON_MEMBERS
+ /* */
+ vlc_sem_t ready;
+
/* video output module and opengl provider */
vout_thread_t *p_opengl;
module_t *p_module;
} projectm_thread_t;
-struct aout_filter_sys_t
+struct filter_sys_t
{
projectm_thread_t *p_thread;
};
-static void DoWork( aout_instance_t *, aout_filter_t *, aout_buffer_t *,
- aout_buffer_t * );
+static block_t *DoWork( filter_t *, block_t * );
static void* Thread( vlc_object_t * );
p_thread->p_opengl->render.i_height = p_thread->i_height;
p_thread->p_opengl->render.i_aspect = VOUT_ASPECT_FACTOR;
p_thread->p_opengl->b_fullscreen = false;
+ p_thread->p_opengl->b_autoscale = true;
p_thread->p_opengl->i_alignment = 0;
p_thread->p_opengl->fmt_in.i_sar_num = 1;
p_thread->p_opengl->fmt_in.i_sar_den = 1;
*/
static int Open( vlc_object_t * p_this )
{
- aout_filter_t *p_filter = (aout_filter_t *)p_this;
- aout_filter_sys_t *p_sys;
+ filter_t *p_filter = (filter_t *)p_this;
+ filter_sys_t *p_sys;
projectm_thread_t *p_thread;
/* Test the audio format */
- if( p_filter->input.i_format != VLC_CODEC_FL32 ||
- p_filter->output.i_format != VLC_CODEC_FL32 )
+ if( p_filter->fmt_in.audio.i_format != VLC_CODEC_FL32 ||
+ p_filter->fmt_out.audio.i_format != VLC_CODEC_FL32 )
{
msg_Warn( p_filter, "bad input or output format" );
return VLC_EGENERIC;
}
- if( !AOUT_FMTS_SIMILAR( &p_filter->input, &p_filter->output ) )
+ if( !AOUT_FMTS_SIMILAR( &p_filter->fmt_in.audio, &p_filter->fmt_out.audio ) )
{
msg_Warn( p_filter, "input and outut are not similar" );
return VLC_EGENERIC;
}
- p_filter->pf_do_work = DoWork;
- p_filter->b_in_place = true;
+ p_filter->pf_audio_filter = DoWork;
- p_sys = p_filter->p_sys = (aout_filter_sys_t*)malloc( sizeof( *p_sys ) );
+ p_sys = p_filter->p_sys = (filter_sys_t*)malloc( sizeof( *p_sys ) );
if( !p_sys )
return VLC_ENOMEM;
p_sys->p_thread = p_thread = (projectm_thread_t *)
vlc_object_create( p_filter, sizeof( projectm_thread_t ) );
vlc_object_attach( p_sys->p_thread, p_filter );
+ vlc_sem_init( &p_thread->ready, 0 );
+ p_thread->b_error = false;
p_thread->i_width = var_CreateGetInteger( p_filter, "projectm-width" );
p_thread->i_height = var_CreateGetInteger( p_filter, "projectm-height" );
- /* Create the openGL provider */
- int i_ret = initOpenGL( p_sys->p_thread );
- if( i_ret != VLC_SUCCESS )
- {
- vlc_object_detach( p_sys->p_thread );
- vlc_object_release( p_sys->p_thread );
- free( p_sys );
- return i_ret;
- }
-
- p_thread->i_channels = aout_FormatNbChannels( &p_filter->input );
+ p_thread->i_channels = aout_FormatNbChannels( &p_filter->fmt_in.audio );
p_thread->psz_config = var_CreateGetString( p_filter, "projectm-config" );
vlc_mutex_init( &p_thread->lock );
p_thread->p_buffer = NULL;
/* Create the thread */
if( vlc_thread_create( p_thread, "projectm update thread", Thread,
VLC_THREAD_PRIORITY_LOW ) )
- {
- msg_Err( p_filter, "cannot launch the projectm thread" );
- vlc_object_detach( p_thread );
- vlc_object_release( p_thread );
- free (p_sys );
- return VLC_EGENERIC;
- }
+ goto error;
+
+ vlc_sem_wait( &p_thread->ready );
+ if( p_thread->b_error )
+ goto error;
return VLC_SUCCESS;
+
+error:
+ vlc_thread_join( p_thread );
+ vlc_sem_destroy( &p_thread->ready );
+ vlc_object_detach( p_thread );
+ vlc_object_release( p_thread );
+ free (p_sys );
+ return VLC_EGENERIC;
}
*/
static void Close( vlc_object_t *p_this )
{
- aout_filter_t *p_filter = (aout_filter_t *)p_this;
- aout_filter_sys_t *p_sys = p_filter->p_sys;
+ filter_t *p_filter = (filter_t *)p_this;
+ filter_sys_t *p_sys = p_filter->p_sys;
projectm_thread_t *p_thread = p_sys->p_thread;
/* Stop the thread */
vlc_thread_join( p_thread );
/* Free the ressources */
+ vlc_sem_destroy( &p_thread->ready );
vlc_mutex_destroy( &p_thread->lock );
free( p_thread->p_buffer );
free( p_thread->psz_config );
* @param p_in_buf: input buffer
* @param p_out_buf: output buffer
*/
-static void DoWork( aout_instance_t *p_aout, aout_filter_t *p_filter,
- aout_buffer_t *p_in_buf, aout_buffer_t *p_out_buf )
+static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
{
projectm_thread_t *p_thread = p_filter->p_sys->p_thread;
- p_out_buf->i_nb_samples = p_in_buf->i_nb_samples;
- p_out_buf->i_nb_bytes = p_in_buf->i_nb_bytes;
-
vlc_mutex_lock( &p_thread->lock );
if( p_thread->i_buffer_size > 0 )
{
vlc_mutex_unlock( &p_thread->lock );
- return;
+ return p_in_buf;
}
int cancel = vlc_savecancel();
projectm_thread_t *p_thread = (projectm_thread_t *)p_this;
+ /* Create the openGL provider */
+ if( initOpenGL( p_thread ) )
+ {
+ p_thread->b_error = true;
+ vlc_sem_post( &p_thread->ready );
+ return NULL;
+ }
+ vlc_sem_post( &p_thread->ready );
+
/* Initialize the opengl provider for this thread */
p_thread->p_opengl->pf_init( p_thread->p_opengl );
while( vlc_object_alive( p_thread ) )
{
+ /* Manage the events */
+ p_thread->p_opengl->pf_manage( p_thread->p_opengl );
/* Render the image and swap the buffers */
vlc_mutex_lock( &p_thread->lock );
if( p_thread->i_nb_samples > 0 )
vlc_mutex_unlock( &p_thread->lock );
/* TODO: use a fps limiter */
- msleep( 1000 );
+ msleep( 10000 );
}