Emulate the Organya thread pauses
Now there's a 100ms pause between songs. Currently only the miniaudio backend supports this.
This commit is contained in:
parent
72eec8227c
commit
ab09dc67eb
3 changed files with 25 additions and 1 deletions
|
@ -20,3 +20,4 @@ void AudioBackend_SetSoundPan(AudioBackend_Sound *sound, long pan);
|
||||||
|
|
||||||
void AudioBackend_SetOrganyaCallback(void (*callback)(void));
|
void AudioBackend_SetOrganyaCallback(void (*callback)(void));
|
||||||
void AudioBackend_SetOrganyaTimer(unsigned int milliseconds);
|
void AudioBackend_SetOrganyaTimer(unsigned int milliseconds);
|
||||||
|
void AudioBackend_SleepOrganya(unsigned int milliseconds);
|
||||||
|
|
|
@ -27,6 +27,7 @@ static unsigned long output_frequency;
|
||||||
|
|
||||||
static void (*organya_callback)(void);
|
static void (*organya_callback)(void);
|
||||||
static unsigned int organya_callback_milliseconds;
|
static unsigned int organya_callback_milliseconds;
|
||||||
|
static unsigned int organya_sleep_timer;
|
||||||
|
|
||||||
static void MixSoundsAndUpdateOrganya(long *stream, size_t frames_total)
|
static void MixSoundsAndUpdateOrganya(long *stream, size_t frames_total)
|
||||||
{
|
{
|
||||||
|
@ -47,6 +48,19 @@ static void MixSoundsAndUpdateOrganya(long *stream, size_t frames_total)
|
||||||
// Instead, we can just do this.
|
// Instead, we can just do this.
|
||||||
unsigned int frames_done = 0;
|
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)
|
||||||
|
{
|
||||||
|
ma_mutex_lock(&mutex);
|
||||||
|
Mixer_MixSounds(stream, frames_to_do);
|
||||||
|
ma_mutex_unlock(&mutex);
|
||||||
|
|
||||||
|
frames_done += frames_to_do;
|
||||||
|
organya_sleep_timer -= frames_to_do;
|
||||||
|
}
|
||||||
|
|
||||||
while (frames_done != frames_total)
|
while (frames_done != frames_total)
|
||||||
{
|
{
|
||||||
static unsigned long organya_countdown;
|
static unsigned long organya_countdown;
|
||||||
|
@ -307,3 +321,12 @@ void AudioBackend_SetOrganyaTimer(unsigned int milliseconds)
|
||||||
|
|
||||||
ma_mutex_unlock(&organya_mutex);
|
ma_mutex_unlock(&organya_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AudioBackend_SleepOrganya(unsigned int milliseconds)
|
||||||
|
{
|
||||||
|
ma_mutex_lock(&organya_mutex);
|
||||||
|
|
||||||
|
organya_sleep_timer = (milliseconds * output_frequency) / 1000;
|
||||||
|
|
||||||
|
ma_mutex_unlock(&organya_mutex);
|
||||||
|
}
|
||||||
|
|
|
@ -868,7 +868,7 @@ void StopOrganyaMusic(void)
|
||||||
memset(key_on, 0, sizeof(key_on));
|
memset(key_on, 0, sizeof(key_on));
|
||||||
memset(key_twin, 0, sizeof(key_twin));
|
memset(key_twin, 0, sizeof(key_twin));
|
||||||
|
|
||||||
// Sleep(100); // TODO - Emulate this
|
AudioBackend_SleepOrganya(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetOrganyaFadeout(void)
|
void SetOrganyaFadeout(void)
|
||||||
|
|
Loading…
Add table
Reference in a new issue