summaryrefslogtreecommitdiff
path: root/src/resources/music.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2007-11-20 12:27:56 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2007-11-20 12:27:56 +0000
commitca58ec1faedca0081ecd233f2cefa1ba783cebf4 (patch)
tree11216c01bb8867a9bd4ad6d4b8bdefc3c61a952a /src/resources/music.cpp
parent5a7abdafdac8f6ddd7972cadbc7e20563a0a29fc (diff)
downloadmana-ca58ec1faedca0081ecd233f2cefa1ba783cebf4.tar.gz
mana-ca58ec1faedca0081ecd233f2cefa1ba783cebf4.tar.bz2
mana-ca58ec1faedca0081ecd233f2cefa1ba783cebf4.tar.xz
mana-ca58ec1faedca0081ecd233f2cefa1ba783cebf4.zip
Merged revisions 3642,3662-3664,3667 via svnmerge from
https://themanaworld.svn.sourceforge.net/svnroot/themanaworld/tmw/trunk ........ r3642 | gmelquio | 2007-10-19 19:46:46 +0200 (Fri, 19 Oct 2007) | 1 line Factored code between resource handlers. Implemented failure-friendly sprite loader. ........ r3662 | gmelquio | 2007-10-21 21:01:16 +0200 (Sun, 21 Oct 2007) | 1 line Added persistent positioning. ........ r3663 | gmelquio | 2007-10-21 21:03:43 +0200 (Sun, 21 Oct 2007) | 1 line Fixed missing pixels at bottom and right. ........ r3664 | gmelquio | 2007-10-21 21:05:56 +0200 (Sun, 21 Oct 2007) | 1 line Changed to use default values when restoring missing settings. ........ r3667 | gmelquio | 2007-10-21 22:09:08 +0200 (Sun, 21 Oct 2007) | 1 line Fixed invisible text in dropboxes and shopboxes. ........
Diffstat (limited to 'src/resources/music.cpp')
-rw-r--r--src/resources/music.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/resources/music.cpp b/src/resources/music.cpp
index 09e2752a..161d8b01 100644
--- a/src/resources/music.cpp
+++ b/src/resources/music.cpp
@@ -23,8 +23,9 @@
#include "music.h"
-Music::Music(const std::string &idPath, Mix_Chunk *music):
- Resource(idPath),
+#include "../log.h"
+
+Music::Music(Mix_Chunk *music):
mChunk(music),
mChannel(-1)
{
@@ -36,20 +37,24 @@ Music::~Music()
Mix_FreeChunk(mChunk);
}
-Music*
-Music::load(void *buffer, unsigned int bufferSize, const std::string &idPath)
+Resource *Music::load(void *buffer, unsigned bufferSize)
{
// Load the raw file data from the buffer in an RWops structure
SDL_RWops *rw = SDL_RWFromMem(buffer, bufferSize);
// Use Mix_LoadMUS to load the raw music data
//Mix_Music* music = Mix_LoadMUS_RW(rw); Need to be implemeted
- Mix_Chunk *tmpMusic = Mix_LoadWAV_RW(rw, 0);
-
- // Now free the SDL_RWops data
- SDL_FreeRW(rw);
+ Mix_Chunk *tmpMusic = Mix_LoadWAV_RW(rw, 1);
- return new Music(idPath, tmpMusic);
+ if (tmpMusic)
+ {
+ return new Music(tmpMusic);
+ }
+ else
+ {
+ logger->log("Error, failed to load music: %s", Mix_GetError());
+ return NULL;
+ }
}
bool