LAGonauta / MetaAudio

GoldSrc engine plugin for 3D sound
GNU General Public License v2.0
98 stars 14 forks source link

Access violation at alure2.dll from the call of my custom entity #27

Closed edgarbarney closed 3 years ago

edgarbarney commented 3 years ago

Hello

In my mod, one of the entities I created emits a dynamic sound. There's no problem with the vanilla sound engine. Works as intended. But when I try with meta audio, the game crashes.

I attached a debugger, tried to replicate the event and found out exception is thrown at alure2.dll, by the launcher.CPP

I was going to try to fix the issue by modifying MetaAudio source code but I couldn't find solution files. Edit: Just found out CMake files but I still can't find the issue.

If you need, here is my entity.

LAGonauta commented 3 years ago

Are you using FLAC files or something like that?

edgarbarney commented 3 years ago

Nope. I was using a custom WAV file at first. But then I tried with vanilla sound files, OGG and FLAC files too. The same thing happened.

LAGonauta commented 3 years ago

Is it related to voice? Just noticed that !HG_GREN3 is crashing the game.

edgarbarney commented 3 years ago

I've tried with random vanilla ambient sounds, not voices tho.

LAGonauta commented 3 years ago

Can you check if this is still happening on newest release candidate? https://github.com/LAGonauta/MetaAudio/releases/tag/v0.3.0-rc1

edgarbarney commented 3 years ago

Yup. Still the same.

By the way, can you provide a dependencies list for this project? I want to try and refactor myself but I cannot build VS projects because of the dependencies.

LAGonauta commented 3 years ago

You will need VS2019 with C++, CMake support, Windows SDK, and C++ ATL installed.

These are my CMakeArgs: https://github.com/LAGonauta/MetaAudio/blob/8d07c1287311be55fc5b864b45c1669916f7f025/CMakeSettings.json#L10

You will need to put libsndfile somewhere: https://github.com/libsndfile/libsndfile/releases/ (i still need to update to 1.0.31, I did not know it was release already. Currently using 1.0.28)

And patch alure2 like that to use the built-in OpenAL Soft:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4c1c16e..e39a9df 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,7 +15,6 @@ include(CheckCXXCompilerFlag)
 include(CheckCXXSourceCompiles)
 include(GNUInstallDirs)

-find_package(OpenAL REQUIRED)
 find_package(Threads)

 # Require C++14
@@ -24,6 +23,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED TRUE)

 set(CXX_FLAGS )

+
 option(ALURE_DISABLE_RTTI "Disable run-time type information" OFF)
 if(MSVC)
     if(ALURE_DISABLE_RTTI)
@@ -113,7 +113,7 @@ set(alure_srcs src/devicemanager.cpp
                src/auxeffectslot.cpp
                src/effect.cpp
 )
-set(alure_libs ${OPENAL_LIBRARY})
+set(alure_libs OpenAL)
 set(decoder_incls )

 unset(HAVE_WAVE)
@@ -198,7 +198,7 @@ if(ALURE_BUILD_SHARED)
                                                   NOMINMAX)
     endif()
     target_include_directories(alure2
-        PUBLIC $<BUILD_INTERFACE:${alure_SOURCE_DIR}/include/AL> ${OPENAL_INCLUDE_DIR}
+        PUBLIC $<BUILD_INTERFACE:${alure_SOURCE_DIR}/include/AL>
         PRIVATE ${alure_SOURCE_DIR}/include ${alure_SOURCE_DIR}/src ${alure_BINARY_DIR}
                 ${decoder_incls}
     )
@@ -215,7 +215,7 @@ if(ALURE_BUILD_STATIC)
     add_library(alure2_s STATIC ${alure_srcs})
     target_compile_definitions(alure2_s PUBLIC ALURE_STATIC_LIB PRIVATE NOMINMAX)
     target_include_directories(alure2_s
-        PUBLIC $<BUILD_INTERFACE:${alure_SOURCE_DIR}/include/AL> ${OPENAL_INCLUDE_DIR}
+        PUBLIC $<BUILD_INTERFACE:${alure_SOURCE_DIR}/include/AL>
         PRIVATE ${alure_SOURCE_DIR}/include ${alure_SOURCE_DIR}/src ${alure_BINARY_DIR}
                 ${decoder_incls}
     )

I think you can also install OpenAL Soft manually and use some CMake parameters, but I do not know how.

Remember to fetch the git submodules.

edgarbarney commented 3 years ago

Fixed.

Changed channel for EMIT_SOUND_DYN to CHAN_AUTO from CHAN_STREAM

LAGonauta commented 3 years ago

Cool 🙂 But I wonder why it was crashing 🤔

edgarbarney commented 3 years ago

Maybe streaming channel is reserved for music or something?