mirror of
https://github.com/sm64pc/sm64pc.git
synced 2025-04-12 00:05:59 +02:00
add config vars for audio thread runahead and sleep
This commit is contained in:
parent
a02075edc3
commit
e93a2bc14e
@ -54,6 +54,8 @@ unsigned int configMasterVolume = MAX_VOLUME; // 0 - MAX_VOLUME
|
||||
unsigned int configMusicVolume = MAX_VOLUME;
|
||||
unsigned int configSfxVolume = MAX_VOLUME;
|
||||
unsigned int configEnvVolume = MAX_VOLUME;
|
||||
float configAudioRunahead = 0.f;
|
||||
float configAudioSleep = 1.f;
|
||||
|
||||
// Keyboard mappings (VK_ values, by default keyboard/gamepad/mouse)
|
||||
unsigned int configKeyA[MAX_BINDS] = { 0x0026, 0x1000, 0x1103 };
|
||||
@ -106,6 +108,8 @@ static const struct ConfigOption options[] = {
|
||||
{.name = "music_volume", .type = CONFIG_TYPE_UINT, .uintValue = &configMusicVolume},
|
||||
{.name = "sfx_volume", .type = CONFIG_TYPE_UINT, .uintValue = &configSfxVolume},
|
||||
{.name = "env_volume", .type = CONFIG_TYPE_UINT, .uintValue = &configEnvVolume},
|
||||
{.name = "audio_sleep", .type = CONFIG_TYPE_FLOAT, .floatValue = &configAudioSleep},
|
||||
{.name = "audio_runahead", .type = CONFIG_TYPE_FLOAT, .floatValue = &configAudioRunahead},
|
||||
{.name = "key_a", .type = CONFIG_TYPE_BIND, .uintValue = configKeyA},
|
||||
{.name = "key_b", .type = CONFIG_TYPE_BIND, .uintValue = configKeyB},
|
||||
{.name = "key_start", .type = CONFIG_TYPE_BIND, .uintValue = configKeyStart},
|
||||
|
@ -23,6 +23,8 @@ extern unsigned int configMasterVolume;
|
||||
extern unsigned int configMusicVolume;
|
||||
extern unsigned int configSfxVolume;
|
||||
extern unsigned int configEnvVolume;
|
||||
extern float configAudioRunahead;
|
||||
extern float configAudioSleep;
|
||||
extern unsigned int configKeyA[];
|
||||
extern unsigned int configKeyB[];
|
||||
extern unsigned int configKeyStart[];
|
||||
|
@ -163,7 +163,8 @@ void* audio_thread() {
|
||||
set_sequence_player_volume(SEQ_PLAYER_SFX, (f32)configSfxVolume / 127.0f * master_mod);
|
||||
set_sequence_player_volume(SEQ_PLAYER_ENV, (f32)configEnvVolume / 127.0f * master_mod);
|
||||
|
||||
int samples_left = audio_api->buffered();
|
||||
int samples_left = audio_api->buffered() - (audio_api->get_desired_buffered() * configAudioRunahead);
|
||||
if (samples_left < 0) samples_left = 0;
|
||||
u32 num_audio_samples = samples_left < audio_api->get_desired_buffered() ? SAMPLES_HIGH : SAMPLES_LOW;
|
||||
// printf("Audio samples: %d %u\n", samples_left, num_audio_samples);
|
||||
s16 audio_buffer[SAMPLES_HIGH * 2];
|
||||
@ -191,7 +192,7 @@ void* audio_thread() {
|
||||
end_time = sys_profile_time();
|
||||
|
||||
// Sleep for the remaining time
|
||||
f64 nap_time = frametime_micro - (end_time - start_time);
|
||||
f64 nap_time = (frametime_micro - (end_time - start_time)) * configAudioSleep;
|
||||
// printf("Audio thread nap time: %f\n", nap_time);
|
||||
if (nap_time > 0.0) sys_sleep(nap_time);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user