diff options
author | Chris Robinson <[email protected]> | 2014-11-23 23:45:30 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2014-11-23 23:45:30 -0800 |
commit | 2111fad92fb6c4ab5cea91a43d543a6f9680e8ed (patch) | |
tree | 26c42281817f8a550c7c2996102d9bba1b9eb88b /Alc | |
parent | 391ab19b028220da6563beceec2fe2261661951c (diff) |
Use a macro to reduce code duplication
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/ALu.c | 26 |
1 files changed, 12 insertions, 14 deletions
@@ -1290,37 +1290,35 @@ ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size) if(buffer) { +#define WRITE(T, a, b, c, d) do { \ + Write_##T((a), (b), (c), (d)); \ + buffer = (char*)buffer + (c)*(d)*sizeof(T); \ +} while(0) switch(device->FmtType) { case DevFmtByte: - Write_ALbyte(&device->DryBuffer[outchanoffset], buffer, SamplesToDo, outchancount); - buffer = (char*)buffer + SamplesToDo*outchancount*sizeof(ALbyte); + WRITE(ALbyte, device->DryBuffer+outchanoffset, buffer, SamplesToDo, outchancount); break; case DevFmtUByte: - Write_ALubyte(&device->DryBuffer[outchanoffset], buffer, SamplesToDo, outchancount); - buffer = (char*)buffer + SamplesToDo*outchancount*sizeof(ALubyte); + WRITE(ALubyte, device->DryBuffer+outchanoffset, buffer, SamplesToDo, outchancount); break; case DevFmtShort: - Write_ALshort(&device->DryBuffer[outchanoffset], buffer, SamplesToDo, outchancount); - buffer = (char*)buffer + SamplesToDo*outchancount*sizeof(ALshort); + WRITE(ALshort, device->DryBuffer+outchanoffset, buffer, SamplesToDo, outchancount); break; case DevFmtUShort: - Write_ALushort(&device->DryBuffer[outchanoffset], buffer, SamplesToDo, outchancount); - buffer = (char*)buffer + SamplesToDo*outchancount*sizeof(ALushort); + WRITE(ALushort, device->DryBuffer+outchanoffset, buffer, SamplesToDo, outchancount); break; case DevFmtInt: - Write_ALint(&device->DryBuffer[outchanoffset], buffer, SamplesToDo, outchancount); - buffer = (char*)buffer + SamplesToDo*outchancount*sizeof(ALint); + WRITE(ALint, device->DryBuffer+outchanoffset, buffer, SamplesToDo, outchancount); break; case DevFmtUInt: - Write_ALuint(&device->DryBuffer[outchanoffset], buffer, SamplesToDo, outchancount); - buffer = (char*)buffer + SamplesToDo*outchancount*sizeof(ALuint); + WRITE(ALuint, device->DryBuffer+outchanoffset, buffer, SamplesToDo, outchancount); break; case DevFmtFloat: - Write_ALfloat(&device->DryBuffer[outchanoffset], buffer, SamplesToDo, outchancount); - buffer = (char*)buffer + SamplesToDo*outchancount*sizeof(ALfloat); + WRITE(ALfloat, device->DryBuffer+outchanoffset, buffer, SamplesToDo, outchancount); break; } +#undef WRITE } size -= SamplesToDo; |