Amend for new AuroraRuntime version

Possibly missed some merge errors
This commit is contained in:
Reece Wilson 2021-06-18 01:07:30 +01:00
parent 8bfc9832e8
commit d625c772dd
11 changed files with 35 additions and 160 deletions

View File

@ -201,7 +201,7 @@ START_API_FUNC
/* Wait to ensure the event handler sees the changed flags before
* returning.
*/
std::lock_guard<std::mutex>{context->mEventCbLock};
std::lock_guard<std::mutex> annoyingWarningGoAway{context->mEventCbLock};
}
}
END_API_FUNC

View File

@ -1078,10 +1078,12 @@ void alc_initconfig(void)
CPUCapFlags = caps & capfilter;
}
#if 0
if(auto priopt = ConfigValueInt(nullptr, nullptr, "rt-prio"))
RTPrioLevel = *priopt;
if(auto limopt = ConfigValueBool(nullptr, nullptr, "rt-time-limit"))
AllowRTTimeLimit = *limopt;
#endif
aluInit();
Voice::InitMixer(ConfigValueStr(nullptr, nullptr, "resampler"));

View File

@ -362,7 +362,9 @@ struct ALCdevice : public al::intrusive_ref<ALCdevice> {
#define RECORD_THREAD_NAME "alsoft-record"
#if 0
extern int RTPrioLevel;
#endif
void SetRTPriority(void);
const ALCchar *DevFmtTypeString(DevFmtType type) noexcept;

View File

@ -279,18 +279,19 @@ void ReadALConfig()
AuString configBuffer;
AuString pathA;
Aurora::FS::GetSystemDomain("OpenAL", pathA);
pathA += "configuration.ini";
Aurora::IO::FS::GetSystemDomain(pathA);
pathA += "/OpenAL/configuration.ini";
if (!Aurora::FS::ReadString(pathA, configBuffer))
if (!Aurora::IO::FS::ReadString(pathA, configBuffer))
{
if (!Aurora::FS::ReadString("openal.ini", configBuffer))
if (!Aurora::IO::FS::ReadString("openal.ini", configBuffer))
{
return;
}
}
LoadConfigFromFile(std::istringstream(configBuffer));
std::istringstream a{ configBuffer };
LoadConfigFromFile(a);
}

View File

@ -7,7 +7,7 @@
void *al_malloc(size_t alignment, size_t size)
{
return Aurora::Memory::SAlloc<void*>(size, alignment);
return Aurora::Memory::FAlloc<void*>(size, alignment);
}
void *al_calloc(size_t alignment, size_t size)

View File

@ -1,27 +1,33 @@
/**
* Aurora Engine semaphore wrapper reimplementation for OpenAL
* Copyright (C) Reece Wilson 2021
* License: MIT
* License: Unlicense
*/
#include "config.h"
#include "threads.h"
using namespace Aurora::Threading;
void althrd_setname(const char *name)
{
// NO OP
Threads::GetThread()->SetName(name);
}
void SetRTPriority(void)
{
Threads::GetThread()->SetPrio(Threads::EThreadPrio::ePrioRT);
}
namespace al
{
semaphore::semaphore(unsigned int initial)
{
_semaphore = Aurora::Threading::SemaphoreNew(initial);
_semaphore = Primitives::SemaphoreUnique(initial);
}
semaphore::~semaphore()
{
Aurora::Threading::SemaphoreDestroy(_semaphore);
}
void semaphore::post()
@ -38,5 +44,4 @@ namespace al
{
return _semaphore->TryLock();
}
}
}

View File

@ -1,10 +1,11 @@
/**
* OpenAL semaphore wrapper reimplementation for the Aurora Engine
* Copyright (C) Reece Wilson 2021
* License: MIT
* License: Unlicense
*/
#pragma once
void SetRTPriority(void);
void althrd_setname(const char *name);
namespace al
@ -23,6 +24,6 @@ namespace al
bool try_wait() noexcept;
private:
Aurora::Threading::ISemaphore* _semaphore;
Aurora::Threading::Primitives::SemaphoreUnique_t _semaphore;
};
}

View File

@ -4,4 +4,4 @@
#define FORCE_ALIGN
#include <AuroraCommon.hpp>
#include <Aurora/Kernel.hpp>
#include <AuroraRuntime.hpp>

View File

@ -1,6 +1,4 @@
#include "config.h"
#include "helpers.h"
#include <algorithm>
@ -22,6 +20,7 @@
#include "strutils.h"
#include "vector.h"
using namespace Aurora::Console::Logging;
void al_print(LogLevel level, FILE *logfile, const char *fmt, ...)
{
@ -42,10 +41,5 @@ void al_print(LogLevel level, FILE *logfile, const char *fmt, ...)
va_end(args2);
va_end(args);
Aurora::Console::Logging::LogGame(str);
}
void SetRTPriority(void)
{
LogGame(str);
}

View File

