summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--src/xine-engine/audio_out.c64
2 files changed, 47 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index 04a2272fb..7f73f7f39 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -30,6 +30,7 @@
* Fixed playback of incomplete OpenDML streams
* Fixed crash when xine_stop is called and the stream is ending
* Fixed crash when the video_out loop still references a disposed stream
+ * Make amp work with 8-bit sounds
xine-lib (1-rc6)
* Moved win32 frontend into separate module.
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 <andy@alsaplayer.org>
@@ -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; i<num_frames*num_channels; i++) {
- test = mem[i] * amp_factor;
-/* Force limit on amp_factor to prevent clipping */
- if (test < INT16_MIN) {
- this->amp_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; i<num_frames*num_channels; i++) {
+ test = mem[i] * amp_factor;
+ /* Force limit on amp_factor to prevent clipping */
+ if (test < INT8_MIN) {
+ this->amp_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; i<num_frames*num_channels; i++) {
+ test = mem[i] * amp_factor;
+ /* Force limit on amp_factor to prevent clipping */
+ if (test < INT16_MIN) {
+ this->amp_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);
}