diff options
author | Perttu Ahola <celeron55@gmail.com> | 2012-03-25 15:52:43 +0300 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2012-03-25 15:52:43 +0300 |
commit | db0928add3af6da67b1717933e92338f1030d5fb (patch) | |
tree | 935d9979e76dae57edb44822368bc9e0e7c10478 /src/sound_openal.cpp | |
parent | a9a923e4dab83374a870ba05f4f1c1c449a38c05 (diff) | |
download | minetest-db0928add3af6da67b1717933e92338f1030d5fb.tar.gz minetest-db0928add3af6da67b1717933e92338f1030d5fb.tar.bz2 minetest-db0928add3af6da67b1717933e92338f1030d5fb.zip |
Sound loading from memory (by using a quick hack)
Diffstat (limited to 'src/sound_openal.cpp')
-rw-r--r-- | src/sound_openal.cpp | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/sound_openal.cpp b/src/sound_openal.cpp index f7bce6546..e635e0fa1 100644 --- a/src/sound_openal.cpp +++ b/src/sound_openal.cpp @@ -41,6 +41,7 @@ with this program; ifnot, write to the Free Software Foundation, Inc., #include <map> #include <vector> #include "utility.h" // myrand() +#include "filesys.h" #define BUFFER_SIZE 30000 @@ -434,9 +435,18 @@ public: bool loadSoundData(const std::string &name, const std::string &filedata) { - errorstream<<"OpenALSoundManager: Loading from filedata not" - " implemented"<<std::endl; - return false; + // The vorbis API sucks; just write it to a file and use vorbisfile + // TODO: Actually load it directly from memory + std::string basepath = porting::path_user + DIR_DELIM + "cache" + + DIR_DELIM + "tmp"; + std::string path = basepath + DIR_DELIM + "tmp.ogg"; + verbosestream<<"OpenALSoundManager::loadSoundData(): Writing " + <<"temporary file to ["<<path<<"]"<<std::endl; + fs::CreateAllDirs(basepath); + std::ofstream of(path.c_str(), std::ios::binary); + of.write(filedata.c_str(), filedata.size()); + of.close(); + return loadSoundFile(name, path); } void updateListener(v3f pos, v3f vel, v3f at, v3f up) |