Changing initing to be more standardised(needs to be refactored)

This commit is contained in:
2025-09-07 22:39:17 +03:00
parent 71e4ff9317
commit 146bd49b36
3 changed files with 27 additions and 14 deletions

View File

@@ -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;
}