diff options
| author | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-06-28 16:38:35 +0000 |
|---|---|---|
| committer | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-06-28 16:38:35 +0000 |
| commit | 2d776fcd61be168e1ff0ff2e4a5e71835e7cea19 (patch) | |
| tree | 7cf274897bf540d5332d446f583ffd066e4e2e1d /src/sound.c | |
| parent | b877ae23ac5d380ab3aa48d7724045cf4883b186 (diff) | |
- prekopanie adresarovej struktury, prva cast
git-svn-id: http://opensvn.csie.org/tuxanci_ng@77 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
Diffstat (limited to 'src/sound.c')
| -rw-r--r-- | src/sound.c | 137 |
1 files changed, 0 insertions, 137 deletions
diff --git a/src/sound.c b/src/sound.c deleted file mode 100644 index a35d996..0000000 --- a/src/sound.c +++ /dev/null @@ -1,137 +0,0 @@ - -#include <stdio.h> -#include <stdlib.h> -#include <assert.h> - -#include "main.h" -#include "interface.h" -#include "list.h" -#include "path.h" -#include "string_length.h" -#include "audio.h" -#include "sound.h" -#include "storage.h" - -static list_t *listStorage; - -static bool_t isSoundInit = FALSE; -static bool_t var_isSoundActive = TRUE; - -bool_t isSoundInicialized() -{ - return isSoundInit; -} - -void initSound() -{ - if( isAudioInicialized() == FALSE ) - { - isSoundInit = FALSE; - return; - } - - listStorage = newStorage(); - isSoundInit = TRUE; - var_isSoundActive = TRUE; - - if( isParamFlag("--nosound") ) - { - setSoundActive(FALSE); - } - - if( isParamFlag("--sound") ) - { - setSoundActive(TRUE); - } - - printf("init sound..\n"); -} - -static Mix_Chunk* loadMixSound(char *file) -{ - Mix_Chunk *new; - char str[STR_PATH_SIZE]; - - - printf("load sound %s..\n", file); - 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()); - return NULL; - } - - return new; -} - - -static void playMixSound(Mix_Chunk *p) -{ - if( Mix_PlayChannel(-1, p, 0) == -1 ) - { - fprintf(stderr, "Nelze prehrat zvuk : %s\n", Mix_GetError()); - return; - } -} - -static void destroySound(void *p) -{ - Mix_FreeChunk((Mix_Chunk *)p); -} - -void addSound(char *file, char *name, char *group) -{ - Mix_Chunk *new; - - if( isSoundInit == FALSE ) - { - return; - } - - assert( file != NULL ); - assert( name != NULL ); - assert( group != NULL ); - - new = loadMixSound(file); - - addItemToStorage(listStorage, group, name, new ); -} - -void playSound(char *name, char *group) -{ - if( isSoundInit == FALSE || - var_isSoundActive == FALSE ) - { - return; - } - - playMixSound( getItemFromStorage(listStorage, group, name) ); -} - -void setSoundActive(bool_t n) -{ - var_isSoundActive = n; -} - -bool_t isSoundActive() -{ - return var_isSoundActive; -} - -void quitSound() -{ - if( isSoundInit == FALSE ) - { - return; - } - - destroyStorage(listStorage, destroySound); - isSoundInit = FALSE; - printf("quit sound..\n"); -} - |