diff --git a/.appveyor.yml b/.appveyor.yml index 95d115ea..84a7dc2f 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -10,6 +10,7 @@ cache: environment: APPVEYOR_SAVE_CACHE_ON_ERROR: true + ALSOFT_DRIVERS: null PYTHON: "C:\\Python36-x64" CMAKE_GENERATOR_BASE: "Visual Studio 15 2017" NAME_SUFFIX: "windows" diff --git a/rwengine/src/audio/Sound.hpp b/rwengine/src/audio/Sound.hpp index 2246e23f..6fc05ac4 100644 --- a/rwengine/src/audio/Sound.hpp +++ b/rwengine/src/audio/Sound.hpp @@ -22,8 +22,8 @@ struct Sound { size_t id = 0; bool isLoaded = false; - std::shared_ptr source = nullptr; - std::unique_ptr buffer = nullptr; + std::shared_ptr source; + std::unique_ptr buffer; Sound() = default; diff --git a/rwengine/src/audio/SoundBuffer.hpp b/rwengine/src/audio/SoundBuffer.hpp index 3d077248..a1660785 100644 --- a/rwengine/src/audio/SoundBuffer.hpp +++ b/rwengine/src/audio/SoundBuffer.hpp @@ -9,10 +9,7 @@ /// OpenAL tool for playing /// sound instance. -class SoundBuffer { - friend class SoundManager; - -public: +struct SoundBuffer { SoundBuffer(); bool bufferData(SoundSource& soundSource); @@ -30,7 +27,6 @@ public: void setGain(float gain); void setMaxDistance(float maxDist); -private: ALuint source; ALuint buffer; }; diff --git a/rwengine/src/audio/SoundManager.cpp b/rwengine/src/audio/SoundManager.cpp index 54c9238a..229b33f1 100644 --- a/rwengine/src/audio/SoundManager.cpp +++ b/rwengine/src/audio/SoundManager.cpp @@ -28,6 +28,11 @@ Sound& SoundManager::getSoundRef(const std::string& name) { return sounds[name]; // @todo reloading, how to check is it wav/mp3? } +SoundManager::SoundManager() { + initializeOpenAL(); + initializeAVCodec(); +} + SoundManager::SoundManager(GameWorld* engine) : _engine(engine) { auto sdtPath = _engine->data->index.findFilePath("audio/sfx.SDT"); auto rawPath = _engine->data->index.findFilePath("audio/sfx.RAW"); diff --git a/rwengine/src/audio/SoundManager.hpp b/rwengine/src/audio/SoundManager.hpp index e9bdddec..f76f443e 100644 --- a/rwengine/src/audio/SoundManager.hpp +++ b/rwengine/src/audio/SoundManager.hpp @@ -29,6 +29,7 @@ class ViewCamera; /// instances simultaneously without duplicating raw source). class SoundManager { public: + SoundManager(); SoundManager(GameWorld* engine); ~SoundManager(); diff --git a/rwengine/src/audio/SoundSource.hpp b/rwengine/src/audio/SoundSource.hpp index 182f3ee4..c007a353 100644 --- a/rwengine/src/audio/SoundSource.hpp +++ b/rwengine/src/audio/SoundSource.hpp @@ -9,7 +9,7 @@ /// (loading and decoding sound) class SoundSource { friend class SoundManager; - friend class SoundBuffer; + friend struct SoundBuffer; public: /// Load sound from mp3/wav file diff --git a/scripts/docker/docker_travis.sh b/scripts/docker/docker_travis.sh index f250b5b6..34c5fca3 100755 --- a/scripts/docker/docker_travis.sh +++ b/scripts/docker/docker_travis.sh @@ -17,6 +17,7 @@ docker=$1 TRAVIS_REPO_SLUG=$TRAVIS_REPO_SLUG \ TRAVIS_BRANCH=$TRAVIS_BRANCH \ USE_CONAN=$USE_CONAN \ + ALSOFT_DRIVERS=null \ DEBUG=$DEBUG \ XDG_RUNTIME_DIR=/tmp diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 2e7de1ee..7d362e79 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -28,6 +28,7 @@ set(TESTS ScriptMachine State StringEncoding + Sound Text TrafficDirector Vehicle diff --git a/tests/test_Sound.cpp b/tests/test_Sound.cpp new file mode 100644 index 00000000..11570fb2 --- /dev/null +++ b/tests/test_Sound.cpp @@ -0,0 +1,97 @@ +#include + +#include + +#include