--- a/sc2src/alsadirect.cpp
+++ b/sc2src/alsadirect.cpp
@@ -68,6 +68,8 @@
static snd_pcm_t *pcm;
static string alsadevice("default");
static snd_pcm_sframes_t alsa_delay;
+
+static void alsa_close_nolock();
// From MPD recovery code.
// Note: no locking: we're called from alsawriter holding the lock.
@@ -195,7 +197,7 @@
}
if (tsk->m_halt) {
LOGDEB("alsawriter: halt\n");
- alsa_close();
+ alsa_close_nolock();
qinit = false;
}
@@ -329,8 +331,13 @@
void alsa_close()
{
+ std::unique_lock<std::mutex> lock(alsa_mutex);
+ alsa_close_nolock();
+}
+
+static void alsa_close_nolock()
+{
LOGDEB("alsawriter: alsa close\n");
- std::unique_lock<std::mutex> lock(alsa_mutex);
alsa_delay = 0;
if (pcm != nullptr) {
snd_pcm_close(pcm);