Re: SDL audio issue with hivelytracker (porting attempt)

From: Fernando_ApesteguĂ­a <fernando.apesteguia_at_gmail.com>
Date: Tue, 15 Mar 2022 14:39:04 UTC
On Tue, Mar 15, 2022 at 3:29 PM Robert Clausecker <fuz@fuz.su> wrote:
>
> Hi Emanual,
>
> It does not look like you adjust any buffer size, but that might be
> handled by code not shown in the patch.
>
> If that's not the issue, I don't have any obvious ideas.

It looks like there is a problem with a buffer indeed:

0x0000000000237024 in rp_mixchunk (at=0x802800080, samples=0,
buf1=0x2ab000 <error: Cannot access memory at address 0x2ab000>,
buf2=0x2ab002 <error: Cannot acce
ss memory at address 0x2ab002>, bufmod=4) at ../replay.c:3464
(gdb) p buf1
$21 = (int8 *) 0x2ab000 <error: Cannot access memory at address 0x2ab000>

In this case, there are still 276 loops to perform but it seems we
already wrote past the end of the buffer.

Cheers.
>
> Yours,
> Robert Clausecker
>
> Am Tue, Mar 15, 2022 at 03:00:03PM +0100 schrieb Emanuel Haupt:
> > Robert Clausecker <fuz@fuz.su> wrote:
> > > Hi Emanuel,
> > >
> > > This is a common issue I had with multiple ports (the latest being
> > > emulators/fceux).  The fragment size must be patched to be a power of
> > > 2 and the buffer for the fragments must be resized to be at least as
> > > large as the fragment size (iirc).  This might be the reason why you
> > > get a signal.
> > >
> > > The fragment size is set in the SDL_AudioSpec structure member samples
> > > passed to SDL_OpenAudio().
> > >
> > > Try to find this call and patch it.
> >
> > I already did that (see also original post):
> > https://github.com/ehaupt/ports-wip/blob/master/ports/audio/hivelytracker/files/patch-replay.c
> >
> > This solved the initial issue but now I'm having problems with the
> > playback.
> >
> > > Yours,
> > > Robert Clausecker
> > >
> > > Am Tue, Mar 15, 2022 at 12:49:08PM +0100 schrieb Emanuel Haupt:
> > > > I've been trying to port the hivelytracker to FreeBSD. After a lot
> > > > of patching I was finally able to start it with:
> > > >
> > > > SDL_AUDIODRIVER=disk
> > > >
> > > > with dsp (default) I would always get:
> > > >
> > > > Fragment size must be a power of two
> > > >
> > > > when
> > > >
> > > > SDL_OpenAudio(...)
> > > >
> > > > was called.
> > > >
> > > > I did some further digging and found some useful references in:
> > > >
> > > > https://cgit.freebsd.org/ports/tree/audio/faudio/files/patch-src_FAudio__platform__sdl2.c
> > > >
> > > > With this patch I was able to get the player to launch without the
> > > > above error:
> > > >
> > > > https://github.com/ehaupt/ports-wip/blob/master/ports/audio/hivelytracker/files/patch-replay.c
> > > >
> > > > The player now starts:
> > > >
> > > > I can click on 'Load Mod', load a sample mod but as soon as I get
> > > > 'Play Song' I get:
> > > >
> > > > Abort trap (core dumped)
> > > >
> > > > I've been trying to get some sense by running it with truss but
> > > > haven't been very successful so far.
> > > >
> > > > The work in progress port can be found here:
> > > > https://github.com/ehaupt/ports-wip/tree/master/ports/audio/hivelytracker
> > > >
> > > > The port still needs some TLC (hardcoded paths, etc...). I'll fix
> > > > that before adding the port.
> > > >
> > > > Could someone with SDL audio experience please have a look? I'd
> > > > appreciate the help.
> > > >
> > > > Emanuel
> > > >
> > > >
> > > > [1] https://github.com/pete-gordon/hivelytracker
> > > >
> > >
> > > --
> > > ()  ascii ribbon campaign - for an 8-bit clean world
> > > /\  - against html email  - against proprietary attachments
> > >
> >
>
> --
> ()  ascii ribbon campaign - for an 8-bit clean world
> /\  - against html email  - against proprietary attachments
>