diff options
author | Pierre Ossman <ossman@cendio.se> | 2007-03-02 09:20:54 +0000 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2007-03-02 09:20:54 +0000 |
commit | 2b82336df2eb8cf1c9ae150b1850540a88f68ecf (patch) | |
tree | d420f33ddcabb54cc7e653f64ca701341cb4dd71 /src/modules/module-alsa-sink.c | |
parent | 19b17ff50447875d55ef4c819fd0f3c45537cce9 (diff) |
Handle suspended alsa devices. Based on patch by ranma. (closes #26)
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1433 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/modules/module-alsa-sink.c')
-rw-r--r-- | src/modules/module-alsa-sink.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/modules/module-alsa-sink.c b/src/modules/module-alsa-sink.c index 6f8f270d..3d9f7577 100644 --- a/src/modules/module-alsa-sink.c +++ b/src/modules/module-alsa-sink.c @@ -141,6 +141,33 @@ static int xrun_recovery(struct userdata *u) { return ret; } +static int suspend_recovery(struct userdata *u) { + int ret; + assert(u); + + pa_log_info("*** ALSA-SUSPEND (playback) ***"); + + if ((ret = snd_pcm_resume(u->pcm_handle)) < 0) { + if (ret == -EAGAIN) + return -1; + + if (ret != -ENOSYS) + pa_log("snd_pcm_resume() failed: %s", snd_strerror(-ret)); + else { + if ((ret = snd_pcm_prepare(u->pcm_handle)) < 0) + pa_log("snd_pcm_prepare() failed: %s", snd_strerror(-ret)); + } + + if (ret < 0) { + clear_up(u); + pa_module_unload_request(u->module); + return -1; + } + } + + return ret; +} + static void do_write(struct userdata *u) { assert(u); @@ -176,6 +203,13 @@ static void do_write(struct userdata *u) { continue; } + if (frames == -ESTRPIPE) { + if (suspend_recovery(u) < 0) + return; + + continue; + } + pa_log("snd_pcm_writei() failed: %s", snd_strerror(-frames)); clear_up(u); @@ -207,6 +241,10 @@ static void fdl_callback(void *userdata) { if (xrun_recovery(u) < 0) return; + if (snd_pcm_state(u->pcm_handle) == SND_PCM_STATE_SUSPENDED) + if (suspend_recovery(u) < 0) + return; + do_write(u); } |