SDL patch: cautious diskwriter/dummy availability

(Gads, I’m full of little patches today.)

Attached is a patch against SDL that enables the audio diskwriter and
dummy video drivers by default during configuration. I think they should
always be available if needed, but obviously, it would cause confusion if
SDL were to default to them when all other drivers fail to start, as they
both currently report themselves to be always available.

Therefore both drivers will, with this patch, verify that the
SDL_AUDIODRIVER/SDL_VIDEODRIVER environment variables were explicitly set
to request them, when asked if they are available. If they weren’t
explicitly requested, they will report unavailability. I think that should
satisfy everyone on the matter.

–ryan.

-------------- next part --------------
— SDL12-virgin/configure.in Tue Jun 19 06:35:05 2001
+++ SDL12/configure.in Tue Jun 26 02:13:48 2001
@@ -368,13 +368,12 @@
fi
}-
dnl rcg07142001 See if the user wants the disk writer audio driver…
CheckDiskAudio()
{
AC_ARG_ENABLE(diskaudio,
-[ --enable-diskaudio support the disk writer audio driver [default=no]],

  •              , enable_diskaudio=no)
    

+[ --enable-diskaudio support the disk writer audio driver [default=yes]],

  •              , enable_diskaudio=yes)
    
    if test x$enable_audio = xyes -a x$enable_diskaudio = xyes; then
    CFLAGS="$CFLAGS -DDISKAUD_SUPPORT"
    AUDIO_SUBDIRS="$AUDIO_SUBDIRS disk"
    @@ -382,7 +381,6 @@
    fi
    }

dnl See if we can use x86 assembly blitters
CheckNASM()
{
@@ -810,8 +808,8 @@
CheckDummyVideo()
{
AC_ARG_ENABLE(video-dummy,
-[ --enable-video-dummy use dummy video driver [default=no]],

  •              , enable_video_dummy=no)
    

+[ --enable-video-dummy use dummy video driver [default=yes]],

  •              , enable_video_dummy=yes)
    
    if test x$enable_video_dummy = xyes; then
    CFLAGS="$CFLAGS -DENABLE_DUMMYVIDEO"
    VIDEO_SUBDIRS="$VIDEO_SUBDIRS dummy"
    @@ -902,7 +900,7 @@
    , enable_pthreads=yes)
    dnl This is used on Linux for glibc binary compatibility (Doh!)
    AC_ARG_ENABLE(pthread-sem,
    -[ --enable-pthread-sem use pthread semaphores [default=yes]],
    +[ --enable-pthread-sem use pthread semaphores [default=yes]],
    , enable_pthread_sem=yes)
    ac_save_libs="$LIBS"
    case “$target” in
    — SDL12-virgin/src/audio/disk/SDL_diskaudio.c Fri Jun 15 18:51:42 2001
    +++ SDL12/src/audio/disk/SDL_diskaudio.c Tue Jun 26 02:07:47 2001
    @@ -25,7 +25,7 @@

#ifdef SAVE_RCSID
static char rcsid =

  • “@(#) $Id: SDL_diskaudio.c,v 1.1 2001/06/16 01:51:42 hercules Exp $”;
  • “@(#) $Id: SDL_diskaudio.c,v 1.0 2001/05/23 00:36:17 icculus Exp $”;
    #endif

/* Output raw audio data to a file. */
@@ -80,23 +80,30 @@
int exists = 0;
struct stat statbuf;
const char *fname = DISKAUD_GetOutputFilename();

  • const char *envr = getenv(“SDL_AUDIODRIVER”);
    available = 0;
  • if (stat(fname, &statbuf) == 0)
  •    exists = 1;
    
  • fd = open(fname, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR);
  • if ( fd != -1 ) {
  •   available = 1;
    
  •   close(fd);
    
  •    if (!exists) {
    
  •        unlink(fname);
    
  •    }
    
  • if ((envr) && (strcmp(envr, DISKAUD_DRIVER_NAME) == 0)) {
  •   if (stat(fname, &statbuf) == 0)
    
  •   	exists = 1;
    
  •   fd = open(fname, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR);
    
  •   if ( fd != -1 ) {
    
  •   	available = 1;
    
  •   	close(fd);
    
  •   	if (!exists) {
    
  •   		unlink(fname);
    
  •   	}
    
  •   }
    
    }
    return(available);
    #else
  • return(1);
  • const char *envr = getenv(“SDL_AUDIODRIVER”);
  • if ((envr) && (strcmp(envr, DISKAUD_DRIVER_NAME) == 0)) {
  •   return(1);
    
  • }
  • return(0);
    #endif
    }

— SDL12-virgin/src/video/dummy/SDL_nullvideo.c Thu Apr 26 09:50:18 2001
+++ SDL12/src/video/dummy/SDL_nullvideo.c Tue Jun 26 02:08:11 2001
@@ -55,6 +55,8 @@
#include “SDL_nullevents_c.h”
#include “SDL_nullmouse_c.h”

+#define DUMMYVID_DRIVER_NAME “dummy”
+
/* Initialization/Query functions */
static int DUMMY_VideoInit(_THIS, SDL_PixelFormat *vformat);
static SDL_Rect **DUMMY_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
@@ -76,7 +78,12 @@

static int DUMMY_Available(void)
{

  • return 1; /* Always available ! */
  • const char *envr = getenv(“SDL_VIDEODRIVER”);
  • if ((envr) && (strcmp(envr, DUMMYVID_DRIVER_NAME) == 0)) {
  •   return(1);
    
  • }
  • return(0);
    }

static void DUMMY_DeleteDevice(SDL_VideoDevice *device)
@@ -136,7 +143,7 @@
}

VideoBootStrap DUMMY_bootstrap = {

  • “dummy”, “SDL dummy video driver”,
  • DUMMYVID_DRIVER_NAME, “SDL dummy video driver”,
    DUMMY_Available, DUMMY_CreateDevice
    };

Attached is a patch against SDL that enables the audio diskwriter and
dummy video drivers by default during configuration. I think they should
always be available if needed, but obviously, it would cause confusion if
SDL were to default to them when all other drivers fail to start, as they
both currently report themselves to be always available.

Added to CVS, thanks!

See ya,
-Sam Lantinga, Lead Programmer, Loki Software, Inc.