Changing initing to be more standardised(needs to be refactored)
This commit is contained in:
@@ -20,20 +20,13 @@ Engine::Engine() {
|
||||
|
||||
Engine::~Engine() { ma_engine_uninit(&maEngine); }
|
||||
|
||||
Containers::Pointer<Sound> Engine::CreateSound(std::string filepath) {
|
||||
Containers::Pointer<Sound> Engine::CreateSound(const std::string filepath) {
|
||||
auto sound = Containers::Pointer<Sound>(new Sound(this));
|
||||
maResponse = ma_sound_init_from_file(&maEngine, filepath.c_str(), 0, NULL,
|
||||
NULL, &sound->maSound);
|
||||
sound->maSound.endCallback = Sound::onSoundFinish;
|
||||
sound->maSound.pEndCallbackUserData = sound.get();
|
||||
|
||||
if (maResponse != MA_SUCCESS) {
|
||||
Utility::Error{} << "Failed to create the sound from the file: "
|
||||
<< filepath.c_str() << " (" << maResponse << ")";
|
||||
throw new std::runtime_error(
|
||||
"Failed to create the sound from file. Check STDERR for more info.");
|
||||
}
|
||||
|
||||
sound->maConfig.pFilePath = filepath.c_str();
|
||||
sound->maConfig.flags = 0;
|
||||
sound->maConfig.pInitialAttachment = NULL;
|
||||
sound->maConfig.pDoneFence = NULL;
|
||||
sound->init("Failed to create the sound from the file: " + filepath);
|
||||
return sound;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user