mirror of
git://source.winehq.org/git/wine.git
synced 2024-07-21 11:54:09 +00:00
mmdevapi: Enforce limits on period and duration.
This commit is contained in:
parent
56f035b56d
commit
38f9ba0070
|
@ -835,14 +835,28 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient *iface,
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mode == AUDCLNT_SHAREMODE_EXCLUSIVE && flags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK){
|
if(mode == AUDCLNT_SHAREMODE_SHARED){
|
||||||
FIXME("EXCLUSIVE mode with EVENTCALLBACK\n");
|
period = DefaultPeriod;
|
||||||
return AUDCLNT_E_DEVICE_IN_USE;
|
if( duration < 3 * period)
|
||||||
|
duration = 3 * period;
|
||||||
|
}else{
|
||||||
|
if(!period)
|
||||||
|
period = DefaultPeriod; /* not minimum */
|
||||||
|
if(period < MinimumPeriod || period > 5000000)
|
||||||
|
return AUDCLNT_E_INVALID_DEVICE_PERIOD;
|
||||||
|
if(duration > 20000000) /* the smaller the period, the lower this limit */
|
||||||
|
return AUDCLNT_E_BUFFER_SIZE_ERROR;
|
||||||
|
if(flags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK){
|
||||||
|
if(duration != period)
|
||||||
|
return AUDCLNT_E_BUFDURATION_PERIOD_NOT_EQUAL;
|
||||||
|
FIXME("EXCLUSIVE mode with EVENTCALLBACK\n");
|
||||||
|
return AUDCLNT_E_DEVICE_IN_USE;
|
||||||
|
}else{
|
||||||
|
if( duration < 8 * period)
|
||||||
|
duration = 8 * period; /* may grow above 2s */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!duration)
|
|
||||||
duration = 300000; /* 0.03s */
|
|
||||||
|
|
||||||
EnterCriticalSection(&This->lock);
|
EnterCriticalSection(&This->lock);
|
||||||
|
|
||||||
if(This->initted){
|
if(This->initted){
|
||||||
|
@ -1001,10 +1015,7 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient *iface,
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(period)
|
This->mmdev_period_rt = period;
|
||||||
This->mmdev_period_rt = period;
|
|
||||||
else
|
|
||||||
This->mmdev_period_rt = DefaultPeriod;
|
|
||||||
|
|
||||||
/* Check if the ALSA buffer is so small that it will run out before
|
/* Check if the ALSA buffer is so small that it will run out before
|
||||||
* the next MMDevAPI period tick occurs. Allow a little wiggle room
|
* the next MMDevAPI period tick occurs. Allow a little wiggle room
|
||||||
|
|
|
@ -961,9 +961,26 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient *iface,
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mode == AUDCLNT_SHAREMODE_EXCLUSIVE && flags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK){
|
if(mode == AUDCLNT_SHAREMODE_SHARED){
|
||||||
FIXME("EXCLUSIVE mode with EVENTCALLBACK\n");
|
period = DefaultPeriod;
|
||||||
return AUDCLNT_E_DEVICE_IN_USE;
|
if( duration < 3 * period)
|
||||||
|
duration = 3 * period;
|
||||||
|
}else{
|
||||||
|
if(!period)
|
||||||
|
period = DefaultPeriod; /* not minimum */
|
||||||
|
if(period < MinimumPeriod || period > 5000000)
|
||||||
|
return AUDCLNT_E_INVALID_DEVICE_PERIOD;
|
||||||
|
if(duration > 20000000) /* the smaller the period, the lower this limit */
|
||||||
|
return AUDCLNT_E_BUFFER_SIZE_ERROR;
|
||||||
|
if(flags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK){
|
||||||
|
if(duration != period)
|
||||||
|
return AUDCLNT_E_BUFDURATION_PERIOD_NOT_EQUAL;
|
||||||
|
FIXME("EXCLUSIVE mode with EVENTCALLBACK\n");
|
||||||
|
return AUDCLNT_E_DEVICE_IN_USE;
|
||||||
|
}else{
|
||||||
|
if( duration < 8 * period)
|
||||||
|
duration = 8 * period; /* may grow above 2s */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OSSpinLockLock(&This->lock);
|
OSSpinLockLock(&This->lock);
|
||||||
|
@ -987,15 +1004,8 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient *iface,
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(period){
|
This->period_ms = period / 10000;
|
||||||
This->period_ms = period / 10000;
|
|
||||||
if(This->period_ms == 0)
|
|
||||||
This->period_ms = 1;
|
|
||||||
}else
|
|
||||||
This->period_ms = MinimumPeriod / 10000;
|
|
||||||
|
|
||||||
if(!duration)
|
|
||||||
duration = 300000; /* 0.03s */
|
|
||||||
This->bufsize_frames = ceil(fmt->nSamplesPerSec * (duration / 10000000.));
|
This->bufsize_frames = ceil(fmt->nSamplesPerSec * (duration / 10000000.));
|
||||||
|
|
||||||
if(This->dataflow == eCapture){
|
if(This->dataflow == eCapture){
|
||||||
|
|
|
@ -906,9 +906,26 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient *iface,
|
||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mode == AUDCLNT_SHAREMODE_EXCLUSIVE && flags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK){
|
if(mode == AUDCLNT_SHAREMODE_SHARED){
|
||||||
FIXME("EXCLUSIVE mode with EVENTCALLBACK\n");
|
period = DefaultPeriod;
|
||||||
return AUDCLNT_E_DEVICE_IN_USE;
|
if( duration < 3 * period)
|
||||||
|
duration = 3 * period;
|
||||||
|
}else{
|
||||||
|
if(!period)
|
||||||
|
period = DefaultPeriod; /* not minimum */
|
||||||
|
if(period < MinimumPeriod || period > 5000000)
|
||||||
|
return AUDCLNT_E_INVALID_DEVICE_PERIOD;
|
||||||
|
if(duration > 20000000) /* the smaller the period, the lower this limit */
|
||||||
|
return AUDCLNT_E_BUFFER_SIZE_ERROR;
|
||||||
|
if(flags & AUDCLNT_STREAMFLAGS_EVENTCALLBACK){
|
||||||
|
if(duration != period)
|
||||||
|
return AUDCLNT_E_BUFDURATION_PERIOD_NOT_EQUAL;
|
||||||
|
FIXME("EXCLUSIVE mode with EVENTCALLBACK\n");
|
||||||
|
return AUDCLNT_E_DEVICE_IN_USE;
|
||||||
|
}else{
|
||||||
|
if( duration < 8 * period)
|
||||||
|
duration = 8 * period; /* may grow above 2s */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EnterCriticalSection(&This->lock);
|
EnterCriticalSection(&This->lock);
|
||||||
|
@ -937,13 +954,8 @@ static HRESULT WINAPI AudioClient_Initialize(IAudioClient *iface,
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(period)
|
This->period_us = period / 10;
|
||||||
This->period_us = period / 10;
|
|
||||||
else
|
|
||||||
This->period_us = DefaultPeriod / 10;
|
|
||||||
|
|
||||||
if(!duration)
|
|
||||||
duration = 300000; /* 0.03s */
|
|
||||||
This->bufsize_frames = ceil(fmt->nSamplesPerSec * (duration / 10000000.));
|
This->bufsize_frames = ceil(fmt->nSamplesPerSec * (duration / 10000000.));
|
||||||
This->local_buffer = HeapAlloc(GetProcessHeap(), 0,
|
This->local_buffer = HeapAlloc(GetProcessHeap(), 0,
|
||||||
This->bufsize_frames * fmt->nBlockAlign);
|
This->bufsize_frames * fmt->nBlockAlign);
|
||||||
|
|
Loading…
Reference in a new issue