diff options
author | Chris Robinson <[email protected]> | 2016-01-25 01:49:28 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2016-01-25 01:49:28 -0800 |
commit | 79e0f3e747880a3e7d8342a8602b796b84c0f322 (patch) | |
tree | 23bdb739831550e48d8b805a821e2cde295948e7 /Alc/backends/wave.c | |
parent | 0189b923a233e269b4c8f9d17f6475ace5e2e4de (diff) |
Don't write one byte at a time for the wave writer on big endian
Diffstat (limited to 'Alc/backends/wave.c')
-rw-r--r-- | Alc/backends/wave.c | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/Alc/backends/wave.c b/Alc/backends/wave.c index d54e21eb..3b87d645 100644 --- a/Alc/backends/wave.c +++ b/Alc/backends/wave.c @@ -163,31 +163,33 @@ static int ALCwaveBackend_mixerProc(void *ptr) if(!IS_LITTLE_ENDIAN) { ALuint bytesize = BytesFromDevFmt(device->FmtType); - ALubyte *bytes = self->mBuffer; ALuint i; - if(bytesize == 1) + if(bytesize == 2) { - for(i = 0;i < self->mSize;i++) - fputc(bytes[i], self->mFile); - } - else if(bytesize == 2) - { - for(i = 0;i < self->mSize;i++) - fputc(bytes[i^1], self->mFile); + ALushort *samples = self->mBuffer; + ALuint len = self->mSize / 2; + for(i = 0;i < len;i++) + { + ALushort samp = samples[i]; + samples[i] = (samp>>8) | (samp<<8); + } } else if(bytesize == 4) { - for(i = 0;i < self->mSize;i++) - fputc(bytes[i^3], self->mFile); + ALuint *samples = self->mBuffer; + ALuint len = self->mSize / 4; + for(i = 0;i < len;i++) + { + ALuint samp = samples[i]; + samples[i] = (samp>>24) | ((samp>>8)&0x0000ff00) | + ((samp<<8)&0x00ff0000) | (samp<<24); + } } } - else - { - fs = fwrite(self->mBuffer, frameSize, device->UpdateSize, - self->mFile); - (void)fs; - } + + fs = fwrite(self->mBuffer, frameSize, device->UpdateSize, self->mFile); + (void)fs; if(ferror(self->mFile)) { ERR("Error writing to file\n"); |