aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-08-07 18:55:00 +0200
committerMax Kellermann <max@duempel.org>2013-08-07 18:56:57 +0200
commit123dd5fe2de35f881a17779e3aca4cd48195610f (patch)
treeca3620bfef6baf27cb4e7a8e9db2d0be808b1072 /src
parent953e3190caa218dfce46dca69a2d110bc4a52e84 (diff)
downloadmpd-123dd5fe2de35f881a17779e3aca4cd48195610f.tar.gz
mpd-123dd5fe2de35f881a17779e3aca4cd48195610f.tar.xz
mpd-123dd5fe2de35f881a17779e3aca4cd48195610f.zip
mixer/alsa: use AllocatedArray for the pollfd buffer
Diffstat (limited to 'src')
-rw-r--r--src/mixer/AlsaMixerPlugin.cxx8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/mixer/AlsaMixerPlugin.cxx b/src/mixer/AlsaMixerPlugin.cxx
index 8f7cd608e..5ab19a8d6 100644
--- a/src/mixer/AlsaMixerPlugin.cxx
+++ b/src/mixer/AlsaMixerPlugin.cxx
@@ -23,6 +23,7 @@
#include "GlobalEvents.hxx"
#include "Main.hxx"
#include "event/MultiSocketMonitor.hxx"
+#include "util/ReusableArray.hxx"
#include <algorithm>
@@ -36,6 +37,8 @@ static constexpr unsigned VOLUME_MIXER_ALSA_INDEX_DEFAULT = 0;
class AlsaMixerMonitor final : private MultiSocketMonitor {
snd_mixer_t *const mixer;
+ ReusableArray<pollfd> pfd_buffer;
+
public:
AlsaMixerMonitor(EventLoop &_loop, snd_mixer_t *_mixer)
:MultiSocketMonitor(_loop), mixer(_mixer) {}
@@ -87,7 +90,8 @@ AlsaMixerMonitor::PrepareSockets(gcc_unused gint *timeout_r)
if (count < 0)
count = 0;
- struct pollfd *pfds = g_new(struct pollfd, count);
+ struct pollfd *pfds = pfd_buffer.Get(count);
+
count = snd_mixer_poll_descriptors(mixer, pfds, count);
if (count < 0)
count = 0;
@@ -109,8 +113,6 @@ AlsaMixerMonitor::PrepareSockets(gcc_unused gint *timeout_r)
for (auto i = pfds; i != end; ++i)
if (i->events != 0)
AddSocket(i->fd, i->events);
-
- g_free(pfds);
}
void