diff options
Diffstat (limited to 'src/audio')
| -rw-r--r-- | src/audio/audio.c | 11 | ||||
| -rw-r--r-- | src/audio/music.c | 35 | ||||
| -rw-r--r-- | src/audio/music.h | 16 | ||||
| -rw-r--r-- | src/audio/sound.c | 18 | ||||
| -rw-r--r-- | src/audio/sound.h | 16 |
5 files changed, 52 insertions, 44 deletions
diff --git a/src/audio/audio.c b/src/audio/audio.c index 9d629eb..14297af 100644 --- a/src/audio/audio.c +++ b/src/audio/audio.c @@ -8,6 +8,7 @@ #include "interface.h" static bool_t isAudioInit = FALSE; + /* * Returns state of audio */ @@ -17,16 +18,16 @@ bool_t isAudioInicialized() } /* - * Inicialize audio + * Initialize audio */ void initAudio() { - if (isParamFlag("--noaudio")) { + if (isParamFlag("--no-audio")) { return; } if (SDL_Init(SDL_INIT_AUDIO) == -1) { - fprintf(stderr, _("Unable to initialize audio: %s\n"), SDL_GetError()); + fprintf(stderr, _("Error! Unable to initialize audio: %s\n"), SDL_GetError()); return; } @@ -40,7 +41,7 @@ void initAudio() Mix_AllocateChannels(16); Mix_Volume(-1, MIX_MAX_VOLUME); - DEBUG_MSG(_("Initializing audio system...\n")); + DEBUG_MSG(_("Initializing audio\n")); isAudioInit = TRUE; } @@ -53,5 +54,5 @@ void quitAudio() Mix_CloseAudio(); isAudioInit = TRUE; - DEBUG_MSG(_("Quitting audio...\n")); + DEBUG_MSG(_("Quitting audio\n")); } diff --git a/src/audio/music.c b/src/audio/music.c index 5af9dda..feabb90 100644 --- a/src/audio/music.c +++ b/src/audio/music.c @@ -15,6 +15,7 @@ static list_t *listStorage; static bool_t isMusicInit = FALSE; static bool_t var_isMusicActive = TRUE; static Mix_Music *currentMusic; + /* * Return state of music initialization */ @@ -38,24 +39,24 @@ void initMusic() isMusicInit = TRUE; var_isMusicActive = TRUE; - if (isParamFlag("--nomusic")) + if (isParamFlag("--no-music")) setMusicActive(FALSE); if (isParamFlag("--music")) setMusicActive(TRUE); - DEBUG_MSG(_("Initializing music...\n")); + DEBUG_MSG(_("Initializing music\n")); } /* - * Load music file and returns it + * Load a file with music and returns it */ static Mix_Music *loadMixMusic(char *file) { Mix_Music *mixer; char str[STR_PATH_SIZE]; - DEBUG_MSG(_("Loading music file: %s\n"), file); + DEBUG_MSG(_("Loading a file with music: %s\n"), file); if (isFillPath(file)) { strcpy(str, file); @@ -68,7 +69,7 @@ static Mix_Music *loadMixMusic(char *file) mixer = Mix_LoadMUS(str); if (mixer == NULL) { - fprintf(stderr, _("Unable to load music from file: %s\n"), file); + fprintf(stderr, _("Unable to load music from file %s\n"), file); return NULL; } @@ -80,8 +81,9 @@ static Mix_Music *loadMixMusic(char *file) */ static void playMixMusic() { - if (currentMusic != NULL) + if (currentMusic != NULL) { Mix_PlayMusic(currentMusic, 1000); + } } /* @@ -115,11 +117,12 @@ void addMusic(char *file, char *name, char *group) */ void stopMusic() { - if (isMusicInit == FALSE || var_isMusicActive == FALSE) + if (isMusicInit == FALSE || var_isMusicActive == FALSE) { return; + } if (currentMusic != NULL) { - DEBUG_MSG(_("Stopping music...\n")); + DEBUG_MSG(_("Stopping music\n")); Mix_HaltMusic(); currentMusic = NULL; @@ -127,7 +130,7 @@ void stopMusic() } /* - * start music playback + * Play music playback */ void playMusic(char *name, char *group) { @@ -145,27 +148,28 @@ void playMusic(char *name, char *group) return; if (currentMusic != NULL && - strcmp(currentMusic_group, group) == 0 && - strcmp(currentMusic_name, name) == 0) { + strcmp(currentMusic_group, group) == 0 && + strcmp(currentMusic_name, name) == 0) { return; } - if (currentMusic != NULL) + if (currentMusic != NULL) { stopMusic(); + } currentMusic = getItemFromStorage(listStorage, group, name); strcpy(currentMusic_group, group); strcpy(currentMusic_name, name); if (currentMusic != NULL) { - DEBUG_MSG(_("Playing music file %s\n"), name); + DEBUG_MSG(_("Playing music from file %s\n"), name); playMixMusic(); } } /* - * Set music active/deactivated + * Set music status to active/inactive */ void setMusicActive(bool_t n) { @@ -206,6 +210,7 @@ void delAllMusicInGroup(char *group) { if (isMusicInit == FALSE) return; + delAllItemFromStorage(listStorage, group, destroyMusic); } @@ -221,5 +226,5 @@ void quitMusic() destroyStorage(listStorage, destroyMusic); isMusicInit = FALSE; - DEBUG_MSG(_("Quitting music...\n")); + DEBUG_MSG(_("Quitting music\n")); } diff --git a/src/audio/music.h b/src/audio/music.h index 1b0e1fb..17e4409 100644 --- a/src/audio/music.h +++ b/src/audio/music.h @@ -8,14 +8,14 @@ # define MUSIC_GROUP_BASE "base" # define MUSIC_GROUP_USER "user" - /* - typedef struct music_struct - { - char *name; - int group; - Mix_Music *music; - } music_t; - */ +/* + typedef struct music_struct + { + char *name; + int group; + Mix_Music *music; + } music_t; + */ extern bool_t isMusicInicialized(); extern void initMusic(); diff --git a/src/audio/sound.c b/src/audio/sound.c index 63d4566..dee6c2d 100644 --- a/src/audio/sound.c +++ b/src/audio/sound.c @@ -13,8 +13,9 @@ static list_t *listStorage; static bool_t isSoundInit = FALSE; static bool_t var_isSoundActive = TRUE; + /* - * Return state of sound + * Return status of sound */ bool_t isSoundInicialized() { @@ -22,7 +23,7 @@ bool_t isSoundInicialized() } /* - * Audio initialization + * Initialize sound */ void initSound() { @@ -35,18 +36,18 @@ void initSound() isSoundInit = TRUE; var_isSoundActive = TRUE; - if (isParamFlag("--nosound")) + if (isParamFlag("--no-sound")) setSoundActive(FALSE); if (isParamFlag("--sound")) setSoundActive(TRUE); - DEBUG_MSG(_("Initializing sound...\n")); + DEBUG_MSG(_("Initializing sound\n")); } /* - * Load sound file (Null/mixer) + * Load sound from file (Null/mixer) */ static Mix_Chunk *loadMixSound(char *file) { @@ -60,7 +61,7 @@ static Mix_Chunk *loadMixSound(char *file) new = Mix_LoadWAV(str); if (new == NULL) { - fprintf(stderr, _("Unable to load sound file: %s with error: %s\n"), str, Mix_GetError()); + fprintf(stderr, _("Unable to load sound from file %s with error: %s\n"), str, Mix_GetError()); return NULL; } @@ -73,7 +74,7 @@ static Mix_Chunk *loadMixSound(char *file) static void playMixSound(Mix_Chunk * p) { if (Mix_PlayChannel(-1, p, 0) == -1) { - fprintf(stderr, _("Unable to playback sound with error: %s\n"), Mix_GetError()); + fprintf(stderr, _("Unable to play sound with error: %s\n"), Mix_GetError()); return; } } @@ -138,8 +139,9 @@ void quitSound() { if (isSoundInit == FALSE) return; + destroyStorage(listStorage, destroySound); isSoundInit = FALSE; - DEBUG_MSG(_("Quitting sound...\n")); + DEBUG_MSG(_("Quitting sound\n")); } diff --git a/src/audio/sound.h b/src/audio/sound.h index f63af13..a5d69d4 100644 --- a/src/audio/sound.h +++ b/src/audio/sound.h @@ -8,14 +8,14 @@ # define SOUND_GROUP_BASE "base" # define SOUND_GROUP_USER "user" - /* - typedef struct sound_struct - { - char *name; - int group; - Mix_Chunk *sound; - } sound_t; - */ +/* + typedef struct sound_struct + { + char *name; + int group; + Mix_Chunk *sound; + } sound_t; + */ extern bool_t isSoundInicialized(); extern void initSound(); |