Don't allow Timidity++ pipes less than 20ms

This prevents Timidity++ from playing externally, so it now always goes through
the sound system. Aside from the issues relating to controlling playback, that
functionality has been busted for who knows how long anyway since Open() always
tries to create a pipe and sound stream regardless of the calculated size.
This commit is contained in:
Chris Robinson 2017-09-06 15:46:34 -07:00 committed by Rachael Alexanderson
parent 1b1f8d605f
commit 666198dec8

View file

@ -143,9 +143,9 @@ CUSTOM_CVAR (Float, timidity_mastervolume, 1.0f, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
CUSTOM_CVAR (Int, timidity_pipe, 90, CVAR_ARCHIVE|CVAR_GLOBALCONFIG) CUSTOM_CVAR (Int, timidity_pipe, 90, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
{ // pipe size in ms { // pipe size in ms
if (timidity_pipe < 0) if (self < 20)
{ // a negative size makes no sense { // Don't allow pipes less than 20ms
timidity_pipe = 0; self = 20;
} }
} }
@ -317,10 +317,9 @@ int TimidityPPMIDIDevice::Open(MidiCallback callback, void *userdata)
#endif #endif
{ {
Printf(PRINT_BOLD, "Could not create a data pipe for TiMidity++.\n"); Printf(PRINT_BOLD, "Could not create a data pipe for TiMidity++.\n");
pipeSize = 0; return 1;
} }
else
{
Stream = GSnd->CreateStream(FillStream, pipeSize, Stream = GSnd->CreateStream(FillStream, pipeSize,
(timidity_stereo ? 0 : SoundStream::Mono) | (timidity_stereo ? 0 : SoundStream::Mono) |
(timidity_8bit ? SoundStream::Bits8 : 0), (timidity_8bit ? SoundStream::Bits8 : 0),
@ -328,7 +327,6 @@ int TimidityPPMIDIDevice::Open(MidiCallback callback, void *userdata)
if (Stream == NULL) if (Stream == NULL)
{ {
Printf(PRINT_BOLD, "Could not create music stream.\n"); Printf(PRINT_BOLD, "Could not create music stream.\n");
pipeSize = 0;
#ifdef _WIN32 #ifdef _WIN32
CloseHandle(WriteWavePipe); CloseHandle(WriteWavePipe);
CloseHandle(ReadWavePipe); CloseHandle(ReadWavePipe);
@ -338,28 +336,12 @@ int TimidityPPMIDIDevice::Open(MidiCallback callback, void *userdata)
close(WavePipe[0]); close(WavePipe[0]);
WavePipe[0] = WavePipe[1] = -1; WavePipe[0] = WavePipe[1] = -1;
#endif #endif
return 1;
} }
} }
if (pipeSize == 0)
{
Printf(PRINT_BOLD, "If your soundcard cannot play more than one\n"
"wave at a time, you will hear no music.\n");
}
#ifdef _WIN32 #ifdef _WIN32
else
{
CommandLine += "-o - -Ors"; CommandLine += "-o - -Ors";
}
#endif
}
#ifdef _WIN32
if (pipeSize == 0)
{
CommandLine += "-Od";
}
CommandLine += timidity_stereo ? 'S' : 'M'; CommandLine += timidity_stereo ? 'S' : 'M';
CommandLine += timidity_8bit ? '8' : '1'; CommandLine += timidity_8bit ? '8' : '1';
if (timidity_byteswap) if (timidity_byteswap)
@ -775,8 +757,7 @@ int TimidityPPMIDIDevice::Resume()
{ {
if (LaunchTimidity()) if (LaunchTimidity())
{ {
// Assume success if not mixing with the sound system if (Stream != NULL && Stream->Play(true, timidity_mastervolume))
if (Stream == NULL || Stream->Play(true, timidity_mastervolume))
{ {
Started = true; Started = true;
return 0; return 0;