Switch to unified view

a/sc2src/alsadirect.cpp b/sc2src/alsadirect.cpp
...
...
66
/* Alsa. Locked while we work with it */
66
/* Alsa. Locked while we work with it */
67
static std::mutex alsa_mutex;
67
static std::mutex alsa_mutex;
68
static snd_pcm_t *pcm;
68
static snd_pcm_t *pcm;
69
static string alsadevice("default");
69
static string alsadevice("default");
70
static snd_pcm_sframes_t alsa_delay;
70
static snd_pcm_sframes_t alsa_delay;
71
72
static void alsa_close_nolock();
71
73
72
// From MPD recovery code.
74
// From MPD recovery code.
73
// Note: no locking: we're called from alsawriter holding the lock.
75
// Note: no locking: we're called from alsawriter holding the lock.
74
static int alsa_recover(snd_pcm_t *pcm, int err)
76
static int alsa_recover(snd_pcm_t *pcm, int err)
75
{
77
{
...
...
193
            buf += tsk->frames_to_bytes(ret);
195
            buf += tsk->frames_to_bytes(ret);
194
            frames -= ret;
196
            frames -= ret;
195
        }
197
        }
196
        if (tsk->m_halt) {
198
        if (tsk->m_halt) {
197
            LOGDEB("alsawriter: halt\n");
199
            LOGDEB("alsawriter: halt\n");
198
            alsa_close();
200
            alsa_close_nolock();
199
            qinit = false;
201
            qinit = false;
200
        }
202
        }
201
203
202
        delete tsk;
204
        delete tsk;
203
    }
205
    }
...
...
327
    return false;
329
    return false;
328
}
330
}
329
331
330
void alsa_close()
332
void alsa_close()
331
{
333
{
334
    std::unique_lock<std::mutex> lock(alsa_mutex);
335
    alsa_close_nolock();
336
}
337
338
static void alsa_close_nolock()
339
{
332
    LOGDEB("alsawriter: alsa close\n");
340
    LOGDEB("alsawriter: alsa close\n");
333
    std::unique_lock<std::mutex> lock(alsa_mutex);
334
    alsa_delay = 0;
341
    alsa_delay = 0;
335
    if (pcm != nullptr) {
342
    if (pcm != nullptr) {
336
        snd_pcm_close(pcm);
343
        snd_pcm_close(pcm);
337
        pcm = nullptr;
344
        pcm = nullptr;
338
    }
345
    }