aboutsummaryrefslogtreecommitdiffstats
path: root/src/mixer/AlsaMixerPlugin.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-10-01 17:20:38 +0200
committerMax Kellermann <max@duempel.org>2013-10-01 17:20:38 +0200
commita2ce2447a68ca25ad72aed7aaf4ea85183c5de88 (patch)
treeb04f80dae675cb5badea2f6a632dded739311cda /src/mixer/AlsaMixerPlugin.cxx
parent5e20b7976f812e4ca2bb0c552c414ef2dfbe81a0 (diff)
parent9a1076256deef8bf806942eb72eabdbfdf74ddb3 (diff)
downloadmpd-a2ce2447a68ca25ad72aed7aaf4ea85183c5de88.tar.gz
mpd-a2ce2447a68ca25ad72aed7aaf4ea85183c5de88.tar.xz
mpd-a2ce2447a68ca25ad72aed7aaf4ea85183c5de88.zip
Merge branch 'v0.17.x'
Diffstat (limited to 'src/mixer/AlsaMixerPlugin.cxx')
-rw-r--r--src/mixer/AlsaMixerPlugin.cxx21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/mixer/AlsaMixerPlugin.cxx b/src/mixer/AlsaMixerPlugin.cxx
index 1ea26d0c1..13e3283f0 100644
--- a/src/mixer/AlsaMixerPlugin.cxx
+++ b/src/mixer/AlsaMixerPlugin.cxx
@@ -38,7 +38,7 @@
static constexpr unsigned VOLUME_MIXER_ALSA_INDEX_DEFAULT = 0;
class AlsaMixerMonitor final : private MultiSocketMonitor {
- snd_mixer_t *const mixer;
+ snd_mixer_t *mixer;
ReusableArray<pollfd> pfd_buffer;
@@ -83,6 +83,9 @@ static constexpr Domain alsa_mixer_domain("alsa_mixer");
int
AlsaMixerMonitor::PrepareSockets()
{
+ if (mixer == nullptr)
+ return -1;
+
int count = snd_mixer_poll_descriptors_count(mixer);
if (count < 0)
count = 0;
@@ -117,7 +120,21 @@ AlsaMixerMonitor::PrepareSockets()
void
AlsaMixerMonitor::DispatchSockets()
{
- snd_mixer_handle_events(mixer);
+ assert(mixer != nullptr);
+
+ int err = snd_mixer_handle_events(mixer);
+ if (err < 0) {
+ g_warning("snd_mixer_handle_events() failed: %s",
+ snd_strerror(err));
+
+ if (err == -ENODEV) {
+ /* the sound device was unplugged; disable
+ this GSource */
+ mixer = nullptr;
+ InvalidateSockets();
+ return;
+ }
+ }
}
/*