mirror of
git://git.9front.org/plan9front/plan9front
synced 2025-01-12 11:10:06 +00:00
games/doom: use wadfs to expose genmidi lump instead of extracting to /tmp
to allow using games/dmid + games/opl3 for music playback, the genmidi
lump must be exposed; previous attempt was insufficient since patch wads
can overwrite iwad contents, which a single wadfs cannot take into account
(commit e7b1c1aad8
).
subsequent fix was to use the normal mechanisms to extract the lump to /tmp
and later the music lumps for playback, but the temp file may not always
be properly cleaned up, preventing any music playback due to conflicts.
so, spawn one wadfs for the iwad and one for each subsequently added pwad,
just making sure that they have sufficient delay to properly initialize
and bind in the right order
This commit is contained in:
parent
ecd0d966e3
commit
e5c7fe6305
4 changed files with 38 additions and 18 deletions
|
@ -1,6 +1,6 @@
|
|||
#!/bin/rc
|
||||
if(test -f /tmp/genmidi.*)
|
||||
c=(games/dmid -i /tmp/genmidi.* '|' games/opl3)
|
||||
if(test -f /mnt/wad/genmidi)
|
||||
c=(games/dmid '|' games/opl3)
|
||||
if not
|
||||
c=(games/midi -c)
|
||||
if(~ `{file -m $1} audio/mus)
|
||||
|
|
|
@ -539,16 +539,34 @@ char title[128];
|
|||
//
|
||||
void D_AddFile (char *file)
|
||||
{
|
||||
int n, ext;
|
||||
int numwadfiles;
|
||||
char *newfile;
|
||||
char *newfile, mnt[16];
|
||||
|
||||
for (numwadfiles = 0 ; wadfiles[numwadfiles] ; numwadfiles++)
|
||||
;
|
||||
for(numwadfiles=0; wadfiles[numwadfiles]; numwadfiles++)
|
||||
;
|
||||
|
||||
newfile = malloc (strlen(file)+1);
|
||||
strcpy (newfile, file);
|
||||
|
||||
ext = cistrstr(file, ".wad") != nil || cistrstr(file, ".lmp") != nil;
|
||||
n = strlen(file) + 1;
|
||||
if(!ext)
|
||||
n += 4;
|
||||
if((newfile = malloc(n)) == NULL)
|
||||
sysfatal("malloc: %r");
|
||||
snprintf(newfile, n, "%s%s", file, ext ? "" : ".wad");
|
||||
wadfiles[numwadfiles] = newfile;
|
||||
|
||||
/* all wads are piled on top of each other at /mnt/wad, iwad first;
|
||||
* binds are deferred to later to leave enough time for each wadfs
|
||||
* to properly initialize */
|
||||
snprintf(mnt, sizeof mnt, "/mnt/wad%d", numwadfiles);
|
||||
switch(rfork(RFPROC|RFFDG)){
|
||||
case -1:
|
||||
sysfatal("rfork: %r");
|
||||
case 0:
|
||||
close(2);
|
||||
execl("/bin/games/wadfs", "wadfs", "-m", mnt, newfile, nil);
|
||||
sysfatal("execl: %r");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -722,8 +740,10 @@ void FindResponseFile (void)
|
|||
//
|
||||
void D_DoomMain (void)
|
||||
{
|
||||
int p;
|
||||
char file[256];
|
||||
int i, p;
|
||||
char file[256], mnt[16];
|
||||
|
||||
rfork(RFNAMEG);
|
||||
|
||||
FindResponseFile ();
|
||||
|
||||
|
@ -1054,6 +1074,12 @@ void D_DoomMain (void)
|
|||
autostart = true;
|
||||
}
|
||||
|
||||
for(i=0; wadfiles[i]; i++){
|
||||
snprintf(mnt, sizeof mnt, "/mnt/wad%d", i);
|
||||
if(bind(mnt, "/mnt/wad", MBEFORE) < 0)
|
||||
sysfatal("bind: %r");
|
||||
}
|
||||
|
||||
p = M_CheckParm ("-playdemo");
|
||||
if (p && p < myargc-1)
|
||||
{
|
||||
|
|
|
@ -463,14 +463,7 @@ void I_PlaySong(musicinfo_t *m, int loop)
|
|||
dup(mpfd[1], 1);
|
||||
for(n=3; n<20; n++) close(n);
|
||||
close(0);
|
||||
snprint(name, sizeof(name), "/tmp/doom.%d", getpid());
|
||||
if(create(name, ORDWR|ORCLOSE, 0666) != 0)
|
||||
sysfatal("create: %r");
|
||||
n = W_LumpLength(m->lumpnum);
|
||||
if(write(0, m->data, n) != n)
|
||||
sysfatal("write: %r");
|
||||
if(seek(0, 0, 0) != 0)
|
||||
sysfatal("seek: %r");
|
||||
snprint(name, sizeof(name), "/mnt/wad/d_%s", m->name);
|
||||
if(bind("/fd/1", "/dev/audio", MREPL) == -1)
|
||||
sysfatal("bind: %r");
|
||||
while(loop && fork() > 0){
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "i_sound.h"
|
||||
#include "i_video.h"
|
||||
|
||||
#include "d_main.h"
|
||||
#include "d_net.h"
|
||||
#include "g_game.h"
|
||||
#include "m_misc.h"
|
||||
|
|
Loading…
Reference in a new issue