$NetBSD: patch-pulse,v 1.1 2008/12/26 21:53:31 ahoka Exp $

--- src/audio/pulse/SDL_pulseaudio.c.orig	2007-12-31 05:47:58.000000000 +0100
+++ src/audio/pulse/SDL_pulseaudio.c
@@ -26,6 +26,7 @@
 /* Allow access to an PulseAudio network stream mixing buffer */
 
 #include <sys/types.h>
+#include <stdlib.h>
 #include <unistd.h>
 #include <signal.h>
 #include <errno.h>
@@ -164,10 +165,10 @@ static int Audio_Available(void)
 	paspec.rate = 11025;
 	paspec.channels = 1;
 	connection = SDL_NAME(pa_simple_new)(
-		SDL_getenv("PASERVER"),      /* server */
+		NULL,                        /* server */
 		"Test stream",               /* application name */
 		PA_STREAM_PLAYBACK,          /* playback mode */
-		SDL_getenv("PADEVICE"),      /* device on the server */
+		NULL,                        /* device on the server */
 		"Simple DirectMedia Layer",  /* stream description */
 		&paspec,                     /* sample format spec */
 		NULL,                        /* channel map */
@@ -272,10 +273,10 @@ static void PULSE_CloseAudio(_THIS)
 }
 
 /* Try to get the name of the program */
-static char *get_progname(void)
+static char *PULSE_GetProgname(void)
 {
-	char *progname = NULL;
 #ifdef __LINUX__
+	char *progname = NULL;
 	FILE *fp;
 	static char temp[BUFSIZ];
 
@@ -292,8 +293,12 @@ static char *get_progname(void)
 		}
 		fclose(fp);
 	}
-#endif
 	return(progname);
+#elif defined(__NetBSD__)
+	return getprogname();
+#else
+	return("unknown");
+#endif
 }
 
 static int PULSE_OpenAudio(_THIS, SDL_AudioSpec *spec)
@@ -340,11 +345,10 @@ static int PULSE_OpenAudio(_THIS, SDL_Au
 	SDL_memset(mixbuf, spec->silence, spec->size);
 	
 	/* Reduced prebuffering compared to the defaults. */
-	paattr.tlength = mixlen;
+	paattr.tlength = mixlen * 2;
 	paattr.minreq = mixlen;
-	paattr.fragsize = mixlen;
-	paattr.prebuf = mixlen;
-	paattr.maxlength = mixlen * 4;
+	paattr.prebuf = mixlen * 2;
+	paattr.maxlength = mixlen * 2;
 	
 	/* The SDL ALSA output hints us that we use Windows' channel mapping */
 	/* http://bugzilla.libsdl.org/show_bug.cgi?id=110 */
@@ -353,11 +357,11 @@ static int PULSE_OpenAudio(_THIS, SDL_Au
 	
 	/* Connect to the PulseAudio server */
 	stream = SDL_NAME(pa_simple_new)(
-		SDL_getenv("PASERVER"),      /* server */
-		get_progname(),              /* application name */
+		NULL,                        /* server */
+		PULSE_GetProgname(),         /* application name */
 		PA_STREAM_PLAYBACK,          /* playback mode */
-		SDL_getenv("PADEVICE"),      /* device on the server */
-		"Simple DirectMedia Layer",  /* stream description */
+		NULL,                        /* device on the server */
+		"SDL Application",           /* stream description */
 		&paspec,                     /* sample format spec */
 		&pacmap,                     /* channel map */
 		&paattr,                     /* buffering attributes */
