X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Fgame_em%2Fsound.c;h=f03abf1e014abbb3c48d95f06b0117924c001396;hp=e230d9924f24349f51ab557d80100821a04814c3;hb=c91aa2b237bef6003ead8dfc98cdcab89f97c654;hpb=51dcb2097c619c5f9ba924a7edb4a3bdd6a6986e diff --git a/src/game_em/sound.c b/src/game_em/sound.c index e230d992..f03abf1e 100644 --- a/src/game_em/sound.c +++ b/src/game_em/sound.c @@ -20,9 +20,6 @@ #include #endif -#include "global.h" -#include "sample.h" - static char audioname[] = "/dev/audio"; static const int sound_priority[SAMPLE_MAX] = @@ -68,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; @@ -83,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 (;;) { @@ -97,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; @@ -243,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"); @@ -295,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) @@ -381,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) @@ -455,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; @@ -465,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; @@ -475,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;