summaryrefslogtreecommitdiff
path: root/src/audio/sound.c
diff options
context:
space:
mode:
authorscarab <scarab@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-08-15 19:57:10 +0000
committerscarab <scarab@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e>2008-08-15 19:57:10 +0000
commit7bbd60007620cf3cc3ee7a913f7010588808ebb2 (patch)
tree34e72f66dfd1076e23c43074786f935aca70cba1 /src/audio/sound.c
parent50ba3d5e1e9f9eeda049a348efa4645af07610bc (diff)
"- initial commit for GETTEXT support and K&R compilance"
git-svn-id: http://opensvn.csie.org/tuxanci_ng@196 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
Diffstat (limited to 'src/audio/sound.c')
-rw-r--r--src/audio/sound.c103
1 files changed, 50 insertions, 53 deletions
diff --git a/src/audio/sound.c b/src/audio/sound.c
index 652de67..72d1584 100644
--- a/src/audio/sound.c
+++ b/src/audio/sound.c
@@ -6,26 +6,26 @@
#include "main.h"
#include "list.h"
#include "storage.h"
-
#include "interface.h"
-
#include "audio.h"
#include "sound.h"
static list_t *listStorage;
-
static bool_t isSoundInit = FALSE;
static bool_t var_isSoundActive = TRUE;
-
+/*
+ * Return state of sound
+ */
bool_t isSoundInicialized()
{
return isSoundInit;
}
-
+/*
+ * Audio initialization
+ */
void initSound()
{
- if( isAudioInicialized() == FALSE )
- {
+ if( isAudioInicialized() == FALSE ) {
isSoundInit = FALSE;
return;
}
@@ -33,105 +33,102 @@ void initSound()
listStorage = newStorage();
isSoundInit = TRUE;
var_isSoundActive = TRUE;
-
- if( isParamFlag("--nosound") )
- {
+ if (isParamFlag("--nosound"))
setSoundActive(FALSE);
- }
-
- if( isParamFlag("--sound") )
- {
+ if (isParamFlag("--sound"))
setSoundActive(TRUE);
- }
-
- printf("init sound..\n");
+#ifdef DEBUG
+ printf(_("Initializing sound...\n"));
+#endif
}
-
+/*
+ * Load sound file (Null/mixer)
+ */
static Mix_Chunk* loadMixSound(char *file)
{
Mix_Chunk *new;
char str[STR_PATH_SIZE];
-
- printf("load sound %s..\n", file);
+#ifdef DEBUG
+ printf("Loading sound file: %s\n", file);
+#endif
sprintf(str, PATH_SOUND "%s", file);
-
accessExistFile(str);
-
new = Mix_LoadWAV(str);
-
- if( new == NULL )
- {
- fprintf(stderr, "Nelze nahrat zvuk %s : %s\n", str, Mix_GetError());
+ if (new == NULL) {
+ fprintf(stderr, _("Unable to load sound file: %s with error: %s\n"), str, Mix_GetError());
return NULL;
}
-
return new;
}
-
+/*
+ * Play sound with mixer
+ */
static void playMixSound(Mix_Chunk *p)
{
- if( Mix_PlayChannel(-1, p, 0) == -1 )
- {
- fprintf(stderr, "Nelze prehrat zvuk : %s\n", Mix_GetError());
+ if (Mix_PlayChannel(-1, p, 0) == -1) {
+ fprintf(stderr, _("Unable to playback sound with error: %s\n"), Mix_GetError());
return;
}
}
-
+/*
+ * Destroy mixer chunk
+ */
static void destroySound(void *p)
{
Mix_FreeChunk((Mix_Chunk *)p);
}
-
+/*
+ * Add sound to list
+ */
void addSound(char *file, char *name, char *group)
{
Mix_Chunk *new;
- if( isSoundInit == FALSE )
- {
+ if (isSoundInit == FALSE)
return;
- }
-
assert( file != NULL );
assert( name != NULL );
assert( group != NULL );
-
new = loadMixSound(file);
-
addItemToStorage(listStorage, group, name, new );
}
-
+/*
+ * Start playback file from list
+ */
void playSound(char *name, char *group)
{
- if( isSoundInit == FALSE ||
- var_isSoundActive == FALSE )
- {
+ if (isSoundInit == FALSE ||
+ var_isSoundActive == FALSE)
return;
- }
-
- playMixSound( getItemFromStorage(listStorage, group, name) );
+ playMixSound(getItemFromStorage(listStorage, group, name));
}
-
+/*
+ * Set if sound is active True/False
+ */
void setSoundActive(bool_t n)
{
var_isSoundActive = n;
}
-
+/*
+ * Return state of sound
+ */
bool_t isSoundActive()
{
return var_isSoundActive;
}
-
+/*
+ * Quit all sound stuff
+ */
void quitSound()
{
if( isSoundInit == FALSE )
- {
return;
- }
-
destroyStorage(listStorage, destroySound);
isSoundInit = FALSE;
- printf("quit sound..\n");
+#ifdef DEBUG
+ printf(_("Quitting sound...\n"));
+#endif
}