Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

ResSoundPack.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004 Ivo Danihelka (ivo@danihelka.net)
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or
00007  * (at your option) any later version.
00008  */
00009 #include "ResSoundPack.h"
00010 
00011 #include "Path.h"
00012 #include "OptionAgent.h"
00013 
00014 //-----------------------------------------------------------------
00015     void
00016 ResSoundPack::unloadRes(Mix_Chunk *res)
00017 {
00018     Mix_FreeChunk(res);
00019 }
00020 //-----------------------------------------------------------------
00021 /**
00022  * Load unshared sound from file.
00023  * @return sound or NULL
00024  */
00025     Mix_Chunk *
00026 ResSoundPack::loadSound(const Path &file)
00027 {
00028     Mix_Chunk *chunk = NULL;
00029     //TODO: ask SoundAgent to load this sound
00030     if (OptionAgent::agent()->getAsBool("sound", true)) {
00031         chunk = Mix_LoadWAV(file.getNative().c_str());
00032         if (NULL == chunk) {
00033             LOG_WARNING(ExInfo("cannot load sound")
00034                 .addInfo("path", file.getNative())
00035                 .addInfo("MixError", Mix_GetError()));
00036         }
00037     }
00038     return chunk;
00039 }
00040 //-----------------------------------------------------------------
00041 /**
00042  * Store sound under this name.
00043  * Nothing is stored when sound cannot be loaded.
00044  */
00045     void
00046 ResSoundPack::addSound(const std::string &name, const Path &file)
00047 {
00048     Mix_Chunk *chunk = loadSound(file);
00049     if (chunk) {
00050         addRes(name, chunk);
00051     }
00052 }
00053 

Generated on Wed Jun 1 09:54:31 2005 for Fish Fillets - Next Generation by  doxygen 1.4.2