diff options
Diffstat (limited to 'servers/audio/audio_driver_dummy.cpp')
-rw-r--r-- | servers/audio/audio_driver_dummy.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/servers/audio/audio_driver_dummy.cpp b/servers/audio/audio_driver_dummy.cpp index 992fece85f..1ae0e7b96b 100644 --- a/servers/audio/audio_driver_dummy.cpp +++ b/servers/audio/audio_driver_dummy.cpp @@ -37,17 +37,16 @@ Error AudioDriverDummy::init() { active = false; thread_exited = false; exit_thread = false; - pcm_open = false; samples_in = NULL; - mix_rate = 44100; + mix_rate = DEFAULT_MIX_RATE; speaker_mode = SPEAKER_MODE_STEREO; channels = 2; - int latency = GLOBAL_DEF("audio/output_latency", 25); - buffer_size = next_power_of_2(latency * mix_rate / 1000); + int latency = GLOBAL_DEF("audio/output_latency", DEFAULT_OUTPUT_LATENCY); + buffer_frames = closest_power_of_2(latency * mix_rate / 1000); - samples_in = memnew_arr(int32_t, buffer_size * channels); + samples_in = memnew_arr(int32_t, buffer_frames * channels); mutex = Mutex::create(); thread = Thread::create(AudioDriverDummy::thread_func, this); @@ -59,17 +58,15 @@ void AudioDriverDummy::thread_func(void *p_udata) { AudioDriverDummy *ad = (AudioDriverDummy *)p_udata; - uint64_t usdelay = (ad->buffer_size / float(ad->mix_rate)) * 1000000; + uint64_t usdelay = (ad->buffer_frames / float(ad->mix_rate)) * 1000000; while (!ad->exit_thread) { - if (!ad->active) { - - } else { + if (ad->active) { ad->lock(); - ad->audio_server_process(ad->buffer_size, ad->samples_in); + ad->audio_server_process(ad->buffer_frames, ad->samples_in); ad->unlock(); }; |