diff options
Diffstat (limited to 'src/resources/music.cpp')
-rw-r--r-- | src/resources/music.cpp | 23 |
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 |