mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-16 17:41:19 +00:00
- thinned out the FSoundFontReader interface a bit more by moving the file open code into the FSoundFontReader class itself.
This commit is contained in:
parent
e968ef9ded
commit
9d5f4969e7
4 changed files with 47 additions and 20 deletions
|
@ -41,6 +41,7 @@
|
||||||
#include "i_system.h"
|
#include "i_system.h"
|
||||||
#include "gameconfigfile.h"
|
#include "gameconfigfile.h"
|
||||||
#include "resourcefiles/resourcefile.h"
|
#include "resourcefiles/resourcefile.h"
|
||||||
|
#include "timiditypp/common.h"
|
||||||
|
|
||||||
FSoundFontManager sfmanager;
|
FSoundFontManager sfmanager;
|
||||||
|
|
||||||
|
@ -99,6 +100,44 @@ int FSoundFontReader::pathcmp(const char *p1, const char *p2)
|
||||||
return mCaseSensitivePaths? strcmp(p1, p2) : stricmp(p1, p2);
|
return mCaseSensitivePaths? strcmp(p1, p2) : stricmp(p1, p2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
FileReader FSoundFontReader::Open(const char *name, std::string& filename)
|
||||||
|
{
|
||||||
|
FileReader fr;
|
||||||
|
if (name == nullptr)
|
||||||
|
{
|
||||||
|
fr = OpenMainConfigFile();
|
||||||
|
filename = MainConfigFileName();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
auto res = LookupFile(name);
|
||||||
|
fr = std::move(res.first);
|
||||||
|
filename = res.second;
|
||||||
|
}
|
||||||
|
return fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// This is the interface function for Timidity++
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
struct TimidityPlus::timidity_file* FSoundFontReader::open_timidity_file(const char* name)
|
||||||
|
{
|
||||||
|
std::string filename;
|
||||||
|
|
||||||
|
FileReader fr = Open(name, filename);
|
||||||
|
if (!fr.isOpen()) return nullptr;
|
||||||
|
|
||||||
|
auto tf = new TimidityPlus::timidity_file;
|
||||||
|
tf->url = std::move(fr);
|
||||||
|
tf->filename = std::move(filename);
|
||||||
|
return tf;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// Note that the file type has already been checked
|
// Note that the file type has already been checked
|
||||||
|
|
|
@ -20,6 +20,10 @@ struct FSoundFontInfo
|
||||||
int type;
|
int type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace TimidityPlus
|
||||||
|
{
|
||||||
|
struct timidity_file;
|
||||||
|
}
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -56,6 +60,9 @@ public:
|
||||||
{
|
{
|
||||||
return ""; // archived patch sets do not use paths
|
return ""; // archived patch sets do not use paths
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual FileReader Open(const char* name, std::string &filename);
|
||||||
|
virtual struct TimidityPlus::timidity_file* open_timidity_file(const char* name);
|
||||||
};
|
};
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -132,25 +132,7 @@ double flt_rand()
|
||||||
|
|
||||||
struct timidity_file *open_file(const char *name, SoundFontReaderInterface *sfreader)
|
struct timidity_file *open_file(const char *name, SoundFontReaderInterface *sfreader)
|
||||||
{
|
{
|
||||||
FileReader fr;
|
return sfreader->open_timidity_file(name);
|
||||||
FString filename;
|
|
||||||
if (name == nullptr)
|
|
||||||
{
|
|
||||||
fr = sfreader->OpenMainConfigFile();
|
|
||||||
filename = sfreader->MainConfigFileName();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
auto res = sfreader->LookupFile(name);
|
|
||||||
fr = std::move(res.first);
|
|
||||||
filename = res.second;
|
|
||||||
}
|
|
||||||
if (!fr.isOpen()) return nullptr;
|
|
||||||
|
|
||||||
auto tf = new timidity_file;
|
|
||||||
tf->url = std::move(fr);
|
|
||||||
tf->filename = filename.GetChars();
|
|
||||||
return tf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This closes files opened with open_file */
|
/* This closes files opened with open_file */
|
||||||
|
|
|
@ -170,6 +170,5 @@ const int max_voices = DEFAULT_VOICES;
|
||||||
const int temper_type_mute = 0;
|
const int temper_type_mute = 0;
|
||||||
const int opt_preserve_silence = 0;
|
const int opt_preserve_silence = 0;
|
||||||
const int opt_init_keysig = 8;
|
const int opt_init_keysig = 8;
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif /* TIMIDITY_H_INCLUDED */
|
#endif /* TIMIDITY_H_INCLUDED */
|
||||||
|
|
Loading…
Reference in a new issue