vlc/modules/audio_mixer/float32.c

84 lines
2.7 KiB
C
Raw Normal View History

/*****************************************************************************
* float32.c : precise float32 audio mixer implementation
*****************************************************************************
2005-07-09 08:17:09 +02:00
* Copyright (C) 2002 the VideoLAN team
* $Id$
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
2007-09-10 20:56:52 +02:00
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
2006-01-13 00:10:04 +01:00
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stddef.h>
#include <vlc_common.h>
2008-05-08 17:30:33 +02:00
#include <vlc_plugin.h>
#include <vlc_aout.h>
#include <vlc_aout_mixer.h>
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static int Create( vlc_object_t * );
static void DoWork( aout_mixer_t *, aout_buffer_t *, float );
/*****************************************************************************
* Module descriptor
*****************************************************************************/
vlc_module_begin ()
set_category( CAT_AUDIO )
set_subcategory( SUBCAT_AUDIO_MISC )
set_description( N_("Float32 audio mixer") )
set_capability( "audio mixer", 10 )
set_callbacks( Create, NULL )
vlc_module_end ()
/**
* Initializes the mixer
*/
static int Create( vlc_object_t *p_this )
{
aout_mixer_t * p_mixer = (aout_mixer_t *)p_this;
if ( p_mixer->fmt.i_format != VLC_CODEC_FL32 )
return -1;
p_mixer->mix = DoWork;
return 0;
}
/**
* Mixes a new output buffer
*/
static void DoWork( aout_mixer_t * p_mixer, aout_buffer_t *p_buffer,
float f_multiplier )
{
f_multiplier *= p_mixer->input->multiplier;
if( f_multiplier == 1.0 )
return; /* nothing to do */
float *p = (float *)p_buffer->p_buffer;
for( size_t i = p_buffer->i_buffer / sizeof(float); i > 0; i-- )
*(p++) *= f_multiplier;
}