X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fsound.h;h=db99a81d2a77f660a4503973488b4cea5ae39dd5;hb=77570cca460afce38d688221214f93f0c6d0a8c9;hp=310308a88e6747c18c024c50a2c46f5e45dc0d00;hpb=c431e727cdc0ecec3468ab4b89cae2e9708aa49a;p=rocksndiamonds.git diff --git a/src/libgame/sound.h b/src/libgame/sound.h index 310308a8..db99a81d 100644 --- a/src/libgame/sound.h +++ b/src/libgame/sound.h @@ -36,6 +36,10 @@ #include "system.h" +#if defined(PLATFORM_UNIX) && !defined(TARGET_SDL) +#define AUDIO_UNIX_NATIVE +#endif + #if defined(PLATFORM_LINUX) || defined(PLATFORM_FREEBSD) || defined(VOXWARE) #define AUDIO_LINUX_IOCTL #endif @@ -55,6 +59,7 @@ #define AUDIO_NUM_CHANNELS_MONO 1 #define AUDIO_NUM_CHANNELS_STEREO 2 +#define AUDIO_FORMAT_UNKNOWN (0) #define AUDIO_FORMAT_U8 (1 << 0) #define AUDIO_FORMAT_S16 (1 << 1) #define AUDIO_FORMAT_LE (1 << 2) @@ -71,7 +76,12 @@ #define SOUND_FADING_VOLUME_THRESHOLD (SOUND_FADING_VOLUME_STEP * 2) #endif +#if defined(AUDIO_STREAMING_DSP) #define DEFAULT_AUDIO_SAMPLE_RATE AUDIO_SAMPLE_RATE_22050 +#else +#define DEFAULT_AUDIO_SAMPLE_RATE AUDIO_SAMPLE_RATE_8000 +#endif + #define DEFAULT_AUDIO_FRAGMENT_SIZE_UNIX AUDIO_FRAGMENT_SIZE_512 #define DEFAULT_AUDIO_FRAGMENT_SIZE_WIN32 AUDIO_FRAGMENT_SIZE_2048 @@ -82,15 +92,18 @@ #endif #if defined(TARGET_SDL) -#define NUM_MIXER_CHANNELS MIX_CHANNELS +#define NUM_MIXER_CHANNELS MIX_CHANNELS #else -#define NUM_MIXER_CHANNELS 8 +#define NUM_MIXER_CHANNELS 8 #endif +#define MUSIC_CHANNEL 0 +#define FIRST_SOUND_CHANNEL 1 + #if !defined(PLATFORM_HPUX) -#define SND_BLOCKSIZE 4096 +#define SND_BLOCKSIZE 4096 #else -#define SND_BLOCKSIZE 32768 +#define SND_BLOCKSIZE 32768 #endif /* some values for PlaySound(), StopSound() and friends */ @@ -119,6 +132,7 @@ #endif +#if 0 #define PSND_NO_LOOP 0 #define PSND_LOOP 1 #define PSND_MUSIC 2 @@ -140,6 +154,7 @@ #define SND_RELOAD_SOUNDS 1 #define SND_RELOAD_MUSIC 2 +#endif #define SND_TYPE_NONE 0 #define SND_TYPE_WAV 1 @@ -204,54 +219,80 @@ struct SoundEffectInfo }; struct SampleInfo -{ - int type; +{ char *source_filename; int num_references; + int type; + int format; long data_len; void *data_ptr; - int format; }; typedef struct SampleInfo SoundInfo; typedef struct SampleInfo MusicInfo; +#define SND_CTRL_NONE (0) +#define SND_CTRL_MUSIC (1 << 0) +#define SND_CTRL_LOOP (1 << 1) +#define SND_CTRL_FADE (1 << 2) +#define SND_CTRL_STOP (1 << 3) +#define SND_CTRL_ALL_SOUNDS (1 << 4) +#define SND_CTRL_RELOAD_SOUNDS (1 << 5) +#define SND_CTRL_RELOAD_MUSIC (1 << 6) + +#define SND_CTRL_PLAY_SOUND (SND_CTRL_NONE) +#define SND_CTRL_PLAY_LOOP (SND_CTRL_LOOP) +#define SND_CTRL_PLAY_MUSIC (SND_CTRL_LOOP | SND_CTRL_MUSIC) + +#define SND_CTRL_FADE_SOUND (SND_CTRL_FADE) +#define SND_CTRL_FADE_MUSIC (SND_CTRL_FADE | SND_CTRL_MUSIC) +#define SND_CTRL_FADE_ALL (SND_CTRL_FADE | SND_CTRL_ALL_SOUNDS) + +#define SND_CTRL_STOP_SOUND (SND_CTRL_STOP) +#define SND_CTRL_STOP_MUSIC (SND_CTRL_STOP | SND_CTRL_MUSIC) +#define SND_CTRL_STOP_ALL (SND_CTRL_STOP | SND_CTRL_ALL_SOUNDS) + +#define IS_MUSIC(x) ((x).state & SND_CTRL_MUSIC) +#define IS_LOOP(x) ((x).state & SND_CTRL_LOOP) +#define IS_FADING(x) ((x).state & SND_CTRL_FADE) +#define IS_STOPPING(x) ((x).state & SND_CTRL_STOP) +#define IS_RELOADING(x) ((x).state & (SND_CTRL_RELOAD_SOUNDS | \ + SND_CTRL_RELOAD_MUSIC)) +#define ALL_SOUNDS(x) ((x).state & SND_CTRL_ALL_SOUNDS) + struct SoundControl { + boolean active; + int nr; int volume; - int stereo; + int stereo_position; - boolean active; - boolean loop; - boolean music; - boolean fade_sound; - boolean stop_sound; - boolean stop_all_sounds; - boolean reload_sounds; - boolean reload_music; + int state; - int playingtime; - long playingpos; + unsigned long playing_starttime; + unsigned long playing_pos; + int type; + int format; long data_len; void *data_ptr; - int format; #if defined(PLATFORM_MSDOS) int voice; #endif }; +typedef struct SoundControl SoundControl; + /* general sound functions */ void UnixOpenAudio(void); void UnixCloseAudio(void); -/* sound server functions */ -void InitPlaylist(void); -void StartSoundserver(void); -void SoundServer(void); +/* mixer functions */ +void Mixer_InitChannels(void); +void StartMixer(void); /* sound client functions */ void PlayMusic(int); @@ -259,7 +300,7 @@ void PlaySound(int); void PlaySoundStereo(int, int); void PlaySoundLoop(int); void PlaySoundMusic(int); -void PlaySoundExt(int, int, int, boolean); +void PlaySoundExt(int, int, int, int); void FadeMusic(void); void FadeSound(int); void FadeSounds(void);