mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-11 15:22:16 +00:00
Initial attempt to make timidity work on Linux again
Add code to find the timidity executable, and split the command line into separate arguments by spaces.
For some reason, this doesn't work, although reverting 64e96c5f
makes timidity work again.
This commit is contained in:
parent
49b77f3a17
commit
233fce7ef6
1 changed files with 59 additions and 18 deletions
|
@ -525,15 +525,56 @@ bool TimidityPPMIDIDevice::LaunchTimidity ()
|
||||||
int forkres;
|
int forkres;
|
||||||
glob_t glb;
|
glob_t glb;
|
||||||
|
|
||||||
switch (glob (CommandLine.GetChars(), 0, NULL, &glb))
|
// Get timidity executable path
|
||||||
{
|
int spaceIdx = 0;
|
||||||
case 0: // all good
|
int spaceInExePathCount = -1;
|
||||||
break;
|
FString TimidityExe;
|
||||||
|
do {
|
||||||
case GLOB_NOSPACE:
|
spaceIdx = CommandLine.IndexOf(' ', spaceIdx);
|
||||||
|
spaceInExePathCount += 1;
|
||||||
|
TimidityExe = CommandLine.Left(spaceIdx);
|
||||||
|
glob(TimidityExe.GetChars(), 0, NULL, &glb);
|
||||||
|
} while (spaceIdx != -1 && glb.gl_pathc == 0);
|
||||||
|
if (spaceIdx == -1) return false;
|
||||||
globfree(&glb);
|
globfree(&glb);
|
||||||
default:
|
|
||||||
return false;
|
int strCount = 1;
|
||||||
|
for (spaceIdx = 0; spaceIdx < CommandLine.Len(); spaceIdx++) {
|
||||||
|
if (CommandLine[spaceIdx] == ' ') {
|
||||||
|
++strCount;
|
||||||
|
if (CommandLine[spaceIdx+1] == ' ') {
|
||||||
|
--strCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
strCount -= spaceInExePathCount;
|
||||||
|
|
||||||
|
char** TimidityArgs = new char*[strCount];
|
||||||
|
|
||||||
|
spaceIdx = CommandLine.IndexOf(' ');
|
||||||
|
int curSpace = spaceIdx, i = 1;
|
||||||
|
|
||||||
|
TimidityArgs[0] = new char[TimidityExe.Len() + 1];
|
||||||
|
strcpy(TimidityArgs[0], TimidityExe.GetChars());
|
||||||
|
|
||||||
|
int argLen;
|
||||||
|
while (curSpace != -1) {
|
||||||
|
curSpace = CommandLine.IndexOf(' ', spaceIdx);
|
||||||
|
if (curSpace != spaceIdx) {
|
||||||
|
argLen = curSpace - spaceIdx + 1;
|
||||||
|
if (argLen < 0) {
|
||||||
|
argLen = CommandLine.Len() - curSpace;
|
||||||
|
}
|
||||||
|
TimidityArgs[i] = new char[argLen];
|
||||||
|
strcpy(TimidityArgs[i], CommandLine.Mid(spaceIdx, curSpace - spaceIdx).GetChars());
|
||||||
|
i += 1;
|
||||||
|
}
|
||||||
|
spaceIdx = curSpace + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
DPrintf(DMSG_NOTIFY, "Timidity EXE: \x1cG%s\n", TimidityExe.GetChars());
|
||||||
|
for (i = 0; i < strCount; i++) {
|
||||||
|
DPrintf(DMSG_NOTIFY, "arg %d: \x1cG%s\n", i, TimidityArgs[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
forkres = fork ();
|
forkres = fork ();
|
||||||
|
@ -546,7 +587,7 @@ bool TimidityPPMIDIDevice::LaunchTimidity ()
|
||||||
// freopen ("/dev/null", "w", stderr);
|
// freopen ("/dev/null", "w", stderr);
|
||||||
close (WavePipe[1]);
|
close (WavePipe[1]);
|
||||||
|
|
||||||
execvp (glb.gl_pathv[0], glb.gl_pathv);
|
execvp (TimidityExe.GetChars(), TimidityArgs);
|
||||||
fprintf(stderr,"execvp failed\n");
|
fprintf(stderr,"execvp failed\n");
|
||||||
_exit (0); // if execvp succeeds, we never get here
|
_exit (0); // if execvp succeeds, we never get here
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue