mirror of
https://github.com/MadeOfJelly/MushMachine.git
synced 2025-12-06 18:36:35 +01:00
initial import, >900commits predate this
This commit is contained in:
30
framework/sound/src/mm/sound_loader_wav.cpp
Normal file
30
framework/sound/src/mm/sound_loader_wav.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "./sound_loader_wav.hpp"
|
||||
|
||||
#include "./soloud_filesystem_file_impl.hpp"
|
||||
|
||||
#include <mm/services/filesystem.hpp>
|
||||
|
||||
namespace MM {
|
||||
|
||||
std::shared_ptr<::SoLoud::Wav> SoundLoaderWavFile::load(const std::string& path, Engine& engine) const {
|
||||
auto& fs = engine.getService<Services::FilesystemService>();
|
||||
|
||||
if (!fs.isFile(path.c_str()))
|
||||
return nullptr;
|
||||
|
||||
auto h = fs.open(path.c_str());
|
||||
|
||||
MM::SoLoud::FilesystemFile sl_f(h, engine);
|
||||
|
||||
auto ptr = std::make_shared<::SoLoud::Wav>();
|
||||
auto r = ptr->loadFile(&sl_f);
|
||||
if (r != ::SoLoud::SO_NO_ERROR) {
|
||||
// log error
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
} // MM
|
||||
|
||||
Reference in New Issue
Block a user