On Mon, Jan 19, 2009 at 10:41:58AM +0000, Jacob Meuser wrote: > On Mon, Jan 19, 2009 at 10:17:39AM +0100, Alf Schlichting wrote: > > On Mon, Jan 19, 2009 at 07:08:36AM +0200, Antti Harri wrote: > > > On Sun, 18 Jan 2009, Matthias Kilian wrote: > > > > > >> [X] arm by me (fps really sucks on zaurus) > > > > > > For people testing without acceleration this might speed > > > things up in software mode: > > > > > > http://openarena.wikia.com/wiki/FAQ#I_have_no_3D_card_.2F_No_OpenGL_acceleration_.21 > > > > > > +set r_allowSoftwareGL 1 +set r_mode 0 +set r_lodbias 4 \ > > > +set r_textureMode GL_NEAREST_MIPMAP_NEAREST +set r_picmip 2 +set \ > > > r_vertexLight 1 > > > > > > -- > > > Antti Harri > > > > > > > I have been using ioquake3 with Quake 3 Arena for some time with > > an Ati X800 as well as an X1950 Pro on an Intel Dual Core. I get > > stuttering/distortion in sound every 3-5 minutes or more often > > which is quite annoying. > > > > I tried different graphic settings from 1280x1024 with every knob > > to max to 600x800 with r_picmip 10 and r_vertexlight 1. timedemo > > gives 370 FPS, in game i have set it to com_maxfps 85. The stuttering > > still continues. > > The bugs in the audio code of ioquake3/quake3 are well known and > > fixed in more advanced engines like cnq3 from promode.org > > and the upcoming QuakeLive. > > I backported the audio fixes from cnq3 (a ioquake3 fork) but the > > symptoms are still there. > > However, i remember to have running Quake 3 under Linux on a > > 400 Mhz AMD K2 and a 3dfx card (later Ati 9200 with the x11-radeon driver) > > as well as on a laptop with Windows XP and a 8mb Ati mobility card > > without any issues regarding sound. > > > > That of course where the days before ioquake3's switch to SDL:) > > Another SDL-based engine, Darkplaces (for Quake I) shows the same symptoms. > > > > Basically i think that load alone is not the issue here since reducing > > the graphics to the bare minimum doesn't help. > > > > Forgot to say, since ca. 2 months i was forced to use aucat since useing > > libsndio without aucat produces distortion. I'm at work now so no > > dmesg, sorry. Soundcards i used where mainly 2 different soundblaster cards > > and 1 azalia. > > Btw., emu(4) and aucat proved to be an excellent solution so far > > (beside the stuttering), no noticable latency. > > > > Alf > > > > Allthough i do not have a radeon in that machine at the moment i > > can plug in one any time for testing, i would love to get this > > working. > > > > the 2nd and 3rd chunks in ports/devel/sdl/patches/patch-src_audio_SDL_audio_c > *could* be the problem here. but those did fix other SDL applications, > and even stopped segfaults in some apps, at least with the audio(4) backend. > the code is twisty, but I'm 99% sure at least the third chunk is correct. > the second is not really correct, but as I said, it fixed some apps. > > it could be that this engine relies on the "vanilla" "broken" behaviour > though. it does seem like a buffer size problem. > > running aucat pretty much guarantees there will be no conversions in > SDL, which makes those changes irrelevant. since using aucat seems > to help ... > > if you guys remove those changes and it significantly helps these games, > I'll test other apps and see if they're still needed ... there's lots > of SDL apps, but I think I remember some of the ones that were > crashing without those changes. ffplay comes to mind. so do the > nintendo emulators.
I've spent the day playing games ... as research ;) first, on my i386 (Celeron M 440 CPU/82945GM video/82801GB audio), turning on OpenGL mode definitely makes audio stutter. quake2 and znses in particular are very clearly affected. I can use both with their highest resolution X11 full-screen mode and audio is perfect. but even the lowest resolution windowed OpenGL mode makes the audio stutter. video is fine, but the audio stutters. now on my amd64 (Athlon 3000+ CPU/Radeon 9200 SE video/SBLive! audio) I can use OpenGL in relatively high resolution and audio is fine. if I try to use ultra high resolution or full-screen, then audio starts stutterring. on my i386, both audio and video are on pci0, on my amd64, video is on pci1 and audio is on pci0. and it's my understanding that radeon is faster at rendering than intel. but clearly, there is some connection between graphics processing and the ability to feed the audio device quickly enough. not sure if this an issue in SDL, the kernel, or simply the hardware. also, I've done some cleanup to the SDL sndio backend, and changed it to be more like other sndio backends in the way it configures the buffer and took a couple hints from the ALSA backend. this seems to have greatly improved audio in openarena. this was one of the first sndio backends I did. I've learned a bit and some bugs in libsndio have been fixed since then. I've tested it on several SDL apps and I'm quite happy with the results. unfortunately a couple games (quake2 and csmash) stutter a bit when they don't supply a sample rate that the audio device can handle natively, but using aucat clears it up. twiddling some config options to make those apps use a natively supported sample rate, if the app has such an option, works too. so here's the diff. it's likely I'll commit this very soon, but please give it a trial and let me know how it goes. note, you don't need to rebuild anything other than SDL to test this. a simple 'cd /usr/ports/devel/sdl; patch -p 0 < sdl.diff; make update' is all it takes. n.b. as you can see, those patch chunks mentioned above are still needed. hopefully this will be fixed in SDL-1.3. -- [email protected] SDF Public Access UNIX System - http://sdf.lonestar.org Index: Makefile =================================================================== RCS file: /home2/cvs/OpenBSD/ports/devel/sdl/Makefile,v retrieving revision 1.71 diff -u -r1.71 Makefile --- Makefile 8 Jan 2009 20:38:11 -0000 1.71 +++ Makefile 20 Jan 2009 07:28:14 -0000 @@ -4,7 +4,7 @@ VERSION= 1.2.13 DISTNAME= SDL-${VERSION} -PKGNAME= ${DISTNAME:L}p10 +PKGNAME= ${DISTNAME:L}p11 CATEGORIES= devel HOMEPAGE= http://www.libsdl.org/ Index: files/SDL_libsndioaudio.c =================================================================== RCS file: /home2/cvs/OpenBSD/ports/devel/sdl/files/SDL_libsndioaudio.c,v retrieving revision 1.4 diff -u -r1.4 SDL_libsndioaudio.c --- files/SDL_libsndioaudio.c 8 Jan 2009 20:10:46 -0000 1.4 +++ files/SDL_libsndioaudio.c 20 Jan 2009 07:28:14 -0000 @@ -32,14 +32,14 @@ #include "SDL_libsndioaudio.h" /* The tag name used by libsndio audio */ -#define LIBSNDIO_DRIVER_NAME "libsndio" +#define SNDIO_DRIVER_NAME "sndio" /* Audio driver functions */ -static int LIBSNDIO_OpenAudio(_THIS, SDL_AudioSpec *spec); -static void LIBSNDIO_WaitAudio(_THIS); -static void LIBSNDIO_PlayAudio(_THIS); -static Uint8 *LIBSNDIO_GetAudioBuf(_THIS); -static void LIBSNDIO_CloseAudio(_THIS); +static int SNDIO_OpenAudio(_THIS, SDL_AudioSpec *spec); +static void SNDIO_WaitAudio(_THIS); +static void SNDIO_PlayAudio(_THIS); +static Uint8 *SNDIO_GetAudioBuf(_THIS); +static void SNDIO_CloseAudio(_THIS); /* Audio driver bootstrap functions */ @@ -83,11 +83,11 @@ SDL_memset(this->hidden, 0, (sizeof *this->hidden)); /* Set the function pointers */ - this->OpenAudio = LIBSNDIO_OpenAudio; - this->WaitAudio = LIBSNDIO_WaitAudio; - this->PlayAudio = LIBSNDIO_PlayAudio; - this->GetAudioBuf = LIBSNDIO_GetAudioBuf; - this->CloseAudio = LIBSNDIO_CloseAudio; + this->OpenAudio = SNDIO_OpenAudio; + this->WaitAudio = SNDIO_WaitAudio; + this->PlayAudio = SNDIO_PlayAudio; + this->GetAudioBuf = SNDIO_GetAudioBuf; + this->CloseAudio = SNDIO_CloseAudio; this->free = Audio_DeleteDevice; @@ -96,18 +96,16 @@ return this; } -AudioBootStrap LIBSNDIO_bootstrap = { - LIBSNDIO_DRIVER_NAME, "libsndio", +AudioBootStrap SNDIO_bootstrap = { + SNDIO_DRIVER_NAME, "sndio", Audio_Available, Audio_CreateDevice }; /* This function waits until it is possible to write a full sound buffer */ -static void LIBSNDIO_WaitAudio(_THIS) +static void SNDIO_WaitAudio(_THIS) { - Sint32 ticks; - /* Check to see if the thread-parent process is still alive */ { static int cnt = 0; /* Note that this only works with thread implementations @@ -119,26 +117,15 @@ } } } - - /* Use timer for general audio synchronization */ - ticks = ((Sint32)(next_frame - SDL_GetTicks()))-FUDGE_TICKS; - if ( ticks > 0 ) { - SDL_Delay(ticks); - } } -static void LIBSNDIO_PlayAudio(_THIS) +static void SNDIO_PlayAudio(_THIS) { int written; /* Write the audio data */ written = sio_write(hdl, mixbuf, mixlen); - /* If timer synchronization is enabled, set the next write frame */ - if ( frame_ticks ) { - next_frame += frame_ticks; - } - /* If we couldn't write, assume fatal error for now */ if ( written == 0 ) { this->enabled = 0; @@ -148,12 +135,12 @@ #endif } -static Uint8 *LIBSNDIO_GetAudioBuf(_THIS) +static Uint8 *SNDIO_GetAudioBuf(_THIS) { return(mixbuf); } -static void LIBSNDIO_CloseAudio(_THIS) +static void SNDIO_CloseAudio(_THIS) { if ( mixbuf != NULL ) { SDL_FreeAudioMem(mixbuf); @@ -165,14 +152,10 @@ } } -static int LIBSNDIO_OpenAudio(_THIS, SDL_AudioSpec *spec) +static int SNDIO_OpenAudio(_THIS, SDL_AudioSpec *spec) { struct sio_par par; - /* Reset the timer synchronization flag */ - frame_ticks = 0.0; - next_frame = 0; - mixbuf = NULL; if ((hdl = sio_open(NULL, SIO_PLAY, 0)) == NULL) { @@ -212,19 +195,14 @@ par.sig = 0; break; default: - SDL_SetError("LIBSNDIO unknown format"); + SDL_SetError("SNDIO unknown format"); return(-1); } par.rate = spec->freq; par.pchan = spec->channels; - - /* Calculate the final parameters for this audio specification */ - SDL_CalculateAudioSpec(spec); - - /* bufsz is in frames, size is in bytes. they both are counts - of the total buffer size (total latency desired) */ - par.appbufsz = spec->size / par.pchan / (par.bits / 8); + par.round = spec->samples; + par.appbufsz = par.round * 2; if (sio_setpar(hdl, &par) == 0) { SDL_SetError("sio_setpar() failed"); @@ -269,19 +247,15 @@ } else if (par.bits == 8) { spec->format = par.sig ? AUDIO_S8 : AUDIO_U8; } else { - SDL_SetError("LIBSNDIO couldn't configure a suitable format"); + SDL_SetError("SNDIO couldn't configure a suitable format"); return(-1); } spec->freq = par.rate; spec->channels = par.pchan; + spec->samples = par.round; - /* tell SDL we want to write in par.round sized blocks */ - /* this is problematic for some applications, don't do it now. - maybe in SDL-1.3. - spec->size = par.bufsz * par.pchan * par.bps; - frame_ticks = (float)par.bufsz / par.rate; - */ + SDL_CalculateAudioSpec(spec); /* Allocate mixing buffer */ mixlen = spec->size; Index: files/SDL_libsndioaudio.h =================================================================== RCS file: /home2/cvs/OpenBSD/ports/devel/sdl/files/SDL_libsndioaudio.h,v retrieving revision 1.2 diff -u -r1.2 SDL_libsndioaudio.h --- files/SDL_libsndioaudio.h 13 Nov 2008 22:09:59 -0000 1.2 +++ files/SDL_libsndioaudio.h 20 Jan 2009 07:28:14 -0000 @@ -38,19 +38,13 @@ Uint8 *mixbuf; int mixlen; - /* Support for audio timing using a timer, in addition to select() */ - float frame_ticks; - float next_frame; }; -#define FUDGE_TICKS 10 /* The scheduler overhead ticks per frame */ /* Old variable names */ #define stream (this->hidden->stream) #define parent (this->hidden->parent) #define mixbuf (this->hidden->mixbuf) #define mixlen (this->hidden->mixlen) -#define frame_ticks (this->hidden->frame_ticks) -#define next_frame (this->hidden->next_frame) #define hdl (this->hidden->hdl) #endif /* _SDL_libsaaudio_h */ Index: patches/patch-configure =================================================================== RCS file: /home2/cvs/OpenBSD/ports/devel/sdl/patches/patch-configure,v retrieving revision 1.19 diff -u -r1.19 patch-configure --- patches/patch-configure 30 Dec 2008 02:15:20 -0000 1.19 +++ patches/patch-configure 20 Jan 2009 07:28:14 -0000 @@ -6,12 +6,12 @@ } + -+CheckLibsndio() ++CheckSndio() +{ -+ if [ x"$WITH_LIBSNDIO" = x"Yes" ]; then ++ if [ x"$WITH_SNDIO" = x"Yes" ]; then + + cat >>confdefs.h <<\_ACEOF -+#define SDL_AUDIO_DRIVER_LIBSNDIO 1 ++#define SDL_AUDIO_DRIVER_SNDIO 1 +_ACEOF + SOURCES="$SOURCES $srcdir/src/audio/libsndio/*.c" + EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lsndio" @@ -36,7 +36,7 @@ CheckALSA CheckARTSC CheckESD -+ CheckLibsndio ++ CheckSndio CheckPulseAudio CheckNAS CheckX11 Index: patches/patch-include_SDL_config_h_in =================================================================== RCS file: /home2/cvs/OpenBSD/ports/devel/sdl/patches/patch-include_SDL_config_h_in,v retrieving revision 1.1 diff -u -r1.1 patch-include_SDL_config_h_in --- patches/patch-include_SDL_config_h_in 2 Nov 2008 14:53:51 -0000 1.1 +++ patches/patch-include_SDL_config_h_in 20 Jan 2009 07:28:14 -0000 @@ -5,7 +5,7 @@ #undef SDL_AUDIO_DRIVER_QNXNTO #undef SDL_AUDIO_DRIVER_SNDMGR #undef SDL_AUDIO_DRIVER_SUNAUDIO -+#undef SDL_AUDIO_DRIVER_LIBSNDIO ++#undef SDL_AUDIO_DRIVER_SNDIO #undef SDL_AUDIO_DRIVER_WAVEOUT /* Enable various cdrom drivers */ Index: patches/patch-src_audio_SDL_audio_c =================================================================== RCS file: /home2/cvs/OpenBSD/ports/devel/sdl/patches/patch-src_audio_SDL_audio_c,v retrieving revision 1.15 diff -u -r1.15 patch-src_audio_SDL_audio_c --- patches/patch-src_audio_SDL_audio_c 30 Dec 2008 02:15:20 -0000 1.15 +++ patches/patch-src_audio_SDL_audio_c 20 Jan 2009 07:28:14 -0000 @@ -5,8 +5,8 @@ /* Available audio drivers */ static AudioBootStrap *bootstrap[] = { -+#if SDL_AUDIO_DRIVER_LIBSNDIO -+ &LIBSNDIO_bootstrap, ++#if SDL_AUDIO_DRIVER_SNDIO ++ &SNDIO_bootstrap, +#endif #if SDL_AUDIO_DRIVER_BSD &BSD_AUDIO_bootstrap, Index: patches/patch-src_audio_SDL_sysaudio_h =================================================================== RCS file: /home2/cvs/OpenBSD/ports/devel/sdl/patches/patch-src_audio_SDL_sysaudio_h,v retrieving revision 1.4 diff -u -r1.4 patch-src_audio_SDL_sysaudio_h --- patches/patch-src_audio_SDL_sysaudio_h 2 Nov 2008 14:53:51 -0000 1.4 +++ patches/patch-src_audio_SDL_sysaudio_h 20 Jan 2009 07:28:14 -0000 @@ -5,8 +5,8 @@ #if SDL_AUDIO_DRIVER_BSD extern AudioBootStrap BSD_AUDIO_bootstrap; #endif -+#if SDL_AUDIO_DRIVER_LIBSNDIO -+extern AudioBootStrap LIBSNDIO_bootstrap; ++#if SDL_AUDIO_DRIVER_SNDIO ++extern AudioBootStrap SNDIO_bootstrap; +#endif #if SDL_AUDIO_DRIVER_PULSE extern AudioBootStrap PULSE_bootstrap;
