Mercurial > emacs
comparison src/sound.c @ 83560:738ce3540ffb
Merged from emacs@sv.gnu.org
Patches applied:
* emacs@sv.gnu.org/emacs--devo--0--patch-660
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-661
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-662
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-663
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-664
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-665
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-666
Fix read-only prompt problem in isearch
* emacs@sv.gnu.org/emacs--devo--0--patch-667
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-668
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-669
Merge from gnus--rel--5.10
* emacs@sv.gnu.org/emacs--devo--0--patch-670
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-671
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-672
Update from CVS
* emacs@sv.gnu.org/emacs--devo--0--patch-673
Update from CVS
* emacs@sv.gnu.org/gnus--rel--5.10--patch-206
Merge from emacs--devo--0
* emacs@sv.gnu.org/gnus--rel--5.10--patch-207
Merge from emacs--devo--0
* emacs@sv.gnu.org/gnus--rel--5.10--patch-208
Update from CVS
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-600
author | Karoly Lorentey <karoly@lorentey.hu> |
---|---|
date | Sun, 22 Apr 2007 12:12:29 +0000 |
parents | ebfc3239385f |
children | 922696f363b0 91bf6e05918b |
comparison
equal
deleted
inserted
replaced
83559:edf631bdbb7a | 83560:738ce3540ffb |
---|---|
619 else | 619 else |
620 { | 620 { |
621 char *buffer; | 621 char *buffer; |
622 int nbytes; | 622 int nbytes; |
623 int blksize = sd->period_size ? sd->period_size (sd) : 2048; | 623 int blksize = sd->period_size ? sd->period_size (sd) : 2048; |
624 int data_left = header->data_length; | |
624 | 625 |
625 buffer = (char *) alloca (blksize); | 626 buffer = (char *) alloca (blksize); |
626 lseek (s->fd, sizeof *header, SEEK_SET); | 627 lseek (s->fd, sizeof *header, SEEK_SET); |
627 | 628 while (data_left > 0 |
628 while ((nbytes = emacs_read (s->fd, buffer, blksize)) > 0) | 629 && (nbytes = emacs_read (s->fd, buffer, blksize)) > 0) |
629 sd->write (sd, buffer, nbytes); | 630 { |
631 /* Don't play possible garbage at the end of file */ | |
632 if (data_left < nbytes) nbytes = data_left; | |
633 data_left -= nbytes; | |
634 sd->write (sd, buffer, nbytes); | |
635 } | |
630 | 636 |
631 if (nbytes < 0) | 637 if (nbytes < 0) |
632 sound_perror ("Error reading sound file"); | 638 sound_perror ("Error reading sound file"); |
633 } | 639 } |
634 } | 640 } |
984 static int | 990 static int |
985 alsa_period_size (sd) | 991 alsa_period_size (sd) |
986 struct sound_device *sd; | 992 struct sound_device *sd; |
987 { | 993 { |
988 struct alsa_params *p = (struct alsa_params *) sd->data; | 994 struct alsa_params *p = (struct alsa_params *) sd->data; |
989 return p->period_size; | 995 int fact = snd_pcm_format_size (sd->format, 1) * sd->channels; |
996 return p->period_size * (fact > 0 ? fact : 1); | |
990 } | 997 } |
991 | 998 |
992 static void | 999 static void |
993 alsa_configure (sd) | 1000 alsa_configure (sd) |
994 struct sound_device *sd; | 1001 struct sound_device *sd; |
1207 int nwritten = 0; | 1214 int nwritten = 0; |
1208 int err; | 1215 int err; |
1209 | 1216 |
1210 while (nwritten < nbytes) | 1217 while (nwritten < nbytes) |
1211 { | 1218 { |
1212 err = snd_pcm_writei (p->handle, | 1219 snd_pcm_uframes_t frames = (nbytes - nwritten)/fact; |
1213 buffer + nwritten, | 1220 if (frames == 0) break; |
1214 (nbytes - nwritten)/fact); | 1221 |
1222 err = snd_pcm_writei (p->handle, buffer + nwritten, frames); | |
1215 if (err < 0) | 1223 if (err < 0) |
1216 { | 1224 { |
1217 if (err == -EPIPE) | 1225 if (err == -EPIPE) |
1218 { /* under-run */ | 1226 { /* under-run */ |
1219 err = snd_pcm_prepare (p->handle); | 1227 err = snd_pcm_prepare (p->handle); |