2002-08-29 00:25:39 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* float32.c : precise float32 audio mixer implementation
|
|
|
|
*****************************************************************************
|
2005-07-09 08:17:09 +02:00
|
|
|
* Copyright (C) 2002 the VideoLAN team
|
2004-12-11 15:45:46 +01:00
|
|
|
* $Id$
|
2002-08-29 00:25:39 +02:00
|
|
|
*
|
|
|
|
* 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
|
|
|
*
|
2002-08-29 00:25:39 +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.
|
2002-08-29 00:25:39 +02:00
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* Preamble
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2008-01-23 22:50:58 +01:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
2008-02-03 21:12:50 +01:00
|
|
|
#include <stddef.h>
|
2008-05-31 20:49:57 +02:00
|
|
|
#include <vlc_common.h>
|
2008-05-08 17:30:33 +02:00
|
|
|
#include <vlc_plugin.h>
|
2006-11-26 15:20:34 +01:00
|
|
|
#include <vlc_aout.h>
|
2011-05-30 16:58:28 +02:00
|
|
|
#include <vlc_aout_mixer.h>
|
2002-08-29 00:25:39 +02:00
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* Local prototypes
|
|
|
|
*****************************************************************************/
|
2011-06-07 19:11:41 +02:00
|
|
|
static int Create( vlc_object_t * );
|
|
|
|
static void DoWork( aout_mixer_t *, aout_buffer_t *, float );
|
2002-08-29 00:25:39 +02:00
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
* Module descriptor
|
|
|
|
*****************************************************************************/
|
2008-10-29 20:59:01 +01:00
|
|
|
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 ()
|
2002-08-29 00:25:39 +02:00
|
|
|
|
2011-06-07 19:11:41 +02:00
|
|
|
/**
|
|
|
|
* Initializes the mixer
|
|
|
|
*/
|
2002-08-29 00:25:39 +02:00
|
|
|
static int Create( vlc_object_t *p_this )
|
|
|
|
{
|
2009-08-25 22:42:40 +02:00
|
|
|
aout_mixer_t * p_mixer = (aout_mixer_t *)p_this;
|
2002-08-29 00:25:39 +02:00
|
|
|
|
2009-08-25 22:42:40 +02:00
|
|
|
if ( p_mixer->fmt.i_format != VLC_CODEC_FL32 )
|
2002-08-29 00:25:39 +02:00
|
|
|
return -1;
|
|
|
|
|
2009-08-25 22:42:40 +02:00
|
|
|
p_mixer->mix = DoWork;
|
2002-08-29 00:25:39 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-06-07 19:11:41 +02:00
|
|
|
/**
|
|
|
|
* Mixes a new output buffer
|
|
|
|
*/
|
|
|
|
static void DoWork( aout_mixer_t * p_mixer, aout_buffer_t *p_buffer,
|
|
|
|
float f_multiplier )
|
2002-08-29 00:25:39 +02:00
|
|
|
{
|
2011-06-07 19:11:41 +02:00
|
|
|
f_multiplier *= p_mixer->input->multiplier;
|
2002-08-29 00:25:39 +02:00
|
|
|
|
2011-06-07 19:11:41 +02:00
|
|
|
if( f_multiplier == 1.0 )
|
|
|
|
return; /* nothing to do */
|
2011-04-07 20:36:02 +02:00
|
|
|
|
2011-06-07 19:11:41 +02:00
|
|
|
float *p = (float *)p_buffer->p_buffer;
|
|
|
|
for( size_t i = p_buffer->i_buffer / sizeof(float); i > 0; i-- )
|
|
|
|
*(p++) *= f_multiplier;
|
2002-08-29 00:25:39 +02:00
|
|
|
}
|