Minor fixes

This commit is contained in:
Lynix
2023-11-28 20:05:09 +01:00
parent c7579fb9be
commit 079f153640
16 changed files with 53 additions and 47 deletions

View File

@@ -472,6 +472,7 @@ namespace Nz
// Signal we're good
{
std::unique_lock<std::mutex> lock(m);
m_musicStarted = true;
cv.notify_all();
} // m & cv no longer exists from here
@@ -519,10 +520,11 @@ namespace Nz
std::exception_ptr exceptionPtr;
std::unique_lock<std::mutex> lock(mutex);
m_musicStarted = false;
m_thread = std::thread(&Music::MusicThread, this, std::ref(cv), std::ref(mutex), std::ref(exceptionPtr), startPaused);
// Wait until thread signal it has properly started (or an error occurred)
cv.wait(lock);
cv.wait(lock, [&] { return exceptionPtr || m_musicStarted; });
if (exceptionPtr)
std::rethrow_exception(exceptionPtr);

View File

@@ -4,14 +4,11 @@
#include <Nazara/Audio/OpenALLibrary.hpp>
#include <Nazara/Audio/OpenALDevice.hpp>
#include <Nazara/Core/Algorithm.hpp>
#include <NazaraUtils/Algorithm.hpp>
#include <Nazara/Core/Error.hpp>
#include <Nazara/Core/ErrorFlags.hpp>
#include <Nazara/Core/Log.hpp>
#include <Nazara/Core/StringExt.hpp>
#include <NazaraUtils/CallOnExit.hpp>
#include <array>
#include <cstring>
#include <sstream>
#include <stdexcept>
#include <Nazara/Audio/Debug.hpp>
@@ -30,7 +27,7 @@ namespace Nz
#define NAZARA_AUDIO_AL_ALC_FUNCTION(name)
#define NAZARA_AUDIO_AL_EXT_BEGIN(ext) if (alIsExtensionPresent(#ext)) {
#define NAZARA_AUDIO_AL_EXT_END() }
#define NAZARA_AUDIO_AL_FUNCTION_EXT(name) name = reinterpret_cast<decltype(&::name)>(alGetProcAddress(#name));
#define NAZARA_AUDIO_AL_EXT_FUNCTION(name) name = reinterpret_cast<decltype(&::name)>(alGetProcAddress(#name));
#include <Nazara/Audio/OpenALFunctions.hpp>
m_hasCaptureSupport = alcIsExtensionPresent(nullptr, "ALC_EXT_CAPTURE");
@@ -67,7 +64,7 @@ namespace Nz
{
ErrorFlags disableError(ErrorMode::Silent, ~ErrorMode::ThrowException);
if (!m_library.Load(libname))
if (!m_library.Load(Utf8Path(libname)))
continue;
auto LoadSymbol = [this](const char* name, bool optional)
@@ -82,13 +79,16 @@ namespace Nz
try
{
#define NAZARA_AUDIO_AL_ALC_FUNCTION(name) name = reinterpret_cast<decltype(&::name)>(LoadSymbol(#name, false));
#define NAZARA_AUDIO_AL_EXT_BEGIN(name)
#define NAZARA_AUDIO_AL_EXT_END(name)
#define NAZARA_AUDIO_AL_EXT_FUNCTION(name)
#include <Nazara/Audio/OpenALFunctions.hpp>
}
catch (const std::exception& e)
{
ErrorFlags disableSilent({}, ~ErrorMode::Silent);
NazaraWarning(std::string("failed to load ") + libname + ": " + e.what());
NazaraWarningFmt("failed to load {0}: {1}", libname, e.what());
continue;
}
@@ -104,6 +104,8 @@ namespace Nz
// Load core
#define NAZARA_AUDIO_AL_ALC_FUNCTION(name) name = &::name;
#define NAZARA_AUDIO_AL_EXT_BEGIN(name)
#define NAZARA_AUDIO_AL_EXT_END(name)
#define NAZARA_AUDIO_AL_EXT_FUNCTION(name)
#include <Nazara/Audio/OpenALFunctions.hpp>