Move mixrate and latency definition to AudioServer
Each driver used to define the (same) project settings value, but the
setting names are not driver specific. Ovverriding is still possible via
platform tags.
(cherry picked from commit 90c7102b51)
This commit is contained in:
committed by
Rémi Verschelde
parent
6d1ddf7eb1
commit
92031098bf
@ -38,7 +38,7 @@
|
||||
#include <errno.h>
|
||||
|
||||
Error AudioDriverALSA::init_device() {
|
||||
mix_rate = GLOBAL_DEF("audio/mix_rate", DEFAULT_MIX_RATE);
|
||||
mix_rate = GLOBAL_GET("audio/mix_rate");
|
||||
speaker_mode = SPEAKER_MODE_STEREO;
|
||||
channels = 2;
|
||||
|
||||
@ -104,7 +104,7 @@ Error AudioDriverALSA::init_device() {
|
||||
// In ALSA the period size seems to be the one that will determine the actual latency
|
||||
// Ref: https://www.alsa-project.org/main/index.php/FramesPeriods
|
||||
unsigned int periods = 2;
|
||||
int latency = GLOBAL_DEF("audio/output_latency", DEFAULT_OUTPUT_LATENCY);
|
||||
int latency = GLOBAL_GET("audio/output_latency");
|
||||
buffer_frames = closest_power_of_2(latency * mix_rate / 1000);
|
||||
buffer_size = buffer_frames * periods;
|
||||
period_size = buffer_frames;
|
||||
|
||||
@ -118,7 +118,7 @@ Error AudioDriverCoreAudio::init() {
|
||||
break;
|
||||
}
|
||||
|
||||
mix_rate = GLOBAL_DEF_RST("audio/mix_rate", DEFAULT_MIX_RATE);
|
||||
mix_rate = GLOBAL_GET("audio/mix_rate");
|
||||
|
||||
zeromem(&strdesc, sizeof(strdesc));
|
||||
strdesc.mFormatID = kAudioFormatLinearPCM;
|
||||
@ -133,7 +133,7 @@ Error AudioDriverCoreAudio::init() {
|
||||
result = AudioUnitSetProperty(audio_unit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, kOutputBus, &strdesc, sizeof(strdesc));
|
||||
ERR_FAIL_COND_V(result != noErr, FAILED);
|
||||
|
||||
int latency = GLOBAL_DEF_RST("audio/output_latency", DEFAULT_OUTPUT_LATENCY);
|
||||
int latency = GLOBAL_GET("audio/output_latency");
|
||||
// Sample rate is independent of channels (ref: https://stackoverflow.com/questions/11048825/audio-sample-frequency-rely-on-channels)
|
||||
buffer_frames = closest_power_of_2(latency * mix_rate / 1000);
|
||||
|
||||
@ -419,7 +419,7 @@ Error AudioDriverCoreAudio::capture_init() {
|
||||
break;
|
||||
}
|
||||
|
||||
mix_rate = GLOBAL_DEF_RST("audio/mix_rate", DEFAULT_MIX_RATE);
|
||||
mix_rate = GLOBAL_GET("audio/mix_rate");
|
||||
|
||||
zeromem(&strdesc, sizeof(strdesc));
|
||||
strdesc.mFormatID = kAudioFormatLinearPCM;
|
||||
|
||||
@ -182,7 +182,7 @@ Error AudioDriverPulseAudio::init_device() {
|
||||
break;
|
||||
}
|
||||
|
||||
int latency = GLOBAL_DEF_RST("audio/output_latency", DEFAULT_OUTPUT_LATENCY);
|
||||
int latency = GLOBAL_GET("audio/output_latency");
|
||||
buffer_frames = closest_power_of_2(latency * mix_rate / 1000);
|
||||
pa_buffer_size = buffer_frames * pa_map.channels;
|
||||
|
||||
@ -241,7 +241,7 @@ Error AudioDriverPulseAudio::init() {
|
||||
thread_exited = false;
|
||||
exit_thread = false;
|
||||
|
||||
mix_rate = GLOBAL_DEF_RST("audio/mix_rate", DEFAULT_MIX_RATE);
|
||||
mix_rate = GLOBAL_GET("audio/mix_rate");
|
||||
|
||||
pa_ml = pa_mainloop_new();
|
||||
ERR_FAIL_COND_V(pa_ml == NULL, ERR_CANT_OPEN);
|
||||
|
||||
@ -396,7 +396,7 @@ Error AudioDriverWASAPI::finish_capture_device() {
|
||||
|
||||
Error AudioDriverWASAPI::init() {
|
||||
|
||||
mix_rate = GLOBAL_DEF_RST("audio/mix_rate", DEFAULT_MIX_RATE);
|
||||
mix_rate = GLOBAL_GET("audio/mix_rate");
|
||||
|
||||
Error err = init_render_device();
|
||||
if (err != OK) {
|
||||
|
||||
@ -45,12 +45,12 @@ Error AudioDriverXAudio2::init() {
|
||||
pcm_open = false;
|
||||
samples_in = NULL;
|
||||
|
||||
mix_rate = GLOBAL_DEF_RST("audio/mix_rate", DEFAULT_MIX_RATE);
|
||||
mix_rate = GLOBAL_GET("audio/mix_rate");
|
||||
// FIXME: speaker_mode seems unused in the Xaudio2 driver so far
|
||||
speaker_mode = SPEAKER_MODE_STEREO;
|
||||
channels = 2;
|
||||
|
||||
int latency = GLOBAL_DEF_RST("audio/output_latency", DEFAULT_OUTPUT_LATENCY);
|
||||
int latency = GLOBAL_GET("audio/output_latency");
|
||||
buffer_size = closest_power_of_2(latency * mix_rate / 1000);
|
||||
|
||||
samples_in = memnew_arr(int32_t, buffer_size * channels);
|
||||
|
||||
Reference in New Issue
Block a user