aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/oss.c4
-rw-r--r--Alc/solaris.c44
2 files changed, 26 insertions, 22 deletions
diff --git a/Alc/oss.c b/Alc/oss.c
index 83f8fe55..76455f58 100644
--- a/Alc/oss.c
+++ b/Alc/oss.c
@@ -81,7 +81,7 @@ static ALuint OSSProc(ALvoid *ptr)
oss_data *data = (oss_data*)pDevice->ExtraData;
int wrote;
- while(!data->killNow)
+ while(!data->killNow && !pDevice->Connected)
{
ALint len = data->data_size;
ALubyte *WritePtr = data->mix_data;
@@ -98,6 +98,7 @@ static ALuint OSSProc(ALvoid *ptr)
if(errno != EAGAIN && errno != EWOULDBLOCK)
{
AL_PRINT("write failed: %s\n", strerror(errno));
+ aluHandleDisconnect(pDevice);
len = 0;
}
else
@@ -129,6 +130,7 @@ static ALuint OSSCaptureProc(ALvoid *ptr)
if(amt < 0)
{
AL_PRINT("read failed: %s\n", strerror(errno));
+ aluHandleDisconnect(pDevice);
break;
}
if(amt == 0)
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;