Mercurial > emacs
comparison src/sound.c @ 109423:ae5ef13849d8
Merge from mainline.
author | Katsumi Yamaoka <yamaoka@jpl.org> |
---|---|
date | Sun, 04 Jul 2010 22:11:22 +0000 |
parents | aec1143e8d85 |
children | 750db9f3e6d8 |
comparison
equal
deleted
inserted
replaced
109422:bcedeeedc5fb | 109423:ae5ef13849d8 |
---|---|
113 SOUND_DEVICE, | 113 SOUND_DEVICE, |
114 SOUND_VOLUME, | 114 SOUND_VOLUME, |
115 SOUND_ATTR_SENTINEL | 115 SOUND_ATTR_SENTINEL |
116 }; | 116 }; |
117 | 117 |
118 static void alsa_sound_perror P_ ((char *, int)) NO_RETURN; | 118 static void alsa_sound_perror (char *, int) NO_RETURN; |
119 static void sound_perror P_ ((char *)) NO_RETURN; | 119 static void sound_perror (char *) NO_RETURN; |
120 static void sound_warning P_ ((char *)); | 120 static void sound_warning (char *); |
121 static int parse_sound P_ ((Lisp_Object, Lisp_Object *)); | 121 static int parse_sound (Lisp_Object, Lisp_Object *); |
122 | 122 |
123 /* END: Common Definitions */ | 123 /* END: Common Definitions */ |
124 | 124 |
125 /* BEGIN: Non Windows Definitions */ | 125 /* BEGIN: Non Windows Definitions */ |
126 #ifndef WINDOWSNT | 126 #ifndef WINDOWSNT |
223 | 223 |
224 /* 1 = mono, 2 = stereo, 0 = don't set. */ | 224 /* 1 = mono, 2 = stereo, 0 = don't set. */ |
225 int channels; | 225 int channels; |
226 | 226 |
227 /* Open device SD. */ | 227 /* Open device SD. */ |
228 void (* open) P_ ((struct sound_device *sd)); | 228 void (* open) (struct sound_device *sd); |
229 | 229 |
230 /* Close device SD. */ | 230 /* Close device SD. */ |
231 void (* close) P_ ((struct sound_device *sd)); | 231 void (* close) (struct sound_device *sd); |
232 | 232 |
233 /* Configure SD accoring to device-dependent parameters. */ | 233 /* Configure SD accoring to device-dependent parameters. */ |
234 void (* configure) P_ ((struct sound_device *device)); | 234 void (* configure) (struct sound_device *device); |
235 | 235 |
236 /* Choose a device-dependent format for outputting sound S. */ | 236 /* Choose a device-dependent format for outputting sound S. */ |
237 void (* choose_format) P_ ((struct sound_device *sd, | 237 void (* choose_format) (struct sound_device *sd, |
238 struct sound *s)); | 238 struct sound *s); |
239 | 239 |
240 /* Return a preferred data size in bytes to be sent to write (below) | 240 /* Return a preferred data size in bytes to be sent to write (below) |
241 each time. 2048 is used if this is NULL. */ | 241 each time. 2048 is used if this is NULL. */ |
242 int (* period_size) P_ ((struct sound_device *sd)); | 242 int (* period_size) (struct sound_device *sd); |
243 | 243 |
244 /* Write NYBTES bytes from BUFFER to device SD. */ | 244 /* Write NYBTES bytes from BUFFER to device SD. */ |
245 void (* write) P_ ((struct sound_device *sd, const char *buffer, | 245 void (* write) (struct sound_device *sd, const char *buffer, |
246 int nbytes)); | 246 int nbytes); |
247 | 247 |
248 /* A place for devices to store additional data. */ | 248 /* A place for devices to store additional data. */ |
249 void *data; | 249 void *data; |
250 }; | 250 }; |
251 | 251 |
277 | 277 |
278 /* Sound data, if a string. */ | 278 /* Sound data, if a string. */ |
279 Lisp_Object data; | 279 Lisp_Object data; |
280 | 280 |
281 /* Play sound file S on device SD. */ | 281 /* Play sound file S on device SD. */ |
282 void (* play) P_ ((struct sound *s, struct sound_device *sd)); | 282 void (* play) (struct sound *s, struct sound_device *sd); |
283 }; | 283 }; |
284 | 284 |
285 /* These are set during `play-sound-internal' so that sound_cleanup has | 285 /* These are set during `play-sound-internal' so that sound_cleanup has |
286 access to them. */ | 286 access to them. */ |
287 | 287 |
288 struct sound_device *current_sound_device; | 288 struct sound_device *current_sound_device; |
289 struct sound *current_sound; | 289 struct sound *current_sound; |
290 | 290 |
291 /* Function prototypes. */ | 291 /* Function prototypes. */ |
292 | 292 |
293 static void vox_open P_ ((struct sound_device *)); | 293 static void vox_open (struct sound_device *); |
294 static void vox_configure P_ ((struct sound_device *)); | 294 static void vox_configure (struct sound_device *); |
295 static void vox_close P_ ((struct sound_device *sd)); | 295 static void vox_close (struct sound_device *sd); |
296 static void vox_choose_format P_ ((struct sound_device *, struct sound *)); | 296 static void vox_choose_format (struct sound_device *, struct sound *); |
297 static int vox_init P_ ((struct sound_device *)); | 297 static int vox_init (struct sound_device *); |
298 static void vox_write P_ ((struct sound_device *, const char *, int)); | 298 static void vox_write (struct sound_device *, const char *, int); |
299 static void find_sound_type P_ ((struct sound *)); | 299 static void find_sound_type (struct sound *); |
300 static u_int32_t le2hl P_ ((u_int32_t)); | 300 static u_int32_t le2hl (u_int32_t); |
301 static u_int16_t le2hs P_ ((u_int16_t)); | 301 static u_int16_t le2hs (u_int16_t); |
302 static u_int32_t be2hl P_ ((u_int32_t)); | 302 static u_int32_t be2hl (u_int32_t); |
303 static int wav_init P_ ((struct sound *)); | 303 static int wav_init (struct sound *); |
304 static void wav_play P_ ((struct sound *, struct sound_device *)); | 304 static void wav_play (struct sound *, struct sound_device *); |
305 static int au_init P_ ((struct sound *)); | 305 static int au_init (struct sound *); |
306 static void au_play P_ ((struct sound *, struct sound_device *)); | 306 static void au_play (struct sound *, struct sound_device *); |
307 | 307 |
308 #if 0 /* Currently not used. */ | 308 #if 0 /* Currently not used. */ |
309 static u_int16_t be2hs P_ ((u_int16_t)); | 309 static u_int16_t be2hs (u_int16_t); |
310 #endif | 310 #endif |
311 | 311 |
312 /* END: Non Windows Definitions */ | 312 /* END: Non Windows Definitions */ |
313 #else /* WINDOWSNT */ | 313 #else /* WINDOWSNT */ |
314 | 314 |
315 /* BEGIN: Windows Specific Definitions */ | 315 /* BEGIN: Windows Specific Definitions */ |
316 static int do_play_sound P_ ((const char *, unsigned long)); | 316 static int do_play_sound (const char *, unsigned long); |
317 /* | 317 /* |
318 END: Windows Specific Definitions */ | 318 END: Windows Specific Definitions */ |
319 #endif /* WINDOWSNT */ | 319 #endif /* WINDOWSNT */ |
320 | 320 |
321 | 321 |
326 /* BEGIN: Common functions */ | 326 /* BEGIN: Common functions */ |
327 | 327 |
328 /* Like perror, but signals an error. */ | 328 /* Like perror, but signals an error. */ |
329 | 329 |
330 static void | 330 static void |
331 sound_perror (msg) | 331 sound_perror (char *msg) |
332 char *msg; | |
333 { | 332 { |
334 int saved_errno = errno; | 333 int saved_errno = errno; |
335 | 334 |
336 turn_on_atimers (1); | 335 turn_on_atimers (1); |
337 #ifdef SIGIO | 336 #ifdef SIGIO |
345 | 344 |
346 | 345 |
347 /* Display a warning message. */ | 346 /* Display a warning message. */ |
348 | 347 |
349 static void | 348 static void |
350 sound_warning (msg) | 349 sound_warning (char *msg) |
351 char *msg; | |
352 { | 350 { |
353 message (msg); | 351 message (msg); |
354 } | 352 } |
355 | 353 |
356 | 354 |
379 | 377 |
380 VOL must be an integer in the range [0, 100], or a float in the | 378 VOL must be an integer in the range [0, 100], or a float in the |
381 range [0, 1]. */ | 379 range [0, 1]. */ |
382 | 380 |
383 static int | 381 static int |
384 parse_sound (sound, attrs) | 382 parse_sound (Lisp_Object sound, Lisp_Object *attrs) |
385 Lisp_Object sound; | |
386 Lisp_Object *attrs; | |
387 { | 383 { |
388 /* SOUND must be a list starting with the symbol `sound'. */ | 384 /* SOUND must be a list starting with the symbol `sound'. */ |
389 if (!CONSP (sound) || !EQ (XCAR (sound), Qsound)) | 385 if (!CONSP (sound) || !EQ (XCAR (sound), Qsound)) |
390 return 0; | 386 return 0; |
391 | 387 |
450 | 446 |
451 /* Find out the type of the sound file whose file descriptor is FD. | 447 /* Find out the type of the sound file whose file descriptor is FD. |
452 S is the sound file structure to fill in. */ | 448 S is the sound file structure to fill in. */ |
453 | 449 |
454 static void | 450 static void |
455 find_sound_type (s) | 451 find_sound_type (struct sound *s) |
456 struct sound *s; | |
457 { | 452 { |
458 if (!wav_init (s) && !au_init (s)) | 453 if (!wav_init (s) && !au_init (s)) |
459 error ("Unknown sound format"); | 454 error ("Unknown sound format"); |
460 } | 455 } |
461 | 456 |
462 | 457 |
463 /* Function installed by play-sound-internal with record_unwind_protect. */ | 458 /* Function installed by play-sound-internal with record_unwind_protect. */ |
464 | 459 |
465 static Lisp_Object | 460 static Lisp_Object |
466 sound_cleanup (arg) | 461 sound_cleanup (Lisp_Object arg) |
467 Lisp_Object arg; | |
468 { | 462 { |
469 if (current_sound_device->close) | 463 if (current_sound_device->close) |
470 current_sound_device->close (current_sound_device); | 464 current_sound_device->close (current_sound_device); |
471 if (current_sound->fd > 0) | 465 if (current_sound->fd > 0) |
472 emacs_close (current_sound->fd); | 466 emacs_close (current_sound->fd); |
482 | 476 |
483 /* Convert 32-bit value VALUE which is in little-endian byte-order | 477 /* Convert 32-bit value VALUE which is in little-endian byte-order |
484 to host byte-order. */ | 478 to host byte-order. */ |
485 | 479 |
486 static u_int32_t | 480 static u_int32_t |
487 le2hl (value) | 481 le2hl (u_int32_t value) |
488 u_int32_t value; | |
489 { | 482 { |
490 #ifdef WORDS_BIG_ENDIAN | 483 #ifdef WORDS_BIG_ENDIAN |
491 unsigned char *p = (unsigned char *) &value; | 484 unsigned char *p = (unsigned char *) &value; |
492 value = p[0] + (p[1] << 8) + (p[2] << 16) + (p[3] << 24); | 485 value = p[0] + (p[1] << 8) + (p[2] << 16) + (p[3] << 24); |
493 #endif | 486 #endif |
497 | 490 |
498 /* Convert 16-bit value VALUE which is in little-endian byte-order | 491 /* Convert 16-bit value VALUE which is in little-endian byte-order |
499 to host byte-order. */ | 492 to host byte-order. */ |
500 | 493 |
501 static u_int16_t | 494 static u_int16_t |
502 le2hs (value) | 495 le2hs (u_int16_t value) |
503 u_int16_t value; | |
504 { | 496 { |
505 #ifdef WORDS_BIG_ENDIAN | 497 #ifdef WORDS_BIG_ENDIAN |
506 unsigned char *p = (unsigned char *) &value; | 498 unsigned char *p = (unsigned char *) &value; |
507 value = p[0] + (p[1] << 8); | 499 value = p[0] + (p[1] << 8); |
508 #endif | 500 #endif |
512 | 504 |
513 /* Convert 32-bit value VALUE which is in big-endian byte-order | 505 /* Convert 32-bit value VALUE which is in big-endian byte-order |
514 to host byte-order. */ | 506 to host byte-order. */ |
515 | 507 |
516 static u_int32_t | 508 static u_int32_t |
517 be2hl (value) | 509 be2hl (u_int32_t value) |
518 u_int32_t value; | |
519 { | 510 { |
520 #ifndef WORDS_BIG_ENDIAN | 511 #ifndef WORDS_BIG_ENDIAN |
521 unsigned char *p = (unsigned char *) &value; | 512 unsigned char *p = (unsigned char *) &value; |
522 value = p[3] + (p[2] << 8) + (p[1] << 16) + (p[0] << 24); | 513 value = p[3] + (p[2] << 8) + (p[1] << 16) + (p[0] << 24); |
523 #endif | 514 #endif |
552 sound file. If the file is a WAV-format file, set up interface | 543 sound file. If the file is a WAV-format file, set up interface |
553 functions in S and convert header fields to host byte-order. | 544 functions in S and convert header fields to host byte-order. |
554 Value is non-zero if the file is a WAV file. */ | 545 Value is non-zero if the file is a WAV file. */ |
555 | 546 |
556 static int | 547 static int |
557 wav_init (s) | 548 wav_init (struct sound *s) |
558 struct sound *s; | |
559 { | 549 { |
560 struct wav_header *header = (struct wav_header *) s->header; | 550 struct wav_header *header = (struct wav_header *) s->header; |
561 | 551 |
562 if (s->header_size < sizeof *header | 552 if (s->header_size < sizeof *header |
563 || bcmp (s->header, "RIFF", 4) != 0) | 553 || bcmp (s->header, "RIFF", 4) != 0) |
588 | 578 |
589 | 579 |
590 /* Play RIFF-WAVE audio file S on sound device SD. */ | 580 /* Play RIFF-WAVE audio file S on sound device SD. */ |
591 | 581 |
592 static void | 582 static void |
593 wav_play (s, sd) | 583 wav_play (struct sound *s, struct sound_device *sd) |
594 struct sound *s; | |
595 struct sound_device *sd; | |
596 { | 584 { |
597 struct wav_header *header = (struct wav_header *) s->header; | 585 struct wav_header *header = (struct wav_header *) s->header; |
598 | 586 |
599 /* Let the device choose a suitable device-dependent format | 587 /* Let the device choose a suitable device-dependent format |
600 for the file. */ | 588 for the file. */ |
663 sound file. If the file is a AU-format file, set up interface | 651 sound file. If the file is a AU-format file, set up interface |
664 functions in S and convert header fields to host byte-order. | 652 functions in S and convert header fields to host byte-order. |
665 Value is non-zero if the file is an AU file. */ | 653 Value is non-zero if the file is an AU file. */ |
666 | 654 |
667 static int | 655 static int |
668 au_init (s) | 656 au_init (struct sound *s) |
669 struct sound *s; | |
670 { | 657 { |
671 struct au_header *header = (struct au_header *) s->header; | 658 struct au_header *header = (struct au_header *) s->header; |
672 | 659 |
673 if (s->header_size < sizeof *header | 660 if (s->header_size < sizeof *header |
674 || bcmp (s->header, ".snd", 4) != 0) | 661 || bcmp (s->header, ".snd", 4) != 0) |
690 | 677 |
691 | 678 |
692 /* Play Sun audio file S on sound device SD. */ | 679 /* Play Sun audio file S on sound device SD. */ |
693 | 680 |
694 static void | 681 static void |
695 au_play (s, sd) | 682 au_play (struct sound *s, struct sound_device *sd) |
696 struct sound *s; | |
697 struct sound_device *sd; | |
698 { | 683 { |
699 struct au_header *header = (struct au_header *) s->header; | 684 struct au_header *header = (struct au_header *) s->header; |
700 | 685 |
701 sd->sample_size = 0; | 686 sd->sample_size = 0; |
702 sd->sample_rate = header->sample_rate; | 687 sd->sample_rate = header->sample_rate; |
738 | 723 |
739 /* Open device SD. If SD->file is non-null, open that device, | 724 /* Open device SD. If SD->file is non-null, open that device, |
740 otherwise use a default device name. */ | 725 otherwise use a default device name. */ |
741 | 726 |
742 static void | 727 static void |
743 vox_open (sd) | 728 vox_open (struct sound_device *sd) |
744 struct sound_device *sd; | |
745 { | 729 { |
746 char *file; | 730 char *file; |
747 | 731 |
748 /* Open the sound device. Default is /dev/dsp. */ | 732 /* Open the sound device. Default is /dev/dsp. */ |
749 if (sd->file) | 733 if (sd->file) |
758 | 742 |
759 | 743 |
760 /* Configure device SD from parameters in it. */ | 744 /* Configure device SD from parameters in it. */ |
761 | 745 |
762 static void | 746 static void |
763 vox_configure (sd) | 747 vox_configure (struct sound_device *sd) |
764 struct sound_device *sd; | |
765 { | 748 { |
766 int val; | 749 int val; |
767 | 750 |
768 xassert (sd->fd >= 0); | 751 xassert (sd->fd >= 0); |
769 | 752 |
812 | 795 |
813 | 796 |
814 /* Close device SD if it is open. */ | 797 /* Close device SD if it is open. */ |
815 | 798 |
816 static void | 799 static void |
817 vox_close (sd) | 800 vox_close (struct sound_device *sd) |
818 struct sound_device *sd; | |
819 { | 801 { |
820 if (sd->fd >= 0) | 802 if (sd->fd >= 0) |
821 { | 803 { |
822 /* On GNU/Linux, it seems that the device driver doesn't like to | 804 /* On GNU/Linux, it seems that the device driver doesn't like to |
823 be interrupted by a signal. Block the ones we know to cause | 805 be interrupted by a signal. Block the ones we know to cause |
843 | 825 |
844 | 826 |
845 /* Choose device-dependent format for device SD from sound file S. */ | 827 /* Choose device-dependent format for device SD from sound file S. */ |
846 | 828 |
847 static void | 829 static void |
848 vox_choose_format (sd, s) | 830 vox_choose_format (struct sound_device *sd, struct sound *s) |
849 struct sound_device *sd; | |
850 struct sound *s; | |
851 { | 831 { |
852 if (s->type == RIFF) | 832 if (s->type == RIFF) |
853 { | 833 { |
854 struct wav_header *h = (struct wav_header *) s->header; | 834 struct wav_header *h = (struct wav_header *) s->header; |
855 if (h->precision == 8) | 835 if (h->precision == 8) |
888 | 868 |
889 /* Initialize device SD. Set up the interface functions in the device | 869 /* Initialize device SD. Set up the interface functions in the device |
890 structure. */ | 870 structure. */ |
891 | 871 |
892 static int | 872 static int |
893 vox_init (sd) | 873 vox_init (struct sound_device *sd) |
894 struct sound_device *sd; | |
895 { | 874 { |
896 char *file; | 875 char *file; |
897 int fd; | 876 int fd; |
898 | 877 |
899 /* Open the sound device. Default is /dev/dsp. */ | 878 /* Open the sound device. Default is /dev/dsp. */ |
919 } | 898 } |
920 | 899 |
921 /* Write NBYTES bytes from BUFFER to device SD. */ | 900 /* Write NBYTES bytes from BUFFER to device SD. */ |
922 | 901 |
923 static void | 902 static void |
924 vox_write (sd, buffer, nbytes) | 903 vox_write (struct sound_device *sd, const char *buffer, int nbytes) |
925 struct sound_device *sd; | |
926 const char *buffer; | |
927 int nbytes; | |
928 { | 904 { |
929 int nwritten = emacs_write (sd->fd, buffer, nbytes); | 905 int nwritten = emacs_write (sd->fd, buffer, nbytes); |
930 if (nwritten < 0) | 906 if (nwritten < 0) |
931 sound_perror ("Error writing to sound device"); | 907 sound_perror ("Error writing to sound device"); |
932 } | 908 } |
937 ***********************************************************************/ | 913 ***********************************************************************/ |
938 | 914 |
939 /* This driver is available on GNU/Linux. */ | 915 /* This driver is available on GNU/Linux. */ |
940 | 916 |
941 static void | 917 static void |
942 alsa_sound_perror (msg, err) | 918 alsa_sound_perror (char *msg, int err) |
943 char *msg; | |
944 int err; | |
945 { | 919 { |
946 error ("%s: %s", msg, snd_strerror (err)); | 920 error ("%s: %s", msg, snd_strerror (err)); |
947 } | 921 } |
948 | 922 |
949 struct alsa_params | 923 struct alsa_params |
956 | 930 |
957 /* Open device SD. If SD->file is non-null, open that device, | 931 /* Open device SD. If SD->file is non-null, open that device, |
958 otherwise use a default device name. */ | 932 otherwise use a default device name. */ |
959 | 933 |
960 static void | 934 static void |
961 alsa_open (sd) | 935 alsa_open (struct sound_device *sd) |
962 struct sound_device *sd; | |
963 { | 936 { |
964 char *file; | 937 char *file; |
965 struct alsa_params *p; | 938 struct alsa_params *p; |
966 int err; | 939 int err; |
967 | 940 |
984 if (err < 0) | 957 if (err < 0) |
985 alsa_sound_perror (file, err); | 958 alsa_sound_perror (file, err); |
986 } | 959 } |
987 | 960 |
988 static int | 961 static int |
989 alsa_period_size (sd) | 962 alsa_period_size (struct sound_device *sd) |
990 struct sound_device *sd; | |
991 { | 963 { |
992 struct alsa_params *p = (struct alsa_params *) sd->data; | 964 struct alsa_params *p = (struct alsa_params *) sd->data; |
993 int fact = snd_pcm_format_size (sd->format, 1) * sd->channels; | 965 int fact = snd_pcm_format_size (sd->format, 1) * sd->channels; |
994 return p->period_size * (fact > 0 ? fact : 1); | 966 return p->period_size * (fact > 0 ? fact : 1); |
995 } | 967 } |
996 | 968 |
997 static void | 969 static void |
998 alsa_configure (sd) | 970 alsa_configure (struct sound_device *sd) |
999 struct sound_device *sd; | |
1000 { | 971 { |
1001 int val, err, dir; | 972 int val, err, dir; |
1002 unsigned uval; | 973 unsigned uval; |
1003 struct alsa_params *p = (struct alsa_params *) sd->data; | 974 struct alsa_params *p = (struct alsa_params *) sd->data; |
1004 snd_pcm_uframes_t buffer_size; | 975 snd_pcm_uframes_t buffer_size; |
1113 | 1084 |
1114 | 1085 |
1115 /* Close device SD if it is open. */ | 1086 /* Close device SD if it is open. */ |
1116 | 1087 |
1117 static void | 1088 static void |
1118 alsa_close (sd) | 1089 alsa_close (struct sound_device *sd) |
1119 struct sound_device *sd; | |
1120 { | 1090 { |
1121 struct alsa_params *p = (struct alsa_params *) sd->data; | 1091 struct alsa_params *p = (struct alsa_params *) sd->data; |
1122 if (p) | 1092 if (p) |
1123 { | 1093 { |
1124 if (p->hwparams) | 1094 if (p->hwparams) |
1135 } | 1105 } |
1136 | 1106 |
1137 /* Choose device-dependent format for device SD from sound file S. */ | 1107 /* Choose device-dependent format for device SD from sound file S. */ |
1138 | 1108 |
1139 static void | 1109 static void |
1140 alsa_choose_format (sd, s) | 1110 alsa_choose_format (struct sound_device *sd, struct sound *s) |
1141 struct sound_device *sd; | |
1142 struct sound *s; | |
1143 { | 1111 { |
1144 struct alsa_params *p = (struct alsa_params *) sd->data; | 1112 struct alsa_params *p = (struct alsa_params *) sd->data; |
1145 if (s->type == RIFF) | 1113 if (s->type == RIFF) |
1146 { | 1114 { |
1147 struct wav_header *h = (struct wav_header *) s->header; | 1115 struct wav_header *h = (struct wav_header *) s->header; |
1192 | 1160 |
1193 | 1161 |
1194 /* Write NBYTES bytes from BUFFER to device SD. */ | 1162 /* Write NBYTES bytes from BUFFER to device SD. */ |
1195 | 1163 |
1196 static void | 1164 static void |
1197 alsa_write (sd, buffer, nbytes) | 1165 alsa_write (struct sound_device *sd, const char *buffer, int nbytes) |
1198 struct sound_device *sd; | |
1199 const char *buffer; | |
1200 int nbytes; | |
1201 { | 1166 { |
1202 struct alsa_params *p = (struct alsa_params *) sd->data; | 1167 struct alsa_params *p = (struct alsa_params *) sd->data; |
1203 | 1168 |
1204 /* The the third parameter to snd_pcm_writei is frames, not bytes. */ | 1169 /* The the third parameter to snd_pcm_writei is frames, not bytes. */ |
1205 int fact = snd_pcm_format_size (sd->format, 1) * sd->channels; | 1170 int fact = snd_pcm_format_size (sd->format, 1) * sd->channels; |
1242 nwritten += err * fact; | 1207 nwritten += err * fact; |
1243 } | 1208 } |
1244 } | 1209 } |
1245 | 1210 |
1246 static void | 1211 static void |
1247 snd_error_quiet (file, line, function, err, fmt) | 1212 snd_error_quiet (const char *file, int line, const char *function, int err, const char *fmt) |
1248 const char *file; | |
1249 int line; | |
1250 const char *function; | |
1251 int err; | |
1252 const char *fmt; | |
1253 { | 1213 { |
1254 } | 1214 } |
1255 | 1215 |
1256 /* Initialize device SD. Set up the interface functions in the device | 1216 /* Initialize device SD. Set up the interface functions in the device |
1257 structure. */ | 1217 structure. */ |
1258 | 1218 |
1259 static int | 1219 static int |
1260 alsa_init (sd) | 1220 alsa_init (struct sound_device *sd) |
1261 struct sound_device *sd; | |
1262 { | 1221 { |
1263 char *file; | 1222 char *file; |
1264 snd_pcm_t *handle; | 1223 snd_pcm_t *handle; |
1265 int err; | 1224 int err; |
1266 | 1225 |
1522 /*********************************************************************** | 1481 /*********************************************************************** |
1523 Initialization | 1482 Initialization |
1524 ***********************************************************************/ | 1483 ***********************************************************************/ |
1525 | 1484 |
1526 void | 1485 void |
1527 syms_of_sound () | 1486 syms_of_sound (void) |
1528 { | 1487 { |
1529 QCdevice = intern_c_string(":device"); | 1488 QCdevice = intern_c_string(":device"); |
1530 staticpro (&QCdevice); | 1489 staticpro (&QCdevice); |
1531 QCvolume = intern_c_string (":volume"); | 1490 QCvolume = intern_c_string (":volume"); |
1532 staticpro (&QCvolume); | 1491 staticpro (&QCvolume); |
1538 defsubr (&Splay_sound_internal); | 1497 defsubr (&Splay_sound_internal); |
1539 } | 1498 } |
1540 | 1499 |
1541 | 1500 |
1542 void | 1501 void |
1543 init_sound () | 1502 init_sound (void) |
1544 { | 1503 { |
1545 } | 1504 } |
1546 | 1505 |
1547 #endif /* HAVE_SOUND */ | 1506 #endif /* HAVE_SOUND */ |
1548 | 1507 |