shithub: cstory

Download patch

ref: 80725016f7190bb55bde96fbe72c7e145de2d67f
parent: 75a31005d119dd6f99f0197424c6b8322c047e75
author: Clownacy <Clownacy@users.noreply.github.com>
date: Sun Oct 11 10:42:04 EDT 2020

Add mutexes to 3DS audio backend

Doesn't seem to fix the annoying crashes though...

--- a/src/Backends/Audio/SoftwareMixer/3DS.cpp
+++ b/src/Backends/Audio/SoftwareMixer/3DS.cpp
@@ -19,6 +19,9 @@
 static ndspWaveBuf dsp_buffers[2];
 static bool current_dsp_buffer;
 
+static LightLock mixer_mutex;
+static LightLock organya_mutex;
+
 static void FullBuffer(short *stream, size_t frames_total)
 {
 	size_t frames_done = 0;
@@ -104,7 +107,8 @@
 			dsp_buffers[1].data_vaddr = &stream_buffer[FRAMES_PER_BUFFER * 2 * 1];
 			dsp_buffers[1].nsamples = FRAMES_PER_BUFFER;
 
-			FullBuffer(stream_buffer, FRAMES_PER_BUFFER * 2);
+			LightLock_Init(&mixer_mutex);
+			LightLock_Init(&organya_mutex);
 
 			return SAMPLE_RATE;
 		}
@@ -132,6 +136,8 @@
 
 bool SoftwareMixerBackend_Start(void)
 {
+	FullBuffer(stream_buffer, FRAMES_PER_BUFFER * 2);
+
 	ndspChnWaveBufAdd(0, &dsp_buffers[0]);
 	ndspChnWaveBufAdd(0, &dsp_buffers[1]);
 
@@ -140,20 +146,20 @@
 
 void SoftwareMixerBackend_LockMixerMutex(void)
 {
-//	ma_mutex_lock(&mutex);
+	LightLock_Lock(&mixer_mutex);
 }
 
 void SoftwareMixerBackend_UnlockMixerMutex(void)
 {
-//	ma_mutex_unlock(&mutex);
+	LightLock_Unlock(&mixer_mutex);
 }
 
 void SoftwareMixerBackend_LockOrganyaMutex(void)
 {
-//	ma_mutex_lock(&organya_mutex);
+	LightLock_Lock(&organya_mutex);
 }
 
 void SoftwareMixerBackend_UnlockOrganyaMutex(void)
 {
-//	ma_mutex_unlock(&organya_mutex);
+	LightLock_Unlock(&organya_mutex);
 }