summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Courtier-Dutton <jcdutton@users.sourceforge.net>2001-12-10 15:33:24 +0000
committerJames Courtier-Dutton <jcdutton@users.sourceforge.net>2001-12-10 15:33:24 +0000
commit481aff5e14424642b1527d26ff803e6b7ef7bedb (patch)
tree8ca8c368b99e153ccf78ca81bfd387c3d59e73ee
parent1128c5d7a315cf76d5f466b0a24872c07a83e615 (diff)
downloadxine-lib-481aff5e14424642b1527d26ff803e6b7ef7bedb.tar.gz
xine-lib-481aff5e14424642b1527d26ff803e6b7ef7bedb.tar.bz2
Fix audio_alsa_out:write.
buffer calculations and parameter types were wrong. CVS patchset: 1211 CVS date: 2001/12/10 15:33:24
-rw-r--r--src/audio_out/audio_alsa_out.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/audio_out/audio_alsa_out.c b/src/audio_out/audio_alsa_out.c
index b3f2687c2..da7e54561 100644
--- a/src/audio_out/audio_alsa_out.c
+++ b/src/audio_out/audio_alsa_out.c
@@ -26,7 +26,7 @@
* (c) 2001 James Courtier-Dutton <James@superbug.demon.co.uk>
*
*
- * $Id: audio_alsa_out.c,v 1.40 2001/11/30 00:53:50 f1rmb Exp $
+ * $Id: audio_alsa_out.c,v 1.41 2001/12/10 15:33:24 jcdutton Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -431,21 +431,24 @@ void xrun(alsa_driver_t *this)
static int ao_alsa_write(ao_driver_t *this_gen,int16_t *data, uint32_t count)
{
- ssize_t r;
+ snd_pcm_sframes_t result;
+ uint8_t *buffer=(uint8_t *)data;
+ snd_pcm_uframes_t number_of_frames = (snd_pcm_uframes_t) count;
alsa_driver_t *this = (alsa_driver_t *) this_gen;
- while( count > 0) {
- r = snd_pcm_writei(this->audio_fd, data, count);
- /* printf("audio_alsa_out:write:r=%d\n",r); */
- if (r == -EAGAIN || (r >=0 && r < count)) {
+ while( number_of_frames > 0) {
+ result = snd_pcm_writei(this->audio_fd, buffer, number_of_frames);
+ /* printf("audio_alsa_out:write:result=%ld\n",result); */
+ if (result == -EAGAIN || (result >=0 && result < number_of_frames)) {
+ /* printf("audio_alsa_out:write:result=%ld\n",result); */
snd_pcm_wait(this->audio_fd, 1000);
- } else if (r == -EPIPE) {
+ } else if (result == -EPIPE) {
xrun(this);
}
- if (r > 0) {
- count -= r;
+ if (result > 0) {
+ number_of_frames -= result;
/* FIXME: maybe not *2 as int16 */
- data += r * 2 * this->num_channels;
+ buffer += result * this->bytes_per_frame;
}
}
/* FIXME: What should this really be? */