mirror of
https://github.com/mpv-player/mpv
synced 2025-03-04 21:27:58 +00:00
ao_wasapi: set buffer size to device period in exclusive mode
This eliminates some intermittent pops heard in a HRT MicroStreamer DAC
uncorrelated with user interaction. As a bonus, this resolves #1773 which I can
o longer reproduce as of this commit. Leave the 50ms buffer for shared mode
since that seems to be working quite well.
This is also the way exclusive mode is done in the MSDN example code:
https://msdn.microsoft.com/en-us/library/windows/desktop/dd370844%28v=vs.85%29.aspx
This was originally increased in c545c40
to mitigate glitches that subsequent
refactorings have eliminated.
This commit is contained in:
parent
84a3c21beb
commit
82f102cfe3
@ -607,18 +607,20 @@ static HRESULT fix_format(struct ao *ao)
|
||||
MP_VERBOSE(state, "Device period: %.2g ms\n",
|
||||
(double) devicePeriod / 10000.0 );
|
||||
|
||||
// integer multiple of device period close to 50ms
|
||||
bufferPeriod = bufferDuration =
|
||||
ceil(50.0 * 10000.0 / devicePeriod) * devicePeriod;
|
||||
if (state->share_mode == AUDCLNT_SHAREMODE_SHARED) {
|
||||
// for shared mode, use integer multiple of device period close to 50ms
|
||||
bufferDuration = devicePeriod * ceil(50.0 * 10000.0 / devicePeriod);
|
||||
bufferPeriod = 0;
|
||||
} else {
|
||||
// in exclusive mode, these should all be the same
|
||||
bufferPeriod = bufferDuration = devicePeriod;
|
||||
}
|
||||
|
||||
// handle unsupported buffer size hopefully this shouldn't happen because of
|
||||
// the above integer device period
|
||||
// http://msdn.microsoft.com/en-us/library/windows/desktop/dd370875%28v=vs.85%29.aspx
|
||||
int retries=0;
|
||||
reinit:
|
||||
if (state->share_mode == AUDCLNT_SHAREMODE_SHARED)
|
||||
bufferPeriod = 0;
|
||||
|
||||
MP_DBG(state, "IAudioClient::Initialize\n");
|
||||
hr = IAudioClient_Initialize(state->pAudioClient,
|
||||
state->share_mode,
|
||||
@ -640,9 +642,12 @@ reinit:
|
||||
|
||||
IAudioClient_GetBufferSize(state->pAudioClient,
|
||||
&state->bufferFrameCount);
|
||||
bufferPeriod = bufferDuration = (REFERENCE_TIME) (0.5 +
|
||||
bufferDuration = (REFERENCE_TIME) (0.5 +
|
||||
(10000.0 * 1000 / state->format.Format.nSamplesPerSec
|
||||
* state->bufferFrameCount));
|
||||
if (state->share_mode == AUDCLNT_SHAREMODE_EXCLUSIVE)
|
||||
bufferPeriod = bufferDuration;
|
||||
|
||||
|
||||
IAudioClient_Release(state->pAudioClient);
|
||||
state->pAudioClient = NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user