more windows Makefile tinkering

It looks like the Windows API call for PlaySound using SND_RESOURCE, from a
mingw32 built program, cannot find the resources that are
embeded into the .exe by the mingw32 resource compiler. That works fine
from visual studio.

For now, fall back to not using the SND_RESOURCE flag, use an ordinary
wav file name in the filesystem. Makefile.mingw32 has been modified
to copy the wav files to the binary directory along with the exe.

This probably won't be the final approach, but it will get things
working for now.
This commit is contained in:
nhmall
2023-01-31 00:45:27 -05:00
parent a7b8099ecb
commit ce0a4f60ca
5 changed files with 127 additions and 31 deletions
+30 -3
View File
@@ -56,15 +56,42 @@ windsound_soundeffect(char *desc, int32_t seid, int32_t volume)
{
#ifdef SND_SOUNDEFFECTS_AUTOMAP
int reslt = 0;
int32_t sefnflag = 0;
char buf[PATHLEN];
const char *filename;
DWORD fdwsound;
if (seid >= se_squeak_C || seid <= se_squeak_B) {
filename = get_sound_effect_filename(seid, buf, sizeof buf, 1);
fdwsound = SND_ASYNC | SND_RESOURCE;
#if defined(__MINGW32__)
/* The mingw32 resources don't seem to be able to be retrieved by the
* API PlaySound function with the SND_RESOURCE flag. Use files from
* the file system instead. */
extern char *sounddir; /* in sounds.c, set in files.c */
char *exedir;
if (!sounddir) {
exedir = exepath();
if (exedir)
if (strlen(exedir) < sizeof buf - 30) {
Strcpy(buf, exedir);
sefnflag = 2; /* 2 = use the directory name already in buf */
}
}
filename = get_sound_effect_filename(seid, buf, sizeof buf, sefnflag);
fdwsound = SND_ASYNC | SND_NODEFAULT;
#else
sefnflag = 1;
/* sefnflag = 1 means just obtain the soundeffect base name with
* no directory name and no file extension. That's because we're
* going to use the base soundeffect name as the name of a resource
* that's embedded into the .exe file, passing SND_RESOURCE flag to
* Windows API PlaySound().
*/
filename = get_sound_effect_filename(seid, buf, sizeof buf, sefnflag);
fdwsound = SND_ASYNC | SND_RESOURCE;
#endif
} else {
filename = get_sound_effect_filename(seid, buf, sizeof buf, 0);
filename = get_sound_effect_filename(seid, buf, sizeof buf, sefnflag);
fdwsound = SND_ASYNC | SND_NODEFAULT;
}