comparison src/sound.c @ 38215:b9fdde642b13

(vox_configure, vox_close): Turn off atimers around ioctls.
author Gerd Moellmann <gerd@gnu.org>
date Wed, 27 Jun 2001 09:22:36 +0000
parents db2901e01b72
children 17465a81d1dd
comparison
equal deleted inserted replaced
38214:a4de79556592 38215:b9fdde642b13
29 #include <fcntl.h> 29 #include <fcntl.h>
30 #include <unistd.h> 30 #include <unistd.h>
31 #include <sys/types.h> 31 #include <sys/types.h>
32 #include <dispextern.h> 32 #include <dispextern.h>
33 #include <errno.h> 33 #include <errno.h>
34 #include <atimer.h>
34 35
35 /* FreeBSD has machine/soundcard.h. Voxware sound driver docs mention 36 /* FreeBSD has machine/soundcard.h. Voxware sound driver docs mention
36 sys/soundcard.h. So, let's try whatever's there. */ 37 sys/soundcard.h. So, let's try whatever's there. */
37 38
38 #ifdef HAVE_MACHINE_SOUNDCARD_H 39 #ifdef HAVE_MACHINE_SOUNDCARD_H
409 410
410 if (STRINGP (attrs[SOUND_FILE])) 411 if (STRINGP (attrs[SOUND_FILE]))
411 { 412 {
412 /* Open the sound file. */ 413 /* Open the sound file. */
413 s.fd = openp (Fcons (Vdata_directory, Qnil), 414 s.fd = openp (Fcons (Vdata_directory, Qnil),
414 attrs[SOUND_FILE], "", &file, 0); 415 attrs[SOUND_FILE], "", &file, 0);
415 if (s.fd < 0) 416 if (s.fd < 0)
416 sound_perror ("Open sound file"); 417 sound_perror ("Open sound file");
417 418
418 /* Read the first bytes from the file. */ 419 /* Read the first bytes from the file. */
419 s.header_size = emacs_read (s.fd, s.header, MAX_SOUND_HEADER_BYTES); 420 s.header_size = emacs_read (s.fd, s.header, MAX_SOUND_HEADER_BYTES);
762 { 763 {
763 int val; 764 int val;
764 765
765 xassert (sd->fd >= 0); 766 xassert (sd->fd >= 0);
766 767
768 turn_on_atimers (0);
769
767 val = sd->format; 770 val = sd->format;
768 if (ioctl (sd->fd, SNDCTL_DSP_SETFMT, &sd->format) < 0 771 if (ioctl (sd->fd, SNDCTL_DSP_SETFMT, &sd->format) < 0
769 || val != sd->format) 772 || val != sd->format)
770 sound_perror ("Set sound format"); 773 sound_perror ("Set sound format");
771 774
789 int volume = sd->volume & 0xff; 792 int volume = sd->volume & 0xff;
790 volume |= volume << 8; 793 volume |= volume << 8;
791 /* This may fail if there is no mixer. Ignore the failure. */ 794 /* This may fail if there is no mixer. Ignore the failure. */
792 ioctl (sd->fd, SOUND_MIXER_WRITE_PCM, &volume); 795 ioctl (sd->fd, SOUND_MIXER_WRITE_PCM, &volume);
793 } 796 }
797
798 turn_on_atimers (1);
794 } 799 }
795 800
796 801
797 /* Close device SD if it is open. */ 802 /* Close device SD if it is open. */
798 803
801 struct sound_device *sd; 806 struct sound_device *sd;
802 { 807 {
803 if (sd->fd >= 0) 808 if (sd->fd >= 0)
804 { 809 {
805 /* Flush sound data, and reset the device. */ 810 /* Flush sound data, and reset the device. */
811 turn_on_atimers (0);
806 ioctl (sd->fd, SNDCTL_DSP_SYNC, NULL); 812 ioctl (sd->fd, SNDCTL_DSP_SYNC, NULL);
813 turn_on_atimers (1);
807 814
808 /* Close the device. */ 815 /* Close the device. */
809 emacs_close (sd->fd); 816 emacs_close (sd->fd);
810 sd->fd = -1; 817 sd->fd = -1;
811 } 818 }