mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 21:32:45 +00:00
fixed latency and buffer duration calculations
This commit is contained in:
parent
129151d5fc
commit
2a594d313c
@ -222,15 +222,15 @@ static IAudioClient *wasapi_init_client(IMMDevice *device, bool exclusive,
|
|||||||
hr = client->lpVtbl->GetDevicePeriod(client, &default_period, &minimum_period);
|
hr = client->lpVtbl->GetDevicePeriod(client, &default_period, &minimum_period);
|
||||||
WASAPI_HR_CHECK(hr, "IAudioClient::GetDevicePeriod", goto error);
|
WASAPI_HR_CHECK(hr, "IAudioClient::GetDevicePeriod", goto error);
|
||||||
|
|
||||||
if (exclusive)
|
if (!exclusive)
|
||||||
{
|
buffer_duration = 0; // required for event driven shared mode
|
||||||
if (latency < minimum_period / 10000)
|
|
||||||
buffer_duration = minimum_period;
|
|
||||||
else
|
|
||||||
buffer_duration = latency * 10000;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
buffer_duration = 0;
|
{
|
||||||
|
// 3 buffers latency (ms) to 2 buffer duration (100ns units)
|
||||||
|
buffer_duration = (double)latency * 10000.0 * 2.0 / 3.0;
|
||||||
|
if (buffer_duration < minimum_period)
|
||||||
|
buffer_duration = minimum_period;
|
||||||
|
}
|
||||||
|
|
||||||
WAVEFORMATEXTENSIBLE wf;
|
WAVEFORMATEXTENSIBLE wf;
|
||||||
wf.Format.nChannels = 2;
|
wf.Format.nChannels = 2;
|
||||||
@ -276,11 +276,13 @@ static IAudioClient *wasapi_init_client(IMMDevice *device, bool exclusive,
|
|||||||
hr = client->lpVtbl->GetStreamLatency(client, &stream_latency);
|
hr = client->lpVtbl->GetStreamLatency(client, &stream_latency);
|
||||||
if(hr != S_OK)
|
if(hr != S_OK)
|
||||||
wasapi_com_err("IAudioClient::GetStreamLatency", hr);
|
wasapi_com_err("IAudioClient::GetStreamLatency", hr);
|
||||||
else if (!exclusive)
|
else if (exclusive)
|
||||||
|
stream_latency *= 1.5;
|
||||||
|
else
|
||||||
stream_latency += default_period;
|
stream_latency += default_period;
|
||||||
|
|
||||||
RARCH_LOG("[WASAPI]: Client initialized (latency %ums).\n",
|
RARCH_LOG("[WASAPI]: Client initialized (max latency %.1fms).\n",
|
||||||
(unsigned)((double)stream_latency / 10000.0 + 0.5));
|
(double)stream_latency / 10000.0 + 0.05);
|
||||||
|
|
||||||
return client;
|
return client;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user