1
0
mirror of https://github.com/borgesdan/xn65 synced 2024-12-29 21:54:47 +01:00

Corrige AudiEngine

This commit is contained in:
Danilo 2024-05-27 21:12:46 -03:00
parent 11c3b6aa4a
commit a51a5ef1af
7 changed files with 58 additions and 39 deletions

View File

@ -1,15 +1,10 @@
#include "platform-dx/implementations.hpp"
namespace xna {
AudioEngine::AudioEngine()
{
void AudioEngine::Initialize() {
impl = unew<PlatformImplementation>();
}
AudioEngine::~AudioEngine() {
impl = nullptr;
}
bool AudioEngine::Reset() {
if (!impl || !impl->_dxAudioEngine)
return false;

View File

@ -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>();
AudioEngine::Initialize();
LoadContent();
}

View File

@ -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();
}

View File

@ -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<DxSoundEffect>(audioEngine.impl->_dxAudioEngine.get(), file.c_str());
impl->_dxSoundEffect = unew<DxSoundEffect>(AudioEngine::impl->_dxAudioEngine.get(), file.c_str());
}
SoundEffect::~SoundEffect() {

View File

@ -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<PlatformImplementation> impl = nullptr;
inline static uptr<PlatformImplementation> impl = nullptr;
private:
AudioEngine();
AudioEngine(AudioEngine&);
AudioEngine(AudioEngine&&);
};
}

View File

@ -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<PSoundEffect> {
public:
SoundEffectReader() : ContentTypeReaderT(typeof<SoundEffect>()) {}
PSoundEffect Read(ContentReader& input, PSoundEffect& existingInstance) override {
return nullptr;
}
};
}
#endif

View File

@ -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);