comparison src/sound.c @ 38338:c6ff61f9af43

(toplevel): Include <signal.h> and "syssignal.h". (vox_configure, vox_close) [SIGIO]: Block/unblock SIGIO around ioctls.
author Gerd Moellmann <gerd@gnu.org>
date Mon, 09 Jul 2001 17:15:27 +0000
parents 17465a81d1dd
children 5f60884970a8
comparison
equal deleted inserted replaced
38337:e861bf91c070 38338:c6ff61f9af43
30 #include <sys/types.h> 30 #include <sys/types.h>
31 #include <errno.h> 31 #include <errno.h>
32 #include "lisp.h" 32 #include "lisp.h"
33 #include "dispextern.h" 33 #include "dispextern.h"
34 #include "atimer.h" 34 #include "atimer.h"
35 #include <signal.h>
36 #include "syssignal.h"
35 37
36 /* FreeBSD has machine/soundcard.h. Voxware sound driver docs mention 38 /* FreeBSD has machine/soundcard.h. Voxware sound driver docs mention
37 sys/soundcard.h. So, let's try whatever's there. */ 39 sys/soundcard.h. So, let's try whatever's there. */
38 40
39 #ifdef HAVE_MACHINE_SOUNDCARD_H 41 #ifdef HAVE_MACHINE_SOUNDCARD_H
763 { 765 {
764 int val; 766 int val;
765 767
766 xassert (sd->fd >= 0); 768 xassert (sd->fd >= 0);
767 769
770 /* On GNU/Linux, it seems that the device driver doesn't like to be
771 interrupted by a signal. Block the ones we know to cause
772 troubles. */
768 turn_on_atimers (0); 773 turn_on_atimers (0);
774 #ifdef SIGIO
775 sigblock (sigmask (SIGIO));
776 #endif
769 777
770 val = sd->format; 778 val = sd->format;
771 if (ioctl (sd->fd, SNDCTL_DSP_SETFMT, &sd->format) < 0 779 if (ioctl (sd->fd, SNDCTL_DSP_SETFMT, &sd->format) < 0
772 || val != sd->format) 780 || val != sd->format)
773 sound_perror ("Set sound format"); 781 sound_perror ("Set sound format");
794 /* This may fail if there is no mixer. Ignore the failure. */ 802 /* This may fail if there is no mixer. Ignore the failure. */
795 ioctl (sd->fd, SOUND_MIXER_WRITE_PCM, &volume); 803 ioctl (sd->fd, SOUND_MIXER_WRITE_PCM, &volume);
796 } 804 }
797 805
798 turn_on_atimers (1); 806 turn_on_atimers (1);
807 #ifdef SIGIO
808 sigunblock (sigmask (SIGIO));
809 #endif
799 } 810 }
800 811
801 812
802 /* Close device SD if it is open. */ 813 /* Close device SD if it is open. */
803 814
805 vox_close (sd) 816 vox_close (sd)
806 struct sound_device *sd; 817 struct sound_device *sd;
807 { 818 {
808 if (sd->fd >= 0) 819 if (sd->fd >= 0)
809 { 820 {
821 /* On GNU/Linux, it seems that the device driver doesn't like to
822 be interrupted by a signal. Block the ones we know to cause
823 troubles. */
824 #ifdef SIGIO
825 sigblock (sigmask (SIGIO));
826 #endif
827 turn_on_atimers (0);
828
810 /* Flush sound data, and reset the device. */ 829 /* Flush sound data, and reset the device. */
811 turn_on_atimers (0);
812 ioctl (sd->fd, SNDCTL_DSP_SYNC, NULL); 830 ioctl (sd->fd, SNDCTL_DSP_SYNC, NULL);
831
813 turn_on_atimers (1); 832 turn_on_atimers (1);
833 #ifdef SIGIO
834 sigunblock (sigmask (SIGIO));
835 #endif
814 836
815 /* Close the device. */ 837 /* Close the device. */
816 emacs_close (sd->fd); 838 emacs_close (sd->fd);
817 sd->fd = -1; 839 sd->fd = -1;
818 } 840 }