On Tue, Jan 20, 2009 at 10:24:47AM +0000, Jacob Meuser wrote:
> 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.

This update breaks scummvm, works fine with p10.

The SDL audio init code from scummvm is extracted into a small
simplified test case below.

p10:
audio open ok

p11:
Could not open audio device: No available audio device

To compile:
gcc atest.c `pkg-config --cflags --libs sdl` -I/usr/local/include -o atest


#include <stdio.h>
#include <stdint.h>
#include <err.h>
#include <SDL.h>

#define SAMPLES_PER_SEC 22050

void
mixCallback(void *arg, uint8_t *samples, int len)
{
}

int
main(int argc, char *argv[])
{
        SDL_AudioSpec desired;
        SDL_AudioSpec obtained;

        int  _samplesPerSec = SAMPLES_PER_SEC;

        // Determine the sample buffer size. We want it to store enough data for
        // about 1/16th of a second. Note that it must be a power of two.
        // So e.g. at 22050 Hz, we request a sample buffer size of 2048.
        int samples = 8192;
        while (16 * samples >= _samplesPerSec) {
                samples >>= 1;
        }

        memset(&desired, 0, sizeof(desired));
        desired.freq = _samplesPerSec;
        desired.format = AUDIO_S16SYS;
        desired.channels = 2;
        desired.samples = (uint16_t)samples;
        desired.callback = mixCallback;
        desired.userdata = NULL;

        if (SDL_OpenAudio(&desired, &obtained) != 0) {
                warnx("Could not open audio device: %s", SDL_GetError());
        } else {
                printf("audio open ok\n");
                SDL_CloseAudio();
        }

        return (0);
}

Reply via email to