Skip to content

WASAPI driver doesn't use the audio/output_latency parameter  #45552

Closed
@Chlipouni

Description

Godot version:

Godot 3.2
Godot 4.0

OS/device including version:

Windows 10

Issue description:

The file "godot/drivers/wasapi/audio_driver_wasapi.cpp" does not contain any reference to the audio/output_latency parameter in order to compute the audio buffer size.

As an example, the audio_driver_alsa.cpp uses the following lines :

	unsigned int periods = 2;
	int latency = GLOBAL_GET("audio/output_latency");
	buffer_frames = closest_power_of_2(latency * mix_rate / 1000);
	buffer_size = buffer_frames * periods;

The audio_driver_wasapi.cpp uses the following logic :

	UINT32 max_frames;
	HRESULT hr = audio_output.audio_client->GetBufferSize(&max_frames);
	ERR_FAIL_COND_V(hr != S_OK, ERR_CANT_OPEN);
	// Due to WASAPI Shared Mode we have no control of the buffer size
	buffer_frames = max_frames;

As a test, I tried to force the buffer_frames value with these modified lines of code (in both init_render_device and init_capture_device methods) :

	UINT32 max_frames = 1024;
	//HRESULT hr = audio_output.audio_client->GetBufferSize(&max_frames);
	//ERR_FAIL_COND_V(hr != S_OK, ERR_CANT_OPEN);
	// Due to WASAPI Shared Mode we have no control of the buffer size
	buffer_frames = max_frames;

With these modifications, I obtain a lower latency on Windows 10 even in shared mode.

Steps to reproduce:
Changing the value of audio/output parameter has no effect on the audio latency.
In my case I am using a Guitar USB controller and the record audio effect in Godot.
The default latency for Windows is too high and not acceptable for a guitar input.

Minimal reproduction project:

No project.
Reading the source code is enough to understand this issue.

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions