diff options
| author | Gerd Moellmann | 2000-12-07 22:09:00 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2000-12-07 22:09:00 +0000 |
| commit | 28fcb7dc3997d9b51ef770e887dbd6eefe564428 (patch) | |
| tree | 611138527281db5d903c73cb77701f7d93d8c6e3 /src | |
| parent | 926b7e5e3ec4ddb93aaf8d1357020a6b7e8a55a1 (diff) | |
| download | emacs-28fcb7dc3997d9b51ef770e887dbd6eefe564428.tar.gz emacs-28fcb7dc3997d9b51ef770e887dbd6eefe564428.zip | |
(vox_configure): Change order of ioctls. Don't
set SNDCTL_DSP_SPEED from bps, don't set SNDCTL_DSP_SAMPLESIZE.
Ignore errors when changing volume.
(vox_close): Don't reset the device.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/sound.c | 46 |
2 files changed, 25 insertions, 26 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index ca92994f021..85c4691d4d3 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -9,6 +9,11 @@ | |||
| 9 | 9 | ||
| 10 | 2000-12-07 Gerd Moellmann <gerd@gnu.org> | 10 | 2000-12-07 Gerd Moellmann <gerd@gnu.org> |
| 11 | 11 | ||
| 12 | * sound.c (vox_configure): Change order of ioctls. Don't | ||
| 13 | set SNDCTL_DSP_SPEED from bps, don't set SNDCTL_DSP_SAMPLESIZE. | ||
| 14 | Ignore errors when changing volume. | ||
| 15 | (vox_close): Don't reset the device. | ||
| 16 | |||
| 12 | * process.c (read_process_output): Make sure the process marker's | 17 | * process.c (read_process_output): Make sure the process marker's |
| 13 | position is valid when the process buffer is changed in | 18 | position is valid when the process buffer is changed in |
| 14 | after-change functions. W3 does that. | 19 | after-change functions. W3 does that. |
diff --git a/src/sound.c b/src/sound.c index fc3adbdba6b..4e61a1f8f25 100644 --- a/src/sound.c +++ b/src/sound.c | |||
| @@ -760,41 +760,36 @@ static void | |||
| 760 | vox_configure (sd) | 760 | vox_configure (sd) |
| 761 | struct sound_device *sd; | 761 | struct sound_device *sd; |
| 762 | { | 762 | { |
| 763 | int requested; | 763 | int val; |
| 764 | 764 | ||
| 765 | xassert (sd->fd >= 0); | 765 | xassert (sd->fd >= 0); |
| 766 | 766 | ||
| 767 | /* Device parameters apparently depend on each other in undocumented | 767 | val = sd->format; |
| 768 | ways (not to imply that there is any real documentation). Be | 768 | if (ioctl (sd->fd, SNDCTL_DSP_SETFMT, &sd->format) < 0 |
| 769 | careful when reordering the calls below. */ | 769 | || val != sd->format) |
| 770 | if (sd->sample_size > 0 | 770 | sound_perror ("Set sound format"); |
| 771 | && ioctl (sd->fd, SNDCTL_DSP_SAMPLESIZE, &sd->sample_size) < 0) | ||
| 772 | sound_perror ("Setting sample size"); | ||
| 773 | |||
| 774 | if (sd->bps > 0 | ||
| 775 | && ioctl (sd->fd, SNDCTL_DSP_SPEED, &sd->bps) < 0) | ||
| 776 | sound_perror ("Setting speed"); | ||
| 777 | |||
| 778 | if (sd->sample_rate > 0 | ||
| 779 | && ioctl (sd->fd, SOUND_PCM_WRITE_RATE, &sd->sample_rate) < 0) | ||
| 780 | sound_perror ("Setting sample rate"); | ||
| 781 | 771 | ||
| 782 | requested = sd->format; | 772 | val = sd->channels != 1; |
| 783 | if (ioctl (sd->fd, SNDCTL_DSP_SETFMT, &sd->format) < 0) | 773 | if (ioctl (sd->fd, SNDCTL_DSP_STEREO, &val) < 0 |
| 784 | sound_perror ("Setting format"); | 774 | || val != (sd->channels != 1)) |
| 785 | else if (requested != sd->format) | 775 | sound_perror ("Set stereo/mono"); |
| 786 | error ("Setting format"); | ||
| 787 | 776 | ||
| 788 | if (sd->channels > 1 | 777 | /* I think bps and sampling_rate are the same, but who knows. |
| 789 | && ioctl (sd->fd, SNDCTL_DSP_STEREO, &sd->channels) < 0) | 778 | Check this. and use SND_DSP_SPEED for both. */ |
| 790 | sound_perror ("Setting channels"); | 779 | if (sd->sample_rate > 0) |
| 780 | { | ||
| 781 | val = sd->sample_rate; | ||
| 782 | if (ioctl (sd->fd, SNDCTL_DSP_SPEED, &sd->sample_rate) < 0 | ||
| 783 | || val != sd->sample_rate) | ||
| 784 | sound_perror ("Set sound speed"); | ||
| 785 | } | ||
| 791 | 786 | ||
| 792 | if (sd->volume > 0) | 787 | if (sd->volume > 0) |
| 793 | { | 788 | { |
| 794 | int volume = sd->volume & 0xff; | 789 | int volume = sd->volume & 0xff; |
| 795 | volume |= volume << 8; | 790 | volume |= volume << 8; |
| 796 | if (ioctl (sd->fd, SOUND_MIXER_WRITE_PCM, &volume) < 0) | 791 | /* This may fail if there is no mixer. Ignore the failure. */ |
| 797 | sound_perror ("Setting volume"); | 792 | ioctl (sd->fd, SOUND_MIXER_WRITE_PCM, &volume); |
| 798 | } | 793 | } |
| 799 | } | 794 | } |
| 800 | 795 | ||
| @@ -809,7 +804,6 @@ vox_close (sd) | |||
| 809 | { | 804 | { |
| 810 | /* Flush sound data, and reset the device. */ | 805 | /* Flush sound data, and reset the device. */ |
| 811 | ioctl (sd->fd, SNDCTL_DSP_SYNC, NULL); | 806 | ioctl (sd->fd, SNDCTL_DSP_SYNC, NULL); |
| 812 | ioctl (sd->fd, SNDCTL_DSP_RESET, NULL); | ||
| 813 | 807 | ||
| 814 | /* Close the device. */ | 808 | /* Close the device. */ |
| 815 | emacs_close (sd->fd); | 809 | emacs_close (sd->fd); |