From ab9b68feafe2cf6012533e5ad0581e6b9d423959 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 29 Nov 2000 00:02:55 +0100 Subject: [PATCH] rnd-20001129-1-src --- src/game.c | 10 +++---- src/init.c | 52 +++++++++--------------------------- src/main.c | 2 +- src/main.h | 2 +- src/msdos.c | 18 ++++++++++--- src/msdos.h | 2 ++ src/screens.c | 6 ++--- src/sound.c | 73 +++++++++++++++++++++++++++------------------------ src/sound.h | 2 +- src/system.c | 33 ++++++++++++++++------- src/system.h | 14 +++++----- 11 files changed, 108 insertions(+), 106 deletions(-) diff --git a/src/game.c b/src/game.c index 1f3aca00..670f8cb1 100644 --- a/src/game.c +++ b/src/game.c @@ -167,10 +167,10 @@ static unsigned int getStateCheckSum(int counter) void GetPlayerConfig() { - if (!sysinfo.audio_available) + if (!audio.sound_available) setup.sound = FALSE; - if (!sysinfo.audio_loops_available) + if (!audio.loops_available) { setup.sound_loops = FALSE; setup.sound_music = FALSE; @@ -6233,7 +6233,7 @@ static void HandleGameButtons(struct GadgetInfo *gi) setup.sound_music = FALSE; FadeSound(background_loop[level_nr % num_bg_loops]); } - else if (sysinfo.audio_loops_available) + else if (audio.loops_available) { setup.sound = setup.sound_music = TRUE; PlaySoundLoop(background_loop[level_nr % num_bg_loops]); @@ -6243,14 +6243,14 @@ static void HandleGameButtons(struct GadgetInfo *gi) case SOUND_CTRL_ID_LOOPS: if (setup.sound_loops) setup.sound_loops = FALSE; - else if (sysinfo.audio_loops_available) + else if (audio.loops_available) setup.sound = setup.sound_loops = TRUE; break; case SOUND_CTRL_ID_SIMPLE: if (setup.sound_simple) setup.sound_simple = FALSE; - else if (sysinfo.audio_available) + else if (audio.sound_available) setup.sound = setup.sound_simple = TRUE; break; diff --git a/src/init.c b/src/init.c index 60e0bcd3..040270a1 100644 --- a/src/init.c +++ b/src/init.c @@ -142,35 +142,7 @@ void InitSound() { int i; - /* REMOVE THIS! (gone to system.c:InitAudio) */ - if (!sysinfo.audio_available) - return; - -#if defined(TARGET_SDL) - if (InitAudio()) - { - sysinfo.audio_available = TRUE; - sysinfo.audio_loops_available = TRUE; - } - else - { - sysinfo.audio_available = FALSE; - } -#else /* !TARGET_SDL */ - -#if defined(PLATFORM_UNIX) - if (!(sysinfo.audio_available = CheckAudio(sound_device_name))) - return; - -#ifdef VOXWARE - sysinfo.audio_loops_available = TRUE; -#endif - -#else /* !PLATFORM_UNIX */ - sysinfo.audio_loops_available = TRUE; - -#endif /* !PLATFORM_UNIX */ -#endif /* !TARGET_SDL */ + audio = InitAudio(); for(i=0; imouse_ptr = mouse_bitmap; allegro_init(); - allegro_drivers(); + allegro_init_drivers(); set_color_depth(8); /* force Windows 95 to switch to fullscreen mode */ @@ -915,6 +920,11 @@ void XAutoRepeatOff(Display *display) keyboard_auto_repeat = FALSE; } +boolean MSDOSInitAudio(void) +{ + return allegro_init_audio(); +} + void NetworkServer(int port, int serveronly) { Error(ERR_WARN, "networking not supported in DOS version"); diff --git a/src/msdos.h b/src/msdos.h index 2a16bb6d..499de70a 100644 --- a/src/msdos.h +++ b/src/msdos.h @@ -703,6 +703,8 @@ Bool XQueryPointer(Display *, Window, Window *, Window *, int *, int *, int *, int *, unsigned int *); void XAutoRepeatOn(Display *); void XAutoRepeatOff(Display *); + +boolean MSDOSInitAudio(void); void NetworkServer(int, int); #endif /* MSDOS_H */ diff --git a/src/screens.c b/src/screens.c index b97c44a1..e4be1318 100644 --- a/src/screens.c +++ b/src/screens.c @@ -1409,7 +1409,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) { int yy = y-1; - if (y == 3 && sysinfo.audio_available) + if (y == 3 && audio.sound_available) { if (setup.sound) { @@ -1423,7 +1423,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) DrawText(SX+14*32, SY+yy*32,"on ",FS_BIG,FC_YELLOW); setup.sound = !setup.sound; } - else if (y == 4 && sysinfo.audio_loops_available) + else if (y == 4 && audio.loops_available) { if (setup.sound_loops) DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE); @@ -1435,7 +1435,7 @@ void HandleSetupScreen(int mx, int my, int dx, int dy, int button) } setup.sound_loops = !setup.sound_loops; } - else if (y == 5 && sysinfo.audio_loops_available) + else if (y == 5 && audio.loops_available) { if (setup.sound_music) DrawText(SX+14*32, SY+yy*32,"off",FS_BIG,FC_BLUE); diff --git a/src/sound.c b/src/sound.c index 185b1822..628dc047 100644 --- a/src/sound.c +++ b/src/sound.c @@ -91,9 +91,14 @@ int CheckAudio(char *audio_device_name) return SOUND_AVAILABLE; } -boolean UnixInitAudio(void) +void UnixInitAudio(struct AudioSystemInfo *audio) { - return TRUE; + if (!(audio->sound_available = CheckAudio(sound_device_name))) + return; + +#ifdef VOXWARE + audio->loops_available = TRUE; +#endif } #endif /* PLATFORM_UNIX */ @@ -104,7 +109,7 @@ void SoundServer() struct SoundControl snd_ctrl; fd_set sound_fdset; - close(sysinfo.audio_process_pipe[1]); /* no writing into pipe needed */ + close(audio.soundserver_pipe[1]); /* no writing into pipe needed */ #endif for(i=0;i= 0) + (audio.device_fd = OpenAudio(sound_device_name)) >= 0) { if (!playing_sounds) /* we just opened the audio device */ { @@ -197,13 +202,12 @@ void SoundServer() /* (with stereo the effective buffer size will shrink to 256) */ fragment_size = 0x00020009; - if (ioctl(sysinfo.audio_fd, SNDCTL_DSP_SETFRAGMENT, &fragment_size) - < 0) + if (ioctl(audio.device_fd,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 */ - if (ioctl(sysinfo.audio_fd, SNDCTL_DSP_STEREO, &stereo) < 0) + if (ioctl(audio.device_fd, SNDCTL_DSP_STEREO, &stereo) < 0) { #ifdef DEBUG static boolean reported = FALSE; @@ -217,13 +221,12 @@ void SoundServer() stereo = FALSE; } - if (ioctl(sysinfo.audio_fd, SNDCTL_DSP_SPEED, &sample_rate) < 0) + if (ioctl(audio.device_fd, 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 */ - if (ioctl(sysinfo.audio_fd, SNDCTL_DSP_GETBLKSIZE, &fragment_size) - < 0) + if (ioctl(audio.device_fd, SNDCTL_DSP_GETBLKSIZE,&fragment_size) < 0) Error(ERR_EXIT_SOUND_SERVER, "cannot get fragment size of /dev/dsp - no sounds"); @@ -234,10 +237,10 @@ void SoundServer() SoundServer_InsertNewSound(snd_ctrl); while(playing_sounds && - select(sysinfo.audio_process_pipe[0] + 1, + select(audio.soundserver_pipe[0] + 1, &sound_fdset, NULL, NULL, &delay) < 1) { - FD_SET(sysinfo.audio_process_pipe[0], &sound_fdset); + FD_SET(audio.soundserver_pipe[0], &sound_fdset); /* first clear the last premixing buffer */ memset(premix_last_buffer,0,fragment_size*sizeof(int)); @@ -334,12 +337,12 @@ void SoundServer() } /* finally play the sound fragment */ - write(sysinfo.audio_fd, playing_buffer,fragment_size); + write(audio.device_fd, playing_buffer,fragment_size); } /* if no sounds playing, free device for other sound programs */ if (!playing_sounds) - close(sysinfo.audio_fd); + close(audio.device_fd); } } @@ -354,15 +357,15 @@ void SoundServer() int wait_percent = 90; /* wait 90% of the real playing time */ int i; - if ((sysinfo.audio_fd = OpenAudio(sound_device_name)) >= 0) + if ((audio.device_fd = OpenAudio(sound_device_name)) >= 0) { playing_sounds = 1; while(playing_sounds && - select(sysinfo.audio_process_pipe[0] + 1, + select(audio.soundserver_pipe[0] + 1, &sound_fdset, NULL, NULL, &delay) < 1) { - FD_SET(sysinfo.audio_process_pipe[0], &sound_fdset); + FD_SET(audio.soundserver_pipe[0], &sound_fdset); /* get pointer and size of the actual sound sample */ sample_ptr = snd_ctrl.data_ptr + snd_ctrl.playingpos; @@ -389,12 +392,12 @@ void SoundServer() playing_sounds = 0; /* finally play the sound fragment */ - write(sysinfo.audio_fd,playing_buffer,sample_size); + write(audio.device_fd,playing_buffer,sample_size); delay.tv_sec = 0; delay.tv_usec = ((sample_size*10*wait_percent)/(sample_rate))*1000; } - close(sysinfo.audio_fd); + close(audio.device_fd); } } @@ -608,7 +611,7 @@ static void SoundServer_StopSound(int nr) #if !defined(PLATFORM_MSDOS) if (!playing_sounds) - close(sysinfo.audio_fd); + close(audio.device_fd); #endif } @@ -627,7 +630,7 @@ static void SoundServer_StopAllSounds() playing_sounds = 0; #if !defined(PLATFORM_MSDOS) - close(sysinfo.audio_fd); + close(audio.device_fd); #endif } #endif /* PLATFORM_MSDOS */ @@ -891,7 +894,7 @@ void PlaySoundExt(int nr, int volume, int stereo, boolean loop) { struct SoundControl snd_ctrl = emptySoundControl; - if (!sysinfo.audio_available || !setup.sound) + if (!audio.sound_available || !setup.sound) return; if (volume