Browse Source

fixed emsc build error

dmuratshin 9 years ago
parent
commit
e2ab86b012

+ 1 - 6
CMakeLists.txt

@@ -35,12 +35,7 @@ set(SRC
 if(EMSCRIPTEN)
 	set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
 	set(SRC ${SRC}
-		src/sound/emscripten/SoundSystemEmscripten.cpp
-		src/sound/emscripten/SoundSystemEmscripten.h
-		src/sound/emscripten/ChannelEmscripten.cpp
-		src/sound/emscripten/ChannelEmscripten.h
-		src/sound/emscripten/SoundEmscripten.cpp
-		src/sound/emscripten/SoundEmscripten.h
+		src/sound/emscripten/SoundSystemEmscriptenNull.cpp
 	)
 
 else(EMSCRIPTEN)

+ 1 - 0
src/oxygine-sound.h

@@ -2,4 +2,5 @@
 #include "sound/SoundInstance.h"
 #include "sound/SoundPlayer.h"
 #include "sound/SoundSystem.h"
+#include "sound/null/SoundSystemNull.h"
 #include "sound/ResSound.h"

+ 3 - 0
src/sound/Sound.h

@@ -6,6 +6,7 @@
 namespace oxygine
 {
     class ResSound;
+    class SoundHandle;
 
     class Sound
     {
@@ -16,6 +17,8 @@ namespace oxygine
         ResSound*   getRes() { return _parent;}
         void        setRes(ResSound* rs) { _parent = rs; }
         virtual int getDuration() const = 0;
+
+        virtual SoundHandle* createSH() = 0;
     private:
         ResSound* _parent;
     };

+ 4 - 1
src/sound/SoundPlayer.cpp

@@ -88,7 +88,10 @@ namespace oxygine
 
     spSoundInstance SoundPlayer::_play(Sound* snd, const PlayOptions& opt, const string& name)
     {
-        SoundHandle* handle = SoundHandleOAL::create(snd);
+        SoundHandle* handle = snd->createSH();
+        if (!handle)
+            return 0;
+
         spSoundInstance s = new SoundInstance(this, handle);
 
         s->setName(name);

+ 1 - 1
src/sound/emscripten/SoundSystemEmscripten.cpp

@@ -1,4 +1,4 @@
-#include "SoundSystemEmscripten.h"
+#include "../SoundSystemEmscripten.h"
 #include "SoundEmscripten.h"
 #include "DebugActor.h"
 #include "utils/stringUtils.h"

+ 1 - 1
src/sound/emscripten/SoundSystemEmscripten.h

@@ -1,5 +1,5 @@
 #pragma once
-#include "SoundSystem.h"
+#include "../SoundSystem.h"
 #include "ChannelEmscripten.h"
 #include "Channels.h"
 

+ 13 - 0
src/sound/emscripten/SoundSystemEmscriptenNull.cpp

@@ -0,0 +1,13 @@
+#include "../null/SoundSystemNull.h"
+namespace oxygine
+{
+
+    SoundSystem*    SoundSystem::create()
+    {
+        if (!SoundSystem::instance)
+            SoundSystem::instance = new SoundSystemNull;
+
+        return SoundSystem::instance;
+    }
+
+}

+ 5 - 0
src/sound/null/SoundNull.cpp

@@ -14,4 +14,9 @@ namespace oxygine
     {
         return 0;
     }
+
+    SoundHandle *SoundNull::createSH()
+    {
+        return 0;
+    }
 }

+ 2 - 0
src/sound/null/SoundNull.h

@@ -10,6 +10,8 @@ namespace oxygine
         ~SoundNull();
 
         int getDuration() const;
+
+        SoundHandle *createSH() override;
     private:
     };
 }

+ 1 - 15
src/sound/null/SoundSystemNull.cpp

@@ -36,26 +36,12 @@ namespace oxygine
         return new SoundNull;
     }
 
-    Sound* SoundSystemNull::createSound(const char* file)
+    Sound* SoundSystemNull::createSound(const char* file, bool)
     {
         return new SoundNull;
     }
 
 
-    Channel*    SoundSystemNull::getFreeChannel()
-    {
-        return 0;
-    }
-
-    float       SoundSystemNull::getVolume() const
-    {
-        return 1.0f;
-    }
-
-    void SoundSystemNull::setVolume(float)
-    {
-
-    }
 
     void SoundSystemNull::update()
     {

+ 8 - 13
src/sound/null/SoundSystemNull.h

@@ -8,21 +8,16 @@ namespace oxygine
     class SoundSystemNull : public SoundSystem
     {
     public:
-        void init(int channels);
-        void release();
-        void pause();
-        void resume();
-        void stop();
+        void init(int channels) override;
+        void release() override;
+        void pause() override;
+        void resume() override;
+        void stop() override;
 
 
-        Sound* createSound(std::vector<unsigned char>& data, bool swap);
-        Sound* createSound(const char* file);
+        Sound* createSound(std::vector<unsigned char>& data, bool swap) override;
+        Sound* createSound(const char* file, bool streaming) override;
 
-
-        Channel*    getFreeChannel();
-        float       getVolume() const;
-
-        void setVolume(float);
-        void update();
+        void update()  override;
     };
 }

+ 6 - 0
src/sound/oal/SoundOAL.cpp

@@ -148,4 +148,10 @@ namespace oxygine
         else
             stream.init(_fileName.c_str());
     }
+
+    oxygine::SoundHandleOAL* SoundOAL::createSH()
+    {
+        return SoundHandleOAL::create(this);
+    }
+
 }

+ 3 - 1
src/sound/oal/SoundOAL.h

@@ -4,12 +4,13 @@
 #include "../OggStream.h"
 #include "../Sound.h"
 #include "../oal.h"
-
+#include "SoundHandleOAL.h"
 
 namespace oxygine
 {
     class WavStream;
     class OggStream;
+    class SoundHandleOAL;
 
     class SoundOAL: public Sound
     {
@@ -31,6 +32,7 @@ namespace oxygine
         void initStream(OggStream& stream);
         void initStream(WavStream& stream);
 
+        SoundHandleOAL* createSH() override;
 
     private:
         bool _init(SoundStream& stream);