mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 23:01:50 +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
2cf8cc47df
commit
16ab52c5f3
4 changed files with 47 additions and 20 deletions
|
@ -39,6 +39,7 @@
|
|||
#include "i_system.h"
|
||||
#include "gameconfigfile.h"
|
||||
#include "resourcefiles/resourcefile.h"
|
||||
#include "timiditypp/common.h"
|
||||
|
||||
FSoundFontManager sfmanager;
|
||||
|
||||
|
@ -97,6 +98,44 @@ int FSoundFontReader::pathcmp(const char *p1, const char *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
|
||||
|
|
|
@ -20,6 +20,10 @@ struct FSoundFontInfo
|
|||
int type;
|
||||
};
|
||||
|
||||
namespace TimidityPlus
|
||||
{
|
||||
struct timidity_file;
|
||||
}
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
|
@ -56,6 +60,9 @@ public:
|
|||
{
|
||||
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);
|
||||
};
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -129,25 +129,7 @@ double flt_rand()
|
|||
|
||||
struct timidity_file *open_file(const char *name, SoundFontReaderInterface *sfreader)
|
||||
{
|
||||
FileReader fr;
|
||||
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;
|
||||
return sfreader->open_timidity_file(name);
|
||||
}
|
||||
|
||||
/* 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 opt_preserve_silence = 0;
|
||||
const int opt_init_keysig = 8;
|
||||
|
||||
}
|
||||
#endif /* TIMIDITY_H_INCLUDED */
|
||||
|
|
Loading…
Reference in a new issue