diff options
author | Chris Robinson <[email protected]> | 2009-09-12 19:36:16 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2009-09-12 19:36:16 -0700 |
commit | 396f2d6050cc519ab3c5292a8ad62bedad913c62 (patch) | |
tree | 8705ad2f67247504f343b221a3a4c178bb8520dd /Alc | |
parent | e25b01c3a2b7e7b3b419c376e63ccae172c268bc (diff) |
Mix the proper size for every update, and notify disconnects
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/wave.c | 17 |
1 files changed, 8 insertions, 9 deletions
@@ -49,7 +49,6 @@ static ALuint WaveProc(ALvoid *ptr) wave_data *data = (wave_data*)pDevice->ExtraData; ALuint frameSize; ALuint now, last; - size_t WriteCnt; size_t fs; ALuint avail; union { @@ -62,7 +61,7 @@ static ALuint WaveProc(ALvoid *ptr) aluChannelsFromFormat(pDevice->Format); last = timeGetTime(); - while(!data->killNow) + while(!data->killNow && pDevice->Connected) { now = timeGetTime(); @@ -73,11 +72,10 @@ static ALuint WaveProc(ALvoid *ptr) continue; } - while(avail > 0) + while(avail >= pDevice->UpdateSize) { SuspendContext(NULL); - WriteCnt = min(data->size, avail); - aluMixData(pDevice->Context, data->buffer, WriteCnt * frameSize, + aluMixData(pDevice->Context, data->buffer, data->size, pDevice->Format); ProcessContext(NULL); @@ -86,19 +84,20 @@ static ALuint WaveProc(ALvoid *ptr) ALubyte *bytes = data->buffer; ALuint i; - for(i = 0;i < WriteCnt*frameSize;i++) + for(i = 0;i < data->size;i++) fputc(bytes[i^1], data->f); } else - fs = fwrite(data->buffer, frameSize, WriteCnt, data->f); + fs = fwrite(data->buffer, frameSize, pDevice->UpdateSize, + data->f); if(ferror(data->f)) { AL_PRINT("Error writing to file\n"); - data->killNow = 1; + aluHandleDisconnect(pDevice); break; } - avail -= WriteCnt; + avail -= pDevice->UpdateSize; } last = now; } |