projects
/
rocksndiamonds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
rnd-20000901-1-src
[rocksndiamonds.git]
/
src
/
sound.c
diff --git
a/src/sound.c
b/src/sound.c
index e89a153fd665db256c4306e1c231632227e83446..6db2f63329a54bab3a1575982463ac276abd13ec 100644
(file)
--- a/
src/sound.c
+++ b/
src/sound.c
@@
-23,7
+23,7
@@
static struct SoundControl emptySoundControl =
-1,0,0, FALSE,FALSE,FALSE,FALSE,FALSE, 0,0L,0L,NULL
};
-1,0,0, FALSE,FALSE,FALSE,FALSE,FALSE, 0,0L,0L,NULL
};
-#if
ndef MSDOS
+#if
!defined(MSDOS) && !defined(WIN32)
static int stereo_volume[PSND_MAX_LEFT2RIGHT+1];
static char premix_first_buffer[SND_BLOCKSIZE];
#ifdef VOXWARE
static int stereo_volume[PSND_MAX_LEFT2RIGHT+1];
static char premix_first_buffer[SND_BLOCKSIZE];
#ifdef VOXWARE
@@
-32,21
+32,22
@@
static char premix_right_buffer[SND_BLOCKSIZE];
static int premix_last_buffer[SND_BLOCKSIZE];
#endif /* VOXWARE */
static unsigned char playing_buffer[SND_BLOCKSIZE];
static int premix_last_buffer[SND_BLOCKSIZE];
#endif /* VOXWARE */
static unsigned char playing_buffer[SND_BLOCKSIZE];
-#endif /*
MSDOS
*/
+#endif /*
!MSDOS && !WIN32
*/
/* forward declaration of internal functions */
#ifdef VOXWARE
static void SoundServer_InsertNewSound(struct SoundControl);
#endif
/* forward declaration of internal functions */
#ifdef VOXWARE
static void SoundServer_InsertNewSound(struct SoundControl);
#endif
-#ifndef VOXWARE
-#if
ndef MSDOS
+
+#if
!defined(VOXWARE) && !defined(MSDOS) && !defined(WIN32)
static unsigned char linear_to_ulaw(int);
static int ulaw_to_linear(unsigned char);
#endif
static unsigned char linear_to_ulaw(int);
static int ulaw_to_linear(unsigned char);
#endif
-#endif
+
#ifdef HPUX_AUDIO
static void HPUX_Audio_Control();
#endif
#ifdef HPUX_AUDIO
static void HPUX_Audio_Control();
#endif
+
#ifdef MSDOS
static void SoundServer_InsertNewSound(struct SoundControl);
static void SoundServer_StopSound(int);
#ifdef MSDOS
static void SoundServer_InsertNewSound(struct SoundControl);
static void SoundServer_StopSound(int);
@@
-56,7
+57,7
@@
static void SoundServer_StopAllSounds();
void SoundServer()
{
int i;
void SoundServer()
{
int i;
-#if
ndef MSDOS
+#if
!defined(MSDOS) && !defined(WIN32)
struct SoundControl snd_ctrl;
fd_set sound_fdset;
struct SoundControl snd_ctrl;
fd_set sound_fdset;
@@
-67,7
+68,7
@@
void SoundServer()
playlist[i] = emptySoundControl;
playing_sounds = 0;
playlist[i] = emptySoundControl;
playing_sounds = 0;
-#if
ndef MSDOS
+#if
!defined(MSDOS) && !defined(WIN32)
stereo_volume[PSND_MAX_LEFT2RIGHT] = 0;
for(i=0;i<PSND_MAX_LEFT2RIGHT;i++)
stereo_volume[i] =
stereo_volume[PSND_MAX_LEFT2RIGHT] = 0;
for(i=0;i<PSND_MAX_LEFT2RIGHT;i++)
stereo_volume[i] =
@@
-137,7
+138,11
@@
void SoundServer()
/* Even if the stereo flag is used as being boolean, it must be
defined as an integer, else 'ioctl()' will fail! */
int stereo = TRUE;
/* Even if the stereo flag is used as being boolean, it must be
defined as an integer, else 'ioctl()' will fail! */
int stereo = TRUE;
+#if 0
int sample_rate = 8000;
int sample_rate = 8000;
+#else
+ int sample_rate = 22050;
+#endif
if (playing_sounds || (sound_device=open(sound_device_name,O_WRONLY))>=0)
{
if (playing_sounds || (sound_device=open(sound_device_name,O_WRONLY))>=0)
{
@@
-347,7
+352,9
@@
void SoundServer()
#endif /* !VOXWARE */
}
#endif /* !VOXWARE */
}
-#endif /* !MSDOS */
+
+#endif /* !MSDOS && !WIN32 */
+
}
#ifdef MSDOS
}
#ifdef MSDOS
@@
-403,6
+410,7
@@
static void sound_handler(struct SoundControl snd_ctrl)
}
#endif /* MSDOS */
}
#endif /* MSDOS */
+#ifndef WIN32
static void SoundServer_InsertNewSound(struct SoundControl snd_ctrl)
{
int i, k;
static void SoundServer_InsertNewSound(struct SoundControl snd_ctrl)
{
int i, k;
@@
-511,6
+519,7
@@
static void SoundServer_InsertNewSound(struct SoundControl snd_ctrl)
}
}
}
}
}
}
+#endif /* !WIN32 */
/*
void SoundServer_FadeSound(int nr)
/*
void SoundServer_FadeSound(int nr)
@@
-526,6
+535,7
@@
void SoundServer_FadeSound(int nr)
}
*/
}
*/
+#ifndef WIN32
#ifdef MSDOS
static void SoundServer_StopSound(int nr)
{
#ifdef MSDOS
static void SoundServer_StopSound(int nr)
{
@@
-570,6
+580,7
@@
static void SoundServer_StopAllSounds()
#endif
}
#endif /* MSDOS */
#endif
}
#endif /* MSDOS */
+#endif /* !WIN32 */
#ifdef HPUX_AUDIO
static void HPUX_Audio_Control()
#ifdef HPUX_AUDIO
static void HPUX_Audio_Control()
@@
-594,8
+605,8
@@
static void HPUX_Audio_Control()
}
#endif /* HPUX_AUDIO */
}
#endif /* HPUX_AUDIO */
-#if
ndef VOXWARE
-#ifndef MSDOS
+#if
!defined(VOXWARE) && !defined(MSDOS) && !defined(WIN32)
+
/* these two are stolen from "sox"... :) */
/*
/* these two are stolen from "sox"... :) */
/*
@@
-699,8
+710,7
@@
static int ulaw_to_linear(unsigned char ulawbyte)
return(sample);
}
return(sample);
}
-#endif /* !MSDOS */
-#endif /* !VOXWARE */
+#endif /* !VOXWARE && !MSDOS && !WIN32 */
/*** THE STUFF ABOVE IS ONLY USED BY THE SOUND SERVER CHILD PROCESS ***/
/*** THE STUFF ABOVE IS ONLY USED BY THE SOUND SERVER CHILD PROCESS ***/
@@
-830,17
+840,6
@@
void PlaySoundExt(int nr, int volume, int stereo, boolean loop)
{
struct SoundControl snd_ctrl = emptySoundControl;
{
struct SoundControl snd_ctrl = emptySoundControl;
-#ifdef USE_SDL_LIBRARY
- Mix_PlayChannel(-1, Sound[nr].mix_chunk, 0);
-
- /*
- Mix_Volume(-1, SDL_MIX_MAXVOLUME / 4);
- Mix_VolumeMusic(SDL_MIX_MAXVOLUME / 4);
- */
-
- return;
-#endif
-
if (sound_status==SOUND_OFF || !setup.sound)
return;
if (sound_status==SOUND_OFF || !setup.sound)
return;
@@
-862,6
+861,14
@@
void PlaySoundExt(int nr, int volume, int stereo, boolean loop)
snd_ctrl.data_ptr = Sound[nr].data_ptr;
snd_ctrl.data_len = Sound[nr].data_len;
snd_ctrl.data_ptr = Sound[nr].data_ptr;
snd_ctrl.data_len = Sound[nr].data_len;
+#ifdef USE_SDL_LIBRARY
+
+ Mix_Volume(-1, SDL_MIX_MAXVOLUME / 4);
+ Mix_VolumeMusic(SDL_MIX_MAXVOLUME / 4);
+
+ Mix_PlayChannel(-1, Sound[nr].mix_chunk, (loop ? -1 : 0));
+
+#else
#ifndef MSDOS
if (write(sound_pipe[1], &snd_ctrl, sizeof(snd_ctrl))<0)
{
#ifndef MSDOS
if (write(sound_pipe[1], &snd_ctrl, sizeof(snd_ctrl))<0)
{
@@
-872,6
+879,7
@@
void PlaySoundExt(int nr, int volume, int stereo, boolean loop)
#else
sound_handler(snd_ctrl);
#endif
#else
sound_handler(snd_ctrl);
#endif
+#endif
}
void FadeSound(int nr)
}
void FadeSound(int nr)
@@
-898,11
+906,6
@@
void StopSoundExt(int nr, int method)
{
struct SoundControl snd_ctrl = emptySoundControl;
{
struct SoundControl snd_ctrl = emptySoundControl;
-#ifdef USE_SDL_LIBRARY
- Mix_HaltMusic();
- return;
-#endif
-
if (sound_status==SOUND_OFF)
return;
if (sound_status==SOUND_OFF)
return;
@@
-917,6
+920,20
@@
void StopSoundExt(int nr, int method)
snd_ctrl.stop_sound = TRUE;
}
snd_ctrl.stop_sound = TRUE;
}
+#ifdef USE_SDL_LIBRARY
+
+ if (SSND_FADING(method))
+ {
+ Mix_FadeOutChannel(-1, 1000);
+ Mix_FadeOutMusic(1000);
+ }
+ else
+ {
+ Mix_HaltChannel(-1);
+ Mix_HaltMusic();
+ }
+
+#else
#ifndef MSDOS
if (write(sound_pipe[1], &snd_ctrl, sizeof(snd_ctrl))<0)
{
#ifndef MSDOS
if (write(sound_pipe[1], &snd_ctrl, sizeof(snd_ctrl))<0)
{
@@
-927,6
+944,7
@@
void StopSoundExt(int nr, int method)
#else
sound_handler(snd_ctrl);
#endif
#else
sound_handler(snd_ctrl);
#endif
+#endif
}
void FreeSounds(int num_sounds)
}
void FreeSounds(int num_sounds)