diff --git a/src/sound.c b/src/sound.c
index ab925241120c2e8c22b05234ae1d90ede8edff79..2fe510b4115479f815d32e3a4d347df286dc9989 100644 (file)
--- a/src/sound.c
+++ b/src/sound.c
*/
#include "glob.h"
-#include "files.h"
#include "sound.h"
+#include "error.h"
#include <SDL.h>
#include <SDL_mixer.h>
short snd_vol = 50;
-int snddisabled = 1;
-
-struct {
+static int snddisabled = 1;
+static struct {
snd_t *s;
Mix_Chunk *c;
} chunks[NUM_CHUNKS];
-void S_init(void)
-{
+void S_init (void) {
if (!SDL_WasInit(SDL_INIT_AUDIO)) {
if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) {
fprintf(stderr, "\nUnable to initialize audio: %s\n", SDL_GetError());
S_volume(snd_vol);
}
-void S_done(void)
-{
+void S_done (void) {
free_chunks();
- Mix_CloseAudio();
- SDL_QuitSubSystem(SDL_INIT_AUDIO);
+ if (SDL_WasInit(SDL_INIT_AUDIO)) {
+ Mix_CloseAudio();
+ SDL_QuitSubSystem(SDL_INIT_AUDIO);
+ }
}
-Mix_Chunk * get_chunk(snd_t *s, int r, int v)
-{
+static Mix_Chunk *get_chunk (snd_t *s, int r, int v) {
int i, fi = -1;
for(i=0; i<NUM_CHUNKS; i++) {
if (chunks[i].s == s) return chunks[i].c;
return chunk;
}
-void free_chunks()
-{
+void free_chunks (void) {
if (snddisabled) return;
Mix_HaltChannel(-1);
int i;
}
}
-short S_play(snd_t *s,short c,unsigned r,short v)
-{
+short S_play(snd_t *s, short c, unsigned r, short v) {
if (snddisabled) return 0;
Mix_Chunk *chunk = get_chunk(s,r,v);
if (chunk==NULL) return 0;
return Mix_PlayChannel(c, chunk, 0);
}
-void S_stop(short c)
-{
+void S_stop (short c) {
Mix_HaltChannel(c);
}
-void S_volume(int v)
-{
+void S_volume (int v) {
if (snddisabled) return;
snd_vol=v;
if (snd_vol>128) snd_vol=128;
Mix_Volume(-1, snd_vol);
}
-void S_wait()
-{
+void S_wait (void) {
if (snddisabled) return;
while (Mix_Playing(-1)) {
SDL_Delay(10);