Skip to content

Conversation

@dwatteau
Copy link
Contributor

@dwatteau dwatteau commented Apr 18, 2025

Here's some work to bring FLAC support back to the Win9x builds.

Current status

We have some users missing FLAC support, for this port:

(e.g. games with Redbook audio, and where the tracks haven't been converted to Ogg Vorbis or MP3. Win9x builds are currently recommended to Windows XP users as well, so this also applies to them.)

It was disabled, because current FLAC releases expect _stat64 (and similar constucts) to be there, but they "weren't added to MSVCRT.DLL until later versions of Windows" (quoting @ccawley2011's comment above). So building it would fail.

I spent some time trying to have mingw2 present some fake 64-bit APIs as shortcuts to the 32-bit ones (that should be good enough for our FLAC usage), to no avail. Removing the (intentionally) hardcoded "bigfile" support from FLAC also felt quite hard.

What this PR does

So I thought about reverting to the last FLAC release which used the old 32-bit APIs on Windows. This PR then adds an exception to the windows-9x toolchain, reusing some work from the old opendingux toolchain, and also reusing the Win95 patch that's been written for SDL1.2.

I had to patch some other stuff, e.g. for better compatibility with newer compilers, and I backported some v1.3.x upstream commits to improve the NASM code targeted at older processors (it's a Win95/Win98 build after all, so I guess supporting old processors and giving them some speed-up could help).

By the way, FLAC 1.3 then forced SSE2 support by default, removed 3DNow support, things like that. (Although we just use the decoder, not the encoder, and only the latter seems to use the more complicated asm code.)

Oh, and if you worry about using a 2007 library, don't forget that this is for users wanting to run ScummVM on a 1995 OS 😁

Tests

I've built the new toolchain, and did a 2.10.0git test build with it. It appears to work just fine.

But I just very, very rarely use this port, so I've asked of of the Win 9x users to test this change and report any problem.

(And as usual I can't make it short, eh!)

Current FLAC expects `_stat64` to always be available on Windows, but
that's not the case for Win9x.

Moreover, even FLAC 1.3.2 in 2017 started to "Assume all currently
used OSes support SSE2", so it's getting harder and harder to have
a modern FLAC running on old Windows releases.

FLAC 1.2.1 appears to do the job, though (with some patches).
It's old (2007), but if your target is a 1995 OS, it shouldn't be
too bad.
@ccawley2011
Copy link
Member

I've tested this briefly with Drascula on Windows 98 SE, and it seems to work well. Thanks for sorting this out.

…s ones

It appears that CentOS 7 used later upstream patches for CVE-2014-9028,
which provide a better fix, and prevent seeking bugs resulting from the
first fixes.
@lephilousophe
Copy link
Member

LGTM. Merging.
Thank you!

@lephilousophe lephilousophe merged commit 7ed57f4 into scummvm:master Apr 24, 2025
@dwatteau dwatteau deleted the feat/win9x-add-patched-flac-1.2.1 branch April 24, 2025 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants