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