IOS/USB: deduplicate scan thread stopping
Unlike other functions, base ctors/dtors are always called automatically.
This commit is contained in:
parent
1f4b9adbf5
commit
ee0d4661ab
|
@ -31,7 +31,10 @@ USBHost::USBHost(Kernel& ios, const std::string& device_name) : Device(ios, devi
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
USBHost::~USBHost() = default;
|
USBHost::~USBHost()
|
||||||
|
{
|
||||||
|
StopThreads();
|
||||||
|
}
|
||||||
|
|
||||||
IPCCommandResult USBHost::Open(const OpenRequest& request)
|
IPCCommandResult USBHost::Open(const OpenRequest& request)
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,13 +53,14 @@ protected:
|
||||||
virtual void OnDeviceChange(ChangeEvent event, std::shared_ptr<USB::Device> changed_device);
|
virtual void OnDeviceChange(ChangeEvent event, std::shared_ptr<USB::Device> changed_device);
|
||||||
virtual void OnDeviceChangeEnd();
|
virtual void OnDeviceChangeEnd();
|
||||||
virtual bool ShouldAddDevice(const USB::Device& device) const;
|
virtual bool ShouldAddDevice(const USB::Device& device) const;
|
||||||
void StartThreads();
|
|
||||||
void StopThreads();
|
|
||||||
|
|
||||||
IPCCommandResult HandleTransfer(std::shared_ptr<USB::Device> device, u32 request,
|
IPCCommandResult HandleTransfer(std::shared_ptr<USB::Device> device, u32 request,
|
||||||
std::function<s32()> submit) const;
|
std::function<s32()> submit) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void StartThreads();
|
||||||
|
void StopThreads();
|
||||||
|
|
||||||
bool AddDevice(std::unique_ptr<USB::Device> device);
|
bool AddDevice(std::unique_ptr<USB::Device> device);
|
||||||
bool UpdateDevices(bool always_add_hooks = false);
|
bool UpdateDevices(bool always_add_hooks = false);
|
||||||
|
|
||||||
|
|
|
@ -26,11 +26,6 @@ OH0::OH0(Kernel& ios, const std::string& device_name) : USBHost(ios, device_name
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
OH0::~OH0()
|
|
||||||
{
|
|
||||||
StopThreads();
|
|
||||||
}
|
|
||||||
|
|
||||||
IPCCommandResult OH0::Open(const OpenRequest& request)
|
IPCCommandResult OH0::Open(const OpenRequest& request)
|
||||||
{
|
{
|
||||||
if (HasFeature(m_ios.GetVersion(), Feature::NewUSB))
|
if (HasFeature(m_ios.GetVersion(), Feature::NewUSB))
|
||||||
|
|
|
@ -37,7 +37,6 @@ class OH0 final : public USBHost
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OH0(Kernel& ios, const std::string& device_name);
|
OH0(Kernel& ios, const std::string& device_name);
|
||||||
~OH0() override;
|
|
||||||
|
|
||||||
IPCCommandResult Open(const OpenRequest& request) override;
|
IPCCommandResult Open(const OpenRequest& request) override;
|
||||||
IPCCommandResult IOCtl(const IOCtlRequest& request) override;
|
IPCCommandResult IOCtl(const IOCtlRequest& request) override;
|
||||||
|
|
|
@ -86,11 +86,6 @@ struct DeviceEntry
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
USBV5ResourceManager::~USBV5ResourceManager()
|
|
||||||
{
|
|
||||||
StopThreads();
|
|
||||||
}
|
|
||||||
|
|
||||||
void USBV5ResourceManager::DoState(PointerWrap& p)
|
void USBV5ResourceManager::DoState(PointerWrap& p)
|
||||||
{
|
{
|
||||||
p.Do(m_devicechange_first_call);
|
p.Do(m_devicechange_first_call);
|
||||||
|
|
|
@ -69,7 +69,6 @@ class USBV5ResourceManager : public USBHost
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using USBHost::USBHost;
|
using USBHost::USBHost;
|
||||||
~USBV5ResourceManager() override;
|
|
||||||
|
|
||||||
IPCCommandResult IOCtl(const IOCtlRequest& request) override = 0;
|
IPCCommandResult IOCtl(const IOCtlRequest& request) override = 0;
|
||||||
IPCCommandResult IOCtlV(const IOCtlVRequest& request) override = 0;
|
IPCCommandResult IOCtlV(const IOCtlVRequest& request) override = 0;
|
||||||
|
|
|
@ -26,11 +26,6 @@ USB_HIDv4::USB_HIDv4(Kernel& ios, const std::string& device_name) : USBHost(ios,
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
USB_HIDv4::~USB_HIDv4()
|
|
||||||
{
|
|
||||||
StopThreads();
|
|
||||||
}
|
|
||||||
|
|
||||||
IPCCommandResult USB_HIDv4::IOCtl(const IOCtlRequest& request)
|
IPCCommandResult USB_HIDv4::IOCtl(const IOCtlRequest& request)
|
||||||
{
|
{
|
||||||
request.Log(GetDeviceName(), Common::Log::IOS_USB);
|
request.Log(GetDeviceName(), Common::Log::IOS_USB);
|
||||||
|
|
|
@ -22,7 +22,6 @@ class USB_HIDv4 final : public USBHost
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
USB_HIDv4(Kernel& ios, const std::string& device_name);
|
USB_HIDv4(Kernel& ios, const std::string& device_name);
|
||||||
~USB_HIDv4() override;
|
|
||||||
|
|
||||||
IPCCommandResult IOCtl(const IOCtlRequest& request) override;
|
IPCCommandResult IOCtl(const IOCtlRequest& request) override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue