clean up and standardize types across the codebase, unify atomic operations, improve UTF-8 handling throughout the system, remove obsolete input and named queue interfaces, redesign process preparation and creation, tighten IPC and service boundaries, improve error handling and reliability, minor documentation cleanup, fix doom surfaces, fix panic in ini parsing.
This commit is contained in:
1 parent
899225f551
commit
c0ad63c27f
226 files changed
+6562
-4147
No files matched your search
@@ -1,5 +1,7 @@
|
||||
// Doom audio mixes PureDOOM SFX with optional SoundFont MIDI into one native render stream.
|
||||
|
||||
#include <ntlite/atomic.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
@@ -206,15 +208,15 @@ typedef struct DOOM_AUDIO_STATE {
|
||||
uint32_t WorkerId;
|
||||
uint32_t SynthLoaderHandle;
|
||||
uint32_t SynthLoaderId;
|
||||
volatile long StopRequested;
|
||||
volatile int32_t StopRequested;
|
||||
tsf* volatile Synth;
|
||||
} DOOM_AUDIO_STATE;
|
||||
|
||||
static DOOM_AUDIO_STATE g_doomAudio;
|
||||
|
||||
// Writes one complete diagnostic line to the process console.
|
||||
// Suppresses audio diagnostics until there is a display-independent user-mode log sink.
|
||||
static void DoomAudioPrint(const char* text) {
|
||||
if (text) (void)NtlConsoleWrite(SYS_HANDLE_INVALID, text, strlen(text), NULL);
|
||||
(void)text;
|
||||
}
|
||||
|
||||
// Opens the default available native render endpoint.
|
||||
@@ -262,8 +264,8 @@ static KSTATUS DoomAudioFindEndpoint(uint32_t* endpointIdOut) {
|
||||
|
||||
// Returns the currently published synthesizer without taking the PureDOOM lock.
|
||||
static tsf* DoomAudioGetSynth(void) {
|
||||
return (tsf*)_InterlockedCompareExchangePointer(
|
||||
(void* volatile*)&g_doomAudio.Synth, NULL, NULL);
|
||||
return (tsf*)NtlAtomicCompareExchangePointer(
|
||||
&g_doomAudio.Synth, NULL, NULL);
|
||||
}
|
||||
|
||||
// Maps the optional SoundFont so TinySoundFont can parse it without a separate input copy.
|
||||
@@ -353,7 +355,7 @@ static void DoomAudioSynthLoader(uintptr_t argument) {
|
||||
SysExitThread(0);
|
||||
}
|
||||
|
||||
if (_InterlockedCompareExchange(&g_doomAudio.StopRequested, 0, 0)) {
|
||||
if (NtlAtomicLoad32(&g_doomAudio.StopRequested)) {
|
||||
(void)SysFreeVm(soundFontBase);
|
||||
SysExitThread(0);
|
||||
}
|
||||
@@ -367,16 +369,15 @@ static void DoomAudioSynthLoader(uintptr_t argument) {
|
||||
|
||||
status = DoomAudioConfigureSynth(synth);
|
||||
if (status != NTLSTATUS_SUCCESS ||
|
||||
_InterlockedCompareExchange(&g_doomAudio.StopRequested, 0, 0)) {
|
||||
NtlAtomicLoad32(&g_doomAudio.StopRequested)) {
|
||||
if (status != NTLSTATUS_SUCCESS)
|
||||
DoomAudioPrint("doom: MIDI synthesizer initialization failed; continuing with sound effects only\n");
|
||||
tsf_close(synth);
|
||||
SysExitThread(0);
|
||||
}
|
||||
|
||||
(void)_InterlockedExchangePointer(
|
||||
(void* volatile*)&g_doomAudio.Synth, synth);
|
||||
DoomAudioPrint("doom: MIDI synthesizer ready\n");
|
||||
(void)NtlAtomicExchangePointer(
|
||||
&g_doomAudio.Synth, synth);
|
||||
SysExitThread(0);
|
||||
}
|
||||
|
||||
@@ -620,7 +621,7 @@ static void DoomAudioWorker(uintptr_t argument) {
|
||||
uint32_t requiredFrames;
|
||||
KSTATUS status;
|
||||
|
||||
if (_InterlockedCompareExchange(&g_doomAudio.StopRequested, 0, 0))
|
||||
if (NtlAtomicLoad32(&g_doomAudio.StopRequested))
|
||||
break;
|
||||
|
||||
status = DoomAudioQueryStream(&info);
|
||||
@@ -686,8 +687,8 @@ static void DoomAudioReleaseResources(void) {
|
||||
(void)SysCloseHandle(g_doomAudio.StreamHandle);
|
||||
g_doomAudio.StreamHandle = 0;
|
||||
}
|
||||
tsf* synth = (tsf*)_InterlockedExchangePointer(
|
||||
(void* volatile*)&g_doomAudio.Synth, NULL);
|
||||
tsf* synth = (tsf*)NtlAtomicExchangePointer(
|
||||
&g_doomAudio.Synth, NULL);
|
||||
if (synth)
|
||||
tsf_close(synth);
|
||||
if (g_doomAudio.CoreMutex) {
|
||||
@@ -767,7 +768,7 @@ void DoomAudioStart(void) {
|
||||
|
||||
// Stops playback immediately without waiting for the producer thread.
|
||||
void DoomAudioAbort(void) {
|
||||
_InterlockedExchange(&g_doomAudio.StopRequested, 1);
|
||||
NtlAtomicExchange32(&g_doomAudio.StopRequested, 1);
|
||||
if (g_doomAudio.StreamHandle)
|
||||
(void)SysAudioStop(g_doomAudio.StreamHandle);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user