mmdevapi: Make buffer size divisible by number of periods.

This commit is contained in:
Andrew Eikum 2014-05-19 08:59:23 -05:00 committed by Alexandre Julliard
parent e6f816c99b
commit b634666e13
4 changed files with 7 additions and 1 deletions

View File

@ -935,7 +935,7 @@ static void test_clock(int share)
if (share) if (share)
ok(gbsize == bufsize, ok(gbsize == bufsize,
"BufferSize %u at rate %u\n", gbsize, pwfx->nSamplesPerSec); "BufferSize %u at rate %u\n", gbsize, pwfx->nSamplesPerSec);
else todo_wine else
ok(gbsize == parts * fragment || gbsize == MulDiv(bufsize, 1, 1024) * 1024, ok(gbsize == parts * fragment || gbsize == MulDiv(bufsize, 1, 1024) * 1024,
"BufferSize %u misfits fragment size %u at rate %u\n", gbsize, fragment, pwfx->nSamplesPerSec); "BufferSize %u misfits fragment size %u at rate %u\n", gbsize, fragment, pwfx->nSamplesPerSec);

View File

@ -1416,6 +1416,8 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient *iface,
* ALSA period 220 vs. 221 frames in mmdevapi and * ALSA period 220 vs. 221 frames in mmdevapi and
* buffer 883 vs. 2205 frames in mmdevapi! */ * buffer 883 vs. 2205 frames in mmdevapi! */
This->bufsize_frames = MulDiv(duration, fmt->nSamplesPerSec, 10000000); This->bufsize_frames = MulDiv(duration, fmt->nSamplesPerSec, 10000000);
if(mode == AUDCLNT_SHAREMODE_EXCLUSIVE)
This->bufsize_frames -= This->bufsize_frames % This->mmdev_period_frames;
This->hidden_frames = This->alsa_period_frames + This->mmdev_period_frames + This->hidden_frames = This->alsa_period_frames + This->mmdev_period_frames +
MulDiv(fmt->nSamplesPerSec, EXTRA_SAFE_RT, 10000000); MulDiv(fmt->nSamplesPerSec, EXTRA_SAFE_RT, 10000000);

View File

@ -1235,6 +1235,8 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient *iface,
This->period_frames = MulDiv(period, This->fmt->nSamplesPerSec, 10000000); This->period_frames = MulDiv(period, This->fmt->nSamplesPerSec, 10000000);
This->bufsize_frames = MulDiv(duration, fmt->nSamplesPerSec, 10000000); This->bufsize_frames = MulDiv(duration, fmt->nSamplesPerSec, 10000000);
if(mode == AUDCLNT_SHAREMODE_EXCLUSIVE)
This->bufsize_frames -= This->bufsize_frames % This->period_frames;
if(This->dataflow == eCapture){ if(This->dataflow == eCapture){
int i, nbuffs = (This->bufsize_frames / This->period_frames) + 1; int i, nbuffs = (This->bufsize_frames / This->period_frames) + 1;

View File

@ -1099,6 +1099,8 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient *iface,
This->period_frames = MulDiv(fmt->nSamplesPerSec, period, 10000000); This->period_frames = MulDiv(fmt->nSamplesPerSec, period, 10000000);
This->bufsize_frames = MulDiv(duration, fmt->nSamplesPerSec, 10000000); This->bufsize_frames = MulDiv(duration, fmt->nSamplesPerSec, 10000000);
if(mode == AUDCLNT_SHAREMODE_EXCLUSIVE)
This->bufsize_frames -= This->bufsize_frames % This->period_frames;
This->local_buffer = HeapAlloc(GetProcessHeap(), 0, This->local_buffer = HeapAlloc(GetProcessHeap(), 0,
This->bufsize_frames * fmt->nBlockAlign); This->bufsize_frames * fmt->nBlockAlign);
if(!This->local_buffer){ if(!This->local_buffer){