aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2008-01-06 00:19:28 -0800
committerChris Robinson <[email protected]>2008-01-06 00:19:28 -0800
commitda3b27048886add6fb3101cf34f8b8ab165d51f7 (patch)
tree5c3604b2ae09ff9bfd5190ea720976bd8299f9ae
parentdd60366aecf6721775eba007465f78c36e17dd5c (diff)
Make OSS's update size dynamic
-rw-r--r--Alc/oss.c38
1 files changed, 21 insertions, 17 deletions
diff --git a/Alc/oss.c b/Alc/oss.c
index a5c2fef4..6229fc09 100644
--- a/Alc/oss.c
+++ b/Alc/oss.c
@@ -78,31 +78,35 @@ static ALuint OSSProc(ALvoid *ptr)
{
ALCdevice *pDevice = (ALCdevice*)ptr;
oss_data *data = (oss_data*)pDevice->ExtraData;
- int remaining;
+ int remaining = 0;
int wrote;
while(!data->killNow)
{
- SuspendContext(NULL);
- aluMixData(pDevice->Context,data->mix_data,data->data_size,pDevice->Format);
- ProcessContext(NULL);
+ int len = data->data_size - remaining;
- remaining = data->data_size;
- while(remaining > 0)
+ if(len > 0)
+ {
+ SuspendContext(NULL);
+ aluMixData(pDevice->Context, data->mix_data+remaining, 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)
{
- wrote = write(data->fd, data->mix_data+data->data_size-remaining, remaining);
- if(wrote < 0)
- {
- AL_PRINT("write failed: %s\n", strerror(errno));
- break;
- }
- if(wrote == 0)
- {
- usleep(1000);
- continue;
- }
remaining -= wrote;
+ if(remaining > 0)
+ memmove(data->mix_data, data->mix_data+wrote, remaining);
}
+ else
+ usleep(1000);
}
return 0;