mirror of https://github.com/PCSX2/pcsx2.git
DEV9: Merge _DEV9open into InitNet, and check ethEnable before calling
This commit is contained in:
parent
7187b883b0
commit
0800cdbbc2
|
@ -219,7 +219,10 @@ s32 DEV9open(void* pDsp)
|
|||
config.hddEnable = false;
|
||||
}
|
||||
|
||||
return _DEV9open();
|
||||
if (config.ethEnable)
|
||||
InitNet();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DEV9close()
|
||||
|
@ -227,7 +230,7 @@ void DEV9close()
|
|||
DevCon.WriteLn("DEV9close");
|
||||
|
||||
dev9.ata->Close();
|
||||
_DEV9close();
|
||||
TermNet();
|
||||
}
|
||||
|
||||
int DEV9irqHandler(void)
|
||||
|
|
|
@ -135,10 +135,6 @@ EXTERN dev9Struct dev9;
|
|||
|
||||
EXTERN int ThreadRun;
|
||||
|
||||
s32 _DEV9open();
|
||||
void _DEV9close();
|
||||
//void DEV9thread();
|
||||
|
||||
//Yes these are meant to be a lowercase extern
|
||||
extern std::string s_strIniPath;
|
||||
extern std::string s_strLogPath;
|
||||
|
|
|
@ -219,35 +219,3 @@ void DEV9configure()
|
|||
gtk_widget_hide(GTK_WIDGET(dlg));
|
||||
paused_core.AllowResume();
|
||||
}
|
||||
|
||||
NetAdapter* GetNetAdapter()
|
||||
{
|
||||
NetAdapter* na;
|
||||
na = new PCAPAdapter();
|
||||
|
||||
if (!na->isInitialised())
|
||||
{
|
||||
delete na;
|
||||
return 0;
|
||||
}
|
||||
return na;
|
||||
}
|
||||
s32 _DEV9open()
|
||||
{
|
||||
NetAdapter* na = GetNetAdapter();
|
||||
if (!na)
|
||||
{
|
||||
Console.Error("Failed to GetNetAdapter()");
|
||||
config.ethEnable = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
InitNet(na);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void _DEV9close()
|
||||
{
|
||||
TermNet();
|
||||
}
|
||||
|
|
|
@ -372,38 +372,3 @@ UINT DEV9ThreadProc() {
|
|||
|
||||
return 0;
|
||||
}*/
|
||||
NetAdapter* GetNetAdapter()
|
||||
{
|
||||
NetAdapter* na = static_cast<NetAdapter*>(new TAPAdapter());
|
||||
|
||||
if (!na->isInitialised())
|
||||
{
|
||||
delete na;
|
||||
return 0;
|
||||
}
|
||||
return na;
|
||||
}
|
||||
s32 _DEV9open()
|
||||
{
|
||||
//handleDEV9Thread = CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE) DEV9ThreadProc, &dwThrdParam, CREATE_SUSPENDED, &dwThreadId);
|
||||
//SetThreadPriority(handleDEV9Thread,THREAD_PRIORITY_HIGHEST);
|
||||
//ResumeThread (handleDEV9Thread);
|
||||
NetAdapter* na = GetNetAdapter();
|
||||
if (!na)
|
||||
{
|
||||
Console.Error("Failed to GetNetAdapter()");
|
||||
config.ethEnable = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
InitNet(na);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void _DEV9close()
|
||||
{
|
||||
//TerminateThread(handleDEV9Thread,0);
|
||||
//handleDEV9Thread = NULL;
|
||||
TermNet();
|
||||
}
|
||||
|
|
|
@ -23,6 +23,11 @@
|
|||
#include "net.h"
|
||||
#include "DEV9.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include "Win32\tap.h"
|
||||
#endif
|
||||
#include "pcap_io.h"
|
||||
|
||||
NetAdapter* nif;
|
||||
std::thread rx_thread;
|
||||
|
||||
|
@ -48,9 +53,34 @@ void tx_put(NetPacket* pkt)
|
|||
//pkt must be copied if its not processed by here, since it can be allocated on the callers stack
|
||||
}
|
||||
|
||||
void InitNet(NetAdapter* ad)
|
||||
NetAdapter* GetNetAdapter()
|
||||
{
|
||||
nif = ad;
|
||||
#ifdef _WIN32
|
||||
NetAdapter* na = static_cast<NetAdapter*>(new TAPAdapter());
|
||||
#else
|
||||
NetAdapter* na = static_cast<NetAdapter*>(new PCAPAdapter());
|
||||
#endif
|
||||
|
||||
if (!na->isInitialised())
|
||||
{
|
||||
delete na;
|
||||
return nullptr;
|
||||
}
|
||||
return na;
|
||||
}
|
||||
|
||||
void InitNet()
|
||||
{
|
||||
NetAdapter* na = GetNetAdapter();
|
||||
|
||||
if (!na)
|
||||
{
|
||||
Console.Error("Failed to GetNetAdapter()");
|
||||
config.ethEnable = false;
|
||||
return;
|
||||
}
|
||||
|
||||
nif = na;
|
||||
RxRunning = true;
|
||||
|
||||
rx_thread = std::thread(NetRxThread);
|
||||
|
|
|
@ -56,5 +56,5 @@ protected:
|
|||
};
|
||||
|
||||
void tx_put(NetPacket* ptr);
|
||||
void InitNet(NetAdapter* adapter);
|
||||
void InitNet();
|
||||
void TermNet();
|
||||
|
|
Loading…
Reference in New Issue