Making sound constructor more generalised(probably will make it public soon)
This commit is contained in:
@@ -1,20 +1,18 @@
|
||||
#include "ChargeAudio.hpp"
|
||||
#include <Magnum/Magnum.h>
|
||||
#include <Magnum/Math/Vector3.h>
|
||||
|
||||
#include <functional>
|
||||
#include <stdexcept>
|
||||
|
||||
using namespace ChargeAudio;
|
||||
Sound::Sound(Engine *engine) : baseEngine(engine) {
|
||||
Sound::Sound(Engine *engine, std::function<void(Sound *)> setupFunction,
|
||||
std::string additionalErrorMessage)
|
||||
: baseEngine(engine) {
|
||||
maConfig = ma_sound_config_init_2(&baseEngine->maEngine);
|
||||
maConfig.endCallback = Sound::onSoundFinish;
|
||||
maConfig.pEndCallbackUserData = this;
|
||||
}
|
||||
|
||||
Sound::~Sound() { ma_sound_uninit(&maSound); }
|
||||
|
||||
Sound::SoundState Sound::GetState() { return state; }
|
||||
|
||||
void Sound::init(std::string additionalErrorMessage) {
|
||||
setupFunction(this);
|
||||
ma_result maResponse =
|
||||
ma_sound_init_ex(&baseEngine->maEngine, &maConfig, &maSound);
|
||||
if (maResponse != MA_SUCCESS) {
|
||||
@@ -26,6 +24,9 @@ void Sound::init(std::string additionalErrorMessage) {
|
||||
}
|
||||
}
|
||||
|
||||
Sound::~Sound() { ma_sound_uninit(&maSound); }
|
||||
Sound::SoundState Sound::GetState() { return state; }
|
||||
|
||||
// Controls
|
||||
void Sound::Play() {
|
||||
ma_sound_start(&maSound);
|
||||
|
||||
Reference in New Issue
Block a user