shithub: qk1

Download patch

ref: 245306e314fe636490b9ad7557a5ea234b589ef2
parent: c93600e9102e4748e54322729651b2371ced90d0
author: Konstantinn Bonnet <[email protected]>
date: Tue Mar 17 13:19:46 EDT 2015

fix wpos overflow giving negative offset for dma buffer pos

sound code is still bugged: sound dies after 5-6 hours, and some of the assumptions made
are invalid (samplepos, etc.).

--- a/README
+++ b/README
@@ -47,8 +47,8 @@
 -----------
 	- compiling with PARANOID reveals several points of failure that are otherwise
           ignored, resulting in abnormal exit (also on linux)
-	- leave running for a couple of hours -> sound dies and eventually, invalid
-	  write/reads -> crash
+	- leave running for a couple of hours → invalid write/reads → crash
+	- unrelated(?): after about 5 hours, sound dies
 	- compile with BAN_TEST -> net_dgrm build fails (struct sockaddr_in)
 	- sprites/particles not scaled correctly on high resolutions (also in quake2)
 	- m_windowed 1: can still look around in frozen world when paused
--- a/snd_9.c
+++ b/snd_9.c
@@ -6,7 +6,7 @@
 
 int audio_fd;
 int sndon;
-int wpos;
+uint wpos;
 int stid = -1;
 enum{
 	Nbuf	= 16
@@ -76,7 +76,7 @@
 	return 1;
 }
 
-int SNDDMA_GetDMAPos(void)
+uint SNDDMA_GetDMAPos(void)
 {
 	if(!sndon)
 		return 0;
--- a/snd_dma.c
+++ b/snd_dma.c
@@ -744,9 +744,9 @@
 
 void GetSoundtime(void)
 {
-	int		samplepos;
+	uint		samplepos;
 	static	int		buffers;
-	static	int		oldsamplepos;
+	static	uint		oldsamplepos;
 	int		fullsamples;
 	
 	fullsamples = shm->samples / shm->channels;
--- a/sound.h
+++ b/sound.h
@@ -38,7 +38,7 @@
 	int				channels;
 	int				samples;				// mono samples in buffer
 	int				submission_chunk;		// don't mix less than this #
-	int				samplepos;				// in mono samples
+	uint				samplepos;				// in mono samples
 	int				samplebits;
 	int				speed;
 	unsigned char	*buffer;
@@ -99,7 +99,7 @@
 qboolean SNDDMA_Init(void);
 
 // gets the current DMA position
-int SNDDMA_GetDMAPos(void);
+uint SNDDMA_GetDMAPos(void);
 
 // shutdown the DMA xfer.
 void SNDDMA_Shutdown(void);