summaryrefslogtreecommitdiff
path: root/src/audio_out/audio_alsa_out.c
diff options
context:
space:
mode:
authorMatthias Kretz <kretz@kde.org>2007-06-04 21:18:49 +0200
committerMatthias Kretz <kretz@kde.org>2007-06-04 21:18:49 +0200
commit24b7171dff5bdbb05dd7ab343e718814aaba9186 (patch)
tree505eb8afa440cf87ae25ca0bf91437c24e930e4a /src/audio_out/audio_alsa_out.c
parenta3571c71d767bd68f7245a46dae1d8f04a91eff9 (diff)
downloadxine-lib-24b7171dff5bdbb05dd7ab343e718814aaba9186.tar.gz
xine-lib-24b7171dff5bdbb05dd7ab343e718814aaba9186.tar.bz2
handle unplugged devices in audio_alsa_out (return -1) and in audio_out close the driver on a return value <0
Diffstat (limited to 'src/audio_out/audio_alsa_out.c')
-rw-r--r--src/audio_out/audio_alsa_out.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/audio_out/audio_alsa_out.c b/src/audio_out/audio_alsa_out.c
index 6ad78da2a..ce3e7fb2b 100644
--- a/src/audio_out/audio_alsa_out.c
+++ b/src/audio_out/audio_alsa_out.c
@@ -752,6 +752,9 @@ static int ao_alsa_write(ao_driver_t *this_gen, int16_t *data, uint32_t count) {
if (res < 0)
return 0;
state = snd_pcm_state(this->audio_fd);
+ } else if (state == SND_PCM_STATE_DISCONNECTED) {
+ /* the device is gone. audio_out.c handles it if we return something < 0 */
+ return -1;
}
if (state == SND_PCM_STATE_XRUN) {
#ifdef LOG_DEBUG
@@ -784,11 +787,11 @@ static int ao_alsa_write(ao_driver_t *this_gen, int16_t *data, uint32_t count) {
#endif
snd_pcm_status(this->audio_fd, pcm_stat);
if ( snd_pcm_status_get_avail(pcm_stat) < number_of_frames) {
- wait_result = snd_pcm_wait(this->audio_fd, 1000000);
+ wait_result = snd_pcm_wait(this->audio_fd, 1000);
#ifdef LOG_DEBUG
printf("audio_alsa_out:write:loop:wait_result=%d\n",wait_result);
#endif
- if (wait_result < 0) return 0;
+ if (wait_result <= 0) return 0;
}
}
if (this->mmap != 0) {
@@ -808,7 +811,10 @@ static int ao_alsa_write(ao_driver_t *this_gen, int16_t *data, uint32_t count) {
return 0;
continue;
}
- if ( (state != SND_PCM_STATE_PREPARED) &&
+ if (state == SND_PCM_STATE_DISCONNECTED) {
+ /* the device is gone. audio_out.c handles it if we return something < 0 */
+ return -1;
+ } else if ( (state != SND_PCM_STATE_PREPARED) &&
(state != SND_PCM_STATE_RUNNING) &&
(state != SND_PCM_STATE_DRAINING) ) {
xprintf(this->class->xine, XINE_VERBOSITY_DEBUG,