diff --git a/framework/platform-dx/audioengine.cpp b/framework/platform-dx/audioengine.cpp index c52bc0d..9765914 100644 --- a/framework/platform-dx/audioengine.cpp +++ b/framework/platform-dx/audioengine.cpp @@ -1,15 +1,10 @@ #include "platform-dx/implementations.hpp" namespace xna { - AudioEngine::AudioEngine() - { + void AudioEngine::Initialize() { impl = unew(); } - AudioEngine::~AudioEngine() { - impl = nullptr; - } - bool AudioEngine::Reset() { if (!impl || !impl->_dxAudioEngine) return false; diff --git a/framework/platform-dx/game.cpp b/framework/platform-dx/game.cpp index d3ab2ce..8c544d6 100644 --- a/framework/platform-dx/game.cpp +++ b/framework/platform-dx/game.cpp @@ -78,25 +78,11 @@ namespace xna { return StartGameLoop(); } - void Game::Initialize() { -//#if (_WIN32_WINNT >= _WIN32_WINNT_WIN10) - Microsoft::WRL::Wrappers::RoInitializeWrapper initialize(RO_INIT_MULTITHREADED); - if (FAILED(initialize)) - { - MessageBox(nullptr, "Ocorreu um erro ao chamar Microsoft::WRL::Wrappers::RoInitializeWrapper.", "XN65", MB_OK); - } -//#else - HRESULT hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED); - if (FAILED(hr)) - { - MessageBox(nullptr, "Ocorreu um erro ao chamar CoInitializeEx.", "XN65", MB_OK); - } -//#endif + void Game::Initialize() { Keyboard::Initialize(); Mouse::Initialize(); GamePad::Initialize(); - - _audioEngine = New(); + AudioEngine::Initialize(); LoadContent(); } diff --git a/framework/platform-dx/init.cpp b/framework/platform-dx/init.cpp index 2314582..d39447b 100644 --- a/framework/platform-dx/init.cpp +++ b/framework/platform-dx/init.cpp @@ -6,7 +6,19 @@ #include "platform-dx/implementations.hpp" namespace xna { - void Platform::Init() { + void Platform::Init() { + Microsoft::WRL::Wrappers::RoInitializeWrapper initialize(RO_INIT_MULTITHREADED); + if (FAILED(initialize)) + { + MessageBox(nullptr, "Ocorreu um erro ao chamar Microsoft::WRL::Wrappers::RoInitializeWrapper.", "XN65", MB_OK); + } + + HRESULT hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED); + if (FAILED(hr)) + { + MessageBox(nullptr, "Ocorreu um erro ao chamar CoInitializeEx.", "XN65", MB_OK); + } + PlatformInit::Init(); } diff --git a/framework/platform-dx/soundeffect.cpp b/framework/platform-dx/soundeffect.cpp index d8a1c30..5017b6f 100644 --- a/framework/platform-dx/soundeffect.cpp +++ b/framework/platform-dx/soundeffect.cpp @@ -11,12 +11,12 @@ namespace xna { impl = nullptr; } - SoundEffect::SoundEffect(AudioEngine& audioEngine, String const& fileName) { - if (!audioEngine.impl->_dxAudioEngine) + SoundEffect::SoundEffect(String const& fileName) { + if (!AudioEngine::impl || !AudioEngine::impl->_dxAudioEngine) return; const auto file = XnaHToWString(fileName); - impl->_dxSoundEffect = unew(audioEngine.impl->_dxAudioEngine.get(), file.c_str()); + impl->_dxSoundEffect = unew(AudioEngine::impl->_dxAudioEngine.get(), file.c_str()); } SoundEffect::~SoundEffect() { diff --git a/inc/audio/audioengine.hpp b/inc/audio/audioengine.hpp index cbf7a3f..f883f99 100644 --- a/inc/audio/audioengine.hpp +++ b/inc/audio/audioengine.hpp @@ -5,21 +5,26 @@ namespace xna { class AudioEngine { - public: - AudioEngine(); - ~AudioEngine(); - bool Reset(); - bool Resume(); - bool Suspend(); - bool Update(); - void DefaultSampleRate(int value); - void MasterVolume(float value); - void MasteringLimit(int limit, int loudness); - void Reverb(AudioReverb value); + public: + static bool Reset(); + static bool Resume(); + static bool Suspend(); + static bool Update(); + static void DefaultSampleRate(int value); + static void MasterVolume(float value); + static void MasteringLimit(int limit, int loudness); + static void Reverb(AudioReverb value); + + static void Initialize(); public: struct PlatformImplementation; - uptr impl = nullptr; + inline static uptr impl = nullptr; + + private: + AudioEngine(); + AudioEngine(AudioEngine&); + AudioEngine(AudioEngine&&); }; } diff --git a/inc/audio/readers/soundeffect.hpp b/inc/audio/readers/soundeffect.hpp new file mode 100644 index 0000000..432af80 --- /dev/null +++ b/inc/audio/readers/soundeffect.hpp @@ -0,0 +1,20 @@ +#ifndef XNA_AUDIO_READERS_SOUNDEFFECT_HPP +#define XNA_AUDIO_READERS_SOUNDEFFECT_HPP + +#include "content/manager.hpp" +#include "content/reader.hpp" +#include "csharp/type.hpp" +#include "audio/soundeffect.hpp" + +namespace xna { + class SoundEffectReader : public ContentTypeReaderT { + public: + SoundEffectReader() : ContentTypeReaderT(typeof()) {} + + PSoundEffect Read(ContentReader& input, PSoundEffect& existingInstance) override { + return nullptr; + } + }; +} + +#endif \ No newline at end of file diff --git a/inc/audio/soundeffect.hpp b/inc/audio/soundeffect.hpp index aff06a8..5de219d 100644 --- a/inc/audio/soundeffect.hpp +++ b/inc/audio/soundeffect.hpp @@ -25,7 +25,8 @@ namespace xna { class SoundEffect { public: - SoundEffect(AudioEngine& audioEngine, String const& fileName); + SoundEffect(); + SoundEffect(String const& fileName); ~SoundEffect(); void Play(); void Play(float volume, float pitch, float pan);