diff options
author | Chris Robinson <[email protected]> | 2020-08-07 06:17:12 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-08-07 06:22:39 -0700 |
commit | e8b3e82f96d28d725bc44f5a99d0b2646394019e (patch) | |
tree | 973ba706cce984ce19f274daf417c75727f1c407 | |
parent | 84354c792e17ff5df5edc8d7612dd5a2e4ae4f28 (diff) |
Change a couple functions into member functions
-rw-r--r-- | alc/alc.cpp | 10 | ||||
-rw-r--r-- | alc/alcmain.h | 5 | ||||
-rw-r--r-- | alc/alu.cpp | 55 | ||||
-rw-r--r-- | alc/alu.h | 5 | ||||
-rw-r--r-- | alc/backends/alsa.cpp | 16 | ||||
-rw-r--r-- | alc/backends/coreaudio.cpp | 2 | ||||
-rw-r--r-- | alc/backends/dsound.cpp | 14 | ||||
-rw-r--r-- | alc/backends/jack.cpp | 4 | ||||
-rw-r--r-- | alc/backends/null.cpp | 6 | ||||
-rw-r--r-- | alc/backends/oboe.cpp | 2 | ||||
-rw-r--r-- | alc/backends/opensl.cpp | 19 | ||||
-rw-r--r-- | alc/backends/oss.cpp | 12 | ||||
-rw-r--r-- | alc/backends/portaudio.cpp | 2 | ||||
-rw-r--r-- | alc/backends/pulseaudio.cpp | 12 | ||||
-rw-r--r-- | alc/backends/sdl2.cpp | 2 | ||||
-rw-r--r-- | alc/backends/sndio.cpp | 8 | ||||
-rw-r--r-- | alc/backends/solaris.cpp | 10 | ||||
-rw-r--r-- | alc/backends/wasapi.cpp | 12 | ||||
-rw-r--r-- | alc/backends/wave.cpp | 6 | ||||
-rw-r--r-- | alc/backends/winmm.cpp | 2 |
20 files changed, 97 insertions, 107 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp index 30d363af..e9405493 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -1935,7 +1935,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList) throw al::backend_exception{ALC_INVALID_DEVICE, "Device reset failure"}; } catch(std::exception &e) { - aluHandleDisconnect(device, "%s", e.what()); + device->handleDisconnect("%s", e.what()); return ALC_INVALID_DEVICE; } @@ -2256,7 +2256,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList) device->Flags.set<DeviceRunning>(); } catch(al::backend_exception& e) { - aluHandleDisconnect(device, "%s", e.what()); + device->handleDisconnect("%s", e.what()); return ALC_INVALID_DEVICE; } } @@ -3829,7 +3829,7 @@ START_API_FUNC dev->Flags.set<DeviceRunning>(); } catch(al::backend_exception& e) { - aluHandleDisconnect(dev.get(), "%s", e.what()); + dev->handleDisconnect("%s", e.what()); alcSetError(dev.get(), ALC_INVALID_DEVICE); } } @@ -3989,7 +3989,7 @@ START_API_FUNC else if(samples < 0 || (samples > 0 && buffer == nullptr)) alcSetError(dev.get(), ALC_INVALID_VALUE); else - aluMixData(dev.get(), buffer, static_cast<ALuint>(samples), dev->channelsFromFmt()); + dev->renderSamples(buffer, static_cast<ALuint>(samples), dev->channelsFromFmt()); } END_API_FUNC @@ -4040,7 +4040,7 @@ START_API_FUNC dev->Flags.set<DeviceRunning>(); } catch(al::backend_exception& e) { - aluHandleDisconnect(dev.get(), "%s", e.what()); + dev->handleDisconnect("%s", e.what()); alcSetError(dev.get(), ALC_INVALID_DEVICE); } } diff --git a/alc/alcmain.h b/alc/alcmain.h index 8d802d85..a5dc655b 100644 --- a/alc/alcmain.h +++ b/alc/alcmain.h @@ -351,6 +351,11 @@ struct ALCdevice : public al::intrusive_ref<ALCdevice> { inline void postProcess(const size_t SamplesToDo) { if LIKELY(PostProcess) (this->*PostProcess)(SamplesToDo); } + void renderSamples(void *outBuffer, const ALuint numSamples, const size_t frameStep); + + /* Caller must lock the device state, and the mixer must not be running. */ + [[gnu::format(printf,2,3)]] void handleDisconnect(const char *msg, ...); + DEF_NEWDEL(ALCdevice) }; diff --git a/alc/alu.cpp b/alc/alu.cpp index adc17877..a5172fb7 100644 --- a/alc/alu.cpp +++ b/alc/alu.cpp @@ -1921,65 +1921,61 @@ void Write(const al::span<const FloatBufferLine> InBuffer, void *OutBuffer, cons } // namespace -void aluMixData(ALCdevice *device, void *OutBuffer, const ALuint NumSamples, - const size_t FrameStep) +void ALCdevice::renderSamples(void *outBuffer, const ALuint numSamples, const size_t frameStep) { FPUCtl mixer_mode{}; - for(ALuint SamplesDone{0u};SamplesDone < NumSamples;) + for(ALuint written{0u};written < numSamples;) { - const ALuint SamplesToDo{minu(NumSamples-SamplesDone, BUFFERSIZE)}; + const ALuint samplesToDo{minu(numSamples-written, BUFFERSIZE)}; /* Clear main mixing buffers. */ - std::for_each(device->MixBuffer.begin(), device->MixBuffer.end(), - [](FloatBufferLine &buffer) -> void { buffer.fill(0.0f); }); + for(FloatBufferLine &buffer : MixBuffer) + buffer.fill(0.0f); /* Increment the mix count at the start (lsb should now be 1). */ - IncrementRef(device->MixCount); + IncrementRef(MixCount); /* Process and mix each context's sources and effects. */ - ProcessContexts(device, SamplesToDo); + ProcessContexts(this, samplesToDo); /* Increment the clock time. Every second's worth of samples is * converted and added to clock base so that large sample counts don't * overflow during conversion. This also guarantees a stable * conversion. */ - device->SamplesDone += SamplesToDo; - device->ClockBase += std::chrono::seconds{device->SamplesDone / device->Frequency}; - device->SamplesDone %= device->Frequency; + SamplesDone += samplesToDo; + ClockBase += std::chrono::seconds{SamplesDone / Frequency}; + SamplesDone %= Frequency; /* Increment the mix count at the end (lsb should now be 0). */ - IncrementRef(device->MixCount); + IncrementRef(MixCount); /* Apply any needed post-process for finalizing the Dry mix to the * RealOut (Ambisonic decode, UHJ encode, etc). */ - device->postProcess(SamplesToDo); - - const al::span<FloatBufferLine> RealOut{device->RealOut.Buffer}; + postProcess(samplesToDo); /* Apply compression, limiting sample amplitude if needed or desired. */ - if(Compressor *comp{device->Limiter.get()}) - comp->process(SamplesToDo, RealOut.data()); + if(Limiter) Limiter->process(samplesToDo, RealOut.Buffer.data()); /* Apply delays and attenuation for mismatched speaker distances. */ - ApplyDistanceComp(RealOut, SamplesToDo, device->ChannelDelay.as_span().cbegin()); + ApplyDistanceComp(RealOut.Buffer, samplesToDo, ChannelDelay.as_span().cbegin()); /* Apply dithering. The compressor should have left enough headroom for * the dither noise to not saturate. */ - if(device->DitherDepth > 0.0f) - ApplyDither(RealOut, &device->DitherSeed, device->DitherDepth, SamplesToDo); + if(DitherDepth > 0.0f) + ApplyDither(RealOut.Buffer, &DitherSeed, DitherDepth, samplesToDo); - if LIKELY(OutBuffer) + if LIKELY(outBuffer) { /* Finally, interleave and convert samples, writing to the device's * output buffer. */ - switch(device->FmtType) + switch(FmtType) { #define HANDLE_WRITE(T) case T: \ - Write<T>(RealOut, OutBuffer, SamplesDone, SamplesToDo, FrameStep); break; + Write<T>(RealOut.Buffer, outBuffer, written, samplesToDo, frameStep); break; HANDLE_WRITE(DevFmtByte) HANDLE_WRITE(DevFmtUByte) HANDLE_WRITE(DevFmtShort) @@ -1991,14 +1987,13 @@ void aluMixData(ALCdevice *device, void *OutBuffer, const ALuint NumSamples, } } - SamplesDone += SamplesToDo; + written += samplesToDo; } } - -void aluHandleDisconnect(ALCdevice *device, const char *msg, ...) +void ALCdevice::handleDisconnect(const char *msg, ...) { - if(!device->Connected.exchange(false, std::memory_order_acq_rel)) + if(!Connected.exchange(false, std::memory_order_acq_rel)) return; AsyncEvent evt{EventType_Disconnected}; @@ -2014,8 +2009,8 @@ void aluHandleDisconnect(ALCdevice *device, const char *msg, ...) if(msglen < 0 || static_cast<size_t>(msglen) >= sizeof(evt.u.user.msg)) evt.u.user.msg[sizeof(evt.u.user.msg)-1] = 0; - IncrementRef(device->MixCount); - for(ALCcontext *ctx : *device->mContexts.load()) + IncrementRef(MixCount); + for(ALCcontext *ctx : *mContexts.load()) { const ALbitfieldSOFT enabledevt{ctx->mEnabledEvts.load(std::memory_order_acquire)}; if((enabledevt&EventType_Disconnected)) @@ -2040,5 +2035,5 @@ void aluHandleDisconnect(ALCdevice *device, const char *msg, ...) }; std::for_each(voicelist.begin(), voicelist.end(), stop_voice); } - IncrementRef(device->MixCount); + IncrementRef(MixCount); } @@ -153,11 +153,6 @@ auto SetAmbiPanIdentity(T iter, I count, F func) -> std::enable_if_t<std::is_int } -void aluMixData(ALCdevice *device, void *OutBuffer, const ALuint NumSamples, - const size_t FrameStep); -/* Caller must lock the device state, and the mixer must not be running. */ -[[gnu::format(printf,2,3)]] void aluHandleDisconnect(ALCdevice *device, const char *msg, ...); - extern const float ConeScale; extern const float ZScale; diff --git a/alc/backends/alsa.cpp b/alc/backends/alsa.cpp index 2259c46c..20ed0e78 100644 --- a/alc/backends/alsa.cpp +++ b/alc/backends/alsa.cpp @@ -457,7 +457,7 @@ int AlsaPlayback::mixerProc() if(state < 0) { ERR("Invalid state detected: %s\n", snd_strerror(state)); - aluHandleDisconnect(mDevice, "Bad state: %s", snd_strerror(state)); + mDevice->handleDisconnect("Bad state: %s", snd_strerror(state)); break; } @@ -510,10 +510,10 @@ int AlsaPlayback::mixerProc() } char *WritePtr{static_cast<char*>(areas->addr) + (offset * areas->step / 8)}; - aluMixData(mDevice, WritePtr, static_cast<ALuint>(frames), areas->step / samplebits); + mDevice->renderSamples(WritePtr, static_cast<ALuint>(frames), areas->step/samplebits); snd_pcm_sframes_t commitres{snd_pcm_mmap_commit(mPcmHandle, offset, frames)}; - if(commitres < 0 || (static_cast<snd_pcm_uframes_t>(commitres)-frames) != 0) + if(commitres < 0 || static_cast<snd_pcm_uframes_t>(commitres) != frames) { ERR("mmap commit error: %s\n", snd_strerror(commitres >= 0 ? -EPIPE : static_cast<int>(commitres))); @@ -541,7 +541,7 @@ int AlsaPlayback::mixerNoMMapProc() if(state < 0) { ERR("Invalid state detected: %s\n", snd_strerror(state)); - aluHandleDisconnect(mDevice, "Bad state: %s", snd_strerror(state)); + mDevice->handleDisconnect("Bad state: %s", snd_strerror(state)); break; } @@ -578,7 +578,7 @@ int AlsaPlayback::mixerNoMMapProc() al::byte *WritePtr{mBuffer.data()}; avail = snd_pcm_bytes_to_frames(mPcmHandle, static_cast<ssize_t>(mBuffer.size())); std::lock_guard<std::mutex> _{mMutex}; - aluMixData(mDevice, WritePtr, static_cast<ALuint>(avail), frame_step); + mDevice->renderSamples(WritePtr, static_cast<ALuint>(avail), frame_step); while(avail > 0) { snd_pcm_sframes_t ret{snd_pcm_writei(mPcmHandle, WritePtr, @@ -1071,7 +1071,7 @@ ALCenum AlsaCapture::captureSamples(al::byte *buffer, ALCuint samples) { const char *err{snd_strerror(static_cast<int>(amt))}; ERR("restore error: %s\n", err); - aluHandleDisconnect(mDevice, "Capture recovery failure: %s", err); + mDevice->handleDisconnect("Capture recovery failure: %s", err); break; } /* If the amount available is less than what's asked, we lost it @@ -1111,7 +1111,7 @@ ALCuint AlsaCapture::availableSamples() { const char *err{snd_strerror(static_cast<int>(avail))}; ERR("restore error: %s\n", err); - aluHandleDisconnect(mDevice, "Capture recovery failure: %s", err); + mDevice->handleDisconnect("Capture recovery failure: %s", err); } } @@ -1147,7 +1147,7 @@ ALCuint AlsaCapture::availableSamples() { const char *err{snd_strerror(static_cast<int>(amt))}; ERR("restore error: %s\n", err); - aluHandleDisconnect(mDevice, "Capture recovery failure: %s", err); + mDevice->handleDisconnect("Capture recovery failure: %s", err); break; } avail = amt; diff --git a/alc/backends/coreaudio.cpp b/alc/backends/coreaudio.cpp index 2884bad6..25fb71ab 100644 --- a/alc/backends/coreaudio.cpp +++ b/alc/backends/coreaudio.cpp @@ -82,7 +82,7 @@ CoreAudioPlayback::~CoreAudioPlayback() OSStatus CoreAudioPlayback::MixerProc(AudioUnitRenderActionFlags*, const AudioTimeStamp*, UInt32, UInt32, AudioBufferList *ioData) noexcept { - aluMixData(mDevice, ioData->mBuffers[0].mData, ioData->mBuffers[0].mDataByteSize/mFrameSize, + mDevice->renderSamples(ioData->mBuffers[0].mData, ioData->mBuffers[0].mDataByteSize/mFrameSize, ioData->mBuffers[0].mNumberChannels); return noErr; } diff --git a/alc/backends/dsound.cpp b/alc/backends/dsound.cpp index e86153aa..c1921430 100644 --- a/alc/backends/dsound.cpp +++ b/alc/backends/dsound.cpp @@ -224,7 +224,7 @@ FORCE_ALIGN int DSoundPlayback::mixerProc() if(FAILED(err)) { ERR("Failed to get buffer caps: 0x%lx\n", err); - aluHandleDisconnect(mDevice, "Failure retrieving playback buffer info: 0x%lx", err); + mDevice->handleDisconnect("Failure retrieving playback buffer info: 0x%lx", err); return 1; } @@ -251,7 +251,7 @@ FORCE_ALIGN int DSoundPlayback::mixerProc() if(FAILED(err)) { ERR("Failed to play buffer: 0x%lx\n", err); - aluHandleDisconnect(mDevice, "Failure starting playback: 0x%lx", err); + mDevice->handleDisconnect("Failure starting playback: 0x%lx", err); return 1; } Playing = true; @@ -285,16 +285,16 @@ FORCE_ALIGN int DSoundPlayback::mixerProc() if(SUCCEEDED(err)) { - aluMixData(mDevice, WritePtr1, WriteCnt1/FrameSize, FrameStep); + mDevice->renderSamples(WritePtr1, WriteCnt1/FrameSize, FrameStep); if(WriteCnt2 > 0) - aluMixData(mDevice, WritePtr2, WriteCnt2/FrameSize, FrameStep); + mDevice->renderSamples(WritePtr2, WriteCnt2/FrameSize, FrameStep); mBuffer->Unlock(WritePtr1, WriteCnt1, WritePtr2, WriteCnt2); } else { ERR("Buffer lock error: %#lx\n", err); - aluHandleDisconnect(mDevice, "Failed to lock output buffer: 0x%lx", err); + mDevice->handleDisconnect("Failed to lock output buffer: 0x%lx", err); return 1; } @@ -717,7 +717,7 @@ void DSoundCapture::stop() if(FAILED(hr)) { ERR("stop failed: 0x%08lx\n", hr); - aluHandleDisconnect(mDevice, "Failure stopping capture: 0x%lx", hr); + mDevice->handleDisconnect("Failure stopping capture: 0x%lx", hr); } } @@ -758,7 +758,7 @@ ALCuint DSoundCapture::availableSamples() if(FAILED(hr)) { ERR("update failed: 0x%08lx\n", hr); - aluHandleDisconnect(mDevice, "Failure retrieving capture data: 0x%lx", hr); + mDevice->handleDisconnect("Failure retrieving capture data: 0x%lx", hr); } return static_cast<ALCuint>(mRing->readSpace()); diff --git a/alc/backends/jack.cpp b/alc/backends/jack.cpp index 6f53b54c..fe3aa794 100644 --- a/alc/backends/jack.cpp +++ b/alc/backends/jack.cpp @@ -287,9 +287,9 @@ int JackPlayback::mixerProc() ALuint len2{minu(static_cast<ALuint>(data.second.len), todo-len1)}; std::lock_guard<std::mutex> _{mMutex}; - aluMixData(mDevice, data.first.buf, len1, frame_step); + mDevice->renderSamples(data.first.buf, len1, frame_step); if(len2 > 0) - aluMixData(mDevice, data.second.buf, len2, frame_step); + mDevice->renderSamples(data.second.buf, len2, frame_step); mRing->writeAdvance(todo); } diff --git a/alc/backends/null.cpp b/alc/backends/null.cpp index 6e47f153..f78a23a0 100644 --- a/alc/backends/null.cpp +++ b/alc/backends/null.cpp @@ -72,8 +72,8 @@ int NullBackend::mixerProc() int64_t done{0}; auto start = std::chrono::steady_clock::now(); - while(!mKillNow.load(std::memory_order_acquire) && - mDevice->Connected.load(std::memory_order_acquire)) + while(!mKillNow.load(std::memory_order_acquire) + && mDevice->Connected.load(std::memory_order_acquire)) { auto now = std::chrono::steady_clock::now(); @@ -86,7 +86,7 @@ int NullBackend::mixerProc() } while(avail-done >= mDevice->UpdateSize) { - aluMixData(mDevice, nullptr, mDevice->UpdateSize, 0u); + mDevice->renderSamples(nullptr, mDevice->UpdateSize, 0u); done += mDevice->UpdateSize; } diff --git a/alc/backends/oboe.cpp b/alc/backends/oboe.cpp index 4a8188f3..f4a9877a 100644 --- a/alc/backends/oboe.cpp +++ b/alc/backends/oboe.cpp @@ -49,7 +49,7 @@ oboe::DataCallbackResult OboePlayback::onAudioReady(oboe::AudioStream *oboeStrea memset(audioData, 0, static_cast<uint32_t>(numFrames*numChannels)*sizeof(int16_t)); } - aluMixData(mDevice, audioData, static_cast<uint32_t>(numFrames), + mDevice->renderSamples(audioData, static_cast<uint32_t>(numFrames), static_cast<uint32_t>(numChannels)); return oboe::DataCallbackResult::Continue; } diff --git a/alc/backends/opensl.cpp b/alc/backends/opensl.cpp index 8c235cd2..8ac11e94 100644 --- a/alc/backends/opensl.cpp +++ b/alc/backends/opensl.cpp @@ -234,10 +234,10 @@ int OpenSLPlayback::mixerProc() const size_t frame_step{mDevice->channelsFromFmt()}; if(SL_RESULT_SUCCESS != result) - aluHandleDisconnect(mDevice, "Failed to get playback buffer: 0x%08x", result); + mDevice->handleDisconnect("Failed to get playback buffer: 0x%08x", result); - while(SL_RESULT_SUCCESS == result && !mKillNow.load(std::memory_order_acquire) && - mDevice->Connected.load(std::memory_order_acquire)) + while(SL_RESULT_SUCCESS == result && !mKillNow.load(std::memory_order_acquire) + && mDevice->Connected.load(std::memory_order_acquire)) { if(mRing->writeSpace() == 0) { @@ -252,7 +252,7 @@ int OpenSLPlayback::mixerProc() } if(SL_RESULT_SUCCESS != result) { - aluHandleDisconnect(mDevice, "Failed to start platback: 0x%08x", result); + mDevice->handleDisconnect("Failed to start platback: 0x%08x", result); break; } @@ -265,10 +265,10 @@ int OpenSLPlayback::mixerProc() std::unique_lock<std::mutex> dlock{mMutex}; auto data = mRing->getWriteVector(); - aluMixData(mDevice, data.first.buf, + mDevice->renderSamples(data.first.buf, static_cast<ALuint>(data.first.len*mDevice->UpdateSize), frame_step); if(data.second.len > 0) - aluMixData(mDevice, data.second.buf, + mDevice->renderSamples(data.second.buf, static_cast<ALuint>(data.second.len*mDevice->UpdateSize), frame_step); size_t todo{data.first.len + data.second.len}; @@ -288,7 +288,7 @@ int OpenSLPlayback::mixerProc() PRINTERR(result, "bufferQueue->Enqueue"); if(SL_RESULT_SUCCESS != result) { - aluHandleDisconnect(mDevice, "Failed to queue audio: 0x%08x", result); + mDevice->handleDisconnect("Failed to queue audio: 0x%08x", result); break; } @@ -874,7 +874,7 @@ ALCenum OpenSLCapture::captureSamples(al::byte *buffer, ALCuint samples) PRINTERR(result, "recordObj->GetInterface"); if UNLIKELY(SL_RESULT_SUCCESS != result) { - aluHandleDisconnect(mDevice, "Failed to get capture buffer queue: 0x%08x", result); + mDevice->handleDisconnect("Failed to get capture buffer queue: 0x%08x", result); bufferQueue = nullptr; } } @@ -904,8 +904,7 @@ ALCenum OpenSLCapture::captureSamples(al::byte *buffer, ALCuint samples) PRINTERR(result, "bufferQueue->Enqueue"); if UNLIKELY(SL_RESULT_SUCCESS != result) { - aluHandleDisconnect(mDevice, "Failed to update capture buffer: 0x%08x", - result); + mDevice->handleDisconnect("Failed to update capture buffer: 0x%08x", result); bufferQueue = nullptr; } } diff --git a/alc/backends/oss.cpp b/alc/backends/oss.cpp index 1fe3c475..0f00115e 100644 --- a/alc/backends/oss.cpp +++ b/alc/backends/oss.cpp @@ -277,7 +277,7 @@ int OSSPlayback::mixerProc() if(errno == EINTR || errno == EAGAIN) continue; ERR("poll failed: %s\n", strerror(errno)); - aluHandleDisconnect(mDevice, "Failed waiting for playback buffer: %s", strerror(errno)); + mDevice->handleDisconnect("Failed waiting for playback buffer: %s", strerror(errno)); break; } else if(pret == 0) @@ -288,7 +288,7 @@ int OSSPlayback::mixerProc() ALubyte *write_ptr{mMixData.data()}; size_t to_write{mMixData.size()}; - aluMixData(mDevice, write_ptr, static_cast<ALuint>(to_write/frame_size), frame_step); + mDevice->renderSamples(write_ptr, static_cast<ALuint>(to_write/frame_size), frame_step); while(to_write > 0 && !mKillNow.load(std::memory_order_acquire)) { ssize_t wrote{write(mFd, write_ptr, to_write)}; @@ -297,8 +297,7 @@ int OSSPlayback::mixerProc() if(errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) continue; ERR("write failed: %s\n", strerror(errno)); - aluHandleDisconnect(mDevice, "Failed writing playback samples: %s", - strerror(errno)); + mDevice->handleDisconnect("Failed writing playback samples: %s", strerror(errno)); break; } @@ -487,7 +486,7 @@ int OSScapture::recordProc() if(errno == EINTR || errno == EAGAIN) continue; ERR("poll failed: %s\n", strerror(errno)); - aluHandleDisconnect(mDevice, "Failed to check capture samples: %s", strerror(errno)); + mDevice->handleDisconnect("Failed to check capture samples: %s", strerror(errno)); break; } else if(sret == 0) @@ -503,8 +502,7 @@ int OSScapture::recordProc() if(amt < 0) { ERR("read failed: %s\n", strerror(errno)); - aluHandleDisconnect(mDevice, "Failed reading capture samples: %s", - strerror(errno)); + mDevice->handleDisconnect("Failed reading capture samples: %s", strerror(errno)); break; } mRing->writeAdvance(static_cast<ALuint>(amt)/frame_size); diff --git a/alc/backends/portaudio.cpp b/alc/backends/portaudio.cpp index 5bb792c3..42dbb4c9 100644 --- a/alc/backends/portaudio.cpp +++ b/alc/backends/portaudio.cpp @@ -110,7 +110,7 @@ PortPlayback::~PortPlayback() int PortPlayback::writeCallback(const void*, void *outputBuffer, unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo*, const PaStreamCallbackFlags) noexcept { - aluMixData(mDevice, outputBuffer, static_cast<ALuint>(framesPerBuffer), + mDevice->renderSamples(outputBuffer, static_cast<ALuint>(framesPerBuffer), static_cast<ALuint>(mParams.channelCount)); return 0; } diff --git a/alc/backends/pulseaudio.cpp b/alc/backends/pulseaudio.cpp index 6b8b4a6a..5bcd8b5f 100644 --- a/alc/backends/pulseaudio.cpp +++ b/alc/backends/pulseaudio.cpp @@ -766,7 +766,7 @@ void PulsePlayback::streamStateCallback(pa_stream *stream) noexcept if(pa_stream_get_state(stream) == PA_STREAM_FAILED) { ERR("Received stream failure!\n"); - aluHandleDisconnect(mDevice, "Playback stream failure"); + mDevice->handleDisconnect("Playback stream failure"); } mMainloop.getCondVar().notify_all(); } @@ -787,7 +787,7 @@ void PulsePlayback::streamWriteCallback(pa_stream *stream, size_t nbytes) noexce buflen = minz(buflen, nbytes); nbytes -= buflen; - aluMixData(mDevice, buf, static_cast<ALuint>(buflen/mFrameSize), mSpec.channels); + mDevice->renderSamples(buf, static_cast<ALuint>(buflen/mFrameSize), mSpec.channels); int ret{pa_stream_write(stream, buf, buflen, free_func, 0, PA_SEEK_RELATIVE)}; if UNLIKELY(ret != PA_OK) @@ -1188,7 +1188,7 @@ void PulseCapture::streamStateCallback(pa_stream *stream) noexcept if(pa_stream_get_state(stream) == PA_STREAM_FAILED) { ERR("Received stream failure!\n"); - aluHandleDisconnect(mDevice, "Capture stream failure"); + mDevice->handleDisconnect("Capture stream failure"); } mMainloop.getCondVar().notify_all(); } @@ -1364,14 +1364,14 @@ ALCenum PulseCapture::captureSamples(al::byte *buffer, ALCuint samples) const pa_stream_state_t state{pa_stream_get_state(mStream)}; if UNLIKELY(!PA_STREAM_IS_GOOD(state)) { - aluHandleDisconnect(mDevice, "Bad capture state: %u", state); + mDevice->handleDisconnect("Bad capture state: %u", state); break; } const void *capbuf; size_t caplen; if UNLIKELY(pa_stream_peek(mStream, &capbuf, &caplen) < 0) { - aluHandleDisconnect(mDevice, "Failed retrieving capture samples: %s", + mDevice->handleDisconnect("Failed retrieving capture samples: %s", pa_strerror(pa_context_errno(mContext))); break; } @@ -1402,7 +1402,7 @@ ALCuint PulseCapture::availableSamples() { const char *err{pa_strerror(static_cast<int>(got))}; ERR("pa_stream_readable_size() failed: %s\n", err); - aluHandleDisconnect(mDevice, "Failed getting readable size: %s", err); + mDevice->handleDisconnect("Failed getting readable size: %s", err); } else { diff --git a/alc/backends/sdl2.cpp b/alc/backends/sdl2.cpp index 7666b616..30335140 100644 --- a/alc/backends/sdl2.cpp +++ b/alc/backends/sdl2.cpp @@ -83,7 +83,7 @@ void Sdl2Backend::audioCallback(Uint8 *stream, int len) noexcept { const auto ulen = static_cast<unsigned int>(len); assert((ulen % mFrameSize) == 0); - aluMixData(mDevice, stream, ulen / mFrameSize, mDevice->channelsFromFmt()); + mDevice->renderSamples(stream, ulen / mFrameSize, mDevice->channelsFromFmt()); } void Sdl2Backend::open(const ALCchar *name) diff --git a/alc/backends/sndio.cpp b/alc/backends/sndio.cpp index bad05acb..c20ce496 100644 --- a/alc/backends/sndio.cpp +++ b/alc/backends/sndio.cpp @@ -79,7 +79,7 @@ int SndioPlayback::mixerProc() sio_initpar(&par); if(!sio_getpar(mSndHandle, &par)) { - aluHandleDisconnect(mDevice, "Failed to get device parameters"); + mDevice->handleDisconnect("Failed to get device parameters"); return 1; } @@ -95,14 +95,14 @@ int SndioPlayback::mixerProc() al::byte *WritePtr{mBuffer.data()}; size_t len{mBuffer.size()}; - aluMixData(mDevice, WritePtr, static_cast<ALuint>(len)/frameSize, frameStep); + mDevice->renderSamples(WritePtr, static_cast<ALuint>(len)/frameSize, frameStep); while(len > 0 && !mKillNow.load(std::memory_order_acquire)) { size_t wrote{sio_write(mSndHandle, WritePtr, len)}; if(wrote == 0) { ERR("sio_write failed\n"); - aluHandleDisconnect(mDevice, "Failed to write playback samples"); + mDevice->handleDisconnect("Failed to write playback samples"); break; } @@ -348,7 +348,7 @@ int SndioCapture::recordProc() size_t got{sio_read(mSndHandle, data.first.buf, minz(todo-total, data.first.len))}; if(!got) { - aluHandleDisconnect(mDevice, "Failed to read capture samples"); + mDevice->handleDisconnect("Failed to read capture samples"); break; } diff --git a/alc/backends/solaris.cpp b/alc/backends/solaris.cpp index 7f6ebb0f..6849a820 100644 --- a/alc/backends/solaris.cpp +++ b/alc/backends/solaris.cpp @@ -106,8 +106,7 @@ int SolarisBackend::mixerProc() if(errno == EINTR || errno == EAGAIN) continue; ERR("poll failed: %s\n", strerror(errno)); - aluHandleDisconnect(mDevice, "Failed to wait for playback buffer: %s", - strerror(errno)); + mDevice->handleDisconnect("Failed to wait for playback buffer: %s", strerror(errno)); break; } else if(pret == 0) @@ -118,7 +117,7 @@ int SolarisBackend::mixerProc() ALubyte *write_ptr{mBuffer.data()}; size_t to_write{mBuffer.size()}; - aluMixData(mDevice, write_ptr, to_write/frame_size, frame_step); + mDevice->renderSamples(write_ptr, static_cast<ALuint>(to_write/frame_size), frame_step); while(to_write > 0 && !mKillNow.load(std::memory_order_acquire)) { ssize_t wrote{write(mFd, write_ptr, to_write)}; @@ -127,12 +126,11 @@ int SolarisBackend::mixerProc() if(errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) continue; ERR("write failed: %s\n", strerror(errno)); - aluHandleDisconnect(mDevice, "Failed to write playback samples: %s", - strerror(errno)); + mDevice->handleDisconnect("Failed to write playback samples: %s", strerror(errno)); break; } - to_write -= wrote; + to_write -= static_cast<size_t>(wrote); write_ptr += wrote; } } diff --git a/alc/backends/wasapi.cpp b/alc/backends/wasapi.cpp index 8e43aa7c..3b209e26 100644 --- a/alc/backends/wasapi.cpp +++ b/alc/backends/wasapi.cpp @@ -683,7 +683,7 @@ FORCE_ALIGN int WasapiPlayback::mixerProc() if(FAILED(hr)) { ERR("CoInitializeEx(nullptr, COINIT_MULTITHREADED) failed: 0x%08lx\n", hr); - aluHandleDisconnect(mDevice, "COM init failed: 0x%08lx", hr); + mDevice->handleDisconnect("COM init failed: 0x%08lx", hr); return 1; } @@ -699,7 +699,7 @@ FORCE_ALIGN int WasapiPlayback::mixerProc() if(FAILED(hr)) { ERR("Failed to get padding: 0x%08lx\n", hr); - aluHandleDisconnect(mDevice, "Failed to retrieve buffer padding: 0x%08lx", hr); + mDevice->handleDisconnect("Failed to retrieve buffer padding: 0x%08lx", hr); break; } mPadding.store(written, std::memory_order_relaxed); @@ -719,7 +719,7 @@ FORCE_ALIGN int WasapiPlayback::mixerProc() { { std::lock_guard<std::mutex> _{mMutex}; - aluMixData(mDevice, buffer, len, mFrameStep); + mDevice->renderSamples(buffer, len, mFrameStep); mPadding.store(written + len, std::memory_order_relaxed); } hr = mRender->ReleaseBuffer(len, 0); @@ -727,7 +727,7 @@ FORCE_ALIGN int WasapiPlayback::mixerProc() if(FAILED(hr)) { ERR("Failed to buffer data: 0x%08lx\n", hr); - aluHandleDisconnect(mDevice, "Failed to send playback samples: 0x%08lx", hr); + mDevice->handleDisconnect("Failed to send playback samples: 0x%08lx", hr); break; } } @@ -1233,7 +1233,7 @@ FORCE_ALIGN int WasapiCapture::recordProc() if(FAILED(hr)) { ERR("CoInitializeEx(nullptr, COINIT_MULTITHREADED) failed: 0x%08lx\n", hr); - aluHandleDisconnect(mDevice, "COM init failed: 0x%08lx", hr); + mDevice->handleDisconnect("COM init failed: 0x%08lx", hr); return 1; } @@ -1305,7 +1305,7 @@ FORCE_ALIGN int WasapiCapture::recordProc() if(FAILED(hr)) { - aluHandleDisconnect(mDevice, "Failed to capture samples: 0x%08lx", hr); + mDevice->handleDisconnect("Failed to capture samples: 0x%08lx", hr); break; } diff --git a/alc/backends/wave.cpp b/alc/backends/wave.cpp index 30a8399b..c452379e 100644 --- a/alc/backends/wave.cpp +++ b/alc/backends/wave.cpp @@ -146,10 +146,10 @@ int WaveBackend::mixerProc() } while(avail-done >= mDevice->UpdateSize) { - aluMixData(mDevice, mBuffer.data(), mDevice->UpdateSize, frameStep); + mDevice->renderSamples(mBuffer.data(), mDevice->UpdateSize, frameStep); done += mDevice->UpdateSize; - if(!IS_LITTLE_ENDIAN) + if /*constexpr*/(!IS_LITTLE_ENDIAN) { const ALuint bytesize{mDevice->bytesFromFmt()}; @@ -181,7 +181,7 @@ int WaveBackend::mixerProc() if(ferror(mFile)) { ERR("Error writing to file\n"); - aluHandleDisconnect(mDevice, "Failed to write playback samples"); + mDevice->handleDisconnect("Failed to write playback samples"); break; } } diff --git a/alc/backends/winmm.cpp b/alc/backends/winmm.cpp index 4dd74705..274536b3 100644 --- a/alc/backends/winmm.cpp +++ b/alc/backends/winmm.cpp @@ -199,7 +199,7 @@ FORCE_ALIGN int WinMMPlayback::mixerProc() WAVEHDR &waveHdr = mWaveBuffer[widx]; widx = (widx+1) % mWaveBuffer.size(); - aluMixData(mDevice, waveHdr.lpData, mDevice->UpdateSize, frame_step); + mDevice->renderSamples(waveHdr.lpData, mDevice->UpdateSize, frame_step); mWritable.fetch_sub(1, std::memory_order_acq_rel); waveOutWrite(mOutHdl, &waveHdr, sizeof(WAVEHDR)); } while(--todo); |