From 311ab75ee472b6e3ac9d335e37e9d3884fa60e7e Mon Sep 17 00:00:00 2001 From: f Date: Mon, 31 Jul 2023 12:58:45 +0200 Subject: [PATCH] Make windows soundsystem use GetHWND made invisible window before, was not needed --- platforms/windows/SoundSystem_windows.cpp | 39 ++++------------------- platforms/windows/SoundSystem_windows.hpp | 4 --- 2 files changed, 6 insertions(+), 37 deletions(-) diff --git a/platforms/windows/SoundSystem_windows.cpp b/platforms/windows/SoundSystem_windows.cpp index 7e3d49e..7dc6255 100644 --- a/platforms/windows/SoundSystem_windows.cpp +++ b/platforms/windows/SoundSystem_windows.cpp @@ -6,43 +6,14 @@ SPDX-License-Identifier: BSD-1-Clause ********************************************************************/ + +#include "../../source/Base/Utils.hpp" #include "SoundSystem_windows.hpp" SoundSystemWindows::SoundSystemWindows() { printf("Init SoundSystemWindows\n"); - WNDCLASSA WndClass; - - memset(&WndClass, 0, sizeof(WndClass)); - WndClass.lpfnWndProc = DefWindowProcA; - WndClass.hInstance = GetModuleHandleA(NULL); - WndClass.lpszClassName = "SoundWindow"; - RegisterClassA(&WndClass); - m_hiddenwindow = CreateWindowExA( - 0, - "SoundWindow", - "SoundWindow", - 0x80000000, - 0, - 0, - 0, - 0, - 0, - 0, - WndClass.hInstance, - 0); - if (!m_hiddenwindow) { - printf("SoundSystemWindows cannot create hidden window for directsound8\n"); - return; - } - - initDirectSound(); - -} - -void SoundSystemWindows::initDirectSound() -{ HRESULT result; DSBUFFERDESC bufferDesc; @@ -54,7 +25,7 @@ void SoundSystemWindows::initDirectSound() return; } - result = m_directsound->SetCooperativeLevel(m_hiddenwindow, DSSCL_NORMAL); + result = m_directsound->SetCooperativeLevel(GetHWND(), DSSCL_NORMAL); if (FAILED(result)) { printf("SoundSystemWindows failed set cooperation level\n"); @@ -75,13 +46,15 @@ void SoundSystemWindows::initDirectSound() printf("SoundSystemWindows failed to create primary sound buffer\n"); return; } - + } + SoundSystemWindows::~SoundSystemWindows() { printf("Destroying SoundSystemWindows\n"); + m_directsound->Release(); } diff --git a/platforms/windows/SoundSystem_windows.hpp b/platforms/windows/SoundSystem_windows.hpp index c25f29c..f3842b1 100644 --- a/platforms/windows/SoundSystem_windows.hpp +++ b/platforms/windows/SoundSystem_windows.hpp @@ -37,13 +37,9 @@ public: virtual void stop(const std::string& sound); virtual void playAt(const SoundDesc& sound, float x, float y, float z, float a, float b); private: - HWND m_hiddenwindow; IDirectSound8* m_directsound; IDirectSoundBuffer* m_primarybuffer; std::vector m_buffers; - - void initDirectSound(); - };