aboutsummaryrefslogtreecommitdiff
path: root/Src/Plugins/Portable/pmp_usb/deviceprovider.h
blob: 1f7e83adae7ed1e23ea4fbe0a66d86c5c9c75169 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#pragma once

#include <wtypes.h>
#include "../devices/ifc_deviceprovider.h"
#include "../../Library/ml_pmp/pmp.h"

class DeviceProvider : public ifc_deviceprovider
{
protected:
	DeviceProvider();
	~DeviceProvider();

public:
	static HRESULT CreateInstance(DeviceProvider **instance);

public:
	/* Dispatchable */
	size_t AddRef();
	size_t Release();
	int QueryInterface(GUID interface_guid, void **object);

	/* ifc_deviceprovider */
	HRESULT BeginDiscovery(api_devicemanager *manager);
	HRESULT CancelDiscovery();
	HRESULT GetActive();

public:
	HRESULT Register(api_devicemanager *manager);
	HRESULT Unregister();

	size_t IncrementActivity();
	size_t DecrementActivity();

private:
	void Lock();
	void Unlock();
	DWORD DiscoveryThread();
	friend static int DeviceProvider_DiscoveryThreadStarter(HANDLE handle, void *user_data, intptr_t id);

protected:
	size_t ref;
	size_t activity;
	CRITICAL_SECTION lock;
	api_devicemanager *manager;
	ENUMDRIVES	enumerator;
	HANDLE readyEvent;
	BOOL cancelDiscovery;

protected:
	RECVS_DISPATCH;
};