summaryrefslogtreecommitdiff
path: root/games/fteqw/files/patch-client__snd_linux.c
blob: 287ded7d9863080fde7adb2a7b4ea70e9ffb15e6 (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
--- ./client/snd_linux.c.orig	2008-02-15 14:04:33.000000000 -0300
+++ ./client/snd_linux.c	2008-02-15 14:09:16.000000000 -0300
@@ -114,14 +114,6 @@
 		return 0;
 	}
 
-	if (ioctl(sc->audio_fd, SNDCTL_DSP_GETOSPACE, &info)==-1)
-	{
-		perror("GETOSPACE");
-		Con_Printf(CON_ERROR "OSS: Um, can't do GETOSPACE?\n");
-		OSS_Shutdown(sc);
-		return 0;
-	}
-
 // set sample bits & speed
 
 	ioctl(sc->audio_fd, SNDCTL_DSP_GETFMTS, &fmt);
@@ -149,26 +141,6 @@
 		sc->sn.speed = tryrates[i];
 	}
 
-	if (sc->sn.samples > (info.fragstotal * info.fragsize * 4))
-	{
-		Con_Printf(CON_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;
-
-// 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(CON_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;
@@ -226,6 +198,35 @@
 		return 0;
 	}
 
+	if (ioctl(sc->audio_fd, SNDCTL_DSP_GETOSPACE, &info)==-1)
+	{
+		perror("GETOSPACE");
+		Con_Printf(CON_ERROR "OSS: Um, can't do GETOSPACE?\n");
+		OSS_Shutdown(sc);
+		return 0;
+	}
+
+	sc->sn.samples = info.fragstotal * info.fragsize;
+
+// 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(CON_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(CON_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
 
 	tmp = 0;