From a5b81672803951980b3b2aa7304e1fe69dd0325a Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sat, 28 Mar 2020 17:49:54 -0700 Subject: Make some functions private methods --- alc/backends/pulseaudio.cpp | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'alc/backends') diff --git a/alc/backends/pulseaudio.cpp b/alc/backends/pulseaudio.cpp index e02193a1..5902750b 100644 --- a/alc/backends/pulseaudio.cpp +++ b/alc/backends/pulseaudio.cpp @@ -326,39 +326,29 @@ al::vector CaptureDevices; /* Global flags and properties */ pa_context_flags_t pulse_ctx_flags; -int pulse_poll_func(struct pollfd *ufds, unsigned long nfds, int timeout, void *userdata) noexcept -{ - auto plock = static_cast*>(userdata); - plock->unlock(); - int r{poll(ufds, nfds, timeout)}; - plock->lock(); - return r; -} - class PulseMainloop { std::thread mThread; std::mutex mMutex; std::condition_variable mCondVar; pa_mainloop *mMainloop{nullptr}; -public: - ~PulseMainloop() + static int poll(struct pollfd *ufds, unsigned long nfds, int timeout, void *userdata) noexcept { - if(mThread.joinable()) - { - pa_mainloop_quit(mMainloop, 0); - mThread.join(); - } + auto plock = static_cast*>(userdata); + plock->unlock(); + int r{::poll(ufds, nfds, timeout)}; + plock->lock(); + return r; } - int mainloop_thread() + int mainloop_proc() { SetRTPriority(); std::unique_lock plock{mMutex}; mMainloop = pa_mainloop_new(); - pa_mainloop_set_poll_func(mMainloop, pulse_poll_func, &plock); + pa_mainloop_set_poll_func(mMainloop, poll, &plock); mCondVar.notify_all(); int ret{}; @@ -370,6 +360,16 @@ public: return ret; } +public: + ~PulseMainloop() + { + if(mThread.joinable()) + { + pa_mainloop_quit(mMainloop, 0); + mThread.join(); + } + } + std::unique_lock getUniqueLock() { return std::unique_lock{mMutex}; } std::condition_variable &getCondVar() noexcept { return mCondVar; } @@ -496,7 +496,7 @@ pa_context *PulseMainloop::connectContext(std::unique_lock &plock) if(!mMainloop) { - mThread = std::thread{std::mem_fn(&PulseMainloop::mainloop_thread), this}; + mThread = std::thread{std::mem_fn(&PulseMainloop::mainloop_proc), this}; while(!mMainloop) mCondVar.wait(plock); } -- cgit v1.2.3