wasapi: fixed capturing callback not called if paWinWasapiPolling flag specified, or WOW64 workaround is used, same bug was causing div/0 crash
This commit is contained in:
parent
89406b53db
commit
15aeb7c1c0
1 changed files with 40 additions and 30 deletions
|
|
@ -504,6 +504,8 @@ static UINT32 AlignFramesPerBuffer(UINT32 nFrames, UINT32 nSamplesPerSec, UINT32
|
||||||
// ------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------
|
||||||
static __forceinline UINT32 GetFramesSleepTime(UINT32 nFrames, UINT32 nSamplesPerSec)
|
static __forceinline UINT32 GetFramesSleepTime(UINT32 nFrames, UINT32 nSamplesPerSec)
|
||||||
{
|
{
|
||||||
|
if (nSamplesPerSec == 0)
|
||||||
|
return 0;
|
||||||
#define REFTIMES_PER_SEC 10000000
|
#define REFTIMES_PER_SEC 10000000
|
||||||
#define REFTIMES_PER_MILLISEC 10000
|
#define REFTIMES_PER_MILLISEC 10000
|
||||||
// Calculate the actual duration of the allocated buffer.
|
// Calculate the actual duration of the allocated buffer.
|
||||||
|
|
@ -2833,7 +2835,6 @@ PA_THREAD_FUNC ProcThreadEvent(void *param)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Boost thread priority
|
// Boost thread priority
|
||||||
stream->hAvTask = NULL;
|
|
||||||
PaWasapi_ThreadPriorityBoost((void **)&stream->hAvTask, stream->nThreadPriority);
|
PaWasapi_ThreadPriorityBoost((void **)&stream->hAvTask, stream->nThreadPriority);
|
||||||
|
|
||||||
// Initialize event & start INPUT stream
|
// Initialize event & start INPUT stream
|
||||||
|
|
@ -2927,12 +2928,19 @@ PA_THREAD_FUNC ProcThreadPoll(void *param)
|
||||||
{
|
{
|
||||||
PaWasapiHostProcessor processor[S_COUNT];
|
PaWasapiHostProcessor processor[S_COUNT];
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
DWORD dwResult = S_OUTPUT;
|
|
||||||
BOOL bInitOutput = FALSE;
|
BOOL bInitOutput = FALSE;
|
||||||
PaWasapiStream *stream = (PaWasapiStream *)param;
|
PaWasapiStream *stream = (PaWasapiStream *)param;
|
||||||
|
|
||||||
// Calculate the actual duration of the allocated buffer.
|
// Calculate the actual duration of the allocated buffer.
|
||||||
DWORD sleep_ms = GetFramesSleepTime(stream->out.framesPerHostCallback, stream->out.wavex.Format.nSamplesPerSec);
|
DWORD sleep_ms = 0;
|
||||||
|
DWORD sleep_ms_in = GetFramesSleepTime(stream->in.framesPerHostCallback, stream->in.wavex.Format.nSamplesPerSec);
|
||||||
|
DWORD sleep_ms_out = GetFramesSleepTime(stream->out.framesPerHostCallback, stream->out.wavex.Format.nSamplesPerSec);
|
||||||
|
if ((sleep_ms_in != 0) && (sleep_ms_out != 0))
|
||||||
|
sleep_ms = min(sleep_ms_in, sleep_ms_out);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sleep_ms = (sleep_ms_in ? sleep_ms_in : sleep_ms_out);
|
||||||
|
}
|
||||||
|
|
||||||
// Setup data processors
|
// Setup data processors
|
||||||
PaWasapiHostProcessor defaultProcessor;
|
PaWasapiHostProcessor defaultProcessor;
|
||||||
|
|
@ -2942,7 +2950,6 @@ PA_THREAD_FUNC ProcThreadPoll(void *param)
|
||||||
processor[S_OUTPUT] = (stream->hostProcessOverrideOutput.processor != NULL ? stream->hostProcessOverrideOutput : defaultProcessor);
|
processor[S_OUTPUT] = (stream->hostProcessOverrideOutput.processor != NULL ? stream->hostProcessOverrideOutput : defaultProcessor);
|
||||||
|
|
||||||
// Boost thread priority
|
// Boost thread priority
|
||||||
stream->hAvTask = NULL;
|
|
||||||
PaWasapi_ThreadPriorityBoost((void **)&stream->hAvTask, stream->nThreadPriority);
|
PaWasapi_ThreadPriorityBoost((void **)&stream->hAvTask, stream->nThreadPriority);
|
||||||
|
|
||||||
// Initialize event & start INPUT stream
|
// Initialize event & start INPUT stream
|
||||||
|
|
@ -2976,9 +2983,11 @@ PA_THREAD_FUNC ProcThreadPoll(void *param)
|
||||||
|
|
||||||
// Processing Loop
|
// Processing Loop
|
||||||
while (WaitForSingleObject(stream->hCloseRequest, sleep_ms) == WAIT_TIMEOUT)
|
while (WaitForSingleObject(stream->hCloseRequest, sleep_ms) == WAIT_TIMEOUT)
|
||||||
|
{
|
||||||
|
for (INT32 i = 0; i < S_COUNT; ++i)
|
||||||
{
|
{
|
||||||
// Process S_INPUT/S_OUTPUT
|
// Process S_INPUT/S_OUTPUT
|
||||||
switch (dwResult)
|
switch (i)
|
||||||
{
|
{
|
||||||
// Input stream
|
// Input stream
|
||||||
case S_INPUT: {
|
case S_INPUT: {
|
||||||
|
|
@ -3012,6 +3021,7 @@ PA_THREAD_FUNC ProcThreadPoll(void *param)
|
||||||
break; }
|
break; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Process stop
|
// Process stop
|
||||||
_OnStreamStop(stream);
|
_OnStreamStop(stream);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue