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:
parent
ea5f242f09
commit
acab15a3bd
9 changed files with 153 additions and 90 deletions
73
configure.in
73
configure.in
|
@ -245,13 +245,25 @@ CheckOSS()
|
||||||
if test x$enable_audio = xyes -a x$enable_oss = xyes; then
|
if test x$enable_audio = xyes -a x$enable_oss = xyes; then
|
||||||
AC_MSG_CHECKING(for OSS audio support)
|
AC_MSG_CHECKING(for OSS audio support)
|
||||||
have_oss=no
|
have_oss=no
|
||||||
AC_TRY_COMPILE([
|
if test x$have_oss != xyes; then
|
||||||
#include <sys/soundcard.h>
|
AC_TRY_COMPILE([
|
||||||
],[
|
#include <sys/soundcard.h>
|
||||||
int arg = SNDCTL_DSP_SETFRAGMENT;
|
],[
|
||||||
],[
|
int arg = SNDCTL_DSP_SETFRAGMENT;
|
||||||
have_oss=yes
|
],[
|
||||||
])
|
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)
|
AC_MSG_RESULT($have_oss)
|
||||||
if test x$have_oss = xyes; then
|
if test x$have_oss = xyes; then
|
||||||
CFLAGS="$CFLAGS -DOSS_SUPPORT"
|
CFLAGS="$CFLAGS -DOSS_SUPPORT"
|
||||||
|
@ -286,10 +298,10 @@ dnl Check whether we want to use OpenBSD native audio or not
|
||||||
CheckOPENBSDAUDIO()
|
CheckOPENBSDAUDIO()
|
||||||
{
|
{
|
||||||
AC_ARG_ENABLE(openbsdaudio,
|
AC_ARG_ENABLE(openbsdaudio,
|
||||||
[ --enable-openbsdaudio OpenBSD native audio support [default=no]],
|
[ --enable-openbsdaudio OpenBSD native audio support [default=yes]],
|
||||||
, enable_openbsdaudio=no)
|
, enable_openbsdaudio=yes)
|
||||||
if test x$enable_audio = xyes -a x$enable_openbsdaudio = xyes; then
|
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_SUBDIRS="$AUDIO_SUBDIRS openbsd"
|
||||||
AUDIO_DRIVERS="$AUDIO_DRIVERS openbsd/libaudio_openbsd.la"
|
AUDIO_DRIVERS="$AUDIO_DRIVERS openbsd/libaudio_openbsd.la"
|
||||||
fi
|
fi
|
||||||
|
@ -994,6 +1006,20 @@ CheckPTHREAD()
|
||||||
CFLAGS="$CFLAGS -DPTHREAD_NO_RECURSIVE_MUTEX"
|
CFLAGS="$CFLAGS -DPTHREAD_NO_RECURSIVE_MUTEX"
|
||||||
fi
|
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
|
# Check to see if this is broken glibc 2.0 pthreads
|
||||||
case "$target" in
|
case "$target" in
|
||||||
*-*-linux*)
|
*-*-linux*)
|
||||||
|
@ -1196,7 +1222,7 @@ case "$target" in
|
||||||
fi
|
fi
|
||||||
COPY_ARCH_SRC(src/thread, linux, SDL_systhread.c)
|
COPY_ARCH_SRC(src/thread, linux, SDL_systhread.c)
|
||||||
COPY_ARCH_SRC(src/thread, linux, SDL_systhread_c.h)
|
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)
|
COPY_ARCH_SRC(src/thread, generic, SDL_syssem.c)
|
||||||
else
|
else
|
||||||
COPY_ARCH_SRC(src/thread, linux, SDL_syssem.c)
|
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_systhread_c.h)
|
||||||
COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex.c)
|
COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex.c)
|
||||||
COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex_c.h)
|
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)
|
COPY_ARCH_SRC(src/thread, generic, SDL_syssem.c)
|
||||||
else
|
else
|
||||||
COPY_ARCH_SRC(src/thread, linux, SDL_syssem.c)
|
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_systhread_c.h)
|
||||||
COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex.c)
|
COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex.c)
|
||||||
COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex_c.h)
|
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)
|
COPY_ARCH_SRC(src/thread, generic, SDL_syssem.c)
|
||||||
else
|
else
|
||||||
COPY_ARCH_SRC(src/thread, linux, SDL_syssem.c)
|
COPY_ARCH_SRC(src/thread, linux, SDL_syssem.c)
|
||||||
|
@ -1373,6 +1399,7 @@ case "$target" in
|
||||||
ARCH=openbsd
|
ARCH=openbsd
|
||||||
CheckDummyVideo
|
CheckDummyVideo
|
||||||
CheckDiskAudio
|
CheckDiskAudio
|
||||||
|
CheckOPENBSDAUDIO
|
||||||
CheckNASM
|
CheckNASM
|
||||||
CheckOSS
|
CheckOSS
|
||||||
CheckARTSC
|
CheckARTSC
|
||||||
|
@ -1385,7 +1412,15 @@ case "$target" in
|
||||||
# Set up files for the main() stub
|
# Set up files for the main() stub
|
||||||
COPY_ARCH_SRC(src/main, linux, SDL_main.c)
|
COPY_ARCH_SRC(src/main, linux, SDL_main.c)
|
||||||
# Set up files for the audio library
|
# 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
|
# Set up files for the joystick library
|
||||||
# (No joystick support yet)
|
# (No joystick support yet)
|
||||||
if test x$enable_joystick = xyes; then
|
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_systhread_c.h)
|
||||||
COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex.c)
|
COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex.c)
|
||||||
COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex_c.h)
|
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)
|
COPY_ARCH_SRC(src/thread, generic, SDL_syssem.c)
|
||||||
else
|
else
|
||||||
COPY_ARCH_SRC(src/thread, linux, SDL_syssem.c)
|
COPY_ARCH_SRC(src/thread, linux, SDL_syssem.c)
|
||||||
|
@ -1528,7 +1563,7 @@ case "$target" in
|
||||||
if test x$enable_audio = xyes; then
|
if test x$enable_audio = xyes; then
|
||||||
AUDIO_SUBDIRS="$AUDIO_SUBDIRS dmedia"
|
AUDIO_SUBDIRS="$AUDIO_SUBDIRS dmedia"
|
||||||
AUDIO_DRIVERS="$AUDIO_DRIVERS dmedia/libaudio_dmedia.la"
|
AUDIO_DRIVERS="$AUDIO_DRIVERS dmedia/libaudio_dmedia.la"
|
||||||
LIBS="$LIBS -laudio"
|
SYSTEM_LIBS="$SYSTEM_LIBS -laudio"
|
||||||
fi
|
fi
|
||||||
# Set up files for the joystick library
|
# Set up files for the joystick library
|
||||||
# (No joystick support yet)
|
# (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_systhread_c.h)
|
||||||
COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex.c)
|
COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex.c)
|
||||||
COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex_c.h)
|
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)
|
COPY_ARCH_SRC(src/thread, generic, SDL_syssem.c)
|
||||||
else
|
else
|
||||||
COPY_ARCH_SRC(src/thread, linux, SDL_syssem.c)
|
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_systhread_c.h)
|
||||||
COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex.c)
|
COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex.c)
|
||||||
COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex_c.h)
|
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)
|
COPY_ARCH_SRC(src/thread, generic, SDL_syssem.c)
|
||||||
else
|
else
|
||||||
COPY_ARCH_SRC(src/thread, linux, SDL_syssem.c)
|
COPY_ARCH_SRC(src/thread, linux, SDL_syssem.c)
|
||||||
|
@ -1989,7 +2024,7 @@ if test $ARCH = solaris; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test $ARCH = openbsd; then
|
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
|
fi
|
||||||
|
|
||||||
dnl Output the video drivers we use
|
dnl Output the video drivers we use
|
||||||
|
|
|
@ -49,7 +49,7 @@ typedef struct SDL_SysWMinfo SDL_SysWMinfo;
|
||||||
#else
|
#else
|
||||||
|
|
||||||
/* This is the structure for custom window manager events */
|
/* 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__))
|
(!defined(DISABLE_X11) && !defined(__CYGWIN32__))
|
||||||
/* AIX is unix, of course, but the native compiler CSet doesn't define unix */
|
/* AIX is unix, of course, but the native compiler CSet doesn't define unix */
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
|
|
|
@ -40,6 +40,9 @@ static char rcsid =
|
||||||
|
|
||||||
/* Available audio drivers */
|
/* Available audio drivers */
|
||||||
static AudioBootStrap *bootstrap[] = {
|
static AudioBootStrap *bootstrap[] = {
|
||||||
|
#ifdef OBSD_SUPPORT
|
||||||
|
&OBSD_bootstrap,
|
||||||
|
#endif
|
||||||
#ifdef OSS_SUPPORT
|
#ifdef OSS_SUPPORT
|
||||||
&DSP_bootstrap,
|
&DSP_bootstrap,
|
||||||
&DMA_bootstrap,
|
&DMA_bootstrap,
|
||||||
|
@ -47,9 +50,6 @@ static AudioBootStrap *bootstrap[] = {
|
||||||
#ifdef ALSA_SUPPORT
|
#ifdef ALSA_SUPPORT
|
||||||
&ALSA_bootstrap,
|
&ALSA_bootstrap,
|
||||||
#endif
|
#endif
|
||||||
#ifdef __OpenBSD__
|
|
||||||
&OBSD_bootstrap,
|
|
||||||
#endif
|
|
||||||
#if (defined(unix) && !defined(__CYGWIN32__)) && \
|
#if (defined(unix) && !defined(__CYGWIN32__)) && \
|
||||||
!defined(OSS_SUPPORT) && !defined(ALSA_SUPPORT)
|
!defined(OSS_SUPPORT) && !defined(ALSA_SUPPORT)
|
||||||
&AUDIO_bootstrap,
|
&AUDIO_bootstrap,
|
||||||
|
|
|
@ -39,7 +39,11 @@ static char rcsid =
|
||||||
#include "SDL_audiodev_c.h"
|
#include "SDL_audiodev_c.h"
|
||||||
|
|
||||||
#ifndef _PATH_DEV_DSP
|
#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
|
#endif
|
||||||
#ifndef _PATH_DEV_DSP24
|
#ifndef _PATH_DEV_DSP24
|
||||||
#define _PATH_DEV_DSP24 "/dev/sound/dsp"
|
#define _PATH_DEV_DSP24 "/dev/sound/dsp"
|
||||||
|
|
|
@ -99,6 +99,9 @@ typedef struct AudioBootStrap {
|
||||||
SDL_AudioDevice *(*create)(int devindex);
|
SDL_AudioDevice *(*create)(int devindex);
|
||||||
} AudioBootStrap;
|
} AudioBootStrap;
|
||||||
|
|
||||||
|
#ifdef OBSD_SUPPORT
|
||||||
|
extern AudioBootStrap OBSD_bootstrap;
|
||||||
|
#endif
|
||||||
#ifdef OSS_SUPPORT
|
#ifdef OSS_SUPPORT
|
||||||
extern AudioBootStrap DSP_bootstrap;
|
extern AudioBootStrap DSP_bootstrap;
|
||||||
extern AudioBootStrap DMA_bootstrap;
|
extern AudioBootStrap DMA_bootstrap;
|
||||||
|
@ -106,9 +109,6 @@ extern AudioBootStrap DMA_bootstrap;
|
||||||
#ifdef ALSA_SUPPORT
|
#ifdef ALSA_SUPPORT
|
||||||
extern AudioBootStrap ALSA_bootstrap;
|
extern AudioBootStrap ALSA_bootstrap;
|
||||||
#endif
|
#endif
|
||||||
#ifdef __OpenBSD__
|
|
||||||
extern AudioBootStrap OBSD_bootstrap;
|
|
||||||
#endif
|
|
||||||
#if (defined(unix) && !defined(__CYGWIN32__)) && \
|
#if (defined(unix) && !defined(__CYGWIN32__)) && \
|
||||||
!defined(OSS_SUPPORT) && !defined(ALSA_SUPPORT)
|
!defined(OSS_SUPPORT) && !defined(ALSA_SUPPORT)
|
||||||
extern AudioBootStrap AUDIO_bootstrap;
|
extern AudioBootStrap AUDIO_bootstrap;
|
||||||
|
|
|
@ -39,7 +39,13 @@ static char rcsid =
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/mman.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>
|
#include <sys/soundcard.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef MAP_FAILED
|
#ifndef MAP_FAILED
|
||||||
#define MAP_FAILED ((Uint8 *)-1)
|
#define MAP_FAILED ((Uint8 *)-1)
|
||||||
|
|
|
@ -37,7 +37,13 @@ static char rcsid =
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/stat.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>
|
#include <sys/soundcard.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "SDL_audio.h"
|
#include "SDL_audio.h"
|
||||||
#include "SDL_error.h"
|
#include "SDL_error.h"
|
||||||
|
|
|
@ -140,83 +140,95 @@ AudioBootStrap OBSD_bootstrap = {
|
||||||
static void
|
static void
|
||||||
OBSD_WaitAudio(_THIS)
|
OBSD_WaitAudio(_THIS)
|
||||||
{
|
{
|
||||||
#ifndef USE_BLOCKING_WRITES
|
/* Check to see if the thread-parent process is still alive */
|
||||||
fd_set fdset;
|
{ static int cnt = 0;
|
||||||
|
/* Note that this only works with thread implementations
|
||||||
/* Check to see if the thread-parent process is still alive */
|
that use a different process id for each thread.
|
||||||
{
|
*/
|
||||||
static int cnt = 0;
|
if (parent && (((++cnt)%10) == 0)) { /* Check every 10 loops */
|
||||||
/* Note that this only works with thread implementations
|
if ( kill(parent, 0) < 0 ) {
|
||||||
that use a different process id for each thread. */
|
this->enabled = 0;
|
||||||
if(parent && (((++cnt)%10) == 0)) { /* Check every 10 loops */
|
}
|
||||||
if(kill(parent, 0) < 0)
|
}
|
||||||
this->enabled = 0;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef USE_TIMER_SYNC
|
#ifndef USE_BLOCKING_WRITES /* Not necessary when using blocking writes */
|
||||||
/* See if we need to use timed audio synchronization */
|
/* See if we need to use timed audio synchronization */
|
||||||
if(frame_ticks)
|
if ( frame_ticks ) {
|
||||||
{
|
/* Use timer for general audio synchronization */
|
||||||
/* Use timer for general audio synchronization */
|
Sint32 ticks;
|
||||||
Sint32 ticks;
|
|
||||||
|
|
||||||
ticks = ((Sint32)(next_frame - SDL_GetTicks())) - FUDGE_TICKS;
|
ticks = ((Sint32)(next_frame - SDL_GetTicks()))-FUDGE_TICKS;
|
||||||
if(ticks > 0)
|
if ( ticks > 0 ) {
|
||||||
SDL_Delay(ticks);
|
SDL_Delay(ticks);
|
||||||
}
|
}
|
||||||
else
|
} else {
|
||||||
#endif /* USE_TIMER_SYNC */
|
/* Use select() for audio synchronization */
|
||||||
{
|
fd_set fdset;
|
||||||
/* Use select() for audio synchronization */
|
struct timeval timeout;
|
||||||
struct timeval timeout;
|
|
||||||
FD_ZERO(&fdset);
|
FD_ZERO(&fdset);
|
||||||
FD_SET(audio_fd, &fdset);
|
FD_SET(audio_fd, &fdset);
|
||||||
timeout.tv_sec = 10;
|
timeout.tv_sec = 10;
|
||||||
timeout.tv_usec = 0;
|
timeout.tv_usec = 0;
|
||||||
|
#ifdef DEBUG_AUDIO
|
||||||
#if defined(DEBUG_AUDIO_STREAM) && defined(DEBUG_AUDIO_STREAM)
|
fprintf(stderr, "Waiting for audio to get ready\n");
|
||||||
OBSD_Status(this);
|
#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
|
#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 */
|
#endif /* !USE_BLOCKING_WRITES */
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
OBSD_PlayAudio(_THIS)
|
OBSD_PlayAudio(_THIS)
|
||||||
{
|
{
|
||||||
int written;
|
int written, p=0;
|
||||||
|
|
||||||
/* Write the audio data, checking for EAGAIN on broken audio drivers */
|
/* Write the audio data, checking for EAGAIN on broken audio drivers */
|
||||||
do
|
do {
|
||||||
{
|
written = write(audio_fd, &mixbuf[p], mixlen-p);
|
||||||
written = write(audio_fd, mixbuf, mixlen);
|
if (written>0)
|
||||||
if((written < 0) && ((errno == 0) || (errno == EAGAIN)))
|
p += written;
|
||||||
SDL_Delay(1);
|
if (written == -1 && errno != 0 && errno != EAGAIN && errno != EINTR)
|
||||||
}
|
{
|
||||||
while((written < 0) &&
|
/* Non recoverable error has occurred. It should be reported!!! */
|
||||||
((errno == 0) || (errno == EAGAIN) || (errno == EINTR)));
|
perror("audio");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef USE_TIMER_SYNC
|
if ( p < written || ((written < 0) && ((errno == 0) || (errno == EAGAIN))) ) {
|
||||||
if(frame_ticks)
|
SDL_Delay(1); /* Let a little CPU time go by */
|
||||||
next_frame += frame_ticks;
|
}
|
||||||
#endif
|
} while ( p < written );
|
||||||
|
|
||||||
/* If we couldn't write, assume fatal error for now */
|
/* If timer synchronization is enabled, set the next write frame */
|
||||||
if(written < 0)
|
if ( frame_ticks ) {
|
||||||
this->enabled = 0;
|
next_frame += frame_ticks;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DEBUG_AUDIO_STREAM
|
/* If we couldn't write, assume fatal error for now */
|
||||||
fprintf(stderr, "Wrote %d bytes of audio data\n", written);
|
if ( written < 0 ) {
|
||||||
|
this->enabled = 0;
|
||||||
|
}
|
||||||
|
#ifdef DEBUG_AUDIO
|
||||||
|
fprintf(stderr, "Wrote %d bytes of audio data\n", written);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ static char rcsid =
|
||||||
#ifdef SDL_USE_PTHREADS
|
#ifdef SDL_USE_PTHREADS
|
||||||
|
|
||||||
#ifdef SDL_NO_PTHREAD_SEMAPHORES
|
#ifdef SDL_NO_PTHREAD_SEMAPHORES
|
||||||
#include "generic/SDL_sem.c"
|
#include "generic/SDL_syssem.c"
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue