head 1.5; access; symbols pkgsrc-2013Q2:1.5.0.42 pkgsrc-2013Q2-base:1.5 pkgsrc-2012Q4:1.5.0.40 pkgsrc-2012Q4-base:1.5 pkgsrc-2011Q4:1.5.0.38 pkgsrc-2011Q4-base:1.5 pkgsrc-2011Q2:1.5.0.36 pkgsrc-2011Q2-base:1.5 pkgsrc-2009Q4:1.5.0.34 pkgsrc-2009Q4-base:1.5 pkgsrc-2008Q4:1.5.0.32 pkgsrc-2008Q4-base:1.5 pkgsrc-2008Q3:1.5.0.30 pkgsrc-2008Q3-base:1.5 cube-native-xorg:1.5.0.28 cube-native-xorg-base:1.5 pkgsrc-2008Q2:1.5.0.26 pkgsrc-2008Q2-base:1.5 pkgsrc-2008Q1:1.5.0.24 pkgsrc-2008Q1-base:1.5 pkgsrc-2007Q4:1.5.0.22 pkgsrc-2007Q4-base:1.5 pkgsrc-2007Q3:1.5.0.20 pkgsrc-2007Q3-base:1.5 pkgsrc-2007Q2:1.5.0.18 pkgsrc-2007Q2-base:1.5 pkgsrc-2007Q1:1.5.0.16 pkgsrc-2007Q1-base:1.5 pkgsrc-2006Q4:1.5.0.14 pkgsrc-2006Q4-base:1.5 pkgsrc-2006Q3:1.5.0.12 pkgsrc-2006Q3-base:1.5 pkgsrc-2006Q2:1.5.0.10 pkgsrc-2006Q2-base:1.5 pkgsrc-2006Q1:1.5.0.8 pkgsrc-2006Q1-base:1.5 pkgsrc-2005Q4:1.5.0.6 pkgsrc-2005Q4-base:1.5 pkgsrc-2005Q3:1.5.0.4 pkgsrc-2005Q3-base:1.5 pkgsrc-2005Q2:1.5.0.2 pkgsrc-2005Q2-base:1.5 pkgsrc-2005Q1:1.4.0.8 pkgsrc-2005Q1-base:1.4 pkgsrc-2004Q4:1.4.0.6 pkgsrc-2004Q4-base:1.4 pkgsrc-2004Q3:1.4.0.4 pkgsrc-2004Q3-base:1.4 pkgsrc-2004Q2:1.4.0.2 pkgsrc-2004Q2-base:1.4 pkgsrc-2004Q1:1.3.0.2 pkgsrc-2004Q1-base:1.3 pkgsrc-2003Q4:1.1.1.1.0.4 pkgsrc-2003Q4-base:1.1.1.1 netbsd-1-6-1:1.1.1.1.0.2 netbsd-1-6-1-base:1.1.1.1 pkgsrc-base:1.1.1.1 TNF:1.1.1; locks; strict; comment @# @; 1.5 date 2005.06.02.14.24.04; author blymn; state dead; branches; next 1.4; 1.4 date 2004.06.07.02.29.07; author snj; state Exp; branches; next 1.3; 1.3 date 2004.03.02.23.14.31; author snj; state Exp; branches; next 1.2; 1.2 date 2003.12.13.10.32.53; author xtraeme; state Exp; branches; next 1.1; 1.1 date 2002.09.24.12.49.13; author blymn; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 2002.09.24.12.49.13; author blymn; state Exp; branches; next ; desc @@ 1.5 log @Updated to version 2.0.2 of bzflag: * many many bug fixes * network protocol version updated * new game modes added @ text @$NetBSD: patch-ae,v 1.4 2004/06/07 02:29:07 snj Exp $ --- src/bzflag/Makefile.in.orig 2004-06-03 17:38:21.000000000 -0700 +++ src/bzflag/Makefile.in 2004-06-03 17:41:42.000000000 -0700 @@@@ -179,7 +179,6 @@@@ bzflag_SOURCES = \ @@MACOS_TRUE@@ ../scene/libSceneDB.a \ @@MACOS_TRUE@@ ../geometry/libGeometry.a \ @@MACOS_TRUE@@ ../mediafile/libMediaFile.a \ -@@MACOS_TRUE@@ ../zlib/libz.a \ @@MACOS_TRUE@@ $(REGEX) \ @@MACOS_TRUE@@ $(RESOURCE) \ @@MACOS_TRUE@@ $(GLIBS) @@@@ -193,7 +192,6 @@@@ bzflag_SOURCES = \ @@MACOS_FALSE@@ ../scene/libSceneDB.a \ @@MACOS_FALSE@@ ../geometry/libGeometry.a \ @@MACOS_FALSE@@ ../mediafile/libMediaFile.a \ -@@MACOS_FALSE@@ ../zlib/libz.a \ @@MACOS_FALSE@@ $(REGEX) \ @@MACOS_FALSE@@ $(RESOURCE) \ @@MACOS_FALSE@@ $(GLIBS) @@@@ -203,7 +201,7 @@@@ bzflag_SOURCES = \ # $(ALIBS) AM_CPPFLAGS = $(X_CFLAGS) -bzflag_LDFLAGS = ../date/buildDate.o +bzflag_LDFLAGS = ../date/buildDate.o -lz ${LIBOSSAUDIO} subdir = src/bzflag mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/include/config.h @@@@ -235,7 +233,6 @@@@ bzflag_LDADD = $(LDADD) @@BUILD_REGEX_FALSE@@@@MACOS_FALSE@@@@WIN32_TRUE@@ ../scene/libSceneDB.a \ @@BUILD_REGEX_FALSE@@@@MACOS_FALSE@@@@WIN32_TRUE@@ ../geometry/libGeometry.a \ @@BUILD_REGEX_FALSE@@@@MACOS_FALSE@@@@WIN32_TRUE@@ ../mediafile/libMediaFile.a \ -@@BUILD_REGEX_FALSE@@@@MACOS_FALSE@@@@WIN32_TRUE@@ ../zlib/libz.a \ @@BUILD_REGEX_FALSE@@@@MACOS_FALSE@@@@WIN32_TRUE@@ bzflag.res @@BUILD_REGEX_FALSE@@@@MACOS_FALSE@@@@WIN32_FALSE@@bzflag_DEPENDENCIES = \ @@BUILD_REGEX_FALSE@@@@MACOS_FALSE@@@@WIN32_FALSE@@ ../net/libNet.a \ @@@@ -246,7 +243,6 @@@@ bzflag_LDADD = $(LDADD) @@BUILD_REGEX_FALSE@@@@MACOS_FALSE@@@@WIN32_FALSE@@ ../scene/libSceneDB.a \ @@BUILD_REGEX_FALSE@@@@MACOS_FALSE@@@@WIN32_FALSE@@ ../geometry/libGeometry.a \ @@BUILD_REGEX_FALSE@@@@MACOS_FALSE@@@@WIN32_FALSE@@ ../mediafile/libMediaFile.a \ -@@BUILD_REGEX_FALSE@@@@MACOS_FALSE@@@@WIN32_FALSE@@ ../zlib/libz.a @@BUILD_REGEX_FALSE@@@@MACOS_TRUE@@@@WIN32_TRUE@@bzflag_DEPENDENCIES = \ @@BUILD_REGEX_FALSE@@@@MACOS_TRUE@@@@WIN32_TRUE@@ ../net/libNet.a \ @@BUILD_REGEX_FALSE@@@@MACOS_TRUE@@@@WIN32_TRUE@@ ../common/libCommon.a \ @@@@ -257,7 +253,6 @@@@ bzflag_LDADD = $(LDADD) @@BUILD_REGEX_FALSE@@@@MACOS_TRUE@@@@WIN32_TRUE@@ ../scene/libSceneDB.a \ @@BUILD_REGEX_FALSE@@@@MACOS_TRUE@@@@WIN32_TRUE@@ ../geometry/libGeometry.a \ @@BUILD_REGEX_FALSE@@@@MACOS_TRUE@@@@WIN32_TRUE@@ ../mediafile/libMediaFile.a \ -@@BUILD_REGEX_FALSE@@@@MACOS_TRUE@@@@WIN32_TRUE@@ ../zlib/libz.a \ @@BUILD_REGEX_FALSE@@@@MACOS_TRUE@@@@WIN32_TRUE@@ bzflag.res @@BUILD_REGEX_FALSE@@@@MACOS_TRUE@@@@WIN32_FALSE@@bzflag_DEPENDENCIES = \ @@BUILD_REGEX_FALSE@@@@MACOS_TRUE@@@@WIN32_FALSE@@ ../net/libNet.a \ @@@@ -268,8 +263,7 @@@@ bzflag_LDADD = $(LDADD) @@BUILD_REGEX_FALSE@@@@MACOS_TRUE@@@@WIN32_FALSE@@ ../ogl/libGLKit.a \ @@BUILD_REGEX_FALSE@@@@MACOS_TRUE@@@@WIN32_FALSE@@ ../scene/libSceneDB.a \ @@BUILD_REGEX_FALSE@@@@MACOS_TRUE@@@@WIN32_FALSE@@ ../geometry/libGeometry.a \ -@@BUILD_REGEX_FALSE@@@@MACOS_TRUE@@@@WIN32_FALSE@@ ../mediafile/libMediaFile.a \ -@@BUILD_REGEX_FALSE@@@@MACOS_TRUE@@@@WIN32_FALSE@@ ../zlib/libz.a +@@BUILD_REGEX_FALSE@@@@MACOS_TRUE@@@@WIN32_FALSE@@ ../mediafile/libMediaFile.a @@BUILD_REGEX_TRUE@@@@MACOS_FALSE@@@@WIN32_TRUE@@bzflag_DEPENDENCIES = \ @@BUILD_REGEX_TRUE@@@@MACOS_FALSE@@@@WIN32_TRUE@@ ../net/libNet.a \ @@BUILD_REGEX_TRUE@@@@MACOS_FALSE@@@@WIN32_TRUE@@ ../common/libCommon.a \ @@@@ -279,7 +273,6 @@@@ bzflag_LDADD = $(LDADD) @@BUILD_REGEX_TRUE@@@@MACOS_FALSE@@@@WIN32_TRUE@@ ../scene/libSceneDB.a \ @@BUILD_REGEX_TRUE@@@@MACOS_FALSE@@@@WIN32_TRUE@@ ../geometry/libGeometry.a \ @@BUILD_REGEX_TRUE@@@@MACOS_FALSE@@@@WIN32_TRUE@@ ../mediafile/libMediaFile.a \ -@@BUILD_REGEX_TRUE@@@@MACOS_FALSE@@@@WIN32_TRUE@@ ../zlib/libz.a \ @@BUILD_REGEX_TRUE@@@@MACOS_FALSE@@@@WIN32_TRUE@@ ../regex/libregex.a \ @@BUILD_REGEX_TRUE@@@@MACOS_FALSE@@@@WIN32_TRUE@@ bzflag.res @@BUILD_REGEX_TRUE@@@@MACOS_FALSE@@@@WIN32_FALSE@@bzflag_DEPENDENCIES = \ @@@@ -291,7 +284,6 @@@@ bzflag_LDADD = $(LDADD) @@BUILD_REGEX_TRUE@@@@MACOS_FALSE@@@@WIN32_FALSE@@ ../scene/libSceneDB.a \ @@BUILD_REGEX_TRUE@@@@MACOS_FALSE@@@@WIN32_FALSE@@ ../geometry/libGeometry.a \ @@BUILD_REGEX_TRUE@@@@MACOS_FALSE@@@@WIN32_FALSE@@ ../mediafile/libMediaFile.a \ -@@BUILD_REGEX_TRUE@@@@MACOS_FALSE@@@@WIN32_FALSE@@ ../zlib/libz.a \ @@BUILD_REGEX_TRUE@@@@MACOS_FALSE@@@@WIN32_FALSE@@ ../regex/libregex.a @@BUILD_REGEX_TRUE@@@@MACOS_TRUE@@@@WIN32_TRUE@@bzflag_DEPENDENCIES = \ @@BUILD_REGEX_TRUE@@@@MACOS_TRUE@@@@WIN32_TRUE@@ ../net/libNet.a \ @@@@ -303,7 +295,6 @@@@ bzflag_LDADD = $(LDADD) @@BUILD_REGEX_TRUE@@@@MACOS_TRUE@@@@WIN32_TRUE@@ ../scene/libSceneDB.a \ @@BUILD_REGEX_TRUE@@@@MACOS_TRUE@@@@WIN32_TRUE@@ ../geometry/libGeometry.a \ @@BUILD_REGEX_TRUE@@@@MACOS_TRUE@@@@WIN32_TRUE@@ ../mediafile/libMediaFile.a \ -@@BUILD_REGEX_TRUE@@@@MACOS_TRUE@@@@WIN32_TRUE@@ ../zlib/libz.a \ @@BUILD_REGEX_TRUE@@@@MACOS_TRUE@@@@WIN32_TRUE@@ ../regex/libregex.a \ @@BUILD_REGEX_TRUE@@@@MACOS_TRUE@@@@WIN32_TRUE@@ bzflag.res @@BUILD_REGEX_TRUE@@@@MACOS_TRUE@@@@WIN32_FALSE@@bzflag_DEPENDENCIES = \ @@@@ -316,7 +307,6 @@@@ bzflag_LDADD = $(LDADD) @@BUILD_REGEX_TRUE@@@@MACOS_TRUE@@@@WIN32_FALSE@@ ../scene/libSceneDB.a \ @@BUILD_REGEX_TRUE@@@@MACOS_TRUE@@@@WIN32_FALSE@@ ../geometry/libGeometry.a \ @@BUILD_REGEX_TRUE@@@@MACOS_TRUE@@@@WIN32_FALSE@@ ../mediafile/libMediaFile.a \ -@@BUILD_REGEX_TRUE@@@@MACOS_TRUE@@@@WIN32_FALSE@@ ../zlib/libz.a \ @@BUILD_REGEX_TRUE@@@@MACOS_TRUE@@@@WIN32_FALSE@@ ../regex/libregex.a DEFS = @@DEFS@@ @ 1.4 log @Update to 1.10.6. Changes: * /hostban based on hostmask when adns is available - Nils McCarthy * server option to disallow autopilot - Nils McCarthy * Bots are smarter - Frank Thilo * Fixed the little hop on spawn at some sites - Alfredo Tupone * Fixed issue of players add/removing others from groups - Alfredo Tupone * Fixed false positive filter matches involving apostrophes - Sean Morrison * Curing ghost/duplicated/ungetable flag - Alfredo Tupone * Fixed 0 height flag, no more flags inside buildings - Alfredo Tupone * Observers see Masquerade tank with their true color - Alfredo Tupone * Password file now supports callsigns with non alphanumerics - Alfredo Tupone * Correctly read PNG textures with multiple IDAT chunks - Daniel Remenak * Add aggressive filtering support for all platforms - Sean Morrison * Fixed bug that allowed empty callsigns - Frank Thilo @ text @d1 1 a1 1 $NetBSD$ @ 1.3 log @Update to bzflag-1.10.4. Changes: * Allow variable number of team flags per team with +f bzfs option * bots now fully handle collision check * Notify players when reassigned to a different team on join * Allow multiple bases per team * Alt-Tab & resolution changes do not mess up the screen * No shooting allowed if OO flag is lost in a building * Unclean client disconnects are recognized earlier * Color carried team flags according to their team * Start of better spawn positions based on tanks * Various texture improvements * Add experimental quality setting for enhanced effects * Increase moon segments for exp. quality * Stop infinite spawn loop with complex worlds containing big pyramids * Don't spawn in multiple locations based on multiple r-clicks * Fix Respawning after non-shot kills * Relax kick tolerances and soften kick messages * Remove bad lite effects with Thief steal * Protect against crashes due to bad shot ids * Relax flag drop time for speed checking * Better unresponsive player removal messages * Let genocided players spawn again * Many other bugfixes @ text @d3 11 a13 3 --- src/bzflag/Makefile.in.orig 2004-03-02 14:27:33.000000000 -0800 +++ src/bzflag/Makefile.in 2004-03-02 14:32:25.000000000 -0800 @@@@ -241,7 +241,6 @@@@ bzflag_SOURCES = \ d18 1 d21 1 a21 2 @@@@ -265,7 +264,7 @@@@ bzflag_SOURCES = \ d30 66 a95 19 @@@@ -296,7 +295,7 @@@@ bzflag_LDADD = $(LDADD) @@MACOS_FALSE@@@@WIN32_TRUE@@ ../scene/libSceneDB.a \ @@MACOS_FALSE@@@@WIN32_TRUE@@ ../geometry/libGeometry.a \ @@MACOS_FALSE@@@@WIN32_TRUE@@ ../mediafile/libMediaFile.a \ -@@MACOS_FALSE@@@@WIN32_TRUE@@ ../zlib/libz.a bzflag.res +@@MACOS_FALSE@@@@WIN32_TRUE@@ bzflag.res @@MACOS_FALSE@@@@WIN32_FALSE@@bzflag_DEPENDENCIES = ../net/libNet.a \ @@MACOS_FALSE@@@@WIN32_FALSE@@ ../common/libCommon.a \ @@MACOS_FALSE@@@@WIN32_FALSE@@ ../obstacle/libObstacle.a \ @@@@ -304,8 +303,7 @@@@ bzflag_LDADD = $(LDADD) @@MACOS_FALSE@@@@WIN32_FALSE@@ ../ogl/libGLKit.a \ @@MACOS_FALSE@@@@WIN32_FALSE@@ ../scene/libSceneDB.a \ @@MACOS_FALSE@@@@WIN32_FALSE@@ ../geometry/libGeometry.a \ -@@MACOS_FALSE@@@@WIN32_FALSE@@ ../mediafile/libMediaFile.a \ -@@MACOS_FALSE@@@@WIN32_FALSE@@ ../zlib/libz.a +@@MACOS_FALSE@@@@WIN32_FALSE@@ ../mediafile/libMediaFile.a @@MACOS_TRUE@@@@WIN32_TRUE@@bzflag_DEPENDENCIES = ../net/libNet.a \ @@MACOS_TRUE@@@@WIN32_TRUE@@ ../common/libCommon.a \ @@MACOS_TRUE@@@@WIN32_TRUE@@ ../obstacle/libObstacle.a \ @ 1.2 log @Updated to 1.10.0. The ChangeLog is huge. Selected new features include: * vote based kicking * tunable game parameters like gravity and world size * smarter bots * world weapons * bzadmin text client * autopilot * rabbit game style * single port networking And more... please review Changelog for a detailed list of changes. pkgsrc changes: o USE_X11BASE not needed anymore. I'm sorry, only tested on NetBSD/FreeBSD x86, I need more hardware... @ text @d3 3 a5 3 --- src/bzflag/Makefile.in.orig Wed Dec 10 09:09:45 2003 +++ src/bzflag/Makefile.in Thu Dec 11 02:09:15 2003 @@@@ -168,7 +168,6 @@@@ a11 2 # This is required to hook in ogg/vorbis libraries @@@@ -176,7 +175,7 @@@@ d13 2 d19 1 d21 20 a40 11 CONFIG_HEADER = ../../include/config.h CONFIG_CLEAN_FILES = @@@@ -207,7 +206,7 @@@@ @@MACOS_FALSE@@../common/libCommon.a ../obstacle/libObstacle.a \ @@MACOS_FALSE@@../platform/libPlatform.a ../ogl/libGLKit.a \ @@MACOS_FALSE@@../scene/libSceneDB.a ../geometry/libGeometry.a \ -@@MACOS_FALSE@@../mediafile/libMediaFile.a ../zlib/libz.a +@@MACOS_FALSE@@../mediafile/libMediaFile.a CXXFLAGS = @@CXXFLAGS@@ CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) @ 1.1 log @Initial revision @ text @d3 28 a30 480 --- src/platform/NetBSDMedia.cxx.orig Sun Sep 22 22:29:02 2002 +++ src/platform/NetBSDMedia.cxx @@@@ -0,0 +1,477 @@@@ +/* bzflag + * Copyright (c) 1993 - 2002 Tim Riker + * + * This package is free software; you can redistribute it and/or + * modify it under the terms of the license found in the file + * named LICENSE that should have accompanied this file. + * + * THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#include "NetBSDMedia.h" +#include +#include +#ifdef BSD +#include +#else +#ifdef __NetBSD__ +#include +#else +#include +#endif +#endif +#include +#include +#include +#include +#include "bzsignal.h" +#ifdef __NetBSD__ +#include +#else +#include +#endif +#include +#include +#include +#include + +#ifdef HALF_RATE_AUDIO +static const int defaultAudioRate=11025; +#else +static const int defaultAudioRate=22050; +#endif + +// +// NetBSDMedia +// + +NetBSDMedia::NetBSDMedia() : BzfMedia(), audioReady(False), + audioPortFd(-1), + queueIn(-1), queueOut(-1), + outputBuffer(NULL), + childProcID(0), + audio8Bit(False), + getospaceBroken(False) +{ + // do nothing +} + +NetBSDMedia::~NetBSDMedia() +{ + // do nothing +} + +double NetBSDMedia::getTime() +{ + struct timeval tv; + gettimeofday(&tv, 0); + return (double)tv.tv_sec + 1.0e-6 * (double)tv.tv_usec; +} + +double NetBSDMedia::stopwatch(boolean start) +{ + if (start) { + stopwatchTime = getTime(); + return 0.0; + } + return getTime() - stopwatchTime; +} + +void NetBSDMedia::sleep(float timeInSeconds) +{ + struct timeval tv; + tv.tv_sec = (long)timeInSeconds; + tv.tv_usec = (long)(1.0e6 * (timeInSeconds - tv.tv_sec)); + select(0, NULL, NULL, NULL, &tv); +} + +boolean NetBSDMedia::openAudio() +{ + // don't re-initialize + if (audioReady) return False; + + // check for and open audio hardware + if (!checkForAudioHardware() || !openAudioHardware()) return False; + + // open communication channel (FIFO pipe). close on exec. + int fd[2]; + if (pipe(fd)<0) { + closeAudio(); + return False; + } + queueIn = fd[1]; + queueOut = fd[0]; + fcntl(queueIn, F_SETFL, fcntl(queueIn, F_GETFL, 0) | O_NDELAY); + fcntl(queueOut, F_SETFL, fcntl(queueOut, F_GETFL, 0) | O_NDELAY); + fcntl(queueIn, F_SETFD, fcntl(queueIn, F_GETFD, 0) | FD_CLOEXEC); + fcntl(queueOut, F_SETFD, fcntl(queueOut, F_GETFD, 0) | FD_CLOEXEC); + + // compute maxFd for use in select() call + maxFd = queueOut; + if (maxFd (1 << fragmentSize)) { + audioBufferSize = 1 << fragmentSize; + noSetFragment = true; + } + if (!audio8Bit) + audioBufferSize >>= 1; + + // SNDCTL_DSP_GETOSPACE not supported on all platforms. check if + // it fails here and, if so, do a workaround by using the wall + // clock. *shudder* + if (audioPortFd != -1) { + audio_buf_info info; + if (!openIoctl(SNDCTL_DSP_GETOSPACE, &info, False)) { + getospaceBroken = True; + chunksPending = 0; + chunksPerSecond = (double)getAudioOutputRate() / + (double)getAudioBufferChunkSize(); + } + } + + return (audioPortFd != -1); +} + +void NetBSDMedia::closeAudio() +{ + delete [] outputBuffer; + if (audioPortFd>=0) close(audioPortFd); + if (queueIn!=-1) close(queueIn); + if (queueOut!=-1) close(queueOut); + audioReady=False; + audioPortFd=-1; + queueIn=-1; + queueOut=-1; + outputBuffer=0; +} + +boolean NetBSDMedia::startAudioThread( + void (*proc)(void*), void* data) +{ + // if no audio thread then just call proc and return + if (!hasAudioThread()) { + proc(data); + return True; + } + + // has an audio thread so fork and call proc + if (childProcID) return True; + if ((childProcID=fork()) > 0) { + close(queueOut); + close(audioPortFd); + return True; + } + else if (childProcID < 0) { + return False; + } + close(queueIn); + proc(data); + exit(0); +} + +void NetBSDMedia::stopAudioThread() +{ + if (childProcID != 0) kill(childProcID, SIGTERM); + childProcID=0; +} + +boolean NetBSDMedia::hasAudioThread() const +{ +#if defined(NO_AUDIO_THREAD) + return False; +#else + return True; +#endif +} + +void NetBSDMedia::audioThreadInit(void*) +{ +} + +void NetBSDMedia::writeSoundCommand(const void* cmd, int len) +{ + if (!audioReady) return; + write(queueIn, cmd, len); +} + +boolean NetBSDMedia::readSoundCommand(void* cmd, int len) +{ + return (read(queueOut, cmd, len)==len); +} + +int NetBSDMedia::getAudioOutputRate() const +{ + return audioOutputRate; +} + +int NetBSDMedia::getAudioBufferSize() const +{ + return NumChunks*(audioBufferSize>>1); +} + +int NetBSDMedia::getAudioBufferChunkSize() const +{ + return audioBufferSize>>1; +} + +boolean NetBSDMedia::isAudioTooEmpty() const +{ + if (getospaceBroken) { + if (chunksPending > 0) { + // get time elapsed since chunkTime + const double dt = getTime() - chunkTime; + + // how many chunks could've played in the elapsed time? + const int numChunks = (int)(dt * chunksPerSecond); + + // remove pending chunks + NetBSDMedia* self = (NetBSDMedia*)this; + self->chunksPending -= numChunks; + if (chunksPending < 0) + self->chunksPending = 0; + else + self->chunkTime += (double)numChunks / chunksPerSecond; + } + return chunksPending < audioLowWaterMark; + } + else { + audio_buf_info info; + if (ioctl(audioPortFd, SNDCTL_DSP_GETOSPACE, &info) < 0) + return False; + return info.fragments > info.fragstotal - audioLowWaterMark; + } +} + +void NetBSDMedia::writeAudioFrames8Bit( + const float* samples, int numFrames) +{ + int numSamples = 2 * numFrames; + int limit; + char *smOutputBuffer; + + smOutputBuffer=(char*)outputBuffer; + while (numSamples > 0) { + if (numSamples>audioBufferSize) limit=audioBufferSize; + else limit=numSamples; + for (int j = 0; j < limit; j++) { + if (samples[j] <= -32767.0) smOutputBuffer[j] = 0; + else if (samples[j] >= 32767.0) smOutputBuffer[j] = 255; + else smOutputBuffer[j] = char((samples[j]+32767)/257); + } + + // fill out the chunk (we never write a partial chunk) + if (limit < audioBufferSize) { + for (int j = limit; j < audioBufferSize; ++j) + smOutputBuffer[j] = 127; + limit = audioBufferSize; + } + + write(audioPortFd, smOutputBuffer, limit); + samples += limit; + numSamples -= limit; + } +} + +void NetBSDMedia::writeAudioFrames16Bit( + const float* samples, int numFrames) +{ + int numSamples = 2 * numFrames; + int limit; + + while (numSamples > 0) { + if (numSamples>audioBufferSize) limit=audioBufferSize; + else limit=numSamples; + for (int j = 0; j < limit; j++) { + if (samples[j] < -32767.0) outputBuffer[j] = -32767; + else if (samples[j] > 32767.0) outputBuffer[j] = 32767; + else outputBuffer[j] = short(samples[j]); + } + + // fill out the chunk (we never write a partial chunk) + if (limit < audioBufferSize) { + for (int j = limit; j < audioBufferSize; ++j) + outputBuffer[j] = 0; + limit = audioBufferSize; + } + + write(audioPortFd, outputBuffer, 2*limit); + samples += limit; + numSamples -= limit; + } +} + +void NetBSDMedia::writeAudioFrames( + const float* samples, int numFrames) +{ + if (audio8Bit) writeAudioFrames8Bit(samples, numFrames); + else writeAudioFrames16Bit(samples, numFrames); + + // if we couldn't set the fragment size then force the driver + // to play the short buffer. + if (noSetFragment) { + int dummy = 0; + ioctl(audioPortFd, SNDCTL_DSP_POST, &dummy); + } + + if (getospaceBroken) { + if (chunksPending == 0) + chunkTime = getTime(); + chunksPending += (numFrames + getAudioBufferChunkSize() - 1) / + getAudioBufferChunkSize(); + } +} + +void NetBSDMedia::audioSleep( + boolean checkLowWater, double endTime) +{ + fd_set commandSelectSet; + struct timeval tv; + + // To do both these operations at once, we need to poll. + if (checkLowWater) { + // start looping + TimeKeeper start = TimeKeeper::getCurrent(); + do { + // break if buffer has drained enough + if (isAudioTooEmpty()) break; + FD_ZERO(&commandSelectSet); + FD_SET(queueOut, &commandSelectSet); + tv.tv_sec=0; + tv.tv_usec=50000; + if (select(maxFd, &commandSelectSet, 0, 0, &tv)) break; + + } while (endTime<0.0 || (TimeKeeper::getCurrent()-start)=0.0)?&tv : 0); + } +} +// ex: shiftwidth=2 tabstop=8 @ 1.1.1.1 log @bzflag is an OpenGL based multiplayer tank game. @ text @@