]> git.sesse.net Git - vlc/blob - modules/audio_mixer/float.c
Remove bonjour in access_output
[vlc] / modules / audio_mixer / float.c
1 /*****************************************************************************
2  * float32.c : precise float32 audio volume implementation
3  *****************************************************************************
4  * Copyright (C) 2002 VLC authors and VideoLAN
5  * $Id$
6  *
7  * Authors: Christophe Massiot <massiot@via.ecp.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation; either version 2.1 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this program; if not, write to the Free Software Foundation,
21  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27
28 #ifdef HAVE_CONFIG_H
29 # include "config.h"
30 #endif
31
32 #include <stddef.h>
33 #include <vlc_common.h>
34 #include <vlc_plugin.h>
35 #include <vlc_aout.h>
36 #include <vlc_aout_volume.h>
37
38 /*****************************************************************************
39  * Local prototypes
40  *****************************************************************************/
41 static int Create( vlc_object_t * );
42
43 /*****************************************************************************
44  * Module descriptor
45  *****************************************************************************/
46 vlc_module_begin ()
47     set_category( CAT_AUDIO )
48     set_subcategory( SUBCAT_AUDIO_MISC )
49     set_description( N_("Single precision audio volume") )
50     set_capability( "audio volume", 10 )
51     set_callbacks( Create, NULL )
52 vlc_module_end ()
53
54 /**
55  * Mixes a new output buffer
56  */
57 static void FilterFL32( audio_volume_t *p_volume, block_t *p_buffer,
58                         float f_multiplier )
59 {
60     if( f_multiplier == 1.f )
61         return; /* nothing to do */
62
63     float *p = (float *)p_buffer->p_buffer;
64     for( size_t i = p_buffer->i_buffer / sizeof(*p); i > 0; i-- )
65         *(p++) *= f_multiplier;
66
67     (void) p_volume;
68 }
69
70 static void FilterFL64( audio_volume_t *p_volume, block_t *p_buffer,
71                         float f_multiplier )
72 {
73     double *p = (double *)p_buffer->p_buffer;
74     double mult = f_multiplier;
75     if( mult == 1. )
76         return; /* nothing to do */
77
78     for( size_t i = p_buffer->i_buffer / sizeof(*p); i > 0; i-- )
79         *(p++) *= mult;
80
81     (void) p_volume;
82 }
83
84 /**
85  * Initializes the mixer
86  */
87 static int Create( vlc_object_t *p_this )
88 {
89     audio_volume_t *p_volume = (audio_volume_t *)p_this;
90
91     switch (p_volume->format)
92     {
93         case VLC_CODEC_FL32:
94             p_volume->amplify = FilterFL32;
95             break;
96         case VLC_CODEC_FL64:
97             p_volume->amplify = FilterFL64;
98             break;
99         default:
100             return -1;
101     }
102     return 0;
103 }