lib/alsa/NonBlock: embed in "namespace Alsa"

This commit is contained in:
Max Kellermann 2024-07-11 21:31:04 +02:00
parent 9704cf3dcb
commit 3db8a4f41b
5 changed files with 17 additions and 11 deletions

View File

@ -62,7 +62,7 @@ class AlsaInputStream final
snd_pcm_t *capture_handle;
const size_t frame_size;
AlsaNonBlockPcm non_block;
Alsa::NonBlockPcm non_block;
InjectEvent defer_invalidate_sockets;

View File

@ -5,8 +5,10 @@
#include "Error.hxx"
#include "event/MultiSocketMonitor.hxx"
namespace Alsa {
Event::Duration
AlsaNonBlockPcm::PrepareSockets(MultiSocketMonitor &m, snd_pcm_t *pcm)
NonBlockPcm::PrepareSockets(MultiSocketMonitor &m, snd_pcm_t *pcm)
{
int count = snd_pcm_poll_descriptors_count(pcm);
if (count <= 0) {
@ -31,8 +33,7 @@ AlsaNonBlockPcm::PrepareSockets(MultiSocketMonitor &m, snd_pcm_t *pcm)
}
void
AlsaNonBlockPcm::DispatchSockets(MultiSocketMonitor &m,
snd_pcm_t *pcm)
NonBlockPcm::DispatchSockets(MultiSocketMonitor &m, snd_pcm_t *pcm)
{
int count = snd_pcm_poll_descriptors_count(pcm);
if (count <= 0)
@ -57,7 +58,7 @@ AlsaNonBlockPcm::DispatchSockets(MultiSocketMonitor &m,
}
Event::Duration
AlsaNonBlockMixer::PrepareSockets(MultiSocketMonitor &m, snd_mixer_t *mixer) noexcept
NonBlockMixer::PrepareSockets(MultiSocketMonitor &m, snd_mixer_t *mixer) noexcept
{
int count = snd_mixer_poll_descriptors_count(mixer);
if (count <= 0) {
@ -76,8 +77,7 @@ AlsaNonBlockMixer::PrepareSockets(MultiSocketMonitor &m, snd_mixer_t *mixer) noe
}
void
AlsaNonBlockMixer::DispatchSockets(MultiSocketMonitor &m,
snd_mixer_t *mixer) noexcept
NonBlockMixer::DispatchSockets(MultiSocketMonitor &m, snd_mixer_t *mixer) noexcept
{
int count = snd_mixer_poll_descriptors_count(mixer);
if (count <= 0)
@ -98,3 +98,5 @@ AlsaNonBlockMixer::DispatchSockets(MultiSocketMonitor &m,
unsigned short dummy;
snd_mixer_poll_descriptors_revents(mixer, pfds, i - pfds, &dummy);
}
} // namespace Alsa

View File

@ -10,11 +10,13 @@
class MultiSocketMonitor;
namespace Alsa {
/**
* Helper class for #MultiSocketMonitor's virtual methods which
* manages the file descriptors for a #snd_pcm_t.
*/
class AlsaNonBlockPcm {
class NonBlockPcm {
ReusableArray<pollfd> pfd_buffer;
public:
@ -37,7 +39,7 @@ public:
* Helper class for #MultiSocketMonitor's virtual methods which
* manages the file descriptors for a #snd_mixer_t.
*/
class AlsaNonBlockMixer {
class NonBlockMixer {
ReusableArray<pollfd> pfd_buffer;
public:
@ -50,3 +52,5 @@ public:
*/
void DispatchSockets(MultiSocketMonitor &m, snd_mixer_t *mixer) noexcept;
};
} // namespace Alsa

View File

@ -29,7 +29,7 @@ class AlsaMixerMonitor final : MultiSocketMonitor {
snd_mixer_t *mixer;
AlsaNonBlockMixer non_block;
Alsa::NonBlockMixer non_block;
public:
AlsaMixerMonitor(EventLoop &_loop, snd_mixer_t *_mixer) noexcept

View File

@ -210,7 +210,7 @@ class AlsaOutput final
*/
std::byte *silence;
AlsaNonBlockPcm non_block;
Alsa::NonBlockPcm non_block;
/**
* For copying data from OutputThread to IOThread.