diff options
author | Darren Salt <linux@youmustbejoking.demon.co.uk> | 2007-06-04 20:59:09 +0100 |
---|---|---|
committer | Darren Salt <linux@youmustbejoking.demon.co.uk> | 2007-06-04 20:59:09 +0100 |
commit | 33e68bd91eb35951cfb9b5748c028f3936331cff (patch) | |
tree | 64e082ac978853a0fe55ce6a3da96b49714f76f2 /src/audio_out/audio_alsa_out.c | |
parent | 53c578ab41a18686c99b7168dc6e7de4479fb74f (diff) | |
parent | 6d72cf30f29689035eddbe95d35fd39fcf5d70ca (diff) | |
download | xine-lib-33e68bd91eb35951cfb9b5748c028f3936331cff.tar.gz xine-lib-33e68bd91eb35951cfb9b5748c028f3936331cff.tar.bz2 |
Merge Matthias Kretz's changes.
Diffstat (limited to 'src/audio_out/audio_alsa_out.c')
-rw-r--r-- | src/audio_out/audio_alsa_out.c | 12 |
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, |