aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDLL/client/audio.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'NorthstarDLL/client/audio.cpp')
-rw-r--r--NorthstarDLL/client/audio.cpp88
1 files changed, 44 insertions, 44 deletions
diff --git a/NorthstarDLL/client/audio.cpp b/NorthstarDLL/client/audio.cpp
index 9fcac982..94ce8353 100644
--- a/NorthstarDLL/client/audio.cpp
+++ b/NorthstarDLL/client/audio.cpp
@@ -28,8 +28,8 @@ EventOverrideData::EventOverrideData()
// Empty stereo 48000 WAVE file
unsigned char EMPTY_WAVE[45] = {0x52, 0x49, 0x46, 0x46, 0x25, 0x00, 0x00, 0x00, 0x57, 0x41, 0x56, 0x45, 0x66, 0x6D, 0x74,
- 0x20, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x44, 0xAC, 0x00, 0x00, 0x88, 0x58,
- 0x01, 0x00, 0x02, 0x00, 0x10, 0x00, 0x64, 0x61, 0x74, 0x61, 0x74, 0x00, 0x00, 0x00, 0x00};
+ 0x20, 0x10, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x44, 0xAC, 0x00, 0x00, 0x88, 0x58,
+ 0x01, 0x00, 0x02, 0x00, 0x10, 0x00, 0x64, 0x61, 0x74, 0x61, 0x74, 0x00, 0x00, 0x00, 0x00};
EventOverrideData::EventOverrideData(const std::string& data, const fs::path& path)
{
@@ -45,9 +45,9 @@ EventOverrideData::EventOverrideData(const std::string& data, const fs::path& pa
if (!fs::exists(samplesFolder))
{
spdlog::error(
- "Failed reading audio override file {}: samples folder doesn't exist; should be named the same as the definition file without "
- "JSON extension.",
- path.string());
+ "Failed reading audio override file {}: samples folder doesn't exist; should be named the same as the definition file without "
+ "JSON extension.",
+ path.string());
return;
}
@@ -58,10 +58,10 @@ EventOverrideData::EventOverrideData(const std::string& data, const fs::path& pa
if (dataJson.HasParseError())
{
spdlog::error(
- "Failed reading audio override file {}: encountered parse error \"{}\" at offset {}",
- path.string(),
- GetParseError_En(dataJson.GetParseError()),
- dataJson.GetErrorOffset());
+ "Failed reading audio override file {}: encountered parse error \"{}\" at offset {}",
+ path.string(),
+ GetParseError_En(dataJson.GetParseError()),
+ dataJson.GetErrorOffset());
return;
}
@@ -87,7 +87,7 @@ EventOverrideData::EventOverrideData(const std::string& data, const fs::path& pa
if (!eventId.IsString())
{
spdlog::error(
- "Failed reading audio override file {}: EventId array has a value of invalid type, all must be strings", path.string());
+ "Failed reading audio override file {}: EventId array has a value of invalid type, all must be strings", path.string());
return;
}
@@ -103,8 +103,8 @@ EventOverrideData::EventOverrideData(const std::string& data, const fs::path& pa
else
{
spdlog::error(
- "Failed reading audio override file {}: EventId property is of invalid type (must be a string or an array of strings)",
- path.string());
+ "Failed reading audio override file {}: EventId property is of invalid type (must be a string or an array of strings)",
+ path.string());
return;
}
@@ -118,8 +118,8 @@ EventOverrideData::EventOverrideData(const std::string& data, const fs::path& pa
if (!eventId.IsString())
{
spdlog::error(
- "Failed reading audio override file {}: EventIdRegex array has a value of invalid type, all must be strings",
- path.string());
+ "Failed reading audio override file {}: EventIdRegex array has a value of invalid type, all must be strings",
+ path.string());
return;
}
@@ -154,8 +154,8 @@ EventOverrideData::EventOverrideData(const std::string& data, const fs::path& pa
else
{
spdlog::error(
- "Failed reading audio override file {}: EventIdRegex property is of invalid type (must be a string or an array of strings)",
- path.string());
+ "Failed reading audio override file {}: EventIdRegex property is of invalid type (must be a string or an array of strings)",
+ path.string());
return;
}
}
@@ -181,8 +181,8 @@ EventOverrideData::EventOverrideData(const std::string& data, const fs::path& pa
else
{
spdlog::error(
- "Failed reading audio override file {}: AudioSelectionStrategy string must be either \"sequential\" or \"random\"",
- path.string());
+ "Failed reading audio override file {}: AudioSelectionStrategy string must be either \"sequential\" or \"random\"",
+ path.string());
return;
}
}
@@ -217,25 +217,25 @@ EventOverrideData::EventOverrideData(const std::string& data, const fs::path& pa
// thread off the file read
// should we spawn one thread per read? or should there be a cap to the number of reads at once?
std::thread readThread(
- [pathString, fileSize, data]
- {
- std::shared_lock lock(g_CustomAudioManager.m_loadingMutex);
- std::ifstream wavStream(pathString, std::ios::binary);
-
- // would be weird if this got hit, since it would've worked previously
- if (wavStream.fail())
- {
- spdlog::error("Failed async read of audio sample {}", pathString);
- return;
- }
-
- // read from after the header first to preserve the empty header, then read the header last
- wavStream.seekg(0, std::ios::beg);
- wavStream.read(reinterpret_cast<char*>(data), fileSize);
- wavStream.close();
-
- spdlog::info("Finished async read of audio sample {}", pathString);
- });
+ [pathString, fileSize, data]
+ {
+ std::shared_lock lock(g_CustomAudioManager.m_loadingMutex);
+ std::ifstream wavStream(pathString, std::ios::binary);
+
+ // would be weird if this got hit, since it would've worked previously
+ if (wavStream.fail())
+ {
+ spdlog::error("Failed async read of audio sample {}", pathString);
+ return;
+ }
+
+ // read from after the header first to preserve the empty header, then read the header last
+ wavStream.seekg(0, std::ios::beg);
+ wavStream.read(reinterpret_cast<char*>(data), fileSize);
+ wavStream.close();
+
+ spdlog::info("Finished async read of audio sample {}", pathString);
+ });
readThread.detach();
}
@@ -244,13 +244,13 @@ EventOverrideData::EventOverrideData(const std::string& data, const fs::path& pa
/*
if (dataJson.HasMember("EnableOnLoopedSounds"))
{
- if (!dataJson["EnableOnLoopedSounds"].IsBool())
- {
- spdlog::error("Failed reading audio override file {}: EnableOnLoopedSounds property is of invalid type (must be a bool)",
+ if (!dataJson["EnableOnLoopedSounds"].IsBool())
+ {
+ spdlog::error("Failed reading audio override file {}: EnableOnLoopedSounds property is of invalid type (must be a bool)",
path.string()); return;
- }
+ }
- EnableOnLoopedSounds = dataJson["EnableOnLoopedSounds"].GetBool();
+ EnableOnLoopedSounds = dataJson["EnableOnLoopedSounds"].GetBool();
}
*/
@@ -367,7 +367,7 @@ bool ShouldPlayAudioEvent(const char* eventName, const std::shared_ptr<EventOver
// forward declare
bool __declspec(noinline) __fastcall LoadSampleMetadata_Internal(
- uintptr_t parentEvent, void* sample, void* audioBuffer, unsigned int audioBufferLength, int audioType);
+ uintptr_t parentEvent, void* sample, void* audioBuffer, unsigned int audioBufferLength, int audioType);
// DO NOT TOUCH THIS FUNCTION
// The actual logic of it in a separate function (forcefully not inlined) to preserve the r12 register, which holds the event pointer.
@@ -388,7 +388,7 @@ bool, __fastcall, (void* sample, void* audioBuffer, unsigned int audioBufferLeng
// DO NOT INLINE THIS FUNCTION
// See comment below.
bool __declspec(noinline) __fastcall LoadSampleMetadata_Internal(
- uintptr_t parentEvent, void* sample, void* audioBuffer, unsigned int audioBufferLength, int audioType)
+ uintptr_t parentEvent, void* sample, void* audioBuffer, unsigned int audioBufferLength, int audioType)
{
char* eventName = (char*)parentEvent + 0x110;