summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2009-05-25 12:12:37 -0700
committerChris Robinson <[email protected]>2009-05-25 12:12:37 -0700
commit93fbdb1e6cad97cd7e4a04a57eb1030cc0523478 (patch)
treeed5dc524d01498625098b3f6596ad654b6dbabfa
parentc1de15f84062464db089d895cf17f75ae8faff69 (diff)
Redo OSS mixing loop
-rw-r--r--Alc/oss.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/Alc/oss.c b/Alc/oss.c
index b1ec7887..93df6ae2 100644
--- a/Alc/oss.c
+++ b/Alc/oss.c
@@ -79,35 +79,35 @@ static ALuint OSSProc(ALvoid *ptr)
{
ALCdevice *pDevice = (ALCdevice*)ptr;
oss_data *data = (oss_data*)pDevice->ExtraData;
- int remaining = 0;
int wrote;
while(!data->killNow)
{
- int len = data->data_size - remaining;
+ ALint len = data->data_size;
+ ALubyte *WritePtr = data->mix_data;
- if(len > 0)
- {
- SuspendContext(NULL);
- aluMixData(pDevice->Context, data->mix_data+remaining, len, pDevice->Format);
- ProcessContext(NULL);
- }
+ SuspendContext(NULL);
+ aluMixData(pDevice->Context, WritePtr, len, pDevice->Format);
+ ProcessContext(NULL);
- remaining += len;
- wrote = write(data->fd, data->mix_data, remaining);
- if(wrote < 0)
+ while(len > 0 && !data->killNow)
{
- AL_PRINT("write failed: %s\n", strerror(errno));
- remaining = 0;
+ wrote = write(data->fd, WritePtr, len);
+ if(wrote < 0)
+ {
+ if(errno != EAGAIN && errno != EWOULDBLOCK)
+ {
+ AL_PRINT("write failed: %s\n", strerror(errno));
+ len = 0;
+ }
+ else
+ Sleep(1);
+ continue;
+ }
+
+ len -= wrote;
+ WritePtr += wrote;
}
- else if(wrote > 0)
- {
- remaining -= wrote;
- if(remaining > 0)
- memmove(data->mix_data, data->mix_data+wrote, remaining);
- }
- else
- Sleep(1);
}
return 0;