Commit 4518becb authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Headphone mixer: remove audio filter support

parent bfed7bf6
...@@ -41,13 +41,6 @@ ...@@ -41,13 +41,6 @@
/***************************************************************************** /*****************************************************************************
* Local prototypes * Local prototypes
*****************************************************************************/ *****************************************************************************/
static int Create ( vlc_object_t * );
static void Destroy ( vlc_object_t * );
static void DoWork ( aout_instance_t *, aout_filter_t *, aout_buffer_t *,
aout_buffer_t * );
/* Audio filter2 */
static int OpenFilter ( vlc_object_t * ); static int OpenFilter ( vlc_object_t * );
static void CloseFilter( vlc_object_t * ); static void CloseFilter( vlc_object_t * );
static block_t *Convert( filter_t *, block_t * ); static block_t *Convert( filter_t *, block_t * );
...@@ -92,13 +85,6 @@ vlc_module_begin () ...@@ -92,13 +85,6 @@ vlc_module_begin ()
add_bool( "headphone-dolby", false, NULL, HEADPHONE_DOLBY_TEXT, add_bool( "headphone-dolby", false, NULL, HEADPHONE_DOLBY_TEXT,
HEADPHONE_DOLBY_LONGTEXT, true ) HEADPHONE_DOLBY_LONGTEXT, true )
set_capability( "audio filter", 0 )
set_callbacks( Create, Destroy )
add_shortcut( "headphone" )
/* Audio filter 2 */
add_submodule ()
set_description( N_("Headphone virtual spatialization effect") )
set_capability( "audio filter2", 0 ) set_capability( "audio filter2", 0 )
set_callbacks( OpenFilter, CloseFilter ) set_callbacks( OpenFilter, CloseFilter )
add_shortcut( "headphone" ) add_shortcut( "headphone" )
...@@ -116,14 +102,6 @@ struct atomic_operation_t ...@@ -116,14 +102,6 @@ struct atomic_operation_t
double d_amplitude_factor; double d_amplitude_factor;
}; };
struct aout_filter_sys_t
{
size_t i_overflow_buffer_size;/* in bytes */
uint8_t * p_overflow_buffer;
unsigned int i_nb_atomic_operations;
struct atomic_operation_t * p_atomic_operations;
};
struct filter_sys_t struct filter_sys_t
{ {
size_t i_overflow_buffer_size;/* in bytes */ size_t i_overflow_buffer_size;/* in bytes */
...@@ -150,7 +128,7 @@ struct filter_sys_t ...@@ -150,7 +128,7 @@ struct filter_sys_t
* *
* x-axis * x-axis
* */ * */
static void ComputeChannelOperations( struct aout_filter_sys_t * p_data static void ComputeChannelOperations( struct filter_sys_t * p_data
, unsigned int i_rate, unsigned int i_next_atomic_operation , unsigned int i_rate, unsigned int i_next_atomic_operation
, int i_source_channel_offset, double d_x, double d_z , int i_source_channel_offset, double d_x, double d_z
, double d_compensation_length, double d_channel_amplitude_factor ) , double d_compensation_length, double d_channel_amplitude_factor )
...@@ -207,7 +185,7 @@ static void ComputeChannelOperations( struct aout_filter_sys_t * p_data ...@@ -207,7 +185,7 @@ static void ComputeChannelOperations( struct aout_filter_sys_t * p_data
} }
} }
static int Init( vlc_object_t *p_this, struct aout_filter_sys_t * p_data static int Init( vlc_object_t *p_this, struct filter_sys_t * p_data
, unsigned int i_nb_channels, uint32_t i_physical_channels , unsigned int i_nb_channels, uint32_t i_physical_channels
, unsigned int i_rate ) , unsigned int i_rate )
{ {
...@@ -348,104 +326,13 @@ static int Init( vlc_object_t *p_this, struct aout_filter_sys_t * p_data ...@@ -348,104 +326,13 @@ static int Init( vlc_object_t *p_this, struct aout_filter_sys_t * p_data
return 0; return 0;
} }
/*****************************************************************************
* Create: allocate headphone downmixer
*****************************************************************************/
static int Create( vlc_object_t *p_this )
{
aout_filter_t * p_filter = (aout_filter_t *)p_this;
aout_filter_sys_t *p_sys;
bool b_fit = true;
/* Activate this filter only with stereo devices */
if( p_filter->fmt_out.audio.i_physical_channels
!= (AOUT_CHAN_LEFT|AOUT_CHAN_RIGHT) )
{
msg_Dbg( p_filter, "filter discarded (incompatible format)" );
return VLC_EGENERIC;
}
/* Request a specific format if not already compatible */
if( p_filter->fmt_in.audio.i_original_channels
!= p_filter->fmt_out.audio.i_original_channels )
{
b_fit = false;
p_filter->fmt_in.audio.i_original_channels =
p_filter->fmt_out.audio.i_original_channels;
}
if( p_filter->fmt_in.audio.i_format != VLC_CODEC_FL32
|| p_filter->fmt_out.audio.i_format != VLC_CODEC_FL32 )
{
b_fit = false;
p_filter->fmt_in.audio.i_format = VLC_CODEC_FL32;
p_filter->fmt_out.audio.i_format = VLC_CODEC_FL32;
}
if( p_filter->fmt_in.audio.i_rate != p_filter->fmt_out.audio.i_rate )
{
b_fit = false;
p_filter->fmt_in.audio.i_rate = p_filter->fmt_out.audio.i_rate;
}
if( p_filter->fmt_in.audio.i_physical_channels == (AOUT_CHAN_LEFT|AOUT_CHAN_RIGHT)
&& ( p_filter->fmt_in.audio.i_original_channels & AOUT_CHAN_DOLBYSTEREO )
&& ! config_GetInt ( p_filter , "headphone-dolby" ) )
{
b_fit = false;
p_filter->fmt_in.audio.i_physical_channels = AOUT_CHAN_LEFT | AOUT_CHAN_RIGHT |
AOUT_CHAN_CENTER |
AOUT_CHAN_REARLEFT |
AOUT_CHAN_REARRIGHT;
}
if( !b_fit )
{
msg_Dbg( p_filter, "requesting specific format" );
return VLC_EGENERIC;
}
/* Allocate the memory needed to store the module's structure */
p_sys = p_filter->p_sys = malloc( sizeof(struct aout_filter_sys_t) );
if( p_sys == NULL )
return VLC_ENOMEM;
p_sys->i_overflow_buffer_size = 0;
p_sys->p_overflow_buffer = NULL;
p_sys->i_nb_atomic_operations = 0;
p_sys->p_atomic_operations = NULL;
if( Init( VLC_OBJECT(p_filter), p_sys
, aout_FormatNbChannels ( &p_filter->fmt_in.audio )
, p_filter->fmt_in.audio.i_physical_channels
, p_filter->fmt_in.audio.i_rate ) < 0 )
{
free( p_sys );
return VLC_EGENERIC;
}
p_filter->pf_do_work = DoWork;
p_filter->b_in_place = 0;
return VLC_SUCCESS;
}
/*****************************************************************************
* Destroy: deallocate resources associated with headphone downmixer
*****************************************************************************/
static void Destroy( vlc_object_t *p_this )
{
aout_filter_t * p_filter = (aout_filter_t *)p_this;
free( p_filter->p_sys->p_overflow_buffer );
free( p_filter->p_sys->p_atomic_operations );
free( p_filter->p_sys );
}
/***************************************************************************** /*****************************************************************************
* DoWork: convert a buffer * DoWork: convert a buffer
*****************************************************************************/ *****************************************************************************/
static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter, static void DoWork( filter_t * p_filter,
aout_buffer_t * p_in_buf, aout_buffer_t * p_out_buf ) aout_buffer_t * p_in_buf, aout_buffer_t * p_out_buf )
{ {
VLC_UNUSED(p_aout); filter_sys_t *p_sys = p_filter->p_sys;
aout_filter_sys_t *p_sys = p_filter->p_sys;
int i_input_nb = aout_FormatNbChannels( &p_filter->fmt_in.audio ); int i_input_nb = aout_FormatNbChannels( &p_filter->fmt_in.audio );
int i_output_nb = aout_FormatNbChannels( &p_filter->fmt_out.audio ); int i_output_nb = aout_FormatNbChannels( &p_filter->fmt_out.audio );
...@@ -609,7 +496,7 @@ static int OpenFilter( vlc_object_t *p_this ) ...@@ -609,7 +496,7 @@ static int OpenFilter( vlc_object_t *p_this )
p_sys->i_nb_atomic_operations = 0; p_sys->i_nb_atomic_operations = 0;
p_sys->p_atomic_operations = NULL; p_sys->p_atomic_operations = NULL;
if( Init( VLC_OBJECT(p_filter), (struct aout_filter_sys_t *)p_sys if( Init( VLC_OBJECT(p_filter), p_sys
, aout_FormatNbChannels ( &(p_filter->fmt_in.audio) ) , aout_FormatNbChannels ( &(p_filter->fmt_in.audio) )
, p_filter->fmt_in.audio.i_physical_channels , p_filter->fmt_in.audio.i_physical_channels
, p_filter->fmt_in.audio.i_rate ) < 0 ) , p_filter->fmt_in.audio.i_rate ) < 0 )
...@@ -638,11 +525,6 @@ static void CloseFilter( vlc_object_t *p_this ) ...@@ -638,11 +525,6 @@ static void CloseFilter( vlc_object_t *p_this )
static block_t *Convert( filter_t *p_filter, block_t *p_block ) static block_t *Convert( filter_t *p_filter, block_t *p_block )
{ {
aout_filter_t aout_filter;
aout_buffer_t in_buf, out_buf;
block_t *p_out;
int i_out_size;
if( !p_block || !p_block->i_nb_samples ) if( !p_block || !p_block->i_nb_samples )
{ {
if( p_block ) if( p_block )
...@@ -650,11 +532,11 @@ static block_t *Convert( filter_t *p_filter, block_t *p_block ) ...@@ -650,11 +532,11 @@ static block_t *Convert( filter_t *p_filter, block_t *p_block )
return NULL; return NULL;
} }
i_out_size = p_block->i_nb_samples * size_t i_out_size = p_block->i_nb_samples *
p_filter->fmt_out.audio.i_bitspersample/8 * p_filter->fmt_out.audio.i_bitspersample/8 *
aout_FormatNbChannels( &(p_filter->fmt_out.audio) ); aout_FormatNbChannels( &(p_filter->fmt_out.audio) );
p_out = p_filter->pf_audio_buffer_new( p_filter, i_out_size ); block_t *p_out = filter_NewAudioBuffer( p_filter, i_out_size );
if( !p_out ) if( !p_out )
{ {
msg_Warn( p_filter, "can't get output buffer" ); msg_Warn( p_filter, "can't get output buffer" );
...@@ -667,24 +549,7 @@ static block_t *Convert( filter_t *p_filter, block_t *p_block ) ...@@ -667,24 +549,7 @@ static block_t *Convert( filter_t *p_filter, block_t *p_block )
p_out->i_pts = p_block->i_pts; p_out->i_pts = p_block->i_pts;
p_out->i_length = p_block->i_length; p_out->i_length = p_block->i_length;
aout_filter.p_sys = (struct aout_filter_sys_t *)p_filter->p_sys; DoWork( p_filter, p_block, p_out );
aout_filter.fmt_in.audio = p_filter->fmt_in.audio;
aout_filter.fmt_in.audio.i_format = p_filter->fmt_in.i_codec;
aout_filter.fmt_out.audio = p_filter->fmt_out.audio;
aout_filter.fmt_out.audio.i_format = p_filter->fmt_out.i_codec;
aout_filter.b_in_place = 0;
in_buf.p_buffer = p_block->p_buffer;
in_buf.i_buffer = p_block->i_buffer;
in_buf.i_nb_samples = p_block->i_nb_samples;
out_buf.p_buffer = p_out->p_buffer;
out_buf.i_buffer = p_out->i_buffer;
out_buf.i_nb_samples = p_out->i_nb_samples;
DoWork( (aout_instance_t *)p_filter, &aout_filter, &in_buf, &out_buf );
p_out->i_buffer = out_buf.i_buffer;
p_out->i_nb_samples = out_buf.i_nb_samples;
block_Release( p_block ); block_Release( p_block );
return p_out; return p_out;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment