aboutsummaryrefslogtreecommitdiffstats
path: root/Alc/solaris.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2009-08-26 21:49:38 -0700
committerChris Robinson <[email protected]>2009-08-26 21:49:38 -0700
commit06c576a94591df6672c90ec40cb5941e4fcce756 (patch)
treecf69c632debe1f5b569ef3b69cf1c2f29aac005a /Alc/solaris.c
parent929b025fd617aa7634cd24045911c589c935d0fa (diff)
Support disconnect for OSS and Solaris
Diffstat (limited to 'Alc/solaris.c')
-rw-r--r--Alc/solaris.c44
1 files changed, 23 insertions, 21 deletions
diff --git a/Alc/solaris.c b/Alc/solaris.c
index 2ed8cc5e..267a27a0 100644
--- a/Alc/solaris.c
+++ b/Alc/solaris.c
@@ -56,32 +56,34 @@ static ALuint SolarisProc(ALvoid *ptr)
int remaining = 0;
int wrote;
- while(!data->killNow)
+ while(!data->killNow && !pDevice->Connected)
{
- 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)
- {
- AL_PRINT("write failed: %s\n", strerror(errno));
- remaining = 0;
- }
- else if(wrote > 0)
+ while(len > 0 && !data->killNow)
{
- remaining -= wrote;
- if(remaining > 0)
- memmove(data->mix_data, data->mix_data+wrote, remaining);
+ wrote = write(data->fd, WritePtr, len);
+ if(wrote < 0)
+ {
+ if(errno != EAGAIN && errno != EWOULDBLOCK)
+ {
+ AL_PRINT("write failed: %s\n", strerror(errno));
+ aluHandleDisconnect(pDevice);
+ len = 0;
+ }
+ else
+ Sleep(1);
+ continue;
+ }
+
+ len -= wrote;
+ WritePtr += wrote;
}
- else
- Sleep(1);
}
return 0;