[MPlayer-dev-eng] [PATCH] libao2/ao_alsa9.c: allow playing 8-bit audio
R.L. Horn
eastcheap at fastmail.fm
Tue Dec 3 10:08:06 CET 2002
The enclosed patch should fix problems associated with playing 8-bit wide
audio samples (or anything other than 16-bit samples, for that matter)
using the alsa9 ao driver.
The problem arises because of the following declaration in play_normal():
signed short *output_samples=data;
Later on:
output_samples += ao_data.channels * res;
Unfortunately, samples aren't always shorts, so this can cause some
ugly weirdness.
The patch changes output_samples to a char * and replaces the increment
with:
output_samples += res * bytes_per_sample;
This seems to fix things.
-------------- next part --------------
diff -aur main-old/libao2/ao_alsa9.c main/libao2/ao_alsa9.c
--- main-old/libao2/ao_alsa9.c 2002-11-02 04:59:27.000000000 -0600
+++ main/libao2/ao_alsa9.c 2002-12-03 02:20:46.000000000 -0600
@@ -853,10 +853,16 @@
//bytes_per_sample is always 4 for 2 chn S16_LE
int num_frames = len / bytes_per_sample;
+
+/*
+ Output data aren't always 16-bits wide. Use char instead of short.
signed short *output_samples=data;
+*/
+ char *output_samples = (char *)data;
snd_pcm_sframes_t res = 0;
- //printf("alsa-play: frames=%i, len=%i",num_frames,len);
+ /* XXX */
+ //fprintf(stderr,"alsa-play: frames=%i, len=%i\n",num_frames,len);
if (!alsa_handler) {
printf("alsa-play: device configuration error");
@@ -891,7 +897,10 @@
}
if (res > 0) {
- output_samples += ao_data.channels * res;
+
+ /* output_samples += ao_data.channels * res; */
+ output_samples += res * bytes_per_sample;
+
num_frames -= res;
}
More information about the MPlayer-dev-eng
mailing list