summaryrefslogtreecommitdiff
path: root/games/fteqw/files/patch-client__snd_linux.c
blob: efe25ad5f21be96c379ca12f4cda609cc5f0cf3f (plain) (blame)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
--- ./client/snd_linux.c.orig	Tue Jul 18 00:34:50 2006
+++ ./client/snd_linux.c	Sat Sep  2 18:40:11 2006
@@ -115,14 +115,6 @@
 		return 0;
 	}
 
-	if (ioctl(sc->audio_fd, SNDCTL_DSP_GETOSPACE, &info)==-1)
-	{
-		perror("GETOSPACE");
-		Con_Printf(S_ERROR "OSS: Um, can't do GETOSPACE?\n");
-		OSS_Shutdown(sc);
-		return 0;
-	}
-
 	sc->sn.splitbuffer = 0;
 
 // set sample bits & speed
@@ -152,27 +144,6 @@
 		sc->sn.speed = tryrates[i];
 	}
 
-	if (sc->sn.samples > (info.fragstotal * info.fragsize * 4))
-	{
-		Con_Printf(S_NOTICE "OSS: Enabling bigfoot's mmap hack! Hope you know what you're doing!\n");
-		sc->sn.samples = info.fragstotal * info.fragsize * 4;
-	}
-	sc->sn.samples = info.fragstotal * info.fragsize;
-	sc->sn.submission_chunk = 1;
-
-// memory map the dma buffer
-
-	sc->sn.buffer = (unsigned char *) mmap(NULL, sc->sn.samples, PROT_WRITE, MAP_FILE|MAP_SHARED, sc->audio_fd, 0);
-	if (!sc->sn.buffer)
-	{
-		perror(snddev);
-		Con_Printf(S_ERROR "OSS: Could not mmap %s\n", snddev);
-		OSS_Shutdown(sc);
-		return 0;
-	}
-
-	sc->sn.samples /= (sc->sn.samplebits/8);
-
 	tmp = 0;
 	if (sc->sn.numchannels == 2)
 		tmp = 1;
@@ -228,6 +199,36 @@
 		Con_Printf(S_ERROR "OSS: %d-bit sound not supported.\n", sc->sn.samplebits);
 		OSS_Shutdown(sc);
 		return 0;
+	}
+
+	if (ioctl(sc->audio_fd, SNDCTL_DSP_GETOSPACE, &info)==-1)
+	{
+		perror("GETOSPACE");
+		Con_Printf(S_ERROR "OSS: Um, can't do GETOSPACE?\n");
+		OSS_Shutdown(sc);
+		return 0;
+	}
+
+	sc->sn.samples = info.fragstotal * info.fragsize;
+	sc->sn.submission_chunk = 1;
+
+// memory map the dma buffer
+
+	sc->sn.buffer = (unsigned char *) mmap(NULL, sc->sn.samples, PROT_WRITE, MAP_FILE|MAP_SHARED, sc->audio_fd, 0);
+	if (!sc->sn.buffer)
+	{
+		perror(snddev);
+		Con_Printf(S_ERROR "OSS: Could not mmap %s\n", snddev);
+		OSS_Shutdown(sc);
+		return 0;
+	}
+
+	sc->sn.samples /= (sc->sn.samplebits/8);
+
+	if (sc->sn.samples > (info.fragstotal * info.fragsize * 4))
+	{
+		Con_Printf(S_NOTICE "OSS: Enabling bigfoot's mmap hack! Hope you know what you're doing!\n");
+		sc->sn.samples = info.fragstotal * info.fragsize * 4;
 	}
 
 // toggle the trigger & start her up