From: Christophe Massiot Date: Mon, 16 Sep 2002 20:46:38 +0000 (+0000) Subject: * configure.in: Fixed detection of Qt-embedded. X-Git-Tag: 0.5.0~956 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=cf891bad55157104f8d9d50b1d95b25ebc7f7a5e;p=vlc * configure.in: Fixed detection of Qt-embedded. * modules/codec/a52.c: Fixed detection of A/52 sound. * modules/audio_filter/converter/a52tofloat32.c: Fixed a bug related to downmixing. * ALL: Added hooks for audio volume management. --- diff --git a/configure.in b/configure.in index 5e65cefa29..0954243a00 100644 --- a/configure.in +++ b/configure.in @@ -1394,17 +1394,21 @@ then then test_LDFLAGS="-L${QTDIR}/lib" test_CFLAGS="-I$(QTDIR)/include" - PLUGINS="${PLUGINS} video_output/qte/qte" else test_LDFLAGS="-L${with_qte}/lib" test_CFLAGS="-I${with_qte}/include" - BUILTINS="${BUILTINS} video_output/qte/qte" fi CPPFLAGS="${save_CPPFLAGS} ${test_CFLAGS}" AC_CHECK_HEADERS(qt.h, [ qte_CFLAGS="${qte_CFLAGS} ${test_CFLAGS} -DQT_QWS_IPAQ -DQWS -fno-exceptions -fno-rtti" qte_LDFLAGS="${qte_LDFLAGS} ${test_LDFLAGS} -lqpe -lqte" + if test "x${with_qte}" = "x" + then + PLUGINS="${PLUGINS} video_output/qte/qte" + else + BUILTINS="${BUILTINS} video_output/qte/qte" + fi ]) CPPFLAGS="${save_CPPFLAGS}" fi diff --git a/include/aout_internal.h b/include/aout_internal.h index 8de8f11583..9c0532c27a 100644 --- a/include/aout_internal.h +++ b/include/aout_internal.h @@ -2,7 +2,7 @@ * aout_internal.h : internal defines for audio output ***************************************************************************** * Copyright (C) 2002 VideoLAN - * $Id: aout_internal.h,v 1.16 2002/09/06 23:15:44 massiot Exp $ + * $Id: aout_internal.h,v 1.17 2002/09/16 20:46:37 massiot Exp $ * * Authors: Christophe Massiot * @@ -119,6 +119,11 @@ typedef struct aout_mixer_t struct aout_mixer_sys_t * p_sys; void (* pf_do_work)( struct aout_instance_t *, struct aout_buffer_t * ); + + /* Multiplier used to raise or lower the volume of the sound in + * software. Beware, this creates sound distortion and should be avoided + * as much as possible. This isn't available for non-float32 mixer. */ + float f_multiplier; } aout_mixer_t; /***************************************************************************** @@ -159,7 +164,14 @@ typedef struct aout_output_t struct module_t * p_module; struct aout_sys_t * p_sys; void (* pf_play)( aout_instance_t * ); + int (* pf_volume_get )( aout_instance_t *, audio_volume_t * ); + int (* pf_volume_set )( aout_instance_t *, audio_volume_t ); + int (* pf_volume_infos )( aout_instance_t *, audio_volume_t *, audio_volume_t * ); int i_nb_samples; + + /* Current volume for the output - it's just a placeholder, the plug-in + * may or may not use it. */ + audio_volume_t i_volume; } aout_output_t; /***************************************************************************** @@ -219,6 +231,8 @@ void aout_FiltersPlay( aout_instance_t * p_aout, int aout_MixerNew( aout_instance_t * p_aout ); void aout_MixerDelete( aout_instance_t * p_aout ); void aout_MixerRun( aout_instance_t * p_aout ); +int aout_MixerMultiplierSet( aout_instance_t * p_aout, float f_multiplier ); +int aout_MixerMultiplierGet( aout_instance_t * p_aout, float * pf_multiplier ); int aout_OutputNew( aout_instance_t * p_aout, audio_sample_format_t * p_format ); diff --git a/include/audio_output.h b/include/audio_output.h index e22bfd324d..2439b950f9 100644 --- a/include/audio_output.h +++ b/include/audio_output.h @@ -2,7 +2,7 @@ * audio_output.h : audio output interface ***************************************************************************** * Copyright (C) 2002 VideoLAN - * $Id: audio_output.h,v 1.62 2002/09/02 23:17:05 massiot Exp $ + * $Id: audio_output.h,v 1.63 2002/09/16 20:46:37 massiot Exp $ * * Authors: Christophe Massiot * @@ -165,6 +165,11 @@ struct audio_date_t u32 i_remainder; }; +/***************************************************************************** + * audio_volume_t : integer value for the audio volume + *****************************************************************************/ +typedef unsigned int audio_volume_t; + /***************************************************************************** * Prototypes *****************************************************************************/ @@ -186,3 +191,5 @@ VLC_EXPORT( mtime_t, aout_DateIncrement, ( audio_date_t *, u32 ) ); VLC_EXPORT( aout_input_t *, __aout_InputNew, ( vlc_object_t *, aout_instance_t **, audio_sample_format_t * ) ); VLC_EXPORT( void, aout_InputDelete, ( aout_instance_t *, aout_input_t * ) ); +/* From intf.c : */ + diff --git a/include/vlc_config.h b/include/vlc_config.h index 6fcf8d2713..08b354ea68 100644 --- a/include/vlc_config.h +++ b/include/vlc_config.h @@ -1,8 +1,8 @@ /***************************************************************************** - * config.h: limits and configuration + * vlc_config.h: limits and configuration * Defines all compilation-time configuration constants and size limits ***************************************************************************** - * Copyright (C) 1999, 2000, 2001 VideoLAN + * Copyright (C) 1999-2002 VideoLAN * * Authors: Vincent Seguin * Samuel Hocevar @@ -124,10 +124,10 @@ #define AOUT_MAX_THREADS 10 /* Volume */ -#define VOLUME_DEFAULT 256 -#define VOLUME_STEP 32 -#define VOLUME_MAX 1024 -#define VOLUME_MIN 0 +#define AOUT_VOLUME_DEFAULT 256 +#define AOUT_VOLUME_STEP 32 +#define AOUT_VOLUME_MAX 1024 +#define AOUT_VOLUME_MIN 0 /* Max number of pre-filters per input, and max number of post-filters */ #define AOUT_MAX_FILTERS 10 diff --git a/modules/audio_filter/converter/a52tofloat32.c b/modules/audio_filter/converter/a52tofloat32.c index d36f3cf77c..96081ac26d 100644 --- a/modules/audio_filter/converter/a52tofloat32.c +++ b/modules/audio_filter/converter/a52tofloat32.c @@ -4,7 +4,7 @@ * (http://liba52.sf.net/). ***************************************************************************** * Copyright (C) 2001, 2002 VideoLAN - * $Id: a52tofloat32.c,v 1.1 2002/09/02 23:17:05 massiot Exp $ + * $Id: a52tofloat32.c,v 1.2 2002/09/16 20:46:37 massiot Exp $ * * Authors: Gildas Bazin * Christophe Massiot @@ -190,7 +190,7 @@ static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter, a52_frame( p_sys->p_liba52, p_in_buf->p_buffer, &i_flags, &i_sample_level, 0 ); - if ( i_flags != p_sys->i_flags ) + if ( (i_flags & A52_CHANNEL_MASK) != (p_sys->i_flags & A52_CHANNEL_MASK) ) { msg_Err( p_filter, "liba52 couldn't do the requested downmix 0x%x->0x%x", diff --git a/modules/audio_mixer/float32.c b/modules/audio_mixer/float32.c index 3073755dcd..d649795da9 100644 --- a/modules/audio_mixer/float32.c +++ b/modules/audio_mixer/float32.c @@ -2,7 +2,7 @@ * float32.c : precise float32 audio mixer implementation ***************************************************************************** * Copyright (C) 2002 VideoLAN - * $Id: float32.c,v 1.1 2002/08/28 22:25:38 massiot Exp $ + * $Id: float32.c,v 1.2 2002/09/16 20:46:37 massiot Exp $ * * Authors: Christophe Massiot * @@ -60,7 +60,7 @@ static int Create( vlc_object_t *p_this ) return -1; } - if ( p_aout->i_nb_inputs == 1 ) + if ( p_aout->i_nb_inputs == 1 && p_aout->mixer.f_multiplier == 1.0 ) { /* Tell the trivial mixer to go for it. */ return -1; @@ -75,13 +75,14 @@ static int Create( vlc_object_t *p_this ) * ScaleWords: prepare input words for averaging *****************************************************************************/ static void ScaleWords( float * p_out, const float * p_in, size_t i_nb_words, - int i_nb_inputs ) + int i_nb_inputs, float f_multiplier ) { int i; + f_multiplier /= i_nb_inputs; for ( i = i_nb_words; i--; ) { - *p_out++ = *p_in++ / i_nb_inputs; + *p_out++ = *p_in++ * f_multiplier; } } @@ -89,13 +90,14 @@ static void ScaleWords( float * p_out, const float * p_in, size_t i_nb_words, * MeanWords: average input words *****************************************************************************/ static void MeanWords( float * p_out, const float * p_in, size_t i_nb_words, - int i_nb_inputs ) + int i_nb_inputs, float f_multiplier ) { int i; + f_multiplier /= i_nb_inputs; for ( i = i_nb_words; i--; ) { - *p_out++ += *p_in++ / i_nb_inputs; + *p_out++ += *p_in++ * f_multiplier; } } @@ -134,12 +136,12 @@ static void DoWork( aout_instance_t * p_aout, aout_buffer_t * p_buffer ) if ( !i_input ) { ScaleWords( p_out, p_in, i_available_words, - i_nb_inputs ); + i_nb_inputs, p_aout->mixer.f_multiplier ); } else { MeanWords( p_out, p_in, i_available_words, - i_nb_inputs ); + i_nb_inputs, p_aout->mixer.f_multiplier ); } } @@ -162,11 +164,13 @@ static void DoWork( aout_instance_t * p_aout, aout_buffer_t * p_buffer ) { if ( !i_input ) { - ScaleWords( p_out, p_in, i_nb_words, i_nb_inputs ); + ScaleWords( p_out, p_in, i_nb_words, i_nb_inputs, + p_aout->mixer.f_multiplier ); } else { - MeanWords( p_out, p_in, i_nb_words, i_nb_inputs ); + MeanWords( p_out, p_in, i_nb_words, i_nb_inputs, + p_aout->mixer.f_multiplier ); } } p_input->p_first_byte_to_mix = (void *)(p_in diff --git a/modules/codec/a52.c b/modules/codec/a52.c index b450d4a24a..a21c3e75eb 100644 --- a/modules/codec/a52.c +++ b/modules/codec/a52.c @@ -2,7 +2,7 @@ * a52.c: A/52 basic parser ***************************************************************************** * Copyright (C) 2001-2002 VideoLAN - * $Id: a52.c,v 1.10 2002/09/06 23:15:44 massiot Exp $ + * $Id: a52.c,v 1.11 2002/09/16 20:46:38 massiot Exp $ * * Authors: Stéphane Borel * Christophe Massiot @@ -84,7 +84,7 @@ static int SyncInfo ( const byte_t *, int *, int *, int * ); *****************************************************************************/ vlc_module_begin(); set_description( _("A/52 parser") ); - set_capability( "decoder", 0 ); + set_capability( "decoder", 100 ); set_callbacks( OpenDecoder, NULL ); add_shortcut( "pass_through" ); add_shortcut( "pass" ); diff --git a/src/audio_output/audio_output.c b/src/audio_output/audio_output.c index 3fc2fcbfee..d070fc984e 100644 --- a/src/audio_output/audio_output.c +++ b/src/audio_output/audio_output.c @@ -2,7 +2,7 @@ * audio_output.c : audio output instance miscellaneous functions ***************************************************************************** * Copyright (C) 2002 VideoLAN - * $Id: audio_output.c,v 1.101 2002/09/02 23:17:06 massiot Exp $ + * $Id: audio_output.c,v 1.102 2002/09/16 20:46:38 massiot Exp $ * * Authors: Christophe Massiot * @@ -59,6 +59,7 @@ aout_instance_t * __aout_NewInstance( vlc_object_t * p_parent ) vlc_mutex_init( p_parent, &p_aout->mixer_lock ); vlc_mutex_init( p_parent, &p_aout->output_fifo_lock ); p_aout->i_nb_inputs = 0; + p_aout->mixer.f_multiplier = 1.0; vlc_object_attach( p_aout, p_parent->p_vlc ); diff --git a/src/audio_output/intf.c b/src/audio_output/intf.c new file mode 100644 index 0000000000..41c7226a96 --- /dev/null +++ b/src/audio_output/intf.c @@ -0,0 +1,248 @@ +/***************************************************************************** + * intf.c : audio output API towards the interface modules + ***************************************************************************** + * Copyright (C) 2002 VideoLAN + * $Id: intf.c,v 1.1 2002/09/16 20:46:38 massiot Exp $ + * + * Authors: Christophe Massiot + * + * 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. + * + * 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 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + *****************************************************************************/ + +/***************************************************************************** + * Preamble + *****************************************************************************/ +#include /* calloc(), malloc(), free() */ +#include + +#include + +#include "audio_output.h" +#include "aout_internal.h" + +/* + * Volume management + * + * The hardware volume cannot be set if the output module gets deleted, so + * we must take the mixer lock. The software volume cannot be set while the + * mixer is running, so we need the mixer lock (too). + * + * Here is a schematic of the i_volume range : + * + * |------------------+------------------------------------+--------------| + * 0 pi_low_soft pi_high_soft 1024 + * + * Between pi_low_soft and pi_high_soft, the volume is done in hardware + * by the output module. Outside, the output module will change + * p_aout->mixer.i_multiplier (done in software). This scaling may result + * in cropping errors and should be avoided as much as possible. + * + * It is legal to have *pi_low_soft == *pi_high_soft, and do everything in + * software. In that case, it is recommended to use *pi_low_soft == 256, + * along with the utility functions provided in this file. + * + * It is also legal to have *pi_low_soft == 0 and *pi_high_soft == 1024, and + * completely avoid software scaling. However, some streams (esp. A/52) + * are encoded with a very low volume and users may complain. + */ + +/***************************************************************************** + * aout_VolumeGet : get the volume of the output device + *****************************************************************************/ +int aout_VolumeGet( aout_instance_t * p_aout, audio_volume_t * pi_volume ) +{ + int i_result; + + vlc_mutex_lock( &p_aout->mixer_lock ); + + if ( p_aout->i_nb_inputs == 0 ) + { + /* The output module is destroyed. */ + vlc_mutex_unlock( &p_aout->mixer_lock ); + msg_Err( p_aout, "VolumeGet called without output module" ); + return -1; + } + + i_result = p_aout->output.pf_volume_get( p_aout, pi_volume ); + + vlc_mutex_lock( &p_aout->mixer_lock ); + return i_result; +} + +/***************************************************************************** + * aout_VolumeSet : set the volume of the output device + *****************************************************************************/ +int aout_VolumeSet( aout_instance_t * p_aout, audio_volume_t i_volume ) +{ + int i_result; + + vlc_mutex_lock( &p_aout->mixer_lock ); + + if ( p_aout->i_nb_inputs == 0 ) + { + /* The output module is destroyed. */ + vlc_mutex_unlock( &p_aout->mixer_lock ); + msg_Err( p_aout, "VolumeSet called without output module" ); + return -1; + } + + i_result = p_aout->output.pf_volume_set( p_aout, i_volume ); + + vlc_mutex_lock( &p_aout->mixer_lock ); + return i_result; +} + +/***************************************************************************** + * aout_VolumeInfos : get the boundaries pi_low_soft and pi_high_soft + *****************************************************************************/ +int aout_VolumeInfos( aout_instance_t * p_aout, audio_volume_t * pi_low_soft, + audio_volume_t * pi_high_soft ) +{ + int i_result; + + vlc_mutex_lock( &p_aout->mixer_lock ); + + if ( p_aout->i_nb_inputs == 0 ) + { + /* The output module is destroyed. */ + vlc_mutex_unlock( &p_aout->mixer_lock ); + msg_Err( p_aout, "VolumeInfos called without output module" ); + return -1; + } + + i_result = p_aout->output.pf_volume_infos( p_aout, pi_low_soft, + pi_high_soft ); + + vlc_mutex_lock( &p_aout->mixer_lock ); + return i_result; +} + +/***************************************************************************** + * aout_VolumeUp : raise the output volume + ***************************************************************************** + * If pi_volume != NULL, *pi_volume will contain the volume at the end of the + * function. + *****************************************************************************/ +int aout_VolumeUp( aout_instance_t * p_aout, int i_nb_steps, + audio_volume_t * pi_volume ) +{ + int i_result; + audio_volume_t i_volume; + + vlc_mutex_lock( &p_aout->mixer_lock ); + + if ( p_aout->i_nb_inputs == 0 ) + { + /* The output module is destroyed. */ + vlc_mutex_unlock( &p_aout->mixer_lock ); + msg_Err( p_aout, "VolumeUp called without output module" ); + return -1; + } + + if ( p_aout->output.pf_volume_get( p_aout, &i_volume ) ) + { + vlc_mutex_unlock( &p_aout->mixer_lock ); + return -1; + } + + i_volume += AOUT_VOLUME_STEP * i_nb_steps; + if ( i_volume > 1024 ) i_volume = 1024; + + i_result = p_aout->output.pf_volume_set( p_aout, i_volume ); + + vlc_mutex_lock( &p_aout->mixer_lock ); + + if ( pi_volume != NULL ) *pi_volume = i_volume; + return i_result; +} + +/***************************************************************************** + * aout_VolumeDown : lower the output volume + ***************************************************************************** + * If pi_volume != NULL, *pi_volume will contain the volume at the end of the + * function. + *****************************************************************************/ +int aout_VolumeDown( aout_instance_t * p_aout, int i_nb_steps, + audio_volume_t * pi_volume ) +{ + int i_result; + audio_volume_t i_volume; + + vlc_mutex_lock( &p_aout->mixer_lock ); + + if ( p_aout->i_nb_inputs == 0 ) + { + /* The output module is destroyed. */ + vlc_mutex_unlock( &p_aout->mixer_lock ); + msg_Err( p_aout, "VolumeUp called without output module" ); + return -1; + } + + if ( p_aout->output.pf_volume_get( p_aout, &i_volume ) ) + { + vlc_mutex_unlock( &p_aout->mixer_lock ); + return -1; + } + + if ( i_volume < AOUT_VOLUME_STEP * i_nb_steps ) + i_volume = 0; + else + i_volume -= AOUT_VOLUME_STEP * i_nb_steps; + + i_result = p_aout->output.pf_volume_set( p_aout, i_volume ); + + vlc_mutex_lock( &p_aout->mixer_lock ); + + if ( pi_volume != NULL ) *pi_volume = i_volume; + return i_result; +} + +/* + * The next functions are not supposed to be called by the interface, but + * are placeholders for software-only scaling. + */ + +/* Meant to be called by the output plug-in's Open(). */ +void aout_VolumeSoftInit( aout_instance_t * p_aout ) +{ + p_aout->output.i_volume = AOUT_VOLUME_DEFAULT; +} + +/* Placeholder for pf_volume_infos(). */ +int aout_VolumeSoftInfos( aout_instance_t * p_aout, + audio_volume_t * pi_low_soft, + audio_volume_t * pi_high_soft ) +{ + *pi_low_soft = *pi_high_soft = AOUT_VOLUME_DEFAULT; + return 0; +} + +/* Placeholder for pf_volume_get(). */ +int aout_VolumeSoftGet( aout_instance_t * p_aout, + audio_volume_t * pi_volume ) +{ + *pi_volume = p_aout->output.i_volume; + return 0; +} + + +/* Placeholder for pf_volume_set(). */ +int aout_VolumeSoftSet( aout_instance_t * p_aout, + audio_volume_t i_volume ) +{ + aout_MixerMultiplierSet( p_aout, (float)(i_volume / AOUT_VOLUME_DEFAULT) ); + return 0; +} + diff --git a/src/audio_output/mixer.c b/src/audio_output/mixer.c index 25b7ddbacd..dbda7a0f2e 100644 --- a/src/audio_output/mixer.c +++ b/src/audio_output/mixer.c @@ -2,7 +2,7 @@ * mixer.c : audio output mixing operations ***************************************************************************** * Copyright (C) 2002 VideoLAN - * $Id: mixer.c,v 1.11 2002/08/30 22:22:24 massiot Exp $ + * $Id: mixer.c,v 1.12 2002/09/16 20:46:38 massiot Exp $ * * Authors: Christophe Massiot * @@ -289,3 +289,52 @@ void aout_MixerRun( aout_instance_t * p_aout ) { while( MixBuffer( p_aout ) != -1 ); } + +/***************************************************************************** + * aout_MixerMultiplierSet: set p_aout->mixer.f_multiplier + ***************************************************************************** + * Please note that we assume that you own the mixer lock when entering this + * function. This function returns -1 on error. + *****************************************************************************/ +int aout_MixerMultiplierSet( aout_instance_t * p_aout, float f_multiplier ) +{ + float f_old = p_aout->mixer.f_multiplier; + + if ( p_aout->mixer.mixer.i_format != AOUT_FMT_FLOAT32 ) + { + msg_Warn( p_aout, "MixerMultiplierSet called for non-float32 mixer" ); + return -1; + } + + aout_MixerDelete( p_aout ); + + p_aout->mixer.f_multiplier = f_multiplier; + + if ( aout_MixerNew( p_aout ) ) + { + p_aout->mixer.f_multiplier = f_old; + aout_MixerNew( p_aout ); + return -1; + } + + return 0; +} + +/***************************************************************************** + * aout_MixerMultiplierGet: get p_aout->mixer.f_multiplier + ***************************************************************************** + * Please note that we assume that you own the mixer lock when entering this + * function. This function returns -1 on error. + *****************************************************************************/ +int aout_MixerMultiplierGet( aout_instance_t * p_aout, float * pf_multiplier ) +{ + if ( p_aout->mixer.mixer.i_format != AOUT_FMT_FLOAT32 ) + { + msg_Warn( p_aout, "MixerMultiplierGet called for non-float32 mixer" ); + return -1; + } + + *pf_multiplier = p_aout->mixer.f_multiplier; + return 0; +} + diff --git a/src/libvlc.h b/src/libvlc.h index 53fb3ae53c..09328d6df1 100644 --- a/src/libvlc.h +++ b/src/libvlc.h @@ -2,7 +2,7 @@ * libvlc.h: main libvlc header ***************************************************************************** * Copyright (C) 1998-2002 VideoLAN - * $Id: libvlc.h,v 1.14 2002/08/16 12:31:04 sam Exp $ + * $Id: libvlc.h,v 1.15 2002/09/16 20:46:38 massiot Exp $ * * Authors: Vincent Seguin * Samuel Hocevar @@ -358,7 +358,7 @@ vlc_module_begin(); add_module_with_short( "aout", 'A', "audio output", NULL, NULL, AOUT_TEXT, AOUT_LONGTEXT ); add_bool( "audio", 1, NULL, AUDIO_TEXT, AUDIO_LONGTEXT ); - add_integer( "volume", VOLUME_DEFAULT, NULL, VOLUME_TEXT, VOLUME_LONGTEXT ); + add_integer( "volume", -1, NULL, VOLUME_TEXT, VOLUME_LONGTEXT ); add_integer( "aout-rate", -1, NULL, AOUT_RATE_TEXT, AOUT_RATE_LONGTEXT ); add_integer( "aout-channels", -1, NULL, AOUT_CHANNELS_TEXT, AOUT_CHANNELS_LONGTEXT );