Refactor the audio plugin slightly to more match the format of the other plugin files
This commit is contained in:
parent
1c6af2e321
commit
0ba2ca0f71
|
@ -2,29 +2,48 @@
|
||||||
|
|
||||||
void FixUPXIssue ( BYTE * ProgramLocation );
|
void FixUPXIssue ( BYTE * ProgramLocation );
|
||||||
|
|
||||||
CAudioPlugin::CAudioPlugin ( const char * FileName)
|
CAudioPlugin::CAudioPlugin ( const char * FileName) :
|
||||||
|
m_hDll(NULL),
|
||||||
|
m_Initilized(false),
|
||||||
|
m_RomOpen(false),
|
||||||
|
m_hAudioThread(NULL),
|
||||||
|
m_DacrateChanged(NULL),
|
||||||
|
LenChanged(NULL),
|
||||||
|
Config(NULL),
|
||||||
|
ReadLength(NULL),
|
||||||
|
// InitFunc(NULL),
|
||||||
|
RomOpen(NULL),
|
||||||
|
RomClosed(NULL),
|
||||||
|
CloseDLL(NULL),
|
||||||
|
ProcessAList(NULL),
|
||||||
|
Update(NULL),
|
||||||
|
PluginOpened(NULL),
|
||||||
|
SetSettingInfo(NULL),
|
||||||
|
SetSettingInfo2(NULL)
|
||||||
|
{
|
||||||
|
memset(&m_PluginInfo,0,sizeof(m_PluginInfo));
|
||||||
|
Init(FileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CAudioPlugin::Init ( const char * FileName )
|
||||||
{
|
{
|
||||||
//Make sure all parts of the class are initialized
|
//Make sure all parts of the class are initialized
|
||||||
m_Initilized = false;
|
|
||||||
m_RomOpen = false;
|
|
||||||
hDll = NULL;
|
|
||||||
m_hAudioThread = NULL;
|
|
||||||
UnloadPlugin();
|
UnloadPlugin();
|
||||||
|
|
||||||
//Try to load the DLL library
|
//Try to load the DLL library
|
||||||
UINT LastErrorMode = SetErrorMode( SEM_FAILCRITICALERRORS );
|
UINT LastErrorMode = SetErrorMode( SEM_FAILCRITICALERRORS );
|
||||||
hDll = LoadLibrary(FileName);
|
m_hDll = LoadLibrary(FileName);
|
||||||
SetErrorMode(LastErrorMode);
|
SetErrorMode(LastErrorMode);
|
||||||
|
|
||||||
if (hDll == NULL) {
|
if (m_hDll == NULL) {
|
||||||
UnloadPlugin();
|
UnloadPlugin();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
FixUPXIssue((BYTE *)hDll);
|
FixUPXIssue((BYTE *)m_hDll);
|
||||||
|
|
||||||
//Get DLL information
|
//Get DLL information
|
||||||
void (__cdecl *GetDllInfo) ( PLUGIN_INFO * PluginInfo );
|
void (__cdecl *GetDllInfo) ( PLUGIN_INFO * PluginInfo );
|
||||||
GetDllInfo = (void (__cdecl *)(PLUGIN_INFO *))GetProcAddress( (HMODULE)hDll, "GetDllInfo" );
|
GetDllInfo = (void (__cdecl *)(PLUGIN_INFO *))GetProcAddress( (HMODULE)m_hDll, "GetDllInfo" );
|
||||||
if (GetDllInfo == NULL) { UnloadPlugin(); return; }
|
if (GetDllInfo == NULL) { UnloadPlugin(); return; }
|
||||||
|
|
||||||
GetDllInfo(&m_PluginInfo);
|
GetDllInfo(&m_PluginInfo);
|
||||||
|
@ -32,20 +51,20 @@ CAudioPlugin::CAudioPlugin ( const char * FileName)
|
||||||
|
|
||||||
//Find entries for functions in DLL
|
//Find entries for functions in DLL
|
||||||
void (__cdecl *InitFunc) ( void );
|
void (__cdecl *InitFunc) ( void );
|
||||||
m_DacrateChanged = (void (__cdecl *)(SystemType)) GetProcAddress( (HMODULE)hDll, "AiDacrateChanged" );
|
m_DacrateChanged = (void (__cdecl *)(SystemType)) GetProcAddress( (HMODULE)m_hDll, "AiDacrateChanged" );
|
||||||
LenChanged = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)hDll, "AiLenChanged" );
|
LenChanged = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "AiLenChanged" );
|
||||||
Config = (void (__cdecl *)(DWORD))GetProcAddress( (HMODULE)hDll, "DllConfig" );
|
Config = (void (__cdecl *)(DWORD))GetProcAddress( (HMODULE)m_hDll, "DllConfig" );
|
||||||
ReadLength = (DWORD (__cdecl *)(void))GetProcAddress( (HMODULE)hDll, "AiReadLength" );
|
ReadLength = (DWORD (__cdecl *)(void))GetProcAddress( (HMODULE)m_hDll, "AiReadLength" );
|
||||||
InitFunc = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)hDll, "InitiateAudio" );
|
InitFunc = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "InitiateAudio" );
|
||||||
RomOpen = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)hDll, "RomOpen" );
|
RomOpen = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "RomOpen" );
|
||||||
RomClosed = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)hDll, "RomClosed" );
|
RomClosed = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "RomClosed" );
|
||||||
CloseDLL = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)hDll, "CloseDLL" );
|
CloseDLL = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "CloseDLL" );
|
||||||
ProcessAList = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)hDll, "ProcessAList" );
|
ProcessAList = (void (__cdecl *)(void)) GetProcAddress( (HMODULE)m_hDll, "ProcessAList" );
|
||||||
|
|
||||||
Update = (void (__cdecl *)(BOOL))GetProcAddress( (HMODULE)hDll, "AiUpdate" );
|
Update = (void (__cdecl *)(BOOL))GetProcAddress( (HMODULE)m_hDll, "AiUpdate" );
|
||||||
|
|
||||||
//version 102 functions
|
//version 102 functions
|
||||||
PluginOpened = (void (__cdecl *)(void))GetProcAddress( (HMODULE)hDll, "PluginLoaded" );
|
PluginOpened = (void (__cdecl *)(void))GetProcAddress( (HMODULE)m_hDll, "PluginLoaded" );
|
||||||
|
|
||||||
//Make sure dll had all needed functions
|
//Make sure dll had all needed functions
|
||||||
if (m_DacrateChanged == NULL) { UnloadPlugin(); return; }
|
if (m_DacrateChanged == NULL) { UnloadPlugin(); return; }
|
||||||
|
@ -55,7 +74,7 @@ CAudioPlugin::CAudioPlugin ( const char * FileName)
|
||||||
if (RomClosed == NULL) { UnloadPlugin(); return; }
|
if (RomClosed == NULL) { UnloadPlugin(); return; }
|
||||||
if (ProcessAList == NULL) { UnloadPlugin(); return; }
|
if (ProcessAList == NULL) { UnloadPlugin(); return; }
|
||||||
|
|
||||||
SetSettingInfo2 = (void (__cdecl *)(PLUGIN_SETTINGS2 *))GetProcAddress( (HMODULE)hDll, "SetSettingInfo2" );
|
SetSettingInfo2 = (void (__cdecl *)(PLUGIN_SETTINGS2 *))GetProcAddress( (HMODULE)m_hDll, "SetSettingInfo2" );
|
||||||
if (SetSettingInfo2)
|
if (SetSettingInfo2)
|
||||||
{
|
{
|
||||||
PLUGIN_SETTINGS2 info;
|
PLUGIN_SETTINGS2 info;
|
||||||
|
@ -63,7 +82,7 @@ CAudioPlugin::CAudioPlugin ( const char * FileName)
|
||||||
SetSettingInfo2(&info);
|
SetSettingInfo2(&info);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetSettingInfo = (void (__cdecl *)(PLUGIN_SETTINGS *))GetProcAddress( (HMODULE)hDll, "SetSettingInfo" );
|
SetSettingInfo = (void (__cdecl *)(PLUGIN_SETTINGS *))GetProcAddress( (HMODULE)m_hDll, "SetSettingInfo" );
|
||||||
if (SetSettingInfo)
|
if (SetSettingInfo)
|
||||||
{
|
{
|
||||||
PLUGIN_SETTINGS info;
|
PLUGIN_SETTINGS info;
|
||||||
|
@ -98,7 +117,7 @@ CAudioPlugin::~CAudioPlugin (void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CAudioPlugin::Initiate ( CN64System * System, CMainGui * RenderWindow ) {
|
bool CAudioPlugin::Initiate ( CN64System * System, CMainGui * RenderWindow ) {
|
||||||
typedef struct {
|
struct AUDIO_INFO {
|
||||||
HWND hwnd;
|
HWND hwnd;
|
||||||
HINSTANCE hinst;
|
HINSTANCE hinst;
|
||||||
|
|
||||||
|
@ -122,11 +141,11 @@ bool CAudioPlugin::Initiate ( CN64System * System, CMainGui * RenderWindow ) {
|
||||||
DWORD * AI__BITRATE_REG;
|
DWORD * AI__BITRATE_REG;
|
||||||
|
|
||||||
void (__cdecl *CheckInterrupts)( void );
|
void (__cdecl *CheckInterrupts)( void );
|
||||||
} AUDIO_INFO;
|
};
|
||||||
|
|
||||||
//Get Function from DLL
|
//Get Function from DLL
|
||||||
BOOL (__cdecl *InitiateAudio) ( AUDIO_INFO Audio_Info );
|
BOOL (__cdecl *InitiateAudio) ( AUDIO_INFO Audio_Info );
|
||||||
InitiateAudio = (BOOL (__cdecl *)(AUDIO_INFO))GetProcAddress( (HMODULE)hDll, "InitiateAudio" );
|
InitiateAudio = (BOOL (__cdecl *)(AUDIO_INFO))GetProcAddress( (HMODULE)m_hDll, "InitiateAudio" );
|
||||||
if (InitiateAudio == NULL) { return false; }
|
if (InitiateAudio == NULL) { return false; }
|
||||||
|
|
||||||
AUDIO_INFO Info;
|
AUDIO_INFO Info;
|
||||||
|
@ -249,9 +268,9 @@ void CAudioPlugin::UnloadPlugin(void) {
|
||||||
m_hAudioThread = NULL;
|
m_hAudioThread = NULL;
|
||||||
}
|
}
|
||||||
memset(&m_PluginInfo,0,sizeof(m_PluginInfo));
|
memset(&m_PluginInfo,0,sizeof(m_PluginInfo));
|
||||||
if (hDll != NULL ) {
|
if (m_hDll != NULL ) {
|
||||||
FreeLibrary((HMODULE)hDll);
|
FreeLibrary((HMODULE)m_hDll);
|
||||||
hDll = NULL;
|
m_hDll = NULL;
|
||||||
}
|
}
|
||||||
m_DacrateChanged = NULL;
|
m_DacrateChanged = NULL;
|
||||||
LenChanged = NULL;
|
LenChanged = NULL;
|
||||||
|
|
|
@ -1,26 +1,7 @@
|
||||||
class CAudioPlugin {
|
#ifndef _AUDIOPLUGIN_H_
|
||||||
void * hDll;
|
#define _AUDIOPLUGIN_H_
|
||||||
bool m_Initilized, m_RomOpen;
|
class CAudioPlugin
|
||||||
void * m_hAudioThread;
|
{
|
||||||
PLUGIN_INFO m_PluginInfo;
|
|
||||||
|
|
||||||
DWORD m_StatusReg;
|
|
||||||
|
|
||||||
void UnloadPlugin ( void );
|
|
||||||
bool ValidPluginVersion ( PLUGIN_INFO * PluginInfo );
|
|
||||||
|
|
||||||
void (__cdecl *CloseDLL) ( void );
|
|
||||||
void (__cdecl *RomOpen) ( void );
|
|
||||||
void (__cdecl *RomClosed) ( void );
|
|
||||||
void (__cdecl *Update) ( BOOL Wait );
|
|
||||||
void (__cdecl *m_DacrateChanged) ( SystemType Type );
|
|
||||||
void (__cdecl *PluginOpened) ( void );
|
|
||||||
void (__cdecl *SetSettingInfo) ( PLUGIN_SETTINGS * info );
|
|
||||||
void (__cdecl *SetSettingInfo2) ( PLUGIN_SETTINGS2 * info );
|
|
||||||
|
|
||||||
//Function used in a thread for using audio
|
|
||||||
static void AudioThread (CAudioPlugin * _this);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CAudioPlugin ( const char * FileName);
|
CAudioPlugin ( const char * FileName);
|
||||||
~CAudioPlugin ( void );
|
~CAudioPlugin ( void );
|
||||||
|
@ -38,4 +19,31 @@ public:
|
||||||
void (__cdecl *Config) ( DWORD hParent );
|
void (__cdecl *Config) ( DWORD hParent );
|
||||||
DWORD (__cdecl *ReadLength) ( void );
|
DWORD (__cdecl *ReadLength) ( void );
|
||||||
void (__cdecl *ProcessAList) ( void );
|
void (__cdecl *ProcessAList) ( void );
|
||||||
|
|
||||||
|
private:
|
||||||
|
void * m_hDll;
|
||||||
|
bool m_Initilized, m_RomOpen;
|
||||||
|
void * m_hAudioThread;
|
||||||
|
PLUGIN_INFO m_PluginInfo;
|
||||||
|
|
||||||
|
DWORD m_StatusReg;
|
||||||
|
|
||||||
|
void Init ( const char * FileName );
|
||||||
|
void UnloadPlugin ( void );
|
||||||
|
bool ValidPluginVersion ( PLUGIN_INFO * PluginInfo );
|
||||||
|
|
||||||
|
void (__cdecl *CloseDLL) ( void );
|
||||||
|
void (__cdecl *RomOpen) ( void );
|
||||||
|
void (__cdecl *RomClosed) ( void );
|
||||||
|
void (__cdecl *Update) ( BOOL Wait );
|
||||||
|
void (__cdecl *m_DacrateChanged) ( SystemType Type );
|
||||||
|
void (__cdecl *PluginOpened) ( void );
|
||||||
|
void (__cdecl *SetSettingInfo) ( PLUGIN_SETTINGS * info );
|
||||||
|
void (__cdecl *SetSettingInfo2) ( PLUGIN_SETTINGS2 * info );
|
||||||
|
|
||||||
|
//Function used in a thread for using audio
|
||||||
|
static void AudioThread (CAudioPlugin * _this);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif //_AUDIOPLUGIN_H_
|
Loading…
Reference in New Issue