aboutsummaryrefslogtreecommitdiff
path: root/src/crepe
diff options
context:
space:
mode:
Diffstat (limited to 'src/crepe')
-rw-r--r--src/crepe/Sound.cpp10
-rw-r--r--src/crepe/Sound.h10
-rw-r--r--src/crepe/SoundSystem.cpp11
-rw-r--r--src/crepe/SoundSystem.h6
4 files changed, 14 insertions, 23 deletions
diff --git a/src/crepe/Sound.cpp b/src/crepe/Sound.cpp
index 181366a..09ffd5f 100644
--- a/src/crepe/Sound.cpp
+++ b/src/crepe/Sound.cpp
@@ -7,7 +7,15 @@ using namespace crepe;
Sound::Sound(std::unique_ptr<api::Resource> res) {
dbg_trace();
- this->res = std::move(res);
+ this->load(std::move(res));
+}
+
+Sound::Sound(const char * src) {
+ dbg_trace();
+ this->load(std::make_unique<api::Resource>(src));
+}
+
+void Sound::load(std::unique_ptr<api::Resource> res) {
this->sample.load(this->res->canonical());
}
diff --git a/src/crepe/Sound.h b/src/crepe/Sound.h
index 333465b..163c5b4 100644
--- a/src/crepe/Sound.h
+++ b/src/crepe/Sound.h
@@ -9,8 +9,6 @@
namespace crepe {
-class SoundSystem;
-
class Sound {
public:
/**
@@ -54,15 +52,17 @@ public:
*/
void set_looping(bool looping);
-private:
- friend class SoundSystem;
+public:
+ Sound(const char * src);
Sound(std::unique_ptr<api::Resource> res);
private:
+ void load(std::unique_ptr<api::Resource> res);
+
+private:
std::unique_ptr<api::Resource> res;
SoLoud::Wav sample;
SoLoud::handle handle;
- bool paused;
};
}
diff --git a/src/crepe/SoundSystem.cpp b/src/crepe/SoundSystem.cpp
index 29bd196..00f874c 100644
--- a/src/crepe/SoundSystem.cpp
+++ b/src/crepe/SoundSystem.cpp
@@ -1,7 +1,6 @@
#include "util/log.h"
#include "SoundSystem.h"
-#include <memory>
using namespace crepe;
@@ -10,16 +9,6 @@ SoundSystem & SoundSystem::instance() {
return instance;
}
-std::unique_ptr<Sound> SoundSystem::sound(const std::string & src) {
- auto res = std::make_unique<api::Resource>(src);
- return SoundSystem::sound(std::move(res));
-}
-
-std::unique_ptr<Sound> SoundSystem::sound(std::unique_ptr<api::Resource> res) {
- Sound * out = new Sound(std::move(res));
- return std::unique_ptr<Sound>(out);
-}
-
SoundSystem::SoundSystem() {
dbg_trace();
engine.init();
diff --git a/src/crepe/SoundSystem.h b/src/crepe/SoundSystem.h
index 515cb29..da3927a 100644
--- a/src/crepe/SoundSystem.h
+++ b/src/crepe/SoundSystem.h
@@ -2,17 +2,11 @@
#include <soloud.h>
-#include <memory>
-
#include "Sound.h"
namespace crepe {
class SoundSystem {
-public:
- static std::unique_ptr<Sound> sound(const std::string & res);
- static std::unique_ptr<Sound> sound(std::unique_ptr<api::Resource> res);
-
private:
SoundSystem();
virtual ~SoundSystem();