From: Holger Schemel Date: Thu, 30 Nov 2000 17:48:32 +0000 (+0100) Subject: rnd-20001130-1-src X-Git-Tag: 2.0.0^2~25 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=228a5718ede5ee00512ed2e333b3cee47baa124c;p=rocksndiamonds.git rnd-20001130-1-src --- diff --git a/src/main.c b/src/main.c index 30fea535..8d927cb1 100644 --- a/src/main.c +++ b/src/main.c @@ -35,7 +35,7 @@ Pixmap clipmask[NUM_BITMAPS], tile_clipmask[NUM_TILES]; DrawBuffer drawto, drawto_field, backbuffer, fieldbuffer; Colormap cmap; -char *sound_device_name = SOUND_DEVICE; +char *sound_device_name = AUDIO_DEVICE; int joystick_device = 0; char *joystick_device_name[MAX_PLAYERS] = diff --git a/src/platform.h b/src/platform.h index 6c40c695..02513071 100644 --- a/src/platform.h +++ b/src/platform.h @@ -14,6 +14,8 @@ #ifndef PLATFORM_H #define PLATFORM_H +/* define keywords for supported main platforms */ + #if defined(MSDOS) #define PLATFORM_MSDOS #elif defined(WIN32) @@ -24,6 +26,10 @@ /* define additional keywords for several Unix platforms */ +#if defined(linux) +#define PLATFORM_LINUX +#endif + #if defined(__FreeBSD__) #define PLATFORM_FREEBSD #endif diff --git a/src/sound.c b/src/sound.c index 9d49c7dc..91da5d7d 100644 --- a/src/sound.c +++ b/src/sound.c @@ -26,7 +26,7 @@ static struct SoundControl emptySoundControl = #if defined(PLATFORM_UNIX) static int stereo_volume[PSND_MAX_LEFT2RIGHT+1]; static char premix_first_buffer[SND_BLOCKSIZE]; -#ifdef VOXWARE +#if defined(AUDIO_STREAMING_DSP) static char premix_left_buffer[SND_BLOCKSIZE]; static char premix_right_buffer[SND_BLOCKSIZE]; static int premix_last_buffer[SND_BLOCKSIZE]; @@ -35,16 +35,14 @@ static unsigned char playing_buffer[SND_BLOCKSIZE]; #endif /* forward declaration of internal functions */ -#ifdef VOXWARE +#if defined(AUDIO_STREAMING_DSP) static void SoundServer_InsertNewSound(struct SoundControl); -#else -#if defined(PLATFORM_UNIX) +#elif defined(PLATFORM_UNIX) static unsigned char linear_to_ulaw(int); static int ulaw_to_linear(unsigned char); #endif -#endif -#ifdef HPUX_AUDIO +#if defined(PLATFORM_HPUX) static void HPUX_Audio_Control(); #endif @@ -78,8 +76,8 @@ void UnixOpenAudio(struct AudioSystemInfo *audio) { static char *audio_device_name[] = { - DEV_DSP, - DEV_AUDIO + DEVICENAME_DSP, + DEVICENAME_AUDIO }; int audio_fd; int i; @@ -99,7 +97,7 @@ void UnixOpenAudio(struct AudioSystemInfo *audio) audio->sound_available = TRUE; -#ifdef VOXWARE +#if defined(AUDIO_STREAMING_DSP) audio->loops_available = TRUE; #endif } @@ -132,7 +130,7 @@ void SoundServer() stereo_volume[i] = (int)sqrt((float)(PSND_MAX_LEFT2RIGHT*PSND_MAX_LEFT2RIGHT-i*i)); -#ifdef HPUX_AUDIO +#if defined(PLATFORM_HPUX) HPUX_Audio_Control(); #endif @@ -149,7 +147,7 @@ void SoundServer() != sizeof(snd_ctrl)) Error(ERR_EXIT_SOUND_SERVER, "broken pipe - no sounds"); -#ifdef VOXWARE +#if defined(AUDIO_STREAMING_DSP) if (snd_ctrl.fade_sound) { @@ -356,7 +354,7 @@ void SoundServer() } } -#else /* !VOXWARE */ +#else /* !AUDIO_STREAMING_DSP */ if (snd_ctrl.active && !snd_ctrl.loop) { @@ -411,7 +409,7 @@ void SoundServer() } } -#endif /* !VOXWARE */ +#endif /* !AUDIO_STREAMING_DSP */ } @@ -646,7 +644,7 @@ static void SoundServer_StopAllSounds() #endif /* PLATFORM_MSDOS */ #endif /* !PLATFORM_WIN32 */ -#ifdef HPUX_AUDIO +#if defined(PLATFORM_HPUX) static void HPUX_Audio_Control() { struct audio_describe ainfo; @@ -667,9 +665,9 @@ static void HPUX_Audio_Control() close(audio_ctl); } -#endif /* HPUX_AUDIO */ +#endif /* PLATFORM_HPUX */ -#if !defined(VOXWARE) && defined(PLATFORM_UNIX) +#if defined(PLATFORM_UNIX) && !defined(AUDIO_STREAMING_DSP) /* these two are stolen from "sox"... :) */ @@ -774,7 +772,7 @@ static int ulaw_to_linear(unsigned char ulawbyte) return(sample); } -#endif /* !VOXWARE && PLATFORM_UNIX */ +#endif /* PLATFORM_UNIX && !AUDIO_STREAMING_DSP */ /*** THE STUFF ABOVE IS ONLY USED BY THE SOUND SERVER CHILD PROCESS ***/ diff --git a/src/sound.h b/src/sound.h index c03fdaf1..16fe71de 100644 --- a/src/sound.h +++ b/src/sound.h @@ -14,36 +14,28 @@ #ifndef SOUND_H #define SOUND_H -#include -#include "main.h" - -#ifdef linux -#include -#ifndef VOXWARE -#define VOXWARE -#endif +#include "platform.h" -#if 0 -/* where is the right declaration for 'ioctl'? */ -extern void ioctl(long, long, void *); -#else #include -#endif - -#endif - -#ifdef __FreeBSD__ -#include -#endif +#include #define SND_BLOCKSIZE 4096 -#ifdef _HPUX_SOURCE +#if defined(PLATFORM_LINUX) +#include +#elif defined(PLATFORM_FREEBSD) +#include +#elif defined(PLATFORM_HPUX) #include #undef SND_BLOCKSIZE #define SND_BLOCKSIZE 32768 -#define HPUX_AUDIO -#endif /* _HPUX_SOURCE */ +#endif + +#include "main.h" + +#if defined(PLATFORM_LINUX) || defined(PLATFORM_FREEBSD) || defined(VOXWARE) +#define AUDIO_STREAMING_DSP +#endif #if !defined(PLATFORM_MSDOS) #define MAX_SOUNDS_PLAYING 16 @@ -90,14 +82,14 @@ extern void ioctl(long, long, void *); #define SND_PATH "./sounds" #endif -#define DEV_DSP "/dev/dsp" -#define DEV_AUDIO "/dev/audio" -#define DEV_AUDIOCTL "/dev/audioCtl" +#define DEVICENAME_DSP "/dev/dsp" +#define DEVICENAME_AUDIO "/dev/audio" +#define DEVICENAME_AUDIOCTL "/dev/audioCtl" -#ifdef VOXWARE -#define SOUND_DEVICE DEV_DSP +#if defined(AUDIO_STREAMING_DSP) +#define AUDIO_DEVICE DEVICENAME_DSP #else -#define SOUND_DEVICE DEV_AUDIO +#define AUDIO_DEVICE DEVICENAME_AUDIO #endif struct SoundHeader_SUN