@ -1103,44 +1103,6 @@ bool checkName(const std::string &name)
return std::find_if(enum_names.cbegin(), enum_names.cend(), match_name) != enum_names.cend();
}
<<<<<<< HEAD:alc/hrtf.cpp
=======
void AddFileEntry(const std::string &filename)
{
/* Check if this file has already been enumerated. */
auto enum_iter = std::find_if(EnumeratedHrtfs.cbegin(), EnumeratedHrtfs.cend(),
[&filename](const HrtfEntry &entry) -> bool
{ return entry.mFilename == filename; });
if(enum_iter != EnumeratedHrtfs.cend())
{
TRACE("Skipping duplicate file entry %s\n", filename.c_str());
return;
}
/* TODO: Get a human-readable name from the HRTF data (possibly coming in a
* format update). */
size_t namepos{filename.find_last_of('/')+1};
if(!namepos) namepos = filename.find_last_of('\\')+1;
size_t extpos{filename.find_last_of('.')};
if(extpos <= namepos) extpos = std::string::npos;
const std::string basename{(extpos == std::string::npos) ?
filename.substr(namepos) : filename.substr(namepos, extpos-namepos)};
std::string newname{basename};
int count{1};
while(checkName(newname))
{
newname = basename;
newname += " #";
newname += std::to_string(++count);
}
EnumeratedHrtfs.emplace_back(HrtfEntry{newname, filename});
const HrtfEntry &entry = EnumeratedHrtfs.back();
TRACE("Adding file entry \"%s\"\n", entry.mFilename.c_str());
}
/* Unfortunate that we have to duplicate AddFileEntry to take a memory buffer
* for input instead of opening the given filename.
*/
@ -1190,10 +1152,11 @@ al::vector<std::string> EnumerateHrtf(al::optional<std::string> pathopt)
if(pathopt)
{
AuString pathA;
Aurora::FS::GetSystemDomain("OpenAL", pathA);
Aurora::IO::FS::GetSystemDomain(pathA);
pathA += "/OpenAL/";
AuList<AuString> files;
Aurora::FS::FilesInDirectory(pathA, files);
Aurora::IO::FS::FilesInDirectory(pathA, files);
for (const auto& file : files)
{
@ -1207,8 +1170,10 @@ al::vector<std::string> EnumerateHrtf(al::optional<std::string> pathopt)
al::vector<std::string> list;
list.reserve(EnumeratedHrtfs.size());
for(auto &entry : EnumeratedHrtfs)
for (auto& entry : EnumeratedHrtfs)
{
list.emplace_back(entry.mDispName);
}
return list;
}

View File

@ -1,95 +0,0 @@
#include "config.h"
#include "logging.h"
#include <cstdarg>
#include <cstdio>
#include <string>
#include "strutils.h"
#include "vector.h"
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
void al_print(LogLevel level, FILE *logfile, const char *fmt, ...)
{
al::vector<char> dynmsg;
char stcmsg[256];
char *str{stcmsg};
std::va_list args, args2;
va_start(args, fmt);
va_copy(args2, args);
int msglen{std::vsnprintf(str, sizeof(stcmsg), fmt, args)};
if UNLIKELY(msglen >= 0 && static_cast<size_t>(msglen) >= sizeof(stcmsg))
{
dynmsg.resize(static_cast<size_t>(msglen) + 1u);
str = dynmsg.data();
msglen = std::vsnprintf(str, dynmsg.size(), fmt, args2);
}
va_end(args2);
va_end(args);
std::wstring wstr{utf8_to_wstr(str)};
if(gLogLevel >= level)
{
fputws(wstr.c_str(), logfile);
fflush(logfile);
}
OutputDebugStringW(wstr.c_str());
}
#else
#ifdef __ANDROID__
#include <android/log.h>
#endif
void al_print(LogLevel level, FILE *logfile, const char *fmt, ...)
{
al::vector<char> dynmsg;
char stcmsg[256];
char *str{stcmsg};
std::va_list args, args2;
va_start(args, fmt);
va_copy(args2, args);
int msglen{std::vsnprintf(str, sizeof(stcmsg), fmt, args)};
if UNLIKELY(msglen >= 0 && static_cast<size_t>(msglen) >= sizeof(stcmsg))
{
dynmsg.resize(static_cast<size_t>(msglen) + 1u);
str = dynmsg.data();
msglen = std::vsnprintf(str, dynmsg.size(), fmt, args2);
}
va_end(args2);
va_end(args);
if(gLogLevel >= level)
{
std::fputs(str, logfile);
std::fflush(logfile);
}
#ifdef __ANDROID__
auto android_severity = [](LogLevel l) noexcept
{
switch(l)
{
case LogLevel::Trace: return ANDROID_LOG_DEBUG;
case LogLevel::Warning: return ANDROID_LOG_WARN;
case LogLevel::Error: return ANDROID_LOG_ERROR;
/* Should not happen. */
case LogLevel::Disable:
break;
}
return ANDROID_LOG_ERROR;
};
__android_log_print(android_severity(level), "openal", "%s", str);
#endif
}
#endif