diff options
author | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2005-11-11 00:06:10 +0000 |
---|---|---|
committer | bellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162> | 2005-11-11 00:06:10 +0000 |
commit | 4787c71d179ae9b67b0e682a2a95b6ceca4e68c4 (patch) | |
tree | 4227cb6dd5fd664c780417df94f07f53cc187b8c /audio/alsaaudio.c | |
parent | 541e084426ba3788f19c25e0c442323c9d31bc8d (diff) |
debug fix (malc)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1619 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'audio/alsaaudio.c')
-rw-r--r-- | audio/alsaaudio.c | 63 |
1 files changed, 33 insertions, 30 deletions
diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c index 65a0a0d2e..f7748ca82 100644 --- a/audio/alsaaudio.c +++ b/audio/alsaaudio.c @@ -570,36 +570,39 @@ static int alsa_run_out (HWVoiceOut *hw) hw->clip (dst, src, convert_samples); - again: - written = snd_pcm_writei (alsa->handle, dst, convert_samples); - - if (written < 0) { - switch (written) { - case -EPIPE: - if (!alsa_recover (alsa->handle)) { - goto again; - } - dolog ( - "Failed to write %d frames to %p, handle %p not prepared\n", - convert_samples, - dst, - alsa->handle - ); - goto exit; + while (convert_samples) { + written = snd_pcm_writei (alsa->handle, dst, convert_samples); - case -EAGAIN: - goto again; + if (written < 0) { + switch (written) { + case -EPIPE: + if (!alsa_recover (alsa->handle)) { + continue; + } + dolog ("Failed to write %d frames to %p, " + "handle %p not prepared\n", + convert_samples, + dst, + alsa->handle); + goto exit; - default: - alsa_logerr (written, "Failed to write %d frames to %p\n", - convert_samples, dst); - goto exit; + case -EAGAIN: + continue; + + default: + alsa_logerr (written, "Failed to write %d frames to %p\n", + convert_samples, dst); + goto exit; + } } - } - mixeng_clear (src, written); - rpos = (rpos + written) % hw->samples; - samples -= written; + mixeng_clear (src, written); + rpos = (rpos + written) % hw->samples; + samples -= written; + convert_samples -= written; + dst = advance (dst, written << hw->info.shift); + src += written; + } } exit: @@ -661,8 +664,8 @@ static int alsa_init_out (HWVoiceOut *hw, audsettings_t *as) alsa->pcm_buf = audio_calloc (AUDIO_FUNC, obt.samples, 1 << hw->info.shift); if (!alsa->pcm_buf) { - dolog ("Could not allocate DAC buffer (%d bytes)\n", - hw->samples << hw->info.shift); + dolog ("Could not allocate DAC buffer (%d samples, each %d bytes)\n", + hw->samples, 1 << hw->info.shift); alsa_anal_close (&handle); return -1; } @@ -751,8 +754,8 @@ static int alsa_init_in (HWVoiceIn *hw, audsettings_t *as) alsa->pcm_buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->info.shift); if (!alsa->pcm_buf) { - dolog ("Could not allocate ADC buffer (%d bytes)\n", - hw->samples << hw->info.shift); + dolog ("Could not allocate ADC buffer (%d samples, each %d bytes)\n", + hw->samples, 1 << hw->info.shift); alsa_anal_close (&handle); return -1; } |