| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: audiobell.c,v 1.20 2017/06/04 05:37:56 nat Exp $ */ | | 1 | /* $NetBSD: audiobell.c,v 1.21 2017/06/11 13:02:44 nat Exp $ */ |
2 | | | 2 | |
3 | | | 3 | |
4 | /* | | 4 | /* |
5 | * Copyright (c) 1999 Richard Earnshaw | | 5 | * Copyright (c) 1999 Richard Earnshaw |
6 | * Copyright (c) 2004 Ben Harris | | 6 | * Copyright (c) 2004 Ben Harris |
7 | * | | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | | 8 | * Redistribution and use in source and binary forms, with or without |
9 | * modification, are permitted provided that the following conditions | | 9 | * modification, are permitted provided that the following conditions |
10 | * are met: | | 10 | * are met: |
11 | * 1. Redistributions of source code must retain the above copyright | | 11 | * 1. Redistributions of source code must retain the above copyright |
12 | * notice, this list of conditions and the following disclaimer. | | 12 | * notice, this list of conditions and the following disclaimer. |
13 | * 2. Redistributions in binary form must reproduce the above copyright | | 13 | * 2. Redistributions in binary form must reproduce the above copyright |
14 | * notice, this list of conditions and the following disclaimer in the | | 14 | * notice, this list of conditions and the following disclaimer in the |
| @@ -22,27 +22,27 @@ | | | @@ -22,27 +22,27 @@ |
22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | | 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
23 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | | 23 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
24 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | | 24 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
25 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | | 25 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | | 26 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
27 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | | 27 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 28 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 29 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | | 30 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
31 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 31 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
32 | */ | | 32 | */ |
33 | | | 33 | |
34 | #include <sys/types.h> | | 34 | #include <sys/types.h> |
35 | __KERNEL_RCSID(0, "$NetBSD: audiobell.c,v 1.20 2017/06/04 05:37:56 nat Exp $"); | | 35 | __KERNEL_RCSID(0, "$NetBSD: audiobell.c,v 1.21 2017/06/11 13:02:44 nat Exp $"); |
36 | | | 36 | |
37 | #include <sys/audioio.h> | | 37 | #include <sys/audioio.h> |
38 | #include <sys/conf.h> | | 38 | #include <sys/conf.h> |
39 | #include <sys/device.h> | | 39 | #include <sys/device.h> |
40 | #include <sys/fcntl.h> | | 40 | #include <sys/fcntl.h> |
41 | #include <sys/file.h> | | 41 | #include <sys/file.h> |
42 | #include <sys/filedesc.h> | | 42 | #include <sys/filedesc.h> |
43 | #include <sys/ioctl.h> | | 43 | #include <sys/ioctl.h> |
44 | #include <sys/malloc.h> | | 44 | #include <sys/malloc.h> |
45 | #include <sys/null.h> | | 45 | #include <sys/null.h> |
46 | #include <sys/systm.h> | | 46 | #include <sys/systm.h> |
47 | #include <sys/uio.h> | | 47 | #include <sys/uio.h> |
48 | #include <sys/unistd.h> | | 48 | #include <sys/unistd.h> |
| @@ -113,28 +113,31 @@ audiobell(void *v, u_int pitch, u_int pe | | | @@ -113,28 +113,31 @@ audiobell(void *v, u_int pitch, u_int pe |
113 | | | 113 | |
114 | /* The audio system isn't built for polling. */ | | 114 | /* The audio system isn't built for polling. */ |
115 | if (poll) return; | | 115 | if (poll) return; |
116 | | | 116 | |
117 | /* If not configured, we can't beep. */ | | 117 | /* If not configured, we can't beep. */ |
118 | if (audiobellopen(audio, FWRITE, 0, NULL, &fp) != EMOVEFD || fp == NULL) | | 118 | if (audiobellopen(audio, FWRITE, 0, NULL, &fp) != EMOVEFD || fp == NULL) |
119 | return; | | 119 | return; |
120 | | | 120 | |
121 | if (audiobellioctl(fp, AUDIO_GETINFO, &ai) != 0) { | | 121 | if (audiobellioctl(fp, AUDIO_GETINFO, &ai) != 0) { |
122 | audiobellclose(fp); | | 122 | audiobellclose(fp); |
123 | return; | | 123 | return; |
124 | } | | 124 | } |
125 | | | 125 | |
| | | 126 | AUDIO_INITINFO(&ai); |
| | | 127 | ai.mode = AUMODE_PLAY; |
126 | ai.play.sample_rate = BELL_SAMPLE_RATE; | | 128 | ai.play.sample_rate = BELL_SAMPLE_RATE; |
127 | ai.play.precision = 16; | | 129 | ai.play.precision = 16; |
| | | 130 | ai.play.channels = 1; |
128 | ai.play.gain = 255 * volume / 100; | | 131 | ai.play.gain = 255 * volume / 100; |
129 | | | 132 | |
130 | #if BYTE_ORDER == LITTLE_ENDIAN | | 133 | #if BYTE_ORDER == LITTLE_ENDIAN |
131 | ai.play.encoding = AUDIO_ENCODING_SLINEAR_LE; | | 134 | ai.play.encoding = AUDIO_ENCODING_SLINEAR_LE; |
132 | #else | | 135 | #else |
133 | ai.play.encoding = AUDIO_ENCODING_SLINEAR_BE; | | 136 | ai.play.encoding = AUDIO_ENCODING_SLINEAR_BE; |
134 | #endif | | 137 | #endif |
135 | | | 138 | |
136 | if (audiobellioctl(fp, AUDIO_SETINFO, &ai) != 0) { | | 139 | if (audiobellioctl(fp, AUDIO_SETINFO, &ai) != 0) { |
137 | audiobellclose(fp); | | 140 | audiobellclose(fp); |
138 | return; | | 141 | return; |
139 | } | | 142 | } |
140 | buf = NULL; | | 143 | buf = NULL; |