Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/libs/strmbase/dispatch.c
8675 views
1
/*
2
* ITypeInfo cache for IDispatch
3
*
4
* Copyright 2019 Zebediah Figura
5
*
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Lesser General Public
8
* License as published by the Free Software Foundation; either
9
* version 2.1 of the License, or (at your option) any later version.
10
*
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Lesser General Public License for more details.
15
*
16
* You should have received a copy of the GNU Lesser General Public
17
* License along with this library; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19
*/
20
21
#define COBJMACROS
22
#include "wine/strmbase.h"
23
#include "wine/debug.h"
24
25
WINE_DEFAULT_DEBUG_CHANNEL(quartz);
26
27
static ITypeLib *control_typelib;
28
static ITypeInfo *control_typeinfo[last_tid];
29
30
static REFIID control_tid_id[] =
31
{
32
&IID_IBasicAudio,
33
&IID_IBasicVideo,
34
&IID_IMediaControl,
35
&IID_IMediaEvent,
36
&IID_IMediaPosition,
37
&IID_IVideoWindow,
38
};
39
40
HRESULT strmbase_get_typeinfo(enum strmbase_type_id tid, ITypeInfo **ret)
41
{
42
HRESULT hr;
43
44
if (!control_typelib)
45
{
46
ITypeLib *typelib;
47
48
hr = LoadRegTypeLib(&LIBID_QuartzTypeLib, 1, 0, LOCALE_SYSTEM_DEFAULT, &typelib);
49
if (FAILED(hr))
50
{
51
ERR("Failed to load typelib, hr %#lx.\n", hr);
52
return hr;
53
}
54
if (InterlockedCompareExchangePointer((void **)&control_typelib, typelib, NULL))
55
ITypeLib_Release(typelib);
56
}
57
if (!control_typeinfo[tid])
58
{
59
ITypeInfo *typeinfo;
60
61
hr = ITypeLib_GetTypeInfoOfGuid(control_typelib, control_tid_id[tid], &typeinfo);
62
if (FAILED(hr))
63
{
64
ERR("Failed to get type info for %s, hr %#lx.\n", debugstr_guid(control_tid_id[tid]), hr);
65
return hr;
66
}
67
if (InterlockedCompareExchangePointer((void **)(control_typeinfo + tid), typeinfo, NULL))
68
ITypeInfo_Release(typeinfo);
69
}
70
ITypeInfo_AddRef(*ret = control_typeinfo[tid]);
71
return S_OK;
72
}
73
74
void strmbase_release_typelibs(void)
75
{
76
unsigned int i;
77
78
for (i = 0; i < ARRAY_SIZE(control_typeinfo); ++i)
79
{
80
if (control_typeinfo[i])
81
ITypeInfo_Release(control_typeinfo[i]);
82
}
83
if (control_typelib)
84
ITypeLib_Release(control_typelib);
85
}
86
87