yvt / openspades

Compatible client of Ace of Spades 0.75
http://openspades.yvt.jp/
GNU General Public License v3.0
1.14k stars 217 forks source link

Opus audio codec not found; crashes on start #665

Closed Charles-the-Cat closed 6 years ago

Charles-the-Cat commented 7 years ago

Almost as soon as I launch Openspades on Linux Mint 17.3 (presumably, when I mouse over a menu button), the application crashes with the following error. I have libopus-dev and libopusfile-dev installed.

Audio codec not found for filename: Sounds/Feedback/Limbo/Hover.opus
at /home/charles/Desktop/openspades-0.1.1c/Sources/Core/AudioStream.cpp:69 spades::audio::ALAudioChunk* spades::audio::ALDevice::CreateChunk(const char*) at ALDevice.cpp:777
virtual spades::client::IAudioChunk* spades::audio::ALDevice::RegisterSound(const char*) at   ALDevice.cpp:792
void spades::ScriptContextUtils::ExecuteChecked() at ScriptManager.cpp:338
void spades::ScriptContextHandle::ExecuteChecked() at ScriptManager.cpp:277
virtual void spades::gui::MainScreen::MouseEvent(float, float) at MainScreen.cpp:77
void spades::gui::SDLRunner::Run(int, int) at SDLRunner.cpp:403
void spades::gui::Runner::Run() at Runner.cpp:70
void spades::gui::Runner::RunProtected() at Runner.cpp:42
int main(int, char**) at Main.cpp:312
 @ [/Gui/UIFramework.as:330,6] void spades::ui::UIManager::PlaySound(string)
 > [/Gui/UIControls.as:86,5] void spades::ui::ButtonBase::PlayMouseEnterSound()
 > [/Gui/UIControls.as:184,6] void spades::ui::ButtonBase::MouseEnter()
 > [/Gui/UIFramework.as:136,7] void spades::ui::UIManager::MouseEventDone()
 > [/Gui/UIFramework.as:154,5] void spades::ui::UIManager::MouseEvent(float, float)
 > [/Gui/MainScreen.as:87,4] void spades::MainScreenUI::MouseEvent(float, float)
at /home/charles/Desktop/openspades-0.1.1c/Sources/ScriptBindings/ScriptManager.cpp:361
void spades::ScriptContextUtils::ExecuteChecked() at ScriptManager.cpp:338
void spades::ScriptContextHandle::ExecuteChecked() at ScriptManager.cpp:277
virtual void spades::gui::MainScreen::MouseEvent(float, float) at MainScreen.cpp:77
void spades::gui::SDLRunner::Run(int, int) at SDLRunner.cpp:403
void spades::gui::Runner::Run() at Runner.cpp:70
void spades::gui::Runner::RunProtected() at Runner.cpp:42
int main(int, char**) at Main.cpp:312
Charles-the-Cat commented 7 years ago

Note that launching with the "null" audio driver eliminates this error ... but now, of course, I don't have any sound.

yvt commented 7 years ago

That seems pretty weird since that error message means it didn't even recognize the file name's extension .opus when it is supposed to check all supported formats no matter whether the library is installed...

It could be because std::regex is acting in an unexpected way or a bug in the C++ standard library. Can you attach a debugger and see if this std::regex_match passes when it is supposed to?

Charles-the-Cat commented 7 years ago

I have no idea how to use gdb. (Or C++, for that matter.) Can I just put an SPRaise statement with a generic error I can grep for after line 50, then recompile with CMake and try launching with audio again?

yvt commented 7 years ago

Yes, but just printfs should be sufficient. Like this:

        std::string errMsg;
+       printf("DEBUG: finding an audio codec for %s\n", fileName.c_str());
        for (const auto &codec: g_codecs) {
+           printf("DEBUG: trying %s\n", std::get<0>(codec).c_str());
            if (!std::regex_match(fileName, std::get<2>(codec))) {
+               printf("DEBUG: regex match failed\n");
                continue;
            }
Charles-the-Cat commented 7 years ago

Well, for some reason, after recompiling and launching from ./openspades.mk/bin/openspades, audio works perfectly without crashes... except every time it plays an opus file, my debug statements show up in console.

DEBUG: finding an audio codec for Sounds/Feedback/Limbo/Hover.opus
DEBUG: regex match failed
DEBUG: finding an audio codec for Sounds/Feedback/Limbo/Hover.opus
DEBUG: finding an audio codec for Sounds/Feedback/Limbo/Select.opus
DEBUG: regex match failed
DEBUG: finding an audio codec for Sounds/Feedback/Limbo/Select.opus

<...gameplay....>

DEBUG: finding an audio codec for Sounds/Weapons/Block/Build.opus
DEBUG: regex match failed
DEBUG: finding an audio codec for Sounds/Weapons/Block/Build.opus
DEBUG: finding an audio codec for Sounds/Weapons/Impacts/FleshLocal1.opus
DEBUG: regex match failed
DEBUG: finding an audio codec for Sounds/Weapons/Impacts/FleshLocal1.opus
DEBUG: finding an audio codec for Sounds/Weapons/Impacts/FleshLocal2.opus
DEBUG: regex match failed
DEBUG: finding an audio codec for Sounds/Weapons/Impacts/FleshLocal2.opus
DEBUG: finding an audio codec for Sounds/Weapons/Impacts/FleshLocal3.opus
DEBUG: regex match failed
DEBUG: finding an audio codec for Sounds/Weapons/Impacts/FleshLocal3.opus
DEBUG: finding an audio codec for Sounds/Weapons/Impacts/FleshLocal4.opus
DEBUG: regex match failed
DEBUG: finding an audio codec for Sounds/Weapons/Impacts/FleshLocal4.opus
DEBUG: finding an audio codec for Sounds/Misc/SwitchMapZoom.opus
DEBUG: regex match failed

etc.

I'm hesitant to call this one closed, but if I technically fixed the problem...

yvt commented 7 years ago

Looks like we've encountered a heisenbug!

For a reference, can I ask which version of the compiler you are using? (It can be checked by gcc --version)

NotAFile commented 7 years ago

I had heisenbugs in OS caused by unclean builds. Doing make clean would usually fix stuff

BarnabyWoodrow commented 6 years ago

Can I just ask, how could I fix this? I have this same problem and don't understand what to do

yvt commented 6 years ago

@BarnabyWoodrow Simply put, we don’t exactly know how to fix this. It could be a compiler’s bug, or maybe we ran into an undefined behavior without knowing.

Whatever the reason, the patch I posted in my previous comment, whose only intention is to diagnose the issue, seems to fix the issue.