diff options
author | Chris Robinson <[email protected]> | 2019-04-26 15:58:25 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-04-26 15:58:25 -0700 |
commit | f23ff0394d8ae58dc12f8d1076fe5cd9dfde383d (patch) | |
tree | 6ab98ccc85c76eb77bf8c533cdaae179fb0b6bd4 /Alc/backends/sndio.cpp | |
parent | 348e01dc4bc16ac4543d54b722fb46dbdebcb1e3 (diff) |
Specify the buffer size as itself instead of the period count
Certain backends don't need a buffer size to be a strict multiple of the period
count, which allows a little more flexibility. The period/update size simply
acts as the minimum request, which helps control CPU load by determining how
often parameter and other pre-mixing updates are processed.
Diffstat (limited to 'Alc/backends/sndio.cpp')
-rw-r--r-- | Alc/backends/sndio.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/Alc/backends/sndio.cpp b/Alc/backends/sndio.cpp index 1b869fe7..163dd2ff 100644 --- a/Alc/backends/sndio.cpp +++ b/Alc/backends/sndio.cpp @@ -164,7 +164,7 @@ ALCboolean SndioPlayback::reset() par.le = SIO_LE_NATIVE; par.round = mDevice->UpdateSize; - par.appbufsz = mDevice->UpdateSize * (mDevice->NumUpdates-1); + par.appbufsz = mDevice->BufferSize - mDevice->UpdateSize; if(!par.appbufsz) par.appbufsz = mDevice->UpdateSize; if(!sio_setpar(mSndHandle, &par) || !sio_getpar(mSndHandle, &par)) @@ -203,7 +203,7 @@ ALCboolean SndioPlayback::reset() SetDefaultChannelOrder(mDevice); mDevice->UpdateSize = par.round; - mDevice->NumUpdates = (par.bufsz/par.round) + 1; + mDevice->BufferSize = par.bufsz + par.round; mBuffer.resize(mDevice->UpdateSize * mDevice->frameSizeFromFmt()); std::fill(mBuffer.begin(), mBuffer.end(), 0); @@ -374,12 +374,11 @@ ALCenum SndioCapture::open(const ALCchar *name) par.rchan = mDevice->channelsFromFmt(); par.rate = mDevice->Frequency; - par.appbufsz = maxu(mDevice->UpdateSize*mDevice->NumUpdates, (mDevice->Frequency+9)/10); - par.round = clampu(par.appbufsz/mDevice->NumUpdates, (mDevice->Frequency+99)/100, - (mDevice->Frequency+19)/20); + par.appbufsz = maxu(mDevice->BufferSize, mDevice->Frequency/10); + par.round = minu(par.appbufsz, mDevice->Frequency/40); mDevice->UpdateSize = par.round; - mDevice->NumUpdates = maxu(par.appbufsz/par.round, 1); + mDevice->BufferSize = par.appbufsz; if(!sio_setpar(mSndHandle, &par) || !sio_getpar(mSndHandle, &par)) { @@ -408,11 +407,10 @@ ALCenum SndioCapture::open(const ALCchar *name) return ALC_INVALID_VALUE; } - mRing = CreateRingBuffer(mDevice->UpdateSize*mDevice->NumUpdates, par.bps*par.rchan, false); + mRing = CreateRingBuffer(mDevice->BufferSize, par.bps*par.rchan, false); if(!mRing) { - ERR("Failed to allocate %u-byte ringbuffer\n", - mDevice->UpdateSize*mDevice->NumUpdates*par.bps*par.rchan); + ERR("Failed to allocate %u-byte ringbuffer\n", mDevice->BufferSize*par.bps*par.rchan); return ALC_OUT_OF_MEMORY; } |