For now using unique_ptr and implementation of Sound()
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
#define CHARGE_AUDIO_BASE_H
|
#define CHARGE_AUDIO_BASE_H
|
||||||
#include <Magnum/Magnum.h>
|
#include <Magnum/Magnum.h>
|
||||||
#include <Magnum/Math/Vector.h>
|
#include <Magnum/Math/Vector.h>
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace ChargeAudio {
|
namespace ChargeAudio {
|
||||||
@@ -29,7 +30,7 @@ private:
|
|||||||
class Engine {
|
class Engine {
|
||||||
public:
|
public:
|
||||||
Engine();
|
Engine();
|
||||||
Sound CreateSound(std::string filepath);
|
std::unique_ptr<Sound> CreateSound(std::string filepath);
|
||||||
void SetVolume(float value);
|
void SetVolume(float value);
|
||||||
float GetVolume();
|
float GetVolume();
|
||||||
|
|
||||||
|
@@ -16,12 +16,12 @@ Engine::Engine() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Sound Engine::CreateSound(std::string filepath) {
|
std::unique_ptr<Sound> Engine::CreateSound(std::string filepath) {
|
||||||
Sound sound;
|
auto sound = std::unique_ptr<Sound>(new Sound());
|
||||||
sound.baseEngine = this;
|
sound->baseEngine = this;
|
||||||
|
|
||||||
maResponse = ma_sound_init_from_file(&maEngine, filepath.c_str(), 0, NULL,
|
maResponse = ma_sound_init_from_file(&maEngine, filepath.c_str(), 0, NULL,
|
||||||
NULL, &sound.maSound);
|
NULL, &sound->maSound);
|
||||||
if (maResponse != MA_SUCCESS) {
|
if (maResponse != MA_SUCCESS) {
|
||||||
Utility::Error{} << "Failed to create the sound from the file: "
|
Utility::Error{} << "Failed to create the sound from the file: "
|
||||||
<< filepath.c_str() << " (" << maResponse << ")";
|
<< filepath.c_str() << " (" << maResponse << ")";
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
#include <Magnum/Math/Vector3.h>
|
#include <Magnum/Math/Vector3.h>
|
||||||
|
|
||||||
using namespace ChargeAudio;
|
using namespace ChargeAudio;
|
||||||
|
Sound::Sound() {}
|
||||||
Sound::~Sound() { ma_sound_uninit(&maSound); }
|
Sound::~Sound() { ma_sound_uninit(&maSound); }
|
||||||
|
|
||||||
// Controls
|
// Controls
|
||||||
|
Reference in New Issue
Block a user