aboutsummaryrefslogtreecommitdiffstats
path: root/alc/backends
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2020-03-28 17:49:54 -0700
committerChris Robinson <[email protected]>2020-03-28 18:15:05 -0700
commita5b81672803951980b3b2aa7304e1fe69dd0325a (patch)
tree6b57f792666eddf4af92e823a9f399b0536a7c67 /alc/backends
parent963d9b761b53c270fc8b7e91e32b2fe7b79b51be (diff)
Make some functions private methods
Diffstat (limited to 'alc/backends')
-rw-r--r--alc/backends/pulseaudio.cpp38
1 files changed, 19 insertions, 19 deletions
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<DevMap> 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<std::unique_lock<std::mutex>*>(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<std::unique_lock<std::mutex>*>(userdata);
+ plock->unlock();
+ int r{::poll(ufds, nfds, timeout)};
+ plock->lock();
+ return r;
}
- int mainloop_thread()
+ int mainloop_proc()
{
SetRTPriority();
std::unique_lock<std::mutex> 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<std::mutex> getUniqueLock() { return std::unique_lock<std::mutex>{mMutex}; }
std::condition_variable &getCondVar() noexcept { return mCondVar; }
@@ -496,7 +496,7 @@ pa_context *PulseMainloop::connectContext(std::unique_lock<std::mutex> &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);
}