aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-08-12 15:42:36 -0700
committerChris Robinson <[email protected]>2011-08-12 15:42:36 -0700
commit412cec73de3e127bbfba9f91c9586089217621df (patch)
tree42b6eac24a079727728add68800df5c7badcc07e
parenta72c0f7470ff76c363810cfaf2a3fd6282cd8cc2 (diff)
Avoid a temporary throw-away buffer for mixing null output
-rw-r--r--Alc/ALu.c35
-rw-r--r--Alc/null.c20
2 files changed, 20 insertions, 35 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index 1ba71129..fd9b5334 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -1101,23 +1101,26 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size)
}
}
- switch(device->FmtType)
+ if(buffer)
{
- case DevFmtByte:
- Write_ALbyte(device, buffer, SamplesToDo);
- break;
- case DevFmtUByte:
- Write_ALubyte(device, buffer, SamplesToDo);
- break;
- case DevFmtShort:
- Write_ALshort(device, buffer, SamplesToDo);
- break;
- case DevFmtUShort:
- Write_ALushort(device, buffer, SamplesToDo);
- break;
- case DevFmtFloat:
- Write_ALfloat(device, buffer, SamplesToDo);
- break;
+ switch(device->FmtType)
+ {
+ case DevFmtByte:
+ Write_ALbyte(device, buffer, SamplesToDo);
+ break;
+ case DevFmtUByte:
+ Write_ALubyte(device, buffer, SamplesToDo);
+ break;
+ case DevFmtShort:
+ Write_ALshort(device, buffer, SamplesToDo);
+ break;
+ case DevFmtUShort:
+ Write_ALushort(device, buffer, SamplesToDo);
+ break;
+ case DevFmtFloat:
+ Write_ALfloat(device, buffer, SamplesToDo);
+ break;
+ }
}
size -= SamplesToDo;
diff --git a/Alc/null.c b/Alc/null.c
index 1a3072e8..1f83df34 100644
--- a/Alc/null.c
+++ b/Alc/null.c
@@ -27,9 +27,6 @@
typedef struct {
- ALvoid *buffer;
- ALuint size;
-
volatile int killNow;
ALvoid *thread;
} null_data;
@@ -68,7 +65,7 @@ static ALuint NullProc(ALvoid *ptr)
while(avail-done >= Device->UpdateSize)
{
- aluMixData(Device, data->buffer, Device->UpdateSize);
+ aluMixData(Device, NULL, Device->UpdateSize);
done += Device->UpdateSize;
}
}
@@ -104,23 +101,11 @@ static ALCboolean null_reset_playback(ALCdevice *device)
{
null_data *data = (null_data*)device->ExtraData;
- data->size = device->UpdateSize * FrameSizeFromDevFmt(device->FmtChans,
- device->FmtType);
- data->buffer = malloc(data->size);
- if(!data->buffer)
- {
- ERR("Buffer malloc failed\n");
- return ALC_FALSE;
- }
SetDefaultWFXChannelOrder(device);
data->thread = StartThread(NullProc, device);
if(data->thread == NULL)
- {
- free(data->buffer);
- data->buffer = NULL;
return ALC_FALSE;
- }
return ALC_TRUE;
}
@@ -137,9 +122,6 @@ static void null_stop_playback(ALCdevice *device)
data->thread = NULL;
data->killNow = 0;
-
- free(data->buffer);
- data->buffer = NULL;
}