From 1794e52cf1b01858aff00012b8fd44ba9750cfe2 Mon Sep 17 00:00:00 2001 From: tovjemam Date: Sat, 10 Jan 2026 12:51:53 +0100 Subject: [PATCH] Fix audio on emscripten --- CMakeLists.txt | 1 + src/audio/master.cpp | 3 --- src/audio/master.hpp | 7 ++++--- src/client/app.cpp | 4 ++++ 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f70968..18aa87f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -170,6 +170,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL Emscripten) target_link_options(${MAIN_NAME} PRIVATE "-lwebsocket.js" + "-lopenal" "-sUSE_SDL=2" "-sASYNCIFY" "-sUSE_WEBGL2=1" diff --git a/src/audio/master.cpp b/src/audio/master.cpp index 7b65823..e3f48a9 100644 --- a/src/audio/master.cpp +++ b/src/audio/master.cpp @@ -2,9 +2,6 @@ #include -#include -#include - #include "defs.hpp" #include "sound_source.hpp" #include "source.hpp" diff --git a/src/audio/master.hpp b/src/audio/master.hpp index 1c11d07..bbe9ed8 100644 --- a/src/audio/master.hpp +++ b/src/audio/master.hpp @@ -4,11 +4,12 @@ #include #include -#include "utils/defs.hpp" +#include +#include + #include -class ALCdevice; -class ALCcontext; +#include "utils/defs.hpp" namespace audio { diff --git a/src/client/app.cpp b/src/client/app.cpp index bacdbe5..5ddc86f 100644 --- a/src/client/app.cpp +++ b/src/client/app.cpp @@ -11,7 +11,11 @@ App::App() { std::cout << "Initializing App..." << std::endl; +#ifndef EMSCRIPTEN audiomaster_.SetMasterVolume(0.2f); +#else + audiomaster_.SetMasterVolume(2.0f); +#endif } void App::Frame()