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 @@
|
||||
// WinMM waveform output over the native render-stream syscall ABI.
|
||||
|
||||
#include <ntlite/atomic.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
@@ -158,15 +160,15 @@ typedef struct WINMM_WAVE_BUFFER {
|
||||
uint32_t FrameCount;
|
||||
uint32_t SubmittedFrames;
|
||||
uint64_t PresentedTarget;
|
||||
uint8_t FullySubmitted;
|
||||
bool FullySubmitted;
|
||||
uint64_t Sequence;
|
||||
} WINMM_WAVE_BUFFER;
|
||||
|
||||
typedef struct WINMM_WAVEOUT {
|
||||
struct WINMM_WAVEOUT* RegistryNext;
|
||||
uint32_t Magic;
|
||||
volatile long Lock;
|
||||
volatile long ApiUsers;
|
||||
int32_t Lock;
|
||||
int32_t ApiUsers;
|
||||
uint32_t NativeStream;
|
||||
uint32_t WakeEvent;
|
||||
uint32_t CommandEvent;
|
||||
@@ -180,10 +182,10 @@ typedef struct WINMM_WAVEOUT {
|
||||
uint32_t CallbackMode;
|
||||
uint32_t DeviceId;
|
||||
uint32_t Volume;
|
||||
uint32_t Closing;
|
||||
uint32_t UserPaused;
|
||||
uint32_t AutoPaused;
|
||||
uint32_t Started;
|
||||
bool Closing;
|
||||
bool UserPaused;
|
||||
bool AutoPaused;
|
||||
bool Started;
|
||||
uint32_t TerminalError;
|
||||
WINMM_WAVE_COMMAND Command;
|
||||
MMRESULT CommandResult;
|
||||
@@ -198,7 +200,7 @@ typedef struct WINMM_WAVEOUT {
|
||||
} WINMM_WAVEOUT;
|
||||
|
||||
static WINMM_WAVEOUT* gWaveOutRegistry;
|
||||
static volatile long gWaveOutRegistryLock;
|
||||
static int32_t gWaveOutRegistryLock;
|
||||
|
||||
|
||||
typedef struct WINMM_DEBUG_LINE {
|
||||
@@ -230,12 +232,12 @@ static void WinmmDebugU64(WINMM_DEBUG_LINE* line, uint64_t value) {
|
||||
static void WinmmDebugHex(WINMM_DEBUG_LINE* line, uint64_t value) {
|
||||
static const char digits[] = "0123456789ABCDEF";
|
||||
WinmmDebugText(line, "0x");
|
||||
int started = 0;
|
||||
bool started = false;
|
||||
for (int shift = 60; shift >= 0; shift -= 4) {
|
||||
uint8_t digit = (uint8_t)((value >> shift) & 0xFu);
|
||||
if (!started && digit == 0 && shift)
|
||||
continue;
|
||||
started = 1;
|
||||
started = true;
|
||||
if (line->Length + 1 < sizeof(line->Buffer))
|
||||
line->Buffer[line->Length++] = digits[digit];
|
||||
}
|
||||
@@ -295,14 +297,14 @@ static void WinmmDebugResult(const char* operation,
|
||||
}
|
||||
|
||||
// Acquires one short user-mode spin lock without entering the kernel.
|
||||
static void WinmmLock(volatile long* lock) {
|
||||
while (_InterlockedCompareExchange(lock, 1, 0) != 0)
|
||||
static void WinmmLock(int32_t* lock) {
|
||||
while (NtlAtomicCompareExchange32(lock, 1, 0) != 0)
|
||||
(void)SysYield();
|
||||
}
|
||||
|
||||
// Releases one short user-mode spin lock.
|
||||
static void WinmmUnlock(volatile long* lock) {
|
||||
_InterlockedExchange(lock, 0);
|
||||
static void WinmmUnlock(int32_t* lock) {
|
||||
NtlAtomicExchange32(lock, 0);
|
||||
}
|
||||
|
||||
// Maps one native status to the closest waveform-open result.
|
||||
@@ -321,7 +323,7 @@ static MMRESULT WinmmMapNativeStatus(KSTATUS status) {
|
||||
}
|
||||
|
||||
// Returns whether one source rate is accepted by the native stream ABI.
|
||||
static int WinmmRateIsSupported(uint32_t sampleRate) {
|
||||
static bool WinmmRateIsSupported(uint32_t sampleRate) {
|
||||
return sampleRate == 11025u || sampleRate == 22050u ||
|
||||
sampleRate == 44100u || sampleRate == 48000u;
|
||||
}
|
||||
@@ -439,7 +441,7 @@ static WINMM_WAVEOUT* WinmmReferenceWaveOut(HWAVEOUT handle) {
|
||||
current;
|
||||
current = current->RegistryNext) {
|
||||
if ((HWAVEOUT)current == handle && current->Magic == WINMM_WAVEOUT_MAGIC) {
|
||||
_InterlockedIncrement(¤t->ApiUsers);
|
||||
NtlAtomicIncrement32(¤t->ApiUsers);
|
||||
found = current;
|
||||
break;
|
||||
}
|
||||
@@ -451,19 +453,19 @@ static WINMM_WAVEOUT* WinmmReferenceWaveOut(HWAVEOUT handle) {
|
||||
// Releases one API-use reference acquired through the registry.
|
||||
static void WinmmReleaseWaveOut(WINMM_WAVEOUT* waveOut) {
|
||||
if (waveOut)
|
||||
_InterlockedDecrement(&waveOut->ApiUsers);
|
||||
NtlAtomicDecrement32(&waveOut->ApiUsers);
|
||||
}
|
||||
|
||||
// Removes one waveform handle so no new API references can be acquired.
|
||||
static int WinmmRemoveWaveOut(WINMM_WAVEOUT* waveOut) {
|
||||
int removed = 0;
|
||||
static bool WinmmRemoveWaveOut(WINMM_WAVEOUT* waveOut) {
|
||||
bool removed = false;
|
||||
WinmmLock(&gWaveOutRegistryLock);
|
||||
WINMM_WAVEOUT** link = &gWaveOutRegistry;
|
||||
while (*link) {
|
||||
if (*link == waveOut) {
|
||||
*link = waveOut->RegistryNext;
|
||||
waveOut->RegistryNext = NULL;
|
||||
removed = 1;
|
||||
removed = true;
|
||||
break;
|
||||
}
|
||||
link = &(*link)->RegistryNext;
|
||||
@@ -713,7 +715,7 @@ static KSTATUS WinmmFeedNativeStream(WINMM_WAVEOUT* waveOut,
|
||||
}
|
||||
|
||||
// Determines whether any queued buffer still needs native-ring submission.
|
||||
static int WinmmHasUnsubmittedBuffer(WINMM_WAVEOUT* waveOut) {
|
||||
static bool WinmmHasUnsubmittedBuffer(WINMM_WAVEOUT* waveOut) {
|
||||
return WinmmFindSubmitNode(waveOut) != NULL;
|
||||
}
|
||||
|
||||
@@ -751,7 +753,7 @@ static void WinmmStopEmptyStream(WINMM_WAVEOUT* waveOut) {
|
||||
// Arms native progress conditions and waits for either stream progress or new work.
|
||||
static KSTATUS WinmmWaitForWork(WINMM_WAVEOUT* waveOut,
|
||||
const SYS_AUDIO_STREAM_INFO* info,
|
||||
int hasUnsubmitted) {
|
||||
bool hasUnsubmitted) {
|
||||
SYS_AUDIO_ARM_WAIT_REQUEST arm;
|
||||
memset(&arm, 0, sizeof(arm));
|
||||
arm.Size = sizeof(arm);
|
||||
@@ -877,7 +879,7 @@ static void WinmmWaveWorker(uintptr_t argument) {
|
||||
WinmmFailStream(waveOut, WinmmMapNativeStatus(status));
|
||||
continue;
|
||||
}
|
||||
int hasUnsubmitted = WinmmHasUnsubmittedBuffer(waveOut);
|
||||
bool hasUnsubmitted = WinmmHasUnsubmittedBuffer(waveOut);
|
||||
if (!hasUnsubmitted && waveOut->Started && !waveOut->UserPaused &&
|
||||
!waveOut->AutoPaused && info.FramesConsumed >= waveOut->NativeSubmitted) {
|
||||
status = SysAudioPause(waveOut->NativeStream);
|
||||
@@ -1088,7 +1090,7 @@ __declspec(dllexport) MMRESULT waveOutClose(HWAVEOUT handle) {
|
||||
}
|
||||
|
||||
WinmmLock(&waveOut->Lock);
|
||||
int busy = waveOut->QueueHead != NULL || waveOut->Command != WinmmWaveCommandNone;
|
||||
bool busy = waveOut->QueueHead != NULL || waveOut->Command != WinmmWaveCommandNone;
|
||||
WinmmUnlock(&waveOut->Lock);
|
||||
if (busy) {
|
||||
WinmmDebugResult("close still playing", waveOut, waveOut->HeadersQueued - waveOut->HeadersCompleted);
|
||||
@@ -1103,7 +1105,7 @@ __declspec(dllexport) MMRESULT waveOutClose(HWAVEOUT handle) {
|
||||
waveOut->Closing = 1;
|
||||
(void)SysSignalEvent(waveOut->WakeEvent);
|
||||
KSTATUS status = SysWait(waveOut->WorkerHandle, SYS_WAIT_FLAG_NONE);
|
||||
while (waveOut->ApiUsers > 1)
|
||||
while (NtlAtomicLoad32(&waveOut->ApiUsers) > 1)
|
||||
(void)SysYield();
|
||||
|
||||
waveOut->Magic = 0;
|
||||
|
||||
Reference in new issue
Block a user