port: revert multithreaded audio experiments

until I can figure out how to fix all the funny concurrency issues that cropped up
This commit is contained in:
fgsfds committed 2024-05-19 19:44:34 +02:00
1 parent dce96a4a3d
commit de3b8ff548
16 files changed
+62 -174

No files matched your search

+8 -2
View File
@@ -9840,14 +9840,20 @@ bool aiIfMusicEventQueueIsEmpty(void)
{
f32 value = (u64)osGetCount() * 64 / 3000;
#ifdef PLATFORM_N64 // will hang forever until the audio thread wakes it up
if (g_MusicEventQueueLength) {
#ifndef PLATFORM_N64
musicTickEvents();
#else // HACK: will wait 1 frame and get on with it
static bool waited = false;
if (g_MusicEventQueueLength && !waited) {
waited = true;
#endif
g_Vars.aioffset += 4;
} else {
u8 *cmd = g_Vars.ailist + g_Vars.aioffset;
g_Vars.aioffset = chraiGoToLabel(g_Vars.ailist, g_Vars.aioffset, cmd[3]);
#ifndef PLATFORM_N64
waited = false;
#endif
}
return false;
+1 -1
View File
@@ -47,7 +47,7 @@ void frametimeCalculate(void)
#ifndef PLATFORM_N64
if (g_TickExtraSleep) {
sysFrameLimiterSleep(EXTRA_SLEEP_TIME);
sysSleep(EXTRA_SLEEP_TIME);
}
#endif
} while (g_Vars.mininc60 && diffframe60 < g_Vars.mininc60);
+1 -5
View File
@@ -17,11 +17,7 @@ OSMesgQueue *amgrGetFrameMesgQueue(void);
void amgrStopThread(void);
#ifndef PLATFORM_N64
void amgrLock(void);
void amgrUnlock(void);
#else
#define amgrLock() do {} while(0)
#define amgrUnlock() do {} while(0)
void amgrFrame(void);
#endif
#endif
-3
View File
@@ -34,9 +34,6 @@
#error "64-bit platforms are currently not supported."
#endif
// threading backend
#define PLATFORM_USE_PTHREAD 1
// detect endianness
#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__)
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
-66
View File
@@ -10,13 +10,6 @@
#include "lib/libc/ll.h"
#include "data.h"
#include "types.h"
#ifndef PLATFORM_N64
#include "lib/audiomgr.h"
#include "thread.h"
#include "audio.h"
#include "system.h"
#define AMGR_THREAD_SLEEP_US 2000
#endif
u32 var80091560;
u32 var80091564;
@@ -50,14 +43,6 @@ void *g_AudioSp;
u32 var8005cf90 = 0x00000000;
u8 var8005cf94 = 1;
#ifndef PLATFORM_N64
systhread g_AmgrThread;
sysmutex g_AmgrMutex = SYSMUTEX_STATIC_INIT;
u32 g_AmgrFrame;
u32 g_AmgrFrameTarget;
void *amgrThread(void *arg);
#endif
void amgrHandleDoneMsg(AudioInfo *info);
void amgrHandleFrameMsg(AudioInfo *info, AudioInfo *previnfo);
void amgrMain(void *arg);
@@ -170,9 +155,6 @@ void amgrStartThread(void)
{
osStartThread(&g_AudioManager.thread);
g_AudioIsThreadRunning = true;
#ifndef PLATFORM_N64
sysThreadCreate(&g_AmgrThread, &amgrThread, NULL);
#endif
}
OSMesgQueue *amgrGetFrameMesgQueue(void)
@@ -189,12 +171,6 @@ void amgrStopThread(void)
{
if (g_AudioIsThreadRunning) {
osStopThread(&g_AudioManager.thread);
#ifndef PLATFORM_N64
amgrLock();
g_AudioIsThreadRunning = false;
amgrUnlock();
sysThreadJoin(&g_AmgrThread, NULL);
#endif
}
}
@@ -345,14 +321,11 @@ void amgrHandleDoneMsg(AudioInfo *info)
}
#ifndef PLATFORM_N64
void amgrFrame(void)
{
static AudioInfo *previnfo = NULL;
static s32 count = 0;
amgrLock();
var80091588 = osGetTime();
AudioInfo *info = g_AudioManager.audioInfo[g_AdmaCurFrame % 3];
@@ -390,8 +363,6 @@ void amgrFrame(void)
count++;
amgrUnlock();
var80091590 = osGetTime();
var80091570 = var80091590 - var80091588;
@@ -406,41 +377,4 @@ void amgrFrame(void)
var80091568 = var80091590 - var80091588;
}
}
void amgrLock(void)
{
sysMutexLock(&g_AmgrMutex);
}
void amgrUnlock(void)
{
sysMutexUnlock(&g_AmgrMutex);
}
void *amgrThread(void *arg)
{
const f64 frametime = 1000000.0 / (PAL ? 50.0 : 60.0);
bool running = g_AudioIsThreadRunning;
f64 nexttick = sysGetMicroseconds();
f64 tick;
while (running) {
tick = sysGetMicroseconds() + 0.01;
while (nexttick < tick) {
amgrFrame();
g_AmgrFrame++;
nexttick += frametime;
}
sysSleep(AMGR_THREAD_SLEEP_US);
amgrLock();
running = g_AudioIsThreadRunning;
amgrUnlock();
}
return NULL;
}
#endif