summaryrefslogtreecommitdiff
path: root/src/device_alsa.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/device_alsa.cpp')
-rw-r--r--src/device_alsa.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/device_alsa.cpp b/src/device_alsa.cpp
index 548be0a..035531a 100644
--- a/src/device_alsa.cpp
+++ b/src/device_alsa.cpp
@@ -221,6 +221,15 @@ namespace audiere {
char* sample_buf;
int retry = 0;
+ // reopen a pcm
+ if (m_pcm_handle) {
+ m_pcm_handle = openDevice(m_pcm_name, m_rate);
+ if (!m_pcm_handle) {
+ usleep(100);
+ return;
+ }
+ }
+
sample_buf = m_buffer;
sample_len = m_buffer_size / 4;
@@ -230,13 +239,10 @@ namespace audiere {
if (ret == -EAGAIN) {
snd_pcm_wait(m_pcm_handle, 100);
if (++retry > 50) {
- fprintf(stderr, "audiere: snd_pcm_writei doesn't work anymore, try to reopen a new pcm.\n");
+ fprintf(stderr, "audiere: snd_pcm_writei doesn't work anymore, reopening pcm.\n");
snd_pcm_close(m_pcm_handle);
-
- retry = 0;
- m_pcm_handle = openDevice(m_pcm_name, m_rate);
- if (!m_pcm_handle)
- break;
+ m_pcm_handle = 0;
+ break;
}
} else if (ret == -ESTRPIPE) {
do {