Built and tested with games/capitan-sevilla, games/garden, and games/opensonic. Comments inline.
On Mon, Oct 21, 2019 at 08:24:21PM -0700, Nam Nguyen wrote: [...] > The main issue was stuttering audio in games/opensonic and > games/garden. I tracked this down to src/unix/uthreads.c, where there is > a busy loop and a select() trying to sleep for 1 ms. This actually > sleeps for 10 ms on OpenBSD because of its tick rate. This problem is still there on my testing with capitan and garden. > I initially tried removing the select(). I tested it on > addons/logg/logg.c, a sample program to play ogg files. With the > select() audio stuttered playing back an ogg file. Without the select() > CPU usage spiked to 100%, but it played fine. > > cc -g -I/usr/local/include -L/usr/local/lib -lalleg -llogg -lvorbisenc > -lvorbisfile -lvorbis -o play_ogg logg.c play_ogg.c > > I experimentally arrived at a workaround of spending a bit more time > inside the busy loop before sleeping. I relaxed the constraint of 18 ms > inside the busy loop to 40 ms. Could use an explanatory comment in the patch itself. However, sound stuttering still seems to be present for me. [...] > HOMEPAGE = http://liballeg.org/ Why not switch to https while here? > -MASTER_SITES = ${MASTER_SITE_SOURCEFORGE:=alleg/} > + > +GH_ACCOUNT = liballeg > +GH_PROJECT = allegro5 > +GH_TAGNAME = ${V} >From Makefile.template: # /releases/ -> preferred. ignore GH_*, just use MASTER_SITES and DISTNAME Works for me with the following 2 lines instead of GH_*: MASTER_SITES = https://github.com/liballeg/allegro5/releases/download/${V}/ ... WRKDIST = ${WRKDIR}/allegro5-${V} > Index: patches/patch-src_unix_uthreads_c > =================================================================== > RCS file: patches/patch-src_unix_uthreads_c > diff -N patches/patch-src_unix_uthreads_c > --- /dev/null 1 Jan 1970 00:00:00 -0000 > +++ patches/patch-src_unix_uthreads_c 22 Oct 2019 02:27:13 -0000 > @@ -0,0 +1,18 @@ > +$OpenBSD$ Maybe an explanatory comment here > + > +Index: src/unix/uthreads.c > +--- src/unix/uthreads.c.orig > ++++ src/unix/uthreads.c > +@@ -82,9 +82,9 @@ static void *bg_man_pthreads_threadfunc(void *arg) > + (new_time.tv_usec - old_time.tv_usec)); > + old_time = new_time; > + > +- /* run the callbacks for each 10ms elapsed, but limit to 18ms */ > +- if (interval > 18000) > +- interval = 18000; > ++ /* run the callbacks for each 10ms elapsed, but limit to 40ms */ > ++ if (interval > 40000) > ++ interval = 40000; > + while (interval > 10000) { > + interval -= 10000; > + [...] > +lib/allegro/4.4.3/alleg-sndiodigi.so $ make update-plist Regenerating PLIST here adds @so tag: @so lib/allegro/4.4.3/alleg-sndiodigi.so [...] Otherwise looks good to me. The sound stuttering is already present with 4.2.3p7. Not sure if that is assumed to be related to tickrate? Happy to commit if someone else ok's this.