/***********************************************************
* Rocks'n'Diamonds -- McDuffin Strikes Back! *
*----------------------------------------------------------*
-* ©1995 Artsoft Development *
-* Holger Schemel *
-* 33659 Bielefeld-Senne *
-* Telefon: (0521) 493245 *
-* eMail: aeglos@valinor.owl.de *
-* aeglos@uni-paderborn.de *
-* q99492@pbhrzx.uni-paderborn.de *
+* (c) 1995-98 Artsoft Entertainment *
+* Holger Schemel *
+* Oststrasse 11a *
+* 33604 Bielefeld *
+* phone: ++49 +521 290471 *
+* email: aeglos@valinor.owl.de *
*----------------------------------------------------------*
* sound.c *
***********************************************************/
#include "sound.h"
+#include "misc.h"
/*** THE STUFF BELOW IS ONLY USED BY THE SOUND SERVER CHILD PROCESS ***/
+static int playing_sounds = 0;
static struct SoundControl playlist[MAX_SOUNDS_PLAYING];
static struct SoundControl emptySoundControl =
{
-1,0,0, FALSE,FALSE,FALSE,FALSE,FALSE, 0,0L,0L,NULL
};
+
+#if !defined(MSDOS) && !defined(WIN32)
static int stereo_volume[PSND_MAX_LEFT2RIGHT+1];
static char premix_first_buffer[SND_BLOCKSIZE];
+#ifdef VOXWARE
static char premix_left_buffer[SND_BLOCKSIZE];
static char premix_right_buffer[SND_BLOCKSIZE];
static int premix_last_buffer[SND_BLOCKSIZE];
+#endif /* VOXWARE */
static unsigned char playing_buffer[SND_BLOCKSIZE];
-static int playing_sounds = 0;
+#endif /* !MSDOS && !WIN32 */
+
+/* forward declaration of internal functions */
+#ifdef VOXWARE
+static void SoundServer_InsertNewSound(struct SoundControl);
+#endif
+
+#if !defined(VOXWARE) && !defined(MSDOS) && !defined(WIN32)
+static unsigned char linear_to_ulaw(int);
+static int ulaw_to_linear(unsigned char);
+#endif
+
+#ifdef HPUX_AUDIO
+static void HPUX_Audio_Control();
+#endif
+
+#ifdef MSDOS
+static void SoundServer_InsertNewSound(struct SoundControl);
+static void SoundServer_StopSound(int);
+static void SoundServer_StopAllSounds();
+#endif
+
+int OpenAudio(char *audio_device_name)
+{
+ int audio_fd;
+
+ /* try to open audio device in non-blocking mode */
+ if ((audio_fd = open(audio_device_name, O_WRONLY | O_NONBLOCK)) < 0)
+ return audio_fd;
+
+ /* re-open audio device in blocking mode */
+ close(audio_fd);
+ audio_fd = open(audio_device_name, O_WRONLY);
+
+ return audio_fd;
+}
void SoundServer()
{
+ int i;
+#if !defined(MSDOS) && !defined(WIN32)
struct SoundControl snd_ctrl;
fd_set sound_fdset;
- int i;
close(sound_pipe[1]); /* no writing into pipe needed */
+#endif
for(i=0;i<MAX_SOUNDS_PLAYING;i++)
playlist[i] = emptySoundControl;
+ playing_sounds = 0;
+#if !defined(MSDOS) && !defined(WIN32)
stereo_volume[PSND_MAX_LEFT2RIGHT] = 0;
for(i=0;i<PSND_MAX_LEFT2RIGHT;i++)
stereo_volume[i] =
FD_ZERO(&sound_fdset);
FD_SET(sound_pipe[0], &sound_fdset);
- for(;;) /* wait for calls from PlaySound(), StopSound(), ... */
+ while(1) /* wait for sound playing commands from client */
{
FD_SET(sound_pipe[0], &sound_fdset);
select(sound_pipe[0]+1, &sound_fdset, NULL, NULL, NULL);
if (!FD_ISSET(sound_pipe[0], &sound_fdset))
continue;
if (read(sound_pipe[0], &snd_ctrl, sizeof(snd_ctrl)) != sizeof(snd_ctrl))
- {
- fprintf(stderr,"%s: broken pipe - no sounds\n",progname);
- exit(0);
- }
+ Error(ERR_EXIT_SOUND_SERVER, "broken pipe - no sounds");
#ifdef VOXWARE
if (playing_sounds || snd_ctrl.active)
{
struct timeval delay = { 0, 0 };
- char *sample_ptr;
- long sample_size, max_sample_size;
- long fragment_size;
- BOOL stereo;
+ byte *sample_ptr;
+ long sample_size;
+ static long max_sample_size = 0;
+ static long fragment_size = 0;
+ /* Even if the stereo flag is used as being boolean, it must be
+ defined as an integer, else 'ioctl()' will fail! */
+ int stereo = TRUE;
+#if 0
+ int sample_rate = 8000;
+#else
+ int sample_rate = 22050;
+#endif
- if (playing_sounds || (sound_device=open(sound_device_name,O_WRONLY))>=0)
+ if (playing_sounds ||
+ (sound_device = OpenAudio(sound_device_name)) >= 0)
{
if (!playing_sounds) /* we just opened the audio device */
{
/* 2 buffers / 512 bytes, giving 1/16 second resolution */
/* (with stereo the effective buffer size will shrink to 256) */
fragment_size = 0x00020009;
- ioctl(sound_device, SNDCTL_DSP_SETFRAGMENT, &fragment_size);
+
+ if (ioctl(sound_device, SNDCTL_DSP_SETFRAGMENT, &fragment_size) < 0)
+ Error(ERR_EXIT_SOUND_SERVER,
+ "cannot set fragment size of /dev/dsp - no sounds");
+
/* try if we can use stereo sound */
- stereo = TRUE;
- ioctl(sound_device, SNDCTL_DSP_STEREO, &stereo);
+ if (ioctl(sound_device, SNDCTL_DSP_STEREO, &stereo) < 0)
+ {
+#ifdef DEBUG
+ static boolean reported = FALSE;
+
+ if (!reported)
+ {
+ Error(ERR_RETURN, "cannot get stereo sound on /dev/dsp");
+ reported = TRUE;
+ }
+#endif
+ stereo = FALSE;
+ }
+
+ if (ioctl(sound_device, SNDCTL_DSP_SPEED, &sample_rate) < 0)
+ Error(ERR_EXIT_SOUND_SERVER,
+ "cannot set sample rate of /dev/dsp - no sounds");
+
/* get the real fragmentation size; this should return 512 */
- ioctl(sound_device, SNDCTL_DSP_GETBLKSIZE, &fragment_size);
+ if (ioctl(sound_device, SNDCTL_DSP_GETBLKSIZE, &fragment_size) < 0)
+ Error(ERR_EXIT_SOUND_SERVER,
+ "cannot get fragment size of /dev/dsp - no sounds");
+
max_sample_size = fragment_size / (stereo ? 2 : 1);
}
}
}
-#else /* von '#ifdef VOXWARE' */
+#else /* !VOXWARE */
if (snd_ctrl.active && !snd_ctrl.loop)
{
struct timeval delay = { 0, 0 };
- char *sample_ptr;
+ byte *sample_ptr;
long sample_size, max_sample_size = SND_BLOCKSIZE;
long sample_rate = 8000; /* standard "/dev/audio" sampling rate */
int wait_percent = 90; /* wait 90% of the real playing time */
int i;
- if ((sound_device=open(sound_device_name,O_WRONLY))>=0)
+ if ((sound_device = OpenAudio(sound_device_name)) >= 0)
{
playing_sounds = 1;
FD_SET(sound_pipe[0], &sound_fdset);
/* get pointer and size of the actual sound sample */
- sample_ptr = snd_ctrl.data_ptr+snd_ctrl.playingpos;
+ sample_ptr = snd_ctrl.data_ptr + snd_ctrl.playingpos;
sample_size =
- MIN(max_sample_size,snd_ctrl.data_len-snd_ctrl.playingpos);
+ MIN(max_sample_size, snd_ctrl.data_len - snd_ctrl.playingpos);
snd_ctrl.playingpos += sample_size;
/* fill the first mixing buffer with original sample */
}
}
-#endif /* von '#ifdef VOXWARE' */
+#endif /* !VOXWARE */
+
+ }
+
+#endif /* !MSDOS && !WIN32 */
+
+}
+
+#ifdef MSDOS
+static void sound_handler(struct SoundControl snd_ctrl)
+{
+ int i;
+
+ if (snd_ctrl.fade_sound)
+ {
+ if (!playing_sounds)
+ return;
+
+ for (i=0; i<MAX_SOUNDS_PLAYING; i++)
+ if ((snd_ctrl.stop_all_sounds || playlist[i].nr == snd_ctrl.nr) &&
+ !playlist[i].fade_sound)
+ {
+ playlist[i].fade_sound = TRUE;
+ if (voice_check(playlist[i].voice))
+ voice_ramp_volume(playlist[i].voice, 1000, 0);
+ playlist[i].loop = PSND_NO_LOOP;
+ }
+ }
+ else if (snd_ctrl.stop_all_sounds)
+ {
+ if (!playing_sounds)
+ return;
+ SoundServer_StopAllSounds();
+ }
+ else if (snd_ctrl.stop_sound)
+ {
+ if (!playing_sounds)
+ return;
+ SoundServer_StopSound(snd_ctrl.nr);
+ }
+
+ for (i=0; i<MAX_SOUNDS_PLAYING; i++)
+ {
+ if (!playlist[i].active || playlist[i].loop)
+ continue;
+ playlist[i].playingpos = voice_get_position(playlist[i].voice);
+ playlist[i].volume = voice_get_volume(playlist[i].voice);
+ if (playlist[i].playingpos == -1 || !playlist[i].volume)
+ {
+ deallocate_voice(playlist[i].voice);
+ playlist[i] = emptySoundControl;
+ playing_sounds--;
+ }
}
+
+ if (snd_ctrl.active)
+ SoundServer_InsertNewSound(snd_ctrl);
}
+#endif /* MSDOS */
-void SoundServer_InsertNewSound(struct SoundControl snd_ctrl)
+#ifndef WIN32
+static void SoundServer_InsertNewSound(struct SoundControl snd_ctrl)
{
- int i,k;
+ int i, k;
- /* wenn voll, ältesten Sound 'rauswerfen */
+ /* if playlist is full, remove oldest sound */
if (playing_sounds==MAX_SOUNDS_PLAYING)
{
int longest=0, longest_nr=0;
for(i=0;i<MAX_SOUNDS_PLAYING;i++)
{
- int actual =
- 100 * playlist[i].playingpos / playlist[i].data_len;
+#ifndef MSDOS
+ int actual = 100 * playlist[i].playingpos / playlist[i].data_len;
+#else
+ int actual = playlist[i].playingpos;
+#endif
if (!playlist[i].loop && actual>longest)
{
longest_nr=i;
}
}
+#ifdef MSDOS
+ voice_set_volume(playlist[longest_nr].voice, 0);
+ deallocate_voice(playlist[longest_nr].voice);
+#endif
playlist[longest_nr] = emptySoundControl;
playing_sounds--;
}
- /* nachsehen, ob (und ggf. wie oft) Sound bereits gespielt wird */
+ /* check if sound is already being played (and how often) */
for(k=0,i=0;i<MAX_SOUNDS_PLAYING;i++)
{
if (playlist[i].nr == snd_ctrl.nr)
k++;
}
- /* falls Sound-Loop: nur neu beginnen, wenn Sound gerade ausklingt */
+ /* restart loop sounds only if they are just fading out */
if (k>=1 && snd_ctrl.loop)
{
for(i=0;i<MAX_SOUNDS_PLAYING;i++)
{
playlist[i].fade_sound = FALSE;
playlist[i].volume = PSND_MAX_VOLUME;
+#ifdef MSDOS
+ playlist[i].loop = PSND_LOOP;
+ voice_stop_volumeramp(playlist[i].voice);
+ voice_ramp_volume(playlist[i].voice, playlist[i].volume, 1000);
+#endif
}
}
return;
}
- /* keinen Sound mehr als n mal gleichzeitig spielen (momentan n==2) */
+ /* don't play sound more than n times simultaneously (with n == 2 for now) */
if (k>=2)
{
int longest=0, longest_nr=0;
- /* den bereits am längsten gespielten (gleichen) Sound suchen */
+ /* look for oldest equal sound */
for(i=0;i<MAX_SOUNDS_PLAYING;i++)
{
int actual;
if (!playlist[i].active || playlist[i].nr != snd_ctrl.nr)
continue;
+#ifndef MSDOS
actual = 100 * playlist[i].playingpos / playlist[i].data_len;
+#else
+ actual = playlist[i].playingpos;
+#endif
if (actual>=longest)
{
longest=actual;
longest_nr=i;
}
}
+#ifdef MSDOS
+ voice_set_volume(playlist[longest_nr].voice, 0);
+ deallocate_voice(playlist[longest_nr].voice);
+#endif
playlist[longest_nr] = emptySoundControl;
playing_sounds--;
}
{
playlist[i] = snd_ctrl;
playing_sounds++;
+#ifdef MSDOS
+ playlist[i].voice = allocate_voice(Sound[snd_ctrl.nr].sample_ptr);
+ if(snd_ctrl.loop)
+ voice_set_playmode(playlist[i].voice, PLAYMODE_LOOP);
+ voice_set_volume(playlist[i].voice, snd_ctrl.volume);
+ voice_set_pan(playlist[i].voice, snd_ctrl.stereo);
+ voice_start(playlist[i].voice);
+#endif
break;
}
}
}
+#endif /* !WIN32 */
/*
void SoundServer_FadeSound(int nr)
}
*/
-void SoundServer_StopSound(int nr)
+#ifndef WIN32
+#ifdef MSDOS
+static void SoundServer_StopSound(int nr)
{
int i;
for(i=0;i<MAX_SOUNDS_PLAYING;i++)
if (playlist[i].nr == nr)
{
+#ifdef MSDOS
+ voice_set_volume(playlist[i].voice, 0);
+ deallocate_voice(playlist[i].voice);
+#endif
playlist[i] = emptySoundControl;
playing_sounds--;
}
+#ifndef MSDOS
if (!playing_sounds)
close(sound_device);
+#endif
}
-void SoundServer_StopAllSounds()
+static void SoundServer_StopAllSounds()
{
int i;
for(i=0;i<MAX_SOUNDS_PLAYING;i++)
+ {
+#ifdef MSDOS
+ voice_set_volume(playlist[i].voice, 0);
+ deallocate_voice(playlist[i].voice);
+#endif
playlist[i]=emptySoundControl;
- playing_sounds=0;
+ }
+ playing_sounds = 0;
+#ifndef MSDOS
close(sound_device);
+#endif
}
+#endif /* MSDOS */
+#endif /* !WIN32 */
#ifdef HPUX_AUDIO
-void HPUX_Audio_Control()
+static void HPUX_Audio_Control()
{
struct audio_describe ainfo;
int audio_ctl;
audio_ctl = open("/dev/audioCtl", O_WRONLY | O_NDELAY);
if (audio_ctl == -1)
- {
- fprintf(stderr,"%s: cannot open /dev/audioCtl - no sounds\n",progname);
- exit(0);
- }
+ Error(ERR_EXIT_SOUND_SERVER, "cannot open /dev/audioCtl - no sounds");
if (ioctl(audio_ctl, AUDIO_DESCRIBE, &ainfo) == -1)
- {
- fprintf(stderr,"%s: no audio info - no sounds\n",progname);
- exit(0);
- }
+ Error(ERR_EXIT_SOUND_SERVER, "no audio info - no sounds");
if (ioctl(audio_ctl, AUDIO_SET_DATA_FORMAT, AUDIO_FORMAT_ULAW) == -1)
- {
- fprintf(stderr,"%s: ulaw audio not available - no sounds\n",progname);
- exit(0);
- }
+ Error(ERR_EXIT_SOUND_SERVER, "ulaw audio not available - no sounds");
ioctl(audio_ctl, AUDIO_SET_CHANNELS, 1);
ioctl(audio_ctl, AUDIO_SET_SAMPLE_RATE, 8000);
}
#endif /* HPUX_AUDIO */
+#if !defined(VOXWARE) && !defined(MSDOS) && !defined(WIN32)
+
/* these two are stolen from "sox"... :) */
/*
#define BIAS 0x84 /* define the add-in bias for 16 bit samples */
#define CLIP 32635
-unsigned char linear_to_ulaw(int sample)
+static unsigned char linear_to_ulaw(int sample)
{
static int exp_lut[256] =
{
** Output: signed 16 bit linear sample
*/
-int ulaw_to_linear(unsigned char ulawbyte)
+static int ulaw_to_linear(unsigned char ulawbyte)
{
static int exp_lut[8] = { 0, 132, 396, 924, 1980, 4092, 8316, 16764 };
int sign, exponent, mantissa, sample;
return(sample);
}
+#endif /* !VOXWARE && !MSDOS && !WIN32 */
/*** THE STUFF ABOVE IS ONLY USED BY THE SOUND SERVER CHILD PROCESS ***/
/*** THE STUFF BELOW IS ONLY USED BY THE MAIN PROCESS ***/
-BOOL LoadSound(struct SoundInfo *snd_info)
+#define CHUNK_ID_LEN 4 /* IFF style chunk id length */
+#define WAV_HEADER_SIZE 20 /* size of WAV file header */
+
+boolean LoadSound(struct SoundInfo *snd_info)
{
- FILE *file;
char filename[256];
- char *sound_ext = "8svx";
- struct SoundHeader_8SVX *snd_hdr;
- unsigned char *ptr;
+ char *sound_ext = "wav";
+#ifndef USE_SDL_LIBRARY
+#ifndef MSDOS
+ byte sound_header_buffer[WAV_HEADER_SIZE];
+ char chunk[CHUNK_ID_LEN + 1];
+ int chunk_length, dummy;
+ FILE *file;
+ int i;
+#endif
+#endif
- sprintf(filename,"%s/%s.%s",SND_PATH,snd_info->name,sound_ext);
+ sprintf(filename, "%s/%s/%s.%s",
+ options.ro_base_directory, SOUNDS_DIRECTORY,
+ snd_info->name, sound_ext);
- if (!(file=fopen(filename,"r")))
+#ifdef USE_SDL_LIBRARY
+
+ snd_info->mix_chunk = Mix_LoadWAV(filename);
+ if (snd_info->mix_chunk == NULL)
{
- fprintf(stderr,"%s: cannot open sound file '%s' - no sounds\n",
- progname,filename);
- return(FALSE);
+ Error(ERR_WARN, "cannot read sound file '%s' - no sounds", filename);
+ return FALSE;
}
- if (fseek(file,0,SEEK_END)<0)
+#else /* !USE_SDL_LIBRARY */
+
+#ifndef MSDOS
+
+ if ((file = fopen(filename, "r")) == NULL)
{
- fprintf(stderr,"%s: cannot read sound file '%s' - no sounds\n",
- progname,filename);
- fclose(file);
- return(FALSE);
+ Error(ERR_WARN, "cannot open sound file '%s' - no sounds", filename);
+ return FALSE;
}
- snd_info->file_len = ftell(file);
- rewind(file);
-
- if (!(snd_info->file_ptr=malloc(snd_info->file_len)))
+ /* read chunk "RIFF" */
+ getFileChunk(file, chunk, &chunk_length, BYTE_ORDER_LITTLE_ENDIAN);
+ if (strcmp(chunk, "RIFF") != 0)
{
- fprintf(stderr,"%s: out of memory (this shouldn't happen :) - no sounds\n",
- progname);
+ Error(ERR_WARN, "missing 'RIFF' chunk of sound file '%s'", filename);
fclose(file);
- return(FALSE);
+ return FALSE;
}
- if (fread(snd_info->file_ptr,1,snd_info->file_len,file)!=snd_info->file_len)
+ /* read chunk "WAVE" */
+ getFileChunk(file, chunk, &dummy, BYTE_ORDER_LITTLE_ENDIAN);
+ if (strcmp(chunk, "WAVE") != 0)
{
- fprintf(stderr,"%s: cannot read sound file '%s' - no sounds\n",
- progname,filename);
+ Error(ERR_WARN, "missing 'WAVE' chunk of sound file '%s'", filename);
fclose(file);
- return(FALSE);
+ return FALSE;
}
- fclose(file);
+ /* read header information */
+ for (i=0; i<WAV_HEADER_SIZE; i++)
+ sound_header_buffer[i] = fgetc(file);
+
+ /* read chunk "data" */
+ getFileChunk(file, chunk, &chunk_length, BYTE_ORDER_LITTLE_ENDIAN);
+ if (strcmp(chunk, "data") != 0)
+ {
+ Error(ERR_WARN, "missing 'data' chunk of sound file '%s'", filename);
+ fclose(file);
+ return FALSE;
+ }
- snd_hdr = (struct SoundHeader_8SVX *)snd_info->file_ptr;
+ snd_info->data_len = chunk_length;
+ snd_info->data_ptr = checked_malloc(snd_info->data_len);
- if (strncmp(snd_hdr->magic_FORM,"FORM",4) ||
- snd_info->file_len!=be2long(&snd_hdr->chunk_size)+8 ||
- strncmp(snd_hdr->magic_8SVX,"8SVX",4))
+ /* read sound data */
+ if (fread(snd_info->data_ptr, 1, snd_info->data_len, file) !=
+ snd_info->data_len)
{
- fprintf(stderr,"%s: '%s' is not an IFF/8SVX file or broken- no sounds\n",
- progname,filename);
- return(FALSE);
+ Error(ERR_WARN, "cannot read sound file '%s' - no sounds", filename);
+ fclose(file);
+ return FALSE;
}
- ptr = (unsigned char *)snd_info->file_ptr;
+ fclose(file);
+
+ for (i=0; i<snd_info->data_len; i++)
+ snd_info->data_ptr[i] = snd_info->data_ptr[i] ^ 0x80;
+
+#else /* MSDOS */
- while(ptr<(unsigned char *)snd_info->file_ptr+snd_info->file_len)
+ snd_info->sample_ptr = load_sample(filename);
+ if (!snd_info->sample_ptr)
{
- if (!strncmp(ptr,"VHDR",4))
- {
- ptr+=be2long((unsigned long *)(ptr+4));
- }
- if (!strncmp(ptr,"ANNO",4))
- {
- ptr+=be2long((unsigned long *)(ptr+4));
- }
- if (!strncmp(ptr,"CHAN",4))
- {
- ptr+=be2long((unsigned long *)(ptr+4));
- }
- if (!strncmp(ptr,"BODY",4))
- {
- snd_info->data_ptr = ptr+8;
- snd_info->data_len = be2long((unsigned long *)(ptr+4));
- return(TRUE);
- }
- ptr++;
+ Error(ERR_WARN, "cannot read sound file '%s' - no sounds", filename);
+ return FALSE;
}
- return(FALSE);
+#endif /* MSDOS */
+#endif /* !USE_SDL_LIBRARY */
+
+ return TRUE;
}
void PlaySound(int nr)
PlaySoundExt(nr, PSND_MAX_VOLUME, PSND_MIDDLE, PSND_LOOP);
}
-void PlaySoundExt(int nr, int volume, int stereo, BOOL loop)
+void PlaySoundExt(int nr, int volume, int stereo, boolean loop)
{
struct SoundControl snd_ctrl = emptySoundControl;
- if (sound_status==SOUND_OFF || !sound_on)
+ if (sound_status==SOUND_OFF || !setup.sound)
return;
if (volume<PSND_MIN_VOLUME)
snd_ctrl.data_ptr = Sound[nr].data_ptr;
snd_ctrl.data_len = Sound[nr].data_len;
+#ifdef USE_SDL_LIBRARY
+
+ Mix_Volume(-1, SDL_MIX_MAXVOLUME / 4);
+ Mix_VolumeMusic(SDL_MIX_MAXVOLUME / 4);
+
+ Mix_PlayChannel(-1, Sound[nr].mix_chunk, (loop ? -1 : 0));
+
+#else
+#ifndef MSDOS
if (write(sound_pipe[1], &snd_ctrl, sizeof(snd_ctrl))<0)
{
- fprintf(stderr,"%s: cannot pipe to child process - no sounds\n",progname);
- sound_status=SOUND_OFF;
+ Error(ERR_WARN, "cannot pipe to child process - no sounds");
+ sound_status = SOUND_OFF;
return;
}
+#else
+ sound_handler(snd_ctrl);
+#endif
+#endif
}
void FadeSound(int nr)
snd_ctrl.stop_sound = TRUE;
}
+#ifdef USE_SDL_LIBRARY
+
+ if (SSND_FADING(method))
+ {
+ Mix_FadeOutChannel(-1, 1000);
+ Mix_FadeOutMusic(1000);
+ }
+ else
+ {
+ Mix_HaltChannel(-1);
+ Mix_HaltMusic();
+ }
+
+#else
+#ifndef MSDOS
if (write(sound_pipe[1], &snd_ctrl, sizeof(snd_ctrl))<0)
{
- fprintf(stderr,"%s: cannot pipe to child process - no sounds\n",progname);
- sound_status=SOUND_OFF;
+ Error(ERR_WARN, "cannot pipe to child process - no sounds");
+ sound_status = SOUND_OFF;
return;
}
+#else
+ sound_handler(snd_ctrl);
+#endif
+#endif
}
-void FreeSounds(int max)
+void FreeSounds(int num_sounds)
{
int i;
- if (sound_status==SOUND_OFF)
+ if (sound_status == SOUND_OFF)
return;
- for(i=0;i<max;i++)
- free(Sound[i].file_ptr);
+ for(i=0; i<num_sounds; i++)
+#ifndef MSDOS
+ free(Sound[i].data_ptr);
+#else
+ destroy_sample(Sound[i].sample_ptr);
+#endif
}
/*** THE STUFF ABOVE IS ONLY USED BY THE MAIN PROCESS ***/