blob: a8d99db7338b42ea3b76c44f0076013a01600567 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
$NetBSD: patch-ab,v 1.4 2001/05/16 02:27:53 fredb Exp $
--- ../src/unix/sqUnixSound.c.orig Thu Feb 8 11:27:04 2001
+++ ../src/unix/sqUnixSound.c
@@ -70,9 +70,16 @@
# include <fcntl.h>
# include <sys/time.h>
# include <sys/ioctl.h>
+#ifdef __NetBSD__
+#include <soundcard.h>
+#ifdef NETBSD_OSS_HACK
+#include <sys/audioio.h>
+#endif
+#else
# include <sys/soundcard.h>
+#endif
-# if !defined(OPEN_SOUND_SYSTEM) && !defined(__FreeBSD__)
+# if !defined(OPEN_SOUND_SYSTEM) && !defined(__FreeBSD__) && !defined(__NetBSD__)
# warning:
# warning: sys/soundcard.h did not define OPEN_SOUND_SYSTEM
# warning: SOUND SUPPORT DISABLED
@@ -274,6 +279,34 @@
int snd_AvailableSpace(void)
{
+#ifdef NETBSD_OSS_HACK
+/*
+ This is to work around a bug in NetBSD-1.5.1 and earlier, in which
+ the SNDCTL_DSP_GETOSPACE(&buf_info) ioctl was not handled properly.
+ The correct information is always available via the native audio
+ driver, so use that instead.
+*/
+ struct audio_info info;
+ int freeBlocks;
+
+ if (auFd == -1) return -1;
+
+ if (ioctl(auFd, AUDIO_GETINFO, &info) < 0) {
+ perror("ioctl(AUDIO_GETINFO)");
+ return 0;
+ }
+
+ /* Make certain we have one, full hardware block free. */
+ freeBlocks = info.hiwat - (info.play.seek + info.blocksize - 1)/info.blocksize;
+ if (freeBlocks > 0)
+ {
+ return info.blocksize;
+ }
+ else
+ {
+ auSemaWaiting= true;
+ return 0;
+#else
audio_buf_info info;
if (auFd == -1)
return -1;
@@ -294,6 +326,7 @@
else
{
return info.fragsize;
+#endif
}
}
|