shithub: cstory

Download patch

ref: bc165d0f0a54be959821161045ad64917b0cbed6
parent: 7b1661dcf972717bdc787f7e5f44717a7239afaa
author: Clownacy <Clownacy@users.noreply.github.com>
date: Thu Sep 3 22:26:31 EDT 2020

Remove Organya-sleeping

Turns out that 'Sleep' call is ran on the *main* thread.

I have absolutely no idea why the game does this.

--- a/src/Backends/Audio.h
+++ b/src/Backends/Audio.h
@@ -20,4 +20,3 @@
 
 void AudioBackend_SetOrganyaCallback(void (*callback)(void));
 void AudioBackend_SetOrganyaTimer(unsigned int milliseconds);
-void AudioBackend_SleepOrganya(unsigned int milliseconds);
--- a/src/Backends/Audio/SoftwareMixer.cpp
+++ b/src/Backends/Audio/SoftwareMixer.cpp
@@ -11,7 +11,6 @@
 
 static void (*organya_callback)(void);
 static unsigned int organya_callback_timer_master;
-static unsigned int organya_sleep_timer;
 
 static void MixSoundsAndUpdateOrganya(long *stream, size_t frames_total)
 {
@@ -32,19 +31,6 @@
 		// Instead, we can just do this.
 		unsigned int frames_done = 0;
 
-		// Don't process Organya when it's meant to be sleeping
-		const unsigned int frames_to_do = MIN(organya_sleep_timer, frames_total - frames_done);
-
-		if (frames_to_do != 0)
-		{
-			SoftwareMixerBackend_LockMixerMutex();
-			Mixer_MixSounds(stream, frames_to_do);
-			SoftwareMixerBackend_UnlockMixerMutex();
-
-			frames_done += frames_to_do;
-			organya_sleep_timer -= frames_to_do;
-		}
-
 		while (frames_done != frames_total)
 		{
 			static unsigned long organya_callback_timer;
@@ -200,15 +186,6 @@
 	SoftwareMixerBackend_LockOrganyaMutex();
 
 	organya_callback_timer_master = (milliseconds * output_frequency) / 1000; // convert milliseconds to audio frames
-
-	SoftwareMixerBackend_UnlockOrganyaMutex();
-}
-
-void AudioBackend_SleepOrganya(unsigned int milliseconds)
-{
-	SoftwareMixerBackend_LockOrganyaMutex();
-
-	organya_sleep_timer = (milliseconds * output_frequency) / 1000; // convert milliseconds to audio frames
 
 	SoftwareMixerBackend_UnlockOrganyaMutex();
 }
--- a/src/Organya.cpp
+++ b/src/Organya.cpp
@@ -868,7 +868,7 @@
 	memset(key_on, 0, sizeof(key_on));
 	memset(key_twin, 0, sizeof(key_twin));
 
-	AudioBackend_SleepOrganya(100);
+	//Sleep(100);
 }
 
 void SetOrganyaFadeout(void)