X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Fgame_em%2Fsound.c;h=f03abf1e014abbb3c48d95f06b0117924c001396;hp=8fa4565347e2b77792f3fe586057b47d4cce6332;hb=c91aa2b237bef6003ead8dfc98cdcab89f97c654;hpb=86e1890b2d87dd7710b320e2b306c7291d41e2a5 diff --git a/src/game_em/sound.c b/src/game_em/sound.c index 8fa45653..f03abf1e 100644 --- a/src/game_em/sound.c +++ b/src/game_em/sound.c @@ -20,14 +20,12 @@ #include #endif -#include "global.h" -#include "sample.h" - static char audioname[] = "/dev/audio"; static const int sound_priority[SAMPLE_MAX] = { - SAMPLE_exit, + SAMPLE_exit_open, + SAMPLE_exit_leave, SAMPLE_die, SAMPLE_time, SAMPLE_boom, @@ -40,7 +38,8 @@ static const int sound_priority[SAMPLE_MAX] = SAMPLE_door, SAMPLE_dirt, SAMPLE_blank, - SAMPLE_android, + SAMPLE_android_clone, + SAMPLE_android_move, SAMPLE_ball, SAMPLE_grow, SAMPLE_squash, @@ -57,6 +56,7 @@ static const int sound_priority[SAMPLE_MAX] = SAMPLE_bug, SAMPLE_tank, SAMPLE_eater, + SAMPLE_eater_eat, SAMPLE_alien, SAMPLE_acid }; @@ -65,13 +65,13 @@ int sound_thread(void) { int audio_fd; /* file descriptor of /dev/audio or -1 if not open */ int audio_format; - int sample_rate; + // int sample_rate; int fragment_size; unsigned char *audio_buffer; /* actual buffer pumped to /dev/audio */ short *mix_buffer; char sound_play[SAMPLE_MAX]; /* if set, we should be playing these sounds */ - long sound_pos[SAMPLE_MAX]; /* position in the sound */ + int sound_pos[SAMPLE_MAX]; /* position in the sound */ int mix_play[MIXER_MAX]; /* which sounds we have chosen to mix (calculated each time) */ int mix_count; int i; @@ -80,13 +80,13 @@ int sound_thread(void) audio_fd = -1; audio_format = AUDIO_ULAW; /* defaults for non-OSS /dev/audio */ - sample_rate = 8000; + // sample_rate = 8000; fragment_size = 256; audio_buffer = 0; mix_buffer = 0; mix_count = 0; - memset(sound_play, 0, sizeof(sound_play)); /* not playing any sounds */ + clear_mem(sound_play, sizeof(sound_play)); /* not playing any sounds */ for (;;) { @@ -94,7 +94,9 @@ int sound_thread(void) { /* pick sounds to play, if any */ - if (sound_play[SAMPLE_exit] || sound_play[SAMPLE_die]) + if (sound_play[SAMPLE_exit_open] || + sound_play[SAMPLE_exit_leave] || + sound_play[SAMPLE_die]) sound_play[SAMPLE_boom] = 0; /* no explosions if player goes home */ mix_count = 0; @@ -240,7 +242,7 @@ int sound_thread(void) goto reset; } - sample_rate = i; + // sample_rate = i; if (ioctl(audio_fd, SNDCTL_DSP_GETBLKSIZE, &i) == -1) { Error(ERR_WARN, "unable to get block size in sound thread"); @@ -292,14 +294,14 @@ int sound_thread(void) if (mix_count && audio_fd != -1) { /* prepare mix buffer */ - memset(mix_buffer, 0, fragment_size * sizeof(*mix_buffer)); + clear_mem(mix_buffer, fragment_size * sizeof(*mix_buffer)); for (i = 0; i < mix_count; i++) { register short *mix_ptr = mix_buffer; register short *sound_ptr = sound_data[mix_play[i]] + sound_pos[mix_play[i]]; - register long count = + register int count = sound_length[mix_play[i]] - sound_pos[mix_play[i]]; if (count > fragment_size) @@ -378,16 +380,16 @@ int sound_thread(void) return(0); } -int read_sample(char *name, short **data, long *length) +int read_sample(char *name, short **data, int *length) { int result; FILE *file = 0; short *dataptr = 0; - long datalength; + int datalength; int i, actual, ch; unsigned char buffer[24]; - unsigned long temp; + unsigned int temp; file = fopen(name, "rb"); if (file == 0) @@ -452,7 +454,7 @@ int read_sample(char *name, short **data, long *length) temp = buffer[12] << 24 | buffer[13] << 16 | buffer[14] << 8 | buffer[15]; if (temp != 1) { - fprintf(stderr, "%s: \"%s\": %s (%ld != 1)\n", progname, name, + fprintf(stderr, "%s: \"%s\": %s (%d != 1)\n", progname, name, "bad encoding type", temp); result = 1; goto fail; @@ -462,7 +464,7 @@ int read_sample(char *name, short **data, long *length) temp = buffer[16] << 24 | buffer[17] << 16 | buffer[18] << 8 | buffer[19]; if (temp != 8000) { - fprintf(stderr, "%s: \"%s\": %s (%ld != 8000)\n", progname, name, + fprintf(stderr, "%s: \"%s\": %s (%d != 8000)\n", progname, name, "bad sample rate", temp); result = 1; goto fail; @@ -472,7 +474,7 @@ int read_sample(char *name, short **data, long *length) temp = buffer[20] << 24 | buffer[21] << 16 | buffer[22] << 8 | buffer[23]; if (temp != 1) { - fprintf(stderr, "%s: \"%s\": %s (%ld != 1)\n", progname, name, + fprintf(stderr, "%s: \"%s\": %s (%d != 1)\n", progname, name, "unsupported channels", temp); result = 1; goto fail;