- Changed the internal Timidity player so that it uses timidity_mastervolume

because it has the same sound volume issues as the external one.
- Replaced use of stdio in Timidity with FileReader and added the option to read
  from the lump directory. If the main config file is inside the lump directory
  it will assume that everything else is as well. If it is a real file it will be
  assumed that the rest is real files as well.
- Fixed: None of the error returns in Timidity::read_config_file closed the file being read.


SVN r906 (trunk)
This commit is contained in:
Christoph Oelckers 2008-04-12 21:36:10 +00:00
commit 96b72f2e33
10 changed files with 214 additions and 114 deletions

View file

@ -46,7 +46,7 @@
//==========================================================================
FileReader::FileReader ()
: File(NULL), Length(0), CloseOnDestruct(false)
: File(NULL), Length(0), StartPos(0), CloseOnDestruct(false)
{
}
@ -59,13 +59,10 @@ FileReader::FileReader (const FileReader &other, long length)
FileReader::FileReader (const char *filename)
: File(NULL), Length(0), StartPos(0), FilePos(0), CloseOnDestruct(false)
{
File = fopen (filename, "rb");
if (File == NULL)
if (!Open(filename))
{
I_Error ("Could not open %s", filename);
}
CloseOnDestruct = true;
Length = CalcFileLen();
}
FileReader::FileReader (FILE *file)
@ -89,6 +86,16 @@ FileReader::~FileReader ()
}
}
bool FileReader::Open (const char *filename)
{
File = fopen (filename, "rb");
if (File == NULL) return false;
CloseOnDestruct = true;
Length = CalcFileLen();
return true;
}
void FileReader::ResetFilePtr ()
{
FilePos = ftell (File);
@ -150,16 +157,26 @@ char *FileReader::GetsFromBuffer(const char * bufptr, char *strbuf, int len)
if (len <= 0) return NULL;
char *p = strbuf;
while (len > 1 && bufptr[FilePos] != 0)
while (len > 1)
{
if (bufptr[FilePos] == 0)
{
FilePos++;
break;
}
if (bufptr[FilePos] != '\r')
{
*p++ = bufptr[FilePos];
len--;
if (bufptr[FilePos] == '\n') break;
if (bufptr[FilePos] == '\n')
{
FilePos++;
break;
}
}
FilePos++;
}
if (p==strbuf) return NULL;
*p++=0;
return strbuf;
}