AudioBackend_Tick!!

This commit is contained in:
headshot2017 2024-03-14 22:18:14 -04:00
parent e1d830064c
commit 5c136aea57
3 changed files with 11 additions and 14 deletions

View File

@ -950,12 +950,14 @@ static int channelIDs;
static struct AudioMemPools audioPools[64]; static struct AudioMemPools audioPools[64];
AudioDriver drv; AudioDriver drv;
bool switchAudio = false; bool switchAudio = false;
extern void* audrv_mutex; void* audrv_mutex;
static cc_bool AudioBackend_Init(void) { static cc_bool AudioBackend_Init(void) {
if (switchAudio) return true; if (switchAudio) return true;
switchAudio = true; switchAudio = true;
audrv_mutex = Mutex_Create();
Mem_Set(audioPools, 0, sizeof(audioPools)); Mem_Set(audioPools, 0, sizeof(audioPools));
static const AudioRendererConfig arConfig = static const AudioRendererConfig arConfig =
@ -980,9 +982,17 @@ static cc_bool AudioBackend_Init(void) {
return R_SUCCEEDED(res); return R_SUCCEEDED(res);
} }
void AudioBackend_Tick(void) {
Mutex_Lock(audrv_mutex);
if (switchAudio) audrvUpdate(&drv);
Mutex_Unlock(audrv_mutex);
}
static void AudioBackend_Free(void) { static void AudioBackend_Free(void) {
if (!switchAudio) return; if (!switchAudio) return;
switchAudio = false; switchAudio = false;
Mutex_Free(audrv_mutex);
audrvClose(&drv); audrvClose(&drv);
audrenExit(); audrenExit();

View File

@ -37,8 +37,6 @@ const cc_result ReturnCode_SocketWouldBlock = EWOULDBLOCK;
const cc_result ReturnCode_DirectoryExists = EEXIST; const cc_result ReturnCode_DirectoryExists = EEXIST;
const char* Platform_AppNameSuffix = " Switch"; const char* Platform_AppNameSuffix = " Switch";
void* audrv_mutex;
alignas(16) u8 __nx_exception_stack[0x1000]; alignas(16) u8 __nx_exception_stack[0x1000];
u64 __nx_exception_stack_size = sizeof(__nx_exception_stack); u64 __nx_exception_stack_size = sizeof(__nx_exception_stack);
@ -521,12 +519,9 @@ void Platform_Init(void) {
// Configure our supported input layout: a single player with standard controller styles // Configure our supported input layout: a single player with standard controller styles
padConfigureInput(1, HidNpadStyleSet_NpadStandard); padConfigureInput(1, HidNpadStyleSet_NpadStandard);
hidInitializeTouchScreen(); hidInitializeTouchScreen();
audrv_mutex = Mutex_Create();
} }
void Platform_Free(void) { void Platform_Free(void) {
socketExit(); socketExit();
Mutex_Free(audrv_mutex);
} }
cc_bool Platform_DescribeError(cc_result res, cc_string* dst) { cc_bool Platform_DescribeError(cc_result res, cc_string* dst) {

View File

@ -22,9 +22,6 @@
static EGLDisplay s_display; static EGLDisplay s_display;
static EGLContext s_context; static EGLContext s_context;
static EGLSurface s_surface; static EGLSurface s_surface;
extern AudioDriver drv;
extern bool switchAudio;
extern void* audrv_mutex;
static cc_bool launcherMode; static cc_bool launcherMode;
static Framebuffer fb; static Framebuffer fb;
@ -139,11 +136,6 @@ void Window_ProcessEvents(double delta) {
// Scan the gamepad. This should be done once for each frame // Scan the gamepad. This should be done once for each frame
padUpdate(&pad); padUpdate(&pad);
Mutex_Lock(audrv_mutex);
if (switchAudio)
audrvUpdate(&drv);
Mutex_Unlock(audrv_mutex);
if (!appletMainLoop()) { if (!appletMainLoop()) {
Window_Main.Exists = false; Window_Main.Exists = false;
Window_RequestClose(); Window_RequestClose();