Cleaned up the OpenBSD port, thanks to Peter Valchev

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%4095
This commit is contained in:
Sam Lantinga 2001-07-08 09:00:06 +00:00
parent ea5f242f09
commit acab15a3bd
9 changed files with 153 additions and 90 deletions

View File

@ -245,13 +245,25 @@ CheckOSS()
if test x$enable_audio = xyes -a x$enable_oss = xyes; then
AC_MSG_CHECKING(for OSS audio support)
have_oss=no
AC_TRY_COMPILE([
#include <sys/soundcard.h>
],[
int arg = SNDCTL_DSP_SETFRAGMENT;
],[
have_oss=yes
])
if test x$have_oss != xyes; then
AC_TRY_COMPILE([
#include <sys/soundcard.h>
],[
int arg = SNDCTL_DSP_SETFRAGMENT;
],[
have_oss=yes
])
fi
if test x$have_oss != xyes; then
AC_TRY_COMPILE([
#include <soundcard.h>
],[
int arg = SNDCTL_DSP_SETFRAGMENT;
],[
have_oss=yes
CFLAGS="$CFLAGS -DOSS_USE_SOUNDCARD_H"
])
fi
AC_MSG_RESULT($have_oss)
if test x$have_oss = xyes; then
CFLAGS="$CFLAGS -DOSS_SUPPORT"
@ -286,10 +298,10 @@ dnl Check whether we want to use OpenBSD native audio or not
CheckOPENBSDAUDIO()
{
AC_ARG_ENABLE(openbsdaudio,
[ --enable-openbsdaudio OpenBSD native audio support [default=no]],
, enable_openbsdaudio=no)
[ --enable-openbsdaudio OpenBSD native audio support [default=yes]],
, enable_openbsdaudio=yes)
if test x$enable_audio = xyes -a x$enable_openbsdaudio = xyes; then
SYSTEM_LIBS="$SYSTEM_LIBS $ESD_LIBS"
CFLAGS="$CFLAGS -DOBSD_SUPPORT"
AUDIO_SUBDIRS="$AUDIO_SUBDIRS openbsd"
AUDIO_DRIVERS="$AUDIO_DRIVERS openbsd/libaudio_openbsd.la"
fi
@ -994,6 +1006,20 @@ CheckPTHREAD()
CFLAGS="$CFLAGS -DPTHREAD_NO_RECURSIVE_MUTEX"
fi
# Check to see if pthread semaphore support is missing
if test x$enable_pthread_sem = xyes; then
AC_MSG_CHECKING(for pthread semaphores)
have_pthread_sem=no
AC_TRY_COMPILE([
#include <pthread.h>
#include <semaphore.h>
],[
],[
have_pthread_sem=yes
])
AC_MSG_RESULT($have_pthread_sem)
fi
# Check to see if this is broken glibc 2.0 pthreads
case "$target" in
*-*-linux*)
@ -1196,7 +1222,7 @@ case "$target" in
fi
COPY_ARCH_SRC(src/thread, linux, SDL_systhread.c)
COPY_ARCH_SRC(src/thread, linux, SDL_systhread_c.h)
if test x$use_pthreads = xyes -a x$enable_pthread_sem != xyes; then
if test x$use_pthreads = xyes -a x$have_pthread_sem != xyes; then
COPY_ARCH_SRC(src/thread, generic, SDL_syssem.c)
else
COPY_ARCH_SRC(src/thread, linux, SDL_syssem.c)
@ -1303,7 +1329,7 @@ case "$target" in
COPY_ARCH_SRC(src/thread, linux, SDL_systhread_c.h)
COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex.c)
COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex_c.h)
if test x$use_pthreads = xyes -a x$enable_pthread_sem != xyes; then
if test x$use_pthreads = xyes -a x$have_pthread_sem != xyes; then
COPY_ARCH_SRC(src/thread, generic, SDL_syssem.c)
else
COPY_ARCH_SRC(src/thread, linux, SDL_syssem.c)
@ -1353,7 +1379,7 @@ case "$target" in
COPY_ARCH_SRC(src/thread, linux, SDL_systhread_c.h)
COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex.c)
COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex_c.h)
if test x$use_pthreads = xyes -a x$enable_pthread_sem != xyes; then
if test x$use_pthreads = xyes -a x$have_pthread_sem != xyes; then
COPY_ARCH_SRC(src/thread, generic, SDL_syssem.c)
else
COPY_ARCH_SRC(src/thread, linux, SDL_syssem.c)
@ -1373,6 +1399,7 @@ case "$target" in
ARCH=openbsd
CheckDummyVideo
CheckDiskAudio
CheckOPENBSDAUDIO
CheckNASM
CheckOSS
CheckARTSC
@ -1385,7 +1412,15 @@ case "$target" in
# Set up files for the main() stub
COPY_ARCH_SRC(src/main, linux, SDL_main.c)
# Set up files for the audio library
CheckOPENBSDAUDIO
# We use the OSS and native API's, not the Sun audio API
#if test x$enable_audio = xyes; then
# AUDIO_SUBDIRS="$AUDIO_SUBDIRS sun"
# AUDIO_DRIVERS="$AUDIO_DRIVERS sun/libaudio_sun.la"
#fi
# OpenBSD needs linking with ossaudio emulation library
if test x$have_oss = xyes; then
SYSTEM_LIBS="$SYSTEM_LIBS -lossaudio"
fi
# Set up files for the joystick library
# (No joystick support yet)
if test x$enable_joystick = xyes; then
@ -1402,7 +1437,7 @@ case "$target" in
COPY_ARCH_SRC(src/thread, linux, SDL_systhread_c.h)
COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex.c)
COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex_c.h)
if test x$use_pthreads = xyes -a x$enable_pthread_sem != xyes; then
if test x$use_pthreads = xyes -a x$have_pthread_sem != xyes; then
COPY_ARCH_SRC(src/thread, generic, SDL_syssem.c)
else
COPY_ARCH_SRC(src/thread, linux, SDL_syssem.c)
@ -1528,7 +1563,7 @@ case "$target" in
if test x$enable_audio = xyes; then
AUDIO_SUBDIRS="$AUDIO_SUBDIRS dmedia"
AUDIO_DRIVERS="$AUDIO_DRIVERS dmedia/libaudio_dmedia.la"
LIBS="$LIBS -laudio"
SYSTEM_LIBS="$SYSTEM_LIBS -laudio"
fi
# Set up files for the joystick library
# (No joystick support yet)
@ -1548,7 +1583,7 @@ case "$target" in
COPY_ARCH_SRC(src/thread, linux, SDL_systhread_c.h)
COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex.c)
COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex_c.h)
if test x$enable_pthread_sem != xyes; then
if test x$have_pthread_sem != xyes; then
COPY_ARCH_SRC(src/thread, generic, SDL_syssem.c)
else
COPY_ARCH_SRC(src/thread, linux, SDL_syssem.c)
@ -1937,7 +1972,7 @@ case "$target" in
COPY_ARCH_SRC(src/thread, linux, SDL_systhread_c.h)
COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex.c)
COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex_c.h)
if test x$use_pthreads = xyes -a x$enable_pthread_sem != xyes; then
if test x$use_pthreads = xyes -a x$have_pthread_sem != xyes; then
COPY_ARCH_SRC(src/thread, generic, SDL_syssem.c)
else
COPY_ARCH_SRC(src/thread, linux, SDL_syssem.c)
@ -1989,7 +2024,7 @@ if test $ARCH = solaris; then
fi
if test $ARCH = openbsd; then
SDL_RLD_FLAGS="-L${X11BASE}/lib -Wl,-rpath,\${exec_prefix}/lib -Wl,-rpath,${X11BASE}/lib"
SDL_RLD_FLAGS="-Wl,-rpath,\${exec_prefix}/lib $SYSTEM_LIBS"
fi
dnl Output the video drivers we use

View File

@ -49,7 +49,7 @@ typedef struct SDL_SysWMinfo SDL_SysWMinfo;
#else
/* This is the structure for custom window manager events */
#if (defined(unix) || defined(__unix__) || defined(_AIX)) && \
#if (defined(unix) || defined(__unix__) || defined(_AIX) || defined(__OpenBSD__)) && \
(!defined(DISABLE_X11) && !defined(__CYGWIN32__))
/* AIX is unix, of course, but the native compiler CSet doesn't define unix */
#include <X11/Xlib.h>

View File

@ -40,6 +40,9 @@ static char rcsid =
/* Available audio drivers */
static AudioBootStrap *bootstrap[] = {
#ifdef OBSD_SUPPORT
&OBSD_bootstrap,
#endif
#ifdef OSS_SUPPORT
&DSP_bootstrap,
&DMA_bootstrap,
@ -47,9 +50,6 @@ static AudioBootStrap *bootstrap[] = {
#ifdef ALSA_SUPPORT
&ALSA_bootstrap,
#endif
#ifdef __OpenBSD__
&OBSD_bootstrap,
#endif
#if (defined(unix) && !defined(__CYGWIN32__)) && \
!defined(OSS_SUPPORT) && !defined(ALSA_SUPPORT)
&AUDIO_bootstrap,

View File

@ -39,7 +39,11 @@ static char rcsid =
#include "SDL_audiodev_c.h"
#ifndef _PATH_DEV_DSP
#define _PATH_DEV_DSP "/dev/dsp"
#ifdef __OpenBSD__
#define _PATH_DEV_DSP "/dev/audio"
#else
#define _PATH_DEV_DSP "/dev/dsp"
#endif
#endif
#ifndef _PATH_DEV_DSP24
#define _PATH_DEV_DSP24 "/dev/sound/dsp"

View File

@ -99,6 +99,9 @@ typedef struct AudioBootStrap {
SDL_AudioDevice *(*create)(int devindex);
} AudioBootStrap;
#ifdef OBSD_SUPPORT
extern AudioBootStrap OBSD_bootstrap;
#endif
#ifdef OSS_SUPPORT
extern AudioBootStrap DSP_bootstrap;
extern AudioBootStrap DMA_bootstrap;
@ -106,9 +109,6 @@ extern AudioBootStrap DMA_bootstrap;
#ifdef ALSA_SUPPORT
extern AudioBootStrap ALSA_bootstrap;
#endif
#ifdef __OpenBSD__
extern AudioBootStrap OBSD_bootstrap;
#endif
#if (defined(unix) && !defined(__CYGWIN32__)) && \
!defined(OSS_SUPPORT) && !defined(ALSA_SUPPORT)
extern AudioBootStrap AUDIO_bootstrap;

View File

@ -39,7 +39,13 @@ static char rcsid =
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/mman.h>
#ifdef OSS_USE_SOUNDCARD_H
/* This is installed on some systems */
#include <soundcard.h>
#else
/* This is recommended by OSS */
#include <sys/soundcard.h>
#endif
#ifndef MAP_FAILED
#define MAP_FAILED ((Uint8 *)-1)

View File

@ -37,7 +37,13 @@ static char rcsid =
#include <sys/time.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#ifdef OSS_USE_SOUNDCARD_H
/* This is installed on some systems */
#include <soundcard.h>
#else
/* This is recommended by OSS */
#include <sys/soundcard.h>
#endif
#include "SDL_audio.h"
#include "SDL_error.h"

View File

@ -140,83 +140,95 @@ AudioBootStrap OBSD_bootstrap = {
static void
OBSD_WaitAudio(_THIS)
{
#ifndef USE_BLOCKING_WRITES
fd_set fdset;
/* Check to see if the thread-parent process is still alive */
{
static int cnt = 0;
/* Note that this only works with thread implementations
that use a different process id for each thread. */
if(parent && (((++cnt)%10) == 0)) { /* Check every 10 loops */
if(kill(parent, 0) < 0)
this->enabled = 0;
/* Check to see if the thread-parent process is still alive */
{ static int cnt = 0;
/* Note that this only works with thread implementations
that use a different process id for each thread.
*/
if (parent && (((++cnt)%10) == 0)) { /* Check every 10 loops */
if ( kill(parent, 0) < 0 ) {
this->enabled = 0;
}
}
}
}
#ifdef USE_TIMER_SYNC
/* See if we need to use timed audio synchronization */
if(frame_ticks)
{
/* Use timer for general audio synchronization */
Sint32 ticks;
#ifndef USE_BLOCKING_WRITES /* Not necessary when using blocking writes */
/* See if we need to use timed audio synchronization */
if ( frame_ticks ) {
/* Use timer for general audio synchronization */
Sint32 ticks;
ticks = ((Sint32)(next_frame - SDL_GetTicks())) - FUDGE_TICKS;
if(ticks > 0)
SDL_Delay(ticks);
}
else
#endif /* USE_TIMER_SYNC */
{
/* Use select() for audio synchronization */
struct timeval timeout;
FD_ZERO(&fdset);
FD_SET(audio_fd, &fdset);
timeout.tv_sec = 10;
timeout.tv_usec = 0;
#if defined(DEBUG_AUDIO_STREAM) && defined(DEBUG_AUDIO_STREAM)
OBSD_Status(this);
ticks = ((Sint32)(next_frame - SDL_GetTicks()))-FUDGE_TICKS;
if ( ticks > 0 ) {
SDL_Delay(ticks);
}
} else {
/* Use select() for audio synchronization */
fd_set fdset;
struct timeval timeout;
FD_ZERO(&fdset);
FD_SET(audio_fd, &fdset);
timeout.tv_sec = 10;
timeout.tv_usec = 0;
#ifdef DEBUG_AUDIO
fprintf(stderr, "Waiting for audio to get ready\n");
#endif
if ( select(audio_fd+1, NULL, &fdset, NULL, &timeout) <= 0 ) {
const char *message =
"Audio timeout - buggy audio driver? (disabled)";
/* In general we should never print to the screen,
but in this case we have no other way of letting
the user know what happened.
*/
fprintf(stderr, "SDL: %s\n", message);
this->enabled = 0;
/* Don't try to close - may hang */
audio_fd = -1;
#ifdef DEBUG_AUDIO
fprintf(stderr, "Done disabling audio\n");
#endif
}
#ifdef DEBUG_AUDIO
fprintf(stderr, "Ready!\n");
#endif
if(select(audio_fd+1, NULL, &fdset, NULL, &timeout) <= 0)
{
const char *message =
"Audio timeout - buggy audio driver? (disabled)";
fprintf(stderr, "SDL: %s\n", message);
this->enabled = 0;
audio_fd = -1;
}
}
#endif /* !USE_BLOCKING_WRITES */
}
static void
OBSD_PlayAudio(_THIS)
{
int written;
int written, p=0;
/* Write the audio data, checking for EAGAIN on broken audio drivers */
do
{
written = write(audio_fd, mixbuf, mixlen);
if((written < 0) && ((errno == 0) || (errno == EAGAIN)))
SDL_Delay(1);
}
while((written < 0) &&
((errno == 0) || (errno == EAGAIN) || (errno == EINTR)));
/* Write the audio data, checking for EAGAIN on broken audio drivers */
do {
written = write(audio_fd, &mixbuf[p], mixlen-p);
if (written>0)
p += written;
if (written == -1 && errno != 0 && errno != EAGAIN && errno != EINTR)
{
/* Non recoverable error has occurred. It should be reported!!! */
perror("audio");
break;
}
#ifdef USE_TIMER_SYNC
if(frame_ticks)
next_frame += frame_ticks;
#endif
if ( p < written || ((written < 0) && ((errno == 0) || (errno == EAGAIN))) ) {
SDL_Delay(1); /* Let a little CPU time go by */
}
} while ( p < written );
/* If we couldn't write, assume fatal error for now */
if(written < 0)
this->enabled = 0;
/* If timer synchronization is enabled, set the next write frame */
if ( frame_ticks ) {
next_frame += frame_ticks;
}
#ifdef DEBUG_AUDIO_STREAM
fprintf(stderr, "Wrote %d bytes of audio data\n", written);
/* If we couldn't write, assume fatal error for now */
if ( written < 0 ) {
this->enabled = 0;
}
#ifdef DEBUG_AUDIO
fprintf(stderr, "Wrote %d bytes of audio data\n", written);
#endif
}

View File

@ -48,7 +48,7 @@ static char rcsid =
#ifdef SDL_USE_PTHREADS
#ifdef SDL_NO_PTHREAD_SEMAPHORES
#include "generic/SDL_sem.c"
#include "generic/SDL_syssem.c"
#else
#include <stdio.h>