comparison libao2/ao_null.c @ 25195:1aec672af2d2

Fix ao_null with float samples ao_null accepts float input, but the code calculating ao_data.bps only checked for 1-byte formats and used samplesize 2 for everything else. Because ao_null uses the bps value in its timing calculations this effectively made "playback" advance at half the correct speed. Fixed by calculating samplesize with af_fmt2bits() instead.
author uau
date Sat, 01 Dec 2007 05:17:08 +0000
parents e816d546c4fe
children e45b08f2f5d3
comparison
equal deleted inserted replaced
25194:e816d546c4fe 25195:1aec672af2d2
48 48
49 // open & setup audio device 49 // open & setup audio device
50 // return: 1=success 0=fail 50 // return: 1=success 0=fail
51 static int init(int rate,int channels,int format,int flags){ 51 static int init(int rate,int channels,int format,int flags){
52 52
53 int samplesize = (format == AF_FORMAT_U8 || format == AF_FORMAT_S8) ? 1: 2; 53 int samplesize = af_fmt2bits(format) / 8;
54 ao_data.outburst = 256 * channels * samplesize; 54 ao_data.outburst = 256 * channels * samplesize;
55 // A "buffer" for about 0.2 seconds of audio 55 // A "buffer" for about 0.2 seconds of audio
56 ao_data.buffersize = (int)(rate * 0.2 / 256 + 1) * ao_data.outburst; 56 ao_data.buffersize = (int)(rate * 0.2 / 256 + 1) * ao_data.outburst;
57 ao_data.channels=channels; 57 ao_data.channels=channels;
58 ao_data.samplerate=rate; 58 ao_data.samplerate=rate;