From: Holger Schemel Date: Sun, 28 Apr 2002 16:04:07 +0000 (+0200) Subject: rnd-20020428-1-src X-Git-Tag: 2.1.0^2~45 X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=commitdiff_plain;h=19db00ff98326cb4b92cea42080d7094e0842243 rnd-20020428-1-src --- diff --git a/src/libgame/sound.c b/src/libgame/sound.c index 7858f1f5..20a1978e 100644 --- a/src/libgame/sound.c +++ b/src/libgame/sound.c @@ -357,7 +357,7 @@ void SoundServer(void) select(audio.soundserver_pipe[0] + 1, &sound_fdset, NULL, NULL, &delay) < 1) { - short *sample_ptr; + void *sample_ptr; int sample_size; int max_sample_size; int fragment_size = afmt.fragment_size; @@ -380,23 +380,60 @@ void SoundServer(void) continue; /* get pointer and size of the actual sound sample */ - sample_ptr = (short *)playlist[i].data_ptr +playlist[i].playingpos; + if (playlist[i].format == AUDIO_FORMAT_U8) + sample_ptr = + (byte *)playlist[i].data_ptr + playlist[i].playingpos; + else + sample_ptr = + (short *)playlist[i].data_ptr + playlist[i].playingpos; + sample_size = MIN(max_sample_size, playlist[i].data_len - playlist[i].playingpos); playlist[i].playingpos += sample_size; /* fill the first mixing buffer with original sample */ +#if 1 + if (playlist[i].format == AUDIO_FORMAT_U8) + for (j=0; jdata_ptr; snd_ctrl.data_len = snd_info->data_len; + snd_ctrl.format = snd_info->format; playlist[i] = snd_ctrl; playing_sounds++; @@ -1172,15 +1210,24 @@ static SoundInfo *Load_WAV(char *filename) return NULL; } - /* convert unsigned 8 bit sample data to signed 16 bit sample data */ + if (0) + { + /* convert unsigned 8 bit sample data to signed 16 bit sample data */ + + data_ptr = checked_malloc(snd_info->data_len * sizeof(short)); - data_ptr = checked_malloc(snd_info->data_len * sizeof(short)); + for (i=0; idata_len; i++) + data_ptr[i] = ((short)(((byte *)snd_info->data_ptr)[i] ^ 0x80)) << 8; - for (i=0; idata_len; i++) - data_ptr[i] = ((short)(((byte *)snd_info->data_ptr)[i] ^ 0x80)) << 8; + free(snd_info->data_ptr); + snd_info->data_ptr = data_ptr; - free(snd_info->data_ptr); - snd_info->data_ptr = data_ptr; + snd_info->format = AUDIO_FORMAT_S16; + } + else + { + snd_info->format = AUDIO_FORMAT_U8; + } #endif /* PLATFORM_UNIX */ diff --git a/src/libgame/sound.h b/src/libgame/sound.h index 3986194e..14662343 100644 --- a/src/libgame/sound.h +++ b/src/libgame/sound.h @@ -199,6 +199,7 @@ struct SampleInfo long data_len; void *data_ptr; + int format; }; typedef struct SampleInfo SoundInfo; @@ -224,6 +225,7 @@ struct SoundControl long data_len; void *data_ptr; + int format; #if defined(PLATFORM_MSDOS) int voice;