aboutsummaryrefslogtreecommitdiff
path: root/Src/devices/deviceManagerFactory.cpp
blob: 8ee804cdef88ecf183bfb6f4e8e148f208b475d7 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include "main.h"
#include "./deviceManager.h"
#include "./deviceManagerFactory.h"

DeviceManagerFactory::DeviceManagerFactory() 
	: object(NULL)
{
}

DeviceManagerFactory::~DeviceManagerFactory()
{
	if (NULL != object)
		object->Release();
}

FOURCC DeviceManagerFactory::GetServiceType()
{
	return WaSvc::UNIQUE;
}

const char *DeviceManagerFactory::GetServiceName()
{
	return "Device Manager Interface";
}

GUID DeviceManagerFactory::GetGUID()
{
	return DeviceManagerGUID;
}

void *DeviceManagerFactory::GetInterface(int global_lock)
{	
	if (NULL == object)
	{
		if (FAILED(DeviceManager::CreateInstance(&object)))
			object = NULL;
		
		if (NULL == object) 
			return NULL;
	}

	object->AddRef();
	return object;
}

int DeviceManagerFactory::SupportNonLockingInterface()
{
	return 1;
}

int DeviceManagerFactory::ReleaseInterface(void *ifc)
{
	DeviceManager *object = (DeviceManager*)ifc;
	if (NULL != object) 
		object->Release();
	
	return 1;
}

const char *DeviceManagerFactory::GetTestString()
{
	return NULL;
}

int DeviceManagerFactory::ServiceNotify(int msg, int param1, int param2)
{
	return 1;
}

HRESULT DeviceManagerFactory::Register(api_service *service)
{
	if (NULL == service) 
		return E_INVALIDARG;

	service->service_register(this);
	return S_OK;
}

HRESULT DeviceManagerFactory::Unregister(api_service *service)
{
	if (NULL == service) 
		return E_INVALIDARG;

	service->service_deregister(this);
	return S_OK;
}

#define CBCLASS DeviceManagerFactory
START_DISPATCH;
CB( WASERVICEFACTORY_GETSERVICETYPE,                GetServiceType )
CB( WASERVICEFACTORY_GETSERVICENAME,                GetServiceName )
CB( WASERVICEFACTORY_GETGUID,                       GetGUID )
CB( WASERVICEFACTORY_GETINTERFACE,                  GetInterface )
CB( WASERVICEFACTORY_SUPPORTNONLOCKINGGETINTERFACE, SupportNonLockingInterface )
CB( WASERVICEFACTORY_RELEASEINTERFACE,              ReleaseInterface )
CB( WASERVICEFACTORY_GETTESTSTRING,                 GetTestString )
CB( WASERVICEFACTORY_SERVICENOTIFY,                 ServiceNotify )
END_DISPATCH;

#undef CBCLASS