#ifndef SOUND_H
#define SOUND_H
-#include "main.h"
-#include <math.h>
+#include "platform.h"
-#ifdef linux
-#include <linux/soundcard.h>
-#ifndef VOXWARE
-#define VOXWARE
-#endif
-/* where is the right declaration for 'ioctl'? */
-extern void ioctl(long, long, void *);
-#endif
-
-#ifdef __FreeBSD__
-#include <machine/soundcard.h>
-#endif
+#include <sys/ioctl.h>
+#include <math.h>
#define SND_BLOCKSIZE 4096
-#ifdef _HPUX_SOURCE
+#if defined(PLATFORM_LINUX)
+#include <linux/soundcard.h>
+#elif defined(PLATFORM_FREEBSD)
+#include <machine/soundcard.h>
+#elif defined(PLATFORM_HPUX)
#include <sys/audio.h>
#undef SND_BLOCKSIZE
#define SND_BLOCKSIZE 32768
-#define HPUX_AUDIO
-#endif /* _HPUX_SOURCE */
+#endif
+
+#include "main.h"
-#ifndef MSDOS
+#if defined(PLATFORM_LINUX) || defined(PLATFORM_FREEBSD) || defined(VOXWARE)
+#define AUDIO_STREAMING_DSP
+#endif
+
+#if !defined(PLATFORM_MSDOS)
#define MAX_SOUNDS_PLAYING 16
#else
#define MAX_SOUNDS_PLAYING 8
#endif
/* some values for PlaySound(), StopSound() and friends */
-#ifndef MSDOS
+#if !defined(PLATFORM_MSDOS)
#define PSND_SILENCE 0
#define PSND_MAX_VOLUME_BITS 7
#define PSND_MIN_VOLUME 0
#define SSND_STOPPING(x) (x & (SSND_STOP_SOUND | SSND_STOP_ALL_SOUNDS))
#define SSND_ALL(x) (x&(SSND_FADE_ALL_SOUNDS|SSND_STOP_ALL_SOUNDS))
-#define TRUE 1
-#define FALSE 0
-
/* settings for sound path, sound device, etc. */
#ifndef SND_PATH
#define SND_PATH "./sounds"
#endif
-#define DEV_AUDIO "/dev/audio"
-#define DEV_DSP "/dev/dsp"
-
-#ifdef VOXWARE
-#define SOUND_DEVICE DEV_DSP
-#else
-#define SOUND_DEVICE DEV_AUDIO
-#endif
-
-#define SOUND_OFF 0
-#define SOUND_AVAILABLE 1
+#define DEVICENAME_DSP "/dev/dsp"
+#define DEVICENAME_AUDIO "/dev/audio"
+#define DEVICENAME_AUDIOCTL "/dev/audioCtl"
-#ifdef NO_SOUNDS
-#define SOUND_STATUS SOUND_OFF
+#if defined(AUDIO_STREAMING_DSP)
+#define AUDIO_DEVICE DEVICENAME_DSP
#else
-#define SOUND_STATUS SOUND_AVAILABLE
+#define AUDIO_DEVICE DEVICENAME_AUDIO
#endif
struct SoundHeader_SUN
char magic_8SVX[4];
};
-struct SoundInfo
+struct SampleInfo
{
- unsigned char *name;
- unsigned char *file_ptr;
- char *data_ptr;
- long file_len, data_len;
-#ifdef MSDOS
+ char *name;
+ byte *data_ptr;
+ long data_len;
+
+#if defined(PLATFORM_MSDOS)
SAMPLE *sample_ptr;
#endif
+
+#if defined(TARGET_SDL)
+ Mix_Chunk *mix_chunk;
+#endif
};
struct SoundControl
int nr;
int volume;
int stereo;
- BOOL active;
- BOOL loop;
- BOOL fade_sound;
- BOOL stop_sound;
- BOOL stop_all_sounds;
+ boolean active;
+ boolean loop;
+ boolean fade_sound;
+ boolean stop_sound;
+ boolean stop_all_sounds;
int playingtime;
long playingpos;
long data_len;
- char *data_ptr;
-#ifdef MSDOS
+ byte *data_ptr;
+
+#if defined(PLATFORM_MSDOS)
int voice;
#endif
};
-/* sound server functions */
+/* general sound functions */
+void UnixOpenAudio(struct AudioSystemInfo *);
+void UnixCloseAudio(struct AudioSystemInfo *);
+
+/* sound server functions */
void SoundServer(void);
-void SoundServer_InsertNewSound(struct SoundControl);
-void SoundServer_StopSound(int);
-void SoundServer_StopAllSounds(void);
-void HPUX_Audio_Control(void);
-unsigned char linear_to_ulaw(int);
-int ulaw_to_linear(unsigned char);
-
-/* application functions */
-BOOL LoadSound(struct SoundInfo *);
+
+/* sound client functions */
+boolean LoadSound(struct SampleInfo *);
void PlaySound(int);
void PlaySoundStereo(int, int);
void PlaySoundLoop(int);
-void PlaySoundExt(int, int, int, BOOL);
+void PlaySoundExt(int, int, int, boolean);
void FadeSound(int);
void FadeSounds(void);
void StopSound(int);