From cae319c9d3e0f801677ebc17bc6fc4523c27e84a Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Sat, 16 Oct 2004 18:26:51 +0000 Subject: - Speed up amp set at 0%, add support for 8-bit sounds in the amplifier Fixes sound volume in Totem for: http://www.amayita.com/videos/01_Bar_Victoria.avi 24-bit amp support not implemented, still broken: ftp://ftp.mplayerhq.hu/MPlayer/samples/A-codecs/test-96.wav CVS patchset: 7041 CVS date: 2004/10/16 18:26:51 --- src/xine-engine/audio_out.c | 64 ++++++++++++++++++++++++++++++++------------- 1 file changed, 46 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c index 2fa7980c2..70856b0e7 100644 --- a/src/xine-engine/audio_out.c +++ b/src/xine-engine/audio_out.c @@ -17,7 +17,7 @@ * along with self program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: audio_out.c,v 1.185 2004/09/26 22:54:52 valtri Exp $ + * $Id: audio_out.c,v 1.186 2004/10/16 18:26:51 hadess Exp $ * * 22-8-2001 James imported some useful AC3 sections from the previous alsa driver. * (c) 2001 Andy Lo A Foe @@ -554,33 +554,56 @@ static void audio_filter_compress (aos_t *this, int16_t *mem, int num_frames) { } } -static void audio_filter_amp (aos_t *this, int16_t *mem, int num_frames) { +static void audio_filter_amp (aos_t *this, void *buf, int num_frames) { int i; int num_channels; double amp_factor; - int32_t test; num_channels = _x_ao_mode2channels (this->input.mode); if (!num_channels) return; amp_factor=this->amp_factor; - if (this->amp_mute) amp_factor=0.0; - - for (i=0; iamp_factor = amp_factor = amp_factor * INT16_MIN / test; - test=INT16_MIN; + if (this->amp_mute || amp_factor == 0) { + memset (buf, 0, num_frames * num_channels * (this->input.bits / 8)); + return; + } + + if (this->input.bits == 8) { + int16_t test; + int8_t *mem = (int8_t *) buf; + + for (i=0; iamp_factor = amp_factor = amp_factor * INT8_MIN / test; + test=INT8_MIN; + } + if (test > INT8_MAX) { + this->amp_factor = amp_factor = amp_factor * INT8_MIN / test; + test=INT8_MAX; + } + mem[i] = test; } - if (test > INT16_MAX) { - this->amp_factor = amp_factor = amp_factor * INT16_MIN / test; - test=INT16_MAX; + } else if (this->input.bits == 16) { + int32_t test; + int16_t *mem = (int16_t *) buf; + + for (i=0; iamp_factor = amp_factor = amp_factor * INT16_MIN / test; + test=INT16_MIN; + } + if (test > INT16_MAX) { + this->amp_factor = amp_factor = amp_factor * INT16_MIN / test; + test=INT16_MAX; + } + mem[i] = test; } - mem[i] = test; - } } @@ -651,14 +674,19 @@ static audio_buffer_t* prepare_samples( aos_t *this, audio_buffer_t *buf) { * volume / compressor / equalizer filter */ - if (this->input.bits == 16) { - + if (this->amp_factor == 0) { + if (this->do_amp) + audio_filter_amp (this, buf->mem, buf->num_frames); + } else if (this->input.bits == 16) { if (this->do_equ) audio_filter_equalize (this, buf->mem, buf->num_frames); if (this->do_compress) audio_filter_compress (this, buf->mem, buf->num_frames); if (this->do_amp) audio_filter_amp (this, buf->mem, buf->num_frames); + } else if (this->input.bits == 8) { + if (this->do_amp) + audio_filter_amp (this, buf->mem, buf->num_frames); } -- cgit v1.2.3