* sound.c *
***********************************************************/
-#include "libgame.h"
-
-#include "main_TMP.h"
+#include <sys/time.h>
+#include <unistd.h>
+#include <fcntl.h>
#include "sound.h"
#include "misc.h"
+
+static int num_sounds = 0;
+static struct SampleInfo *Sound = NULL;
+
+
/*** THE STUFF BELOW IS ONLY USED BY THE SOUND SERVER CHILD PROCESS ***/
static int playing_sounds = 0;
audio->device_name = audio_device_name[i];
audio->sound_available = TRUE;
+ audio->sound_enabled = TRUE;
#if defined(AUDIO_STREAMING_DSP)
audio->loops_available = TRUE;
/*** THE STUFF BELOW IS ONLY USED BY THE MAIN PROCESS ***/
+void AllocSoundArray(int num)
+{
+ num_sounds = num;
+ Sound = checked_calloc(num_sounds * sizeof(struct SampleInfo));
+}
+
#define CHUNK_ID_LEN 4 /* IFF style chunk id length */
#define WAV_HEADER_SIZE 20 /* size of WAV file header */
-boolean LoadSound(struct SampleInfo *snd_info)
+boolean LoadSound(int sound_nr, char *sound_name)
{
+ struct SampleInfo *snd_info = &Sound[sound_nr];
char filename[256];
char *sound_ext = "wav";
#if !defined(TARGET_SDL)
#endif
#endif
+ snd_info->name = sound_name;
+
sprintf(filename, "%s/%s/%s.%s",
options.ro_base_directory, SOUNDS_DIRECTORY,
snd_info->name, sound_ext);
{
struct SoundControl snd_ctrl = emptySoundControl;
- if (!audio.sound_available || !setup.sound)
+ if (!audio.sound_available || !audio.sound_enabled)
return;
if (volume<PSND_MIN_VOLUME)
if (write(audio.soundserver_pipe[1], &snd_ctrl, sizeof(snd_ctrl)) < 0)
{
Error(ERR_WARN, "cannot pipe to child process - no sounds");
- audio.sound_available = FALSE;
+ audio.sound_available = audio.sound_enabled = FALSE;
return;
}
#else
if (write(audio.soundserver_pipe[1], &snd_ctrl, sizeof(snd_ctrl)) < 0)
{
Error(ERR_WARN, "cannot pipe to child process - no sounds");
- audio.sound_available = FALSE;
+ audio.sound_available = audio.sound_enabled = FALSE;
return;
}
#else