diff options
| author | Pavel Janík | 2002-01-14 14:37:37 +0000 |
|---|---|---|
| committer | Pavel Janík | 2002-01-14 14:37:37 +0000 |
| commit | a4ff5d679965e2dde0f2599ebe6768b3dd781e06 (patch) | |
| tree | 237355e6fb5a823ac6d857423722b7dc19c552ae /src | |
| parent | 54bff0bd3c6125e9ba5541420f35a6fbcade25ed (diff) | |
| download | emacs-a4ff5d679965e2dde0f2599ebe6768b3dd781e06.tar.gz emacs-a4ff5d679965e2dde0f2599ebe6768b3dd781e06.zip | |
(Fplay_sound): Initialize header_size also for :data case.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/sound.c | 52 |
2 files changed, 31 insertions, 26 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index f319b9eb2f9..4d709d14ef0 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2002-01-14 Pavel Jan,Bm(Bk <Pavel@Janik.cz> | ||
| 2 | |||
| 3 | * sound.c (Fplay_sound): Initialize header_size also for :data | ||
| 4 | case. | ||
| 5 | |||
| 1 | 2002-01-14 Eli Zaretskii <eliz@is.elta.co.il> | 6 | 2002-01-14 Eli Zaretskii <eliz@is.elta.co.il> |
| 2 | 7 | ||
| 3 | Support for the --color command-line argument and tty-color-mode | 8 | Support for the --color command-line argument and tty-color-mode |
diff --git a/src/sound.c b/src/sound.c index 258c67261d3..eaa70204daf 100644 --- a/src/sound.c +++ b/src/sound.c | |||
| @@ -90,10 +90,10 @@ struct au_header | |||
| 90 | { | 90 | { |
| 91 | /* ASCII ".snd" */ | 91 | /* ASCII ".snd" */ |
| 92 | u_int32_t magic_number; | 92 | u_int32_t magic_number; |
| 93 | 93 | ||
| 94 | /* Offset of data part from start of file. Minimum value is 24. */ | 94 | /* Offset of data part from start of file. Minimum value is 24. */ |
| 95 | u_int32_t data_offset; | 95 | u_int32_t data_offset; |
| 96 | 96 | ||
| 97 | /* Size of data part, 0xffffffff if unknown. */ | 97 | /* Size of data part, 0xffffffff if unknown. */ |
| 98 | u_int32_t data_size; | 98 | u_int32_t data_size; |
| 99 | 99 | ||
| @@ -148,7 +148,7 @@ struct sound_device | |||
| 148 | 148 | ||
| 149 | /* 1 = mono, 2 = stereo, 0 = don't set. */ | 149 | /* 1 = mono, 2 = stereo, 0 = don't set. */ |
| 150 | int channels; | 150 | int channels; |
| 151 | 151 | ||
| 152 | /* Open device SD. */ | 152 | /* Open device SD. */ |
| 153 | void (* open) P_ ((struct sound_device *sd)); | 153 | void (* open) P_ ((struct sound_device *sd)); |
| 154 | 154 | ||
| @@ -157,7 +157,7 @@ struct sound_device | |||
| 157 | 157 | ||
| 158 | /* Configure SD accoring to device-dependent parameters. */ | 158 | /* Configure SD accoring to device-dependent parameters. */ |
| 159 | void (* configure) P_ ((struct sound_device *device)); | 159 | void (* configure) P_ ((struct sound_device *device)); |
| 160 | 160 | ||
| 161 | /* Choose a device-dependent format for outputting sound S. */ | 161 | /* Choose a device-dependent format for outputting sound S. */ |
| 162 | void (* choose_format) P_ ((struct sound_device *sd, | 162 | void (* choose_format) P_ ((struct sound_device *sd, |
| 163 | struct sound *s)); | 163 | struct sound *s)); |
| @@ -199,7 +199,7 @@ struct sound | |||
| 199 | Lisp_Object data; | 199 | Lisp_Object data; |
| 200 | 200 | ||
| 201 | /* Play sound file S on device SD. */ | 201 | /* Play sound file S on device SD. */ |
| 202 | void (* play) P_ ((struct sound *s, struct sound_device *sd)); | 202 | void (* play) P_ ((struct sound *s, struct sound_device *sd)); |
| 203 | }; | 203 | }; |
| 204 | 204 | ||
| 205 | /* Indices of attributes in a sound attributes vector. */ | 205 | /* Indices of attributes in a sound attributes vector. */ |
| @@ -447,8 +447,8 @@ a system-dependent default device name is used. */) | |||
| 447 | else | 447 | else |
| 448 | { | 448 | { |
| 449 | s.data = attrs[SOUND_DATA]; | 449 | s.data = attrs[SOUND_DATA]; |
| 450 | bcopy (XSTRING (s.data)->data, s.header, | 450 | s.header_size = min (MAX_SOUND_HEADER_BYTES, STRING_BYTES (XSTRING (s.data))); |
| 451 | min (MAX_SOUND_HEADER_BYTES, STRING_BYTES (XSTRING (s.data)))); | 451 | bcopy (XSTRING (s.data)->data, s.header, s.header_size); |
| 452 | } | 452 | } |
| 453 | 453 | ||
| 454 | /* Find out the type of sound. Give up if we can't tell. */ | 454 | /* Find out the type of sound. Give up if we can't tell. */ |
| @@ -461,7 +461,7 @@ a system-dependent default device name is used. */) | |||
| 461 | sd.file = (char *) alloca (len + 1); | 461 | sd.file = (char *) alloca (len + 1); |
| 462 | strcpy (sd.file, XSTRING (attrs[SOUND_DEVICE])->data); | 462 | strcpy (sd.file, XSTRING (attrs[SOUND_DEVICE])->data); |
| 463 | } | 463 | } |
| 464 | 464 | ||
| 465 | if (INTEGERP (attrs[SOUND_VOLUME])) | 465 | if (INTEGERP (attrs[SOUND_VOLUME])) |
| 466 | sd.volume = XFASTINT (attrs[SOUND_VOLUME]); | 466 | sd.volume = XFASTINT (attrs[SOUND_VOLUME]); |
| 467 | else if (FLOATP (attrs[SOUND_VOLUME])) | 467 | else if (FLOATP (attrs[SOUND_VOLUME])) |
| @@ -610,7 +610,7 @@ wav_init (s) | |||
| 610 | s->play = wav_play; | 610 | s->play = wav_play; |
| 611 | 611 | ||
| 612 | return 1; | 612 | return 1; |
| 613 | } | 613 | } |
| 614 | 614 | ||
| 615 | 615 | ||
| 616 | /* Play RIFF-WAVE audio file S on sound device SD. */ | 616 | /* Play RIFF-WAVE audio file S on sound device SD. */ |
| @@ -625,7 +625,7 @@ wav_play (s, sd) | |||
| 625 | /* Let the device choose a suitable device-dependent format | 625 | /* Let the device choose a suitable device-dependent format |
| 626 | for the file. */ | 626 | for the file. */ |
| 627 | sd->choose_format (sd, s); | 627 | sd->choose_format (sd, s); |
| 628 | 628 | ||
| 629 | /* Configure the device. */ | 629 | /* Configure the device. */ |
| 630 | sd->sample_size = header->sample_size; | 630 | sd->sample_size = header->sample_size; |
| 631 | sd->sample_rate = header->sample_rate; | 631 | sd->sample_rate = header->sample_rate; |
| @@ -645,10 +645,10 @@ wav_play (s, sd) | |||
| 645 | char *buffer; | 645 | char *buffer; |
| 646 | int nbytes; | 646 | int nbytes; |
| 647 | int blksize = 2048; | 647 | int blksize = 2048; |
| 648 | 648 | ||
| 649 | buffer = (char *) alloca (blksize); | 649 | buffer = (char *) alloca (blksize); |
| 650 | lseek (s->fd, sizeof *header, SEEK_SET); | 650 | lseek (s->fd, sizeof *header, SEEK_SET); |
| 651 | 651 | ||
| 652 | while ((nbytes = emacs_read (s->fd, buffer, blksize)) > 0) | 652 | while ((nbytes = emacs_read (s->fd, buffer, blksize)) > 0) |
| 653 | sd->write (sd, buffer, nbytes); | 653 | sd->write (sd, buffer, nbytes); |
| 654 | 654 | ||
| @@ -663,7 +663,7 @@ wav_play (s, sd) | |||
| 663 | Sun Audio (*.au) | 663 | Sun Audio (*.au) |
| 664 | ***********************************************************************/ | 664 | ***********************************************************************/ |
| 665 | 665 | ||
| 666 | /* Sun audio file encodings. */ | 666 | /* Sun audio file encodings. */ |
| 667 | 667 | ||
| 668 | enum au_encoding | 668 | enum au_encoding |
| 669 | { | 669 | { |
| @@ -689,18 +689,18 @@ au_init (s) | |||
| 689 | struct sound *s; | 689 | struct sound *s; |
| 690 | { | 690 | { |
| 691 | struct au_header *header = (struct au_header *) s->header; | 691 | struct au_header *header = (struct au_header *) s->header; |
| 692 | 692 | ||
| 693 | if (s->header_size < sizeof *header | 693 | if (s->header_size < sizeof *header |
| 694 | || bcmp (s->header, ".snd", 4) != 0) | 694 | || bcmp (s->header, ".snd", 4) != 0) |
| 695 | return 0; | 695 | return 0; |
| 696 | 696 | ||
| 697 | header->magic_number = be2hl (header->magic_number); | 697 | header->magic_number = be2hl (header->magic_number); |
| 698 | header->data_offset = be2hl (header->data_offset); | 698 | header->data_offset = be2hl (header->data_offset); |
| 699 | header->data_size = be2hl (header->data_size); | 699 | header->data_size = be2hl (header->data_size); |
| 700 | header->encoding = be2hl (header->encoding); | 700 | header->encoding = be2hl (header->encoding); |
| 701 | header->sample_rate = be2hl (header->sample_rate); | 701 | header->sample_rate = be2hl (header->sample_rate); |
| 702 | header->channels = be2hl (header->channels); | 702 | header->channels = be2hl (header->channels); |
| 703 | 703 | ||
| 704 | /* Set up the interface functions for AU. */ | 704 | /* Set up the interface functions for AU. */ |
| 705 | s->type = SUN_AUDIO; | 705 | s->type = SUN_AUDIO; |
| 706 | s->play = au_play; | 706 | s->play = au_play; |
| @@ -733,15 +733,15 @@ au_play (s, sd) | |||
| 733 | int blksize = 2048; | 733 | int blksize = 2048; |
| 734 | char *buffer; | 734 | char *buffer; |
| 735 | int nbytes; | 735 | int nbytes; |
| 736 | 736 | ||
| 737 | /* Seek */ | 737 | /* Seek */ |
| 738 | lseek (s->fd, header->data_offset, SEEK_SET); | 738 | lseek (s->fd, header->data_offset, SEEK_SET); |
| 739 | 739 | ||
| 740 | /* Copy sound data to the device. */ | 740 | /* Copy sound data to the device. */ |
| 741 | buffer = (char *) alloca (blksize); | 741 | buffer = (char *) alloca (blksize); |
| 742 | while ((nbytes = emacs_read (s->fd, buffer, blksize)) > 0) | 742 | while ((nbytes = emacs_read (s->fd, buffer, blksize)) > 0) |
| 743 | sd->write (sd, buffer, nbytes); | 743 | sd->write (sd, buffer, nbytes); |
| 744 | 744 | ||
| 745 | if (nbytes < 0) | 745 | if (nbytes < 0) |
| 746 | sound_perror ("Error reading sound file"); | 746 | sound_perror ("Error reading sound file"); |
| 747 | } | 747 | } |
| @@ -765,13 +765,13 @@ vox_open (sd) | |||
| 765 | struct sound_device *sd; | 765 | struct sound_device *sd; |
| 766 | { | 766 | { |
| 767 | char *file; | 767 | char *file; |
| 768 | 768 | ||
| 769 | /* Open the sound device. Default is /dev/dsp. */ | 769 | /* Open the sound device. Default is /dev/dsp. */ |
| 770 | if (sd->file) | 770 | if (sd->file) |
| 771 | file = sd->file; | 771 | file = sd->file; |
| 772 | else | 772 | else |
| 773 | file = DEFAULT_SOUND_DEVICE; | 773 | file = DEFAULT_SOUND_DEVICE; |
| 774 | 774 | ||
| 775 | sd->fd = emacs_open (file, O_WRONLY, 0); | 775 | sd->fd = emacs_open (file, O_WRONLY, 0); |
| 776 | if (sd->fd < 0) | 776 | if (sd->fd < 0) |
| 777 | sound_perror (file); | 777 | sound_perror (file); |
| @@ -785,7 +785,7 @@ vox_configure (sd) | |||
| 785 | struct sound_device *sd; | 785 | struct sound_device *sd; |
| 786 | { | 786 | { |
| 787 | int val; | 787 | int val; |
| 788 | 788 | ||
| 789 | xassert (sd->fd >= 0); | 789 | xassert (sd->fd >= 0); |
| 790 | 790 | ||
| 791 | /* On GNU/Linux, it seems that the device driver doesn't like to be | 791 | /* On GNU/Linux, it seems that the device driver doesn't like to be |
| @@ -824,7 +824,7 @@ vox_configure (sd) | |||
| 824 | /* This may fail if there is no mixer. Ignore the failure. */ | 824 | /* This may fail if there is no mixer. Ignore the failure. */ |
| 825 | ioctl (sd->fd, SOUND_MIXER_WRITE_PCM, &volume); | 825 | ioctl (sd->fd, SOUND_MIXER_WRITE_PCM, &volume); |
| 826 | } | 826 | } |
| 827 | 827 | ||
| 828 | turn_on_atimers (1); | 828 | turn_on_atimers (1); |
| 829 | #ifdef SIGIO | 829 | #ifdef SIGIO |
| 830 | sigunblock (sigmask (SIGIO)); | 830 | sigunblock (sigmask (SIGIO)); |
| @@ -847,10 +847,10 @@ vox_close (sd) | |||
| 847 | sigblock (sigmask (SIGIO)); | 847 | sigblock (sigmask (SIGIO)); |
| 848 | #endif | 848 | #endif |
| 849 | turn_on_atimers (0); | 849 | turn_on_atimers (0); |
| 850 | 850 | ||
| 851 | /* Flush sound data, and reset the device. */ | 851 | /* Flush sound data, and reset the device. */ |
| 852 | ioctl (sd->fd, SNDCTL_DSP_SYNC, NULL); | 852 | ioctl (sd->fd, SNDCTL_DSP_SYNC, NULL); |
| 853 | 853 | ||
| 854 | turn_on_atimers (1); | 854 | turn_on_atimers (1); |
| 855 | #ifdef SIGIO | 855 | #ifdef SIGIO |
| 856 | sigunblock (sigmask (SIGIO)); | 856 | sigunblock (sigmask (SIGIO)); |
| @@ -890,7 +890,7 @@ vox_choose_format (sd, s) | |||
| 890 | case AU_ENCODING_IEEE64: | 890 | case AU_ENCODING_IEEE64: |
| 891 | sd->format = AFMT_MU_LAW; | 891 | sd->format = AFMT_MU_LAW; |
| 892 | break; | 892 | break; |
| 893 | 893 | ||
| 894 | case AU_ENCODING_8: | 894 | case AU_ENCODING_8: |
| 895 | case AU_ENCODING_16: | 895 | case AU_ENCODING_16: |
| 896 | case AU_ENCODING_24: | 896 | case AU_ENCODING_24: |