winealsa: Fix return value checking in wavein.
This commit is contained in:
parent
02e1ce0a42
commit
9fb2cacd64
|
@ -162,7 +162,7 @@ static DWORD CALLBACK widRecorder(LPVOID pmt)
|
||||||
/* make sleep time to be # of ms to output a period */
|
/* make sleep time to be # of ms to output a period */
|
||||||
dwSleepTime = (wwi->dwPeriodSize * 1000) / wwi->format.Format.nAvgBytesPerSec;
|
dwSleepTime = (wwi->dwPeriodSize * 1000) / wwi->format.Format.nAvgBytesPerSec;
|
||||||
frames_per_period = snd_pcm_bytes_to_frames(wwi->pcm, wwi->dwPeriodSize);
|
frames_per_period = snd_pcm_bytes_to_frames(wwi->pcm, wwi->dwPeriodSize);
|
||||||
TRACE("sleeptime=%d ms\n", dwSleepTime);
|
TRACE("sleeptime=%d ms, total buffer length=%d ms (%d bytes)\n", dwSleepTime, wwi->dwBufferSize * 1000 / wwi->format.Format.nAvgBytesPerSec, wwi->dwBufferSize);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
/* wait for dwSleepTime or an event in thread's queue */
|
/* wait for dwSleepTime or an event in thread's queue */
|
||||||
|
@ -180,6 +180,7 @@ static DWORD CALLBACK widRecorder(LPVOID pmt)
|
||||||
/* read all the fragments accumulated so far */
|
/* read all the fragments accumulated so far */
|
||||||
frames = snd_pcm_avail_update(wwi->pcm);
|
frames = snd_pcm_avail_update(wwi->pcm);
|
||||||
bytes = snd_pcm_frames_to_bytes(wwi->pcm, frames);
|
bytes = snd_pcm_frames_to_bytes(wwi->pcm, frames);
|
||||||
|
|
||||||
TRACE("frames = %d bytes = %d\n", frames, bytes);
|
TRACE("frames = %d bytes = %d\n", frames, bytes);
|
||||||
periods = bytes / wwi->dwPeriodSize;
|
periods = bytes / wwi->dwPeriodSize;
|
||||||
while ((periods > 0) && (wwi->lpQueuePtr))
|
while ((periods > 0) && (wwi->lpQueuePtr))
|
||||||
|
@ -194,7 +195,7 @@ static DWORD CALLBACK widRecorder(LPVOID pmt)
|
||||||
bytesRead = snd_pcm_frames_to_bytes(wwi->pcm, read);
|
bytesRead = snd_pcm_frames_to_bytes(wwi->pcm, read);
|
||||||
|
|
||||||
TRACE("bytesRead=%d (direct)\n", bytesRead);
|
TRACE("bytesRead=%d (direct)\n", bytesRead);
|
||||||
if (bytesRead != (DWORD) -1)
|
if (read != (DWORD) -1)
|
||||||
{
|
{
|
||||||
/* update number of bytes recorded in current buffer and by this device */
|
/* update number of bytes recorded in current buffer and by this device */
|
||||||
lpWaveHdr->dwBytesRecorded += bytesRead;
|
lpWaveHdr->dwBytesRecorded += bytesRead;
|
||||||
|
@ -216,9 +217,9 @@ static DWORD CALLBACK widRecorder(LPVOID pmt)
|
||||||
lpWaveHdr = lpNext;
|
lpWaveHdr = lpNext;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
TRACE("read(%s, %p, %d) failed (%s)\n", wwi->pcmname,
|
FIXME("read(%s, %p, %d) failed (%s)\n", wwi->pcmname,
|
||||||
lpWaveHdr->lpData + lpWaveHdr->dwBytesRecorded,
|
lpWaveHdr->lpData + lpWaveHdr->dwBytesRecorded,
|
||||||
frames_per_period, strerror(errno));
|
frames_per_period, snd_strerror(read));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -230,14 +231,14 @@ static DWORD CALLBACK widRecorder(LPVOID pmt)
|
||||||
|
|
||||||
TRACE("bytesRead=%d (local)\n", bytesRead);
|
TRACE("bytesRead=%d (local)\n", bytesRead);
|
||||||
|
|
||||||
if (bytesRead == (DWORD) -1) {
|
if (read == (DWORD) -1) {
|
||||||
TRACE("read(%s, %p, %d) failed (%s)\n", wwi->pcmname,
|
TRACE("read(%s, %p, %d) failed (%s)\n", wwi->pcmname,
|
||||||
buffer, frames_per_period, strerror(errno));
|
buffer, frames_per_period, strerror(errno));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* copy data in client buffers */
|
/* copy data in client buffers */
|
||||||
while (bytesRead != (DWORD) -1 && bytesRead > 0)
|
while (read != (DWORD) -1 && bytesRead > 0)
|
||||||
{
|
{
|
||||||
DWORD dwToCopy = min (bytesRead, lpWaveHdr->dwBufferLength - lpWaveHdr->dwBytesRecorded);
|
DWORD dwToCopy = min (bytesRead, lpWaveHdr->dwBufferLength - lpWaveHdr->dwBytesRecorded);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue