X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Faudio_output%2Ffilters.c;h=5a0fa4f728d8003ad900e7f2a6a7527b53797dda;hb=6c9479be6c55fb23fb7bbfce02543e2bd8bce50b;hp=6bbaae12462f450771976471125a617774d2d72b;hpb=df61d33b06e2b3cbbe746b2f5a9bea5b370c24ff;p=vlc diff --git a/src/audio_output/filters.c b/src/audio_output/filters.c index 6bbaae1246..5a0fa4f728 100644 --- a/src/audio_output/filters.c +++ b/src/audio_output/filters.c @@ -28,8 +28,10 @@ # include "config.h" #endif -#include -#include +#include + +#include +#include #ifdef HAVE_ALLOCA_H # include @@ -37,6 +39,7 @@ #include #include "aout_internal.h" +#include /***************************************************************************** * FindFilter: find an audio filter for a specific transformation @@ -45,8 +48,11 @@ static aout_filter_t * FindFilter( aout_instance_t * p_aout, const audio_sample_format_t * p_input_format, const audio_sample_format_t * p_output_format ) { - aout_filter_t * p_filter = vlc_object_create( p_aout, - sizeof(aout_filter_t) ); + static const char typename[] = "audio output"; + aout_filter_t * p_filter; + + p_filter = vlc_custom_create( p_aout, sizeof(*p_filter), + VLC_OBJECT_GENERIC, typename ); if ( p_filter == NULL ) return NULL; vlc_object_attach( p_filter, p_aout ); @@ -54,7 +60,7 @@ static aout_filter_t * FindFilter( aout_instance_t * p_aout, memcpy( &p_filter->input, p_input_format, sizeof(audio_sample_format_t) ); memcpy( &p_filter->output, p_output_format, sizeof(audio_sample_format_t) ); - p_filter->p_module = module_Need( p_filter, "audio filter", NULL, 0 ); + p_filter->p_module = module_need( p_filter, "audio filter", NULL, false ); if ( p_filter->p_module == NULL ) { vlc_object_detach( p_filter ); @@ -120,7 +126,7 @@ static int SplitConversion( const audio_sample_format_t * p_input_format, static void ReleaseFilter( aout_filter_t * p_filter ) { - module_Unneed( p_filter, p_filter->p_module ); + module_unneed( p_filter, p_filter->p_module ); vlc_object_detach( p_filter ); vlc_object_release( p_filter ); } @@ -152,9 +158,9 @@ int aout_FiltersCreatePipeline( aout_instance_t * p_aout, if( *pi_nb_filters + 1 > AOUT_MAX_FILTERS ) { msg_Err( p_aout, "max filter reached (%d)", AOUT_MAX_FILTERS ); - intf_UserFatal( p_aout, false, _("Audio filtering failed"), - _("The maximum number of filters (%d) was reached."), - AOUT_MAX_FILTERS ); + dialog_Fatal( p_aout, _("Audio filtering failed"), + _("The maximum number of filters (%d) was reached."), + AOUT_MAX_FILTERS ); return -1; } @@ -199,9 +205,9 @@ int aout_FiltersCreatePipeline( aout_instance_t * p_aout, { ReleaseFilter( pp_filters[0] ); msg_Err( p_aout, "max filter reached (%d)", AOUT_MAX_FILTERS ); - intf_UserFatal( p_aout, false, _("Audio filtering failed"), - _("The maximum number of filters (%d) was reached."), - AOUT_MAX_FILTERS ); + dialog_Fatal( p_aout, _("Audio filtering failed"), + _("The maximum number of filters (%d) was reached."), + AOUT_MAX_FILTERS ); return -1; } pp_filters[1] = FindFilter( p_aout, &pp_filters[0]->output, @@ -222,9 +228,9 @@ int aout_FiltersCreatePipeline( aout_instance_t * p_aout, { ReleaseFilter( pp_filters[0] ); msg_Err( p_aout, "max filter reached (%d)", AOUT_MAX_FILTERS ); - intf_UserFatal( p_aout, false, _("Audio filtering failed"), - _("The maximum number of filters (%d) was reached."), - AOUT_MAX_FILTERS ); + dialog_Fatal( p_aout, _("Audio filtering failed"), + _("The maximum number of filters (%d) was reached."), + AOUT_MAX_FILTERS ); return -1; } pp_filters[1] = FindFilter( p_aout, &pp_filters[0]->output, @@ -271,9 +277,12 @@ void aout_FiltersDestroyPipeline( aout_instance_t * p_aout, for ( i = 0; i < i_nb_filters; i++ ) { - module_Unneed( pp_filters[i], pp_filters[i]->p_module ); - vlc_object_detach( pp_filters[i] ); - vlc_object_release( pp_filters[i] ); + aout_filter_t *p_filter = pp_filters[i]; + + module_unneed( p_filter, p_filter->p_module ); + free( p_filter->p_owner ); + vlc_object_detach( p_filter ); + vlc_object_release( p_filter ); } } @@ -308,14 +317,14 @@ void aout_FiltersHintBuffers( aout_instance_t * p_aout, p_first_alloc->i_bytes_per_sec = __MAX( p_first_alloc->i_bytes_per_sec, i_input_size ); - p_filter->output_alloc.i_alloc_type = AOUT_ALLOC_NONE; + p_filter->output_alloc.b_alloc = false; } else { /* We're gonna need a buffer allocation. */ memcpy( &p_filter->output_alloc, p_first_alloc, sizeof(aout_alloc_t) ); - p_first_alloc->i_alloc_type = AOUT_ALLOC_STACK; + p_first_alloc->b_alloc = true; p_first_alloc->i_bytes_per_sec = i_input_size; } } @@ -330,7 +339,7 @@ void aout_FiltersPlay( aout_instance_t * p_aout, { int i; - for ( i = 0; i < i_nb_filters; i++ ) + for( i = 0; i < i_nb_filters; i++ ) { aout_filter_t * p_filter = pp_filters[i]; aout_buffer_t * p_output_buffer; @@ -338,29 +347,45 @@ void aout_FiltersPlay( aout_instance_t * p_aout, /* Resamplers can produce slightly more samples than (i_in_nb * * p_filter->output.i_rate / p_filter->input.i_rate) so we need * slightly bigger buffers. */ - aout_BufferAlloc( &p_filter->output_alloc, - ((mtime_t)(*pp_input_buffer)->i_nb_samples + 2) - * 1000000 / p_filter->input.i_rate, - *pp_input_buffer, p_output_buffer ); - if ( p_output_buffer == NULL ) - { - msg_Err( p_aout, "out of memory" ); + p_output_buffer = aout_BufferAlloc( &p_filter->output_alloc, + ((mtime_t)(*pp_input_buffer)->i_nb_samples + 2) + * 1000000 / p_filter->input.i_rate, + *pp_input_buffer ); + if( p_output_buffer == NULL ) return; - } - /* Please note that p_output_buffer->i_nb_samples & i_nb_bytes - * shall be set by the filter plug-in. */ + p_output_buffer->i_pts = (*pp_input_buffer)->i_pts; + p_output_buffer->i_length = (*pp_input_buffer)->i_length; - p_filter->pf_do_work( p_aout, p_filter, *pp_input_buffer, - p_output_buffer ); + /* Please note that p_output_buffer->i_nb_samples & i_buffer + * shall be set by the filter plug-in. */ + if( (*pp_input_buffer)->i_nb_samples > 0 ) + { + p_filter->pf_do_work( p_aout, p_filter, *pp_input_buffer, + p_output_buffer ); + } + else + { + p_output_buffer->i_buffer = 0; + p_output_buffer->i_nb_samples = 0; + } - if ( !p_filter->b_in_place ) + if( !p_filter->b_in_place ) { aout_BufferFree( *pp_input_buffer ); *pp_input_buffer = p_output_buffer; } - - if( p_output_buffer->i_nb_samples <= 0 ) - break; } } +/***************************************************************************** + * aout_filter_RequestVout + *****************************************************************************/ +vout_thread_t *aout_filter_RequestVout( aout_filter_t *p_filter, + vout_thread_t *p_vout, video_format_t *p_fmt ) +{ + if( !p_filter->request_vout.pf_request_vout ) + return NULL; + return p_filter->request_vout.pf_request_vout( p_filter->request_vout.p_private, + p_vout, p_fmt, true ); +} +