22 #ifndef AVDEVICE_DSHOW_H
23 #define AVDEVICE_DSHOW_H
31 #define NO_DSHOW_STRSAFE
36 #ifndef EC_DEVICE_LOST
37 #define EC_DEVICE_LOST 0x1f
48 #define dshowdebug(...) av_log(&ff_dshow_context_class_ptr, AV_LOG_DEBUG, __VA_ARGS__)
50 #define dshowdebug(...)
67 #define DECLARE_QUERYINTERFACE(class, ...) \
69 class##_QueryInterface(class *this, const GUID *riid, void **ppvObject) \
71 struct GUIDoffset ifaces[] = __VA_ARGS__; \
73 dshowdebug(AV_STRINGIFY(class)"_QueryInterface(%p, %p, %p)\n", this, riid, ppvObject); \
77 for (i = 0; i < sizeof(ifaces)/sizeof(ifaces[0]); i++) { \
78 if (IsEqualGUID(riid, ifaces[i].iid)) { \
79 void *obj = (void *) ((uint8_t *) this + ifaces[i].offset); \
80 class##_AddRef(this); \
81 dshowdebug("\tfound %d with offset %d\n", i, ifaces[i].offset); \
82 *ppvObject = (void *) obj; \
86 dshowdebug("\tE_NOINTERFACE\n"); \
88 return E_NOINTERFACE; \
90 #define DECLARE_ADDREF(class) \
91 unsigned long WINAPI \
92 class##_AddRef(class *this) \
94 dshowdebug(AV_STRINGIFY(class)"_AddRef(%p)\t%ld\n", this, this->ref+1); \
95 return InterlockedIncrement(&this->ref); \
97 #define DECLARE_RELEASE(class) \
98 unsigned long WINAPI \
99 class##_Release(class *this) \
101 long ref = InterlockedDecrement(&this->ref); \
102 dshowdebug(AV_STRINGIFY(class)"_Release(%p)\t%ld\n", this, ref); \
104 class##_Destroy(this); \
108 #define DECLARE_DESTROY(class, func) \
109 void class##_Destroy(class *this) \
111 dshowdebug(AV_STRINGIFY(class)"_Destroy(%p)\n", this); \
115 CoTaskMemFree(this->vtbl); \
116 CoTaskMemFree(this); \
119 #define DECLARE_CREATE(class, setup, ...) \
120 class *class##_Create(__VA_ARGS__) \
122 class *this = CoTaskMemAlloc(sizeof(class)); \
123 void *vtbl = CoTaskMemAlloc(sizeof(*this->vtbl)); \
124 dshowdebug(AV_STRINGIFY(class)"_Create(%p)\n", this); \
125 if (!this || !vtbl) \
127 ZeroMemory(this, sizeof(class)); \
128 ZeroMemory(vtbl, sizeof(*this->vtbl)); \
133 dshowdebug("created "AV_STRINGIFY(class)" %p\n", this); \
136 class##_Destroy(this); \
137 dshowdebug("could not create "AV_STRINGIFY(class)"\n"); \
141 #define SETVTBL(vtbl, class, fn) \
142 do { (vtbl)->fn = (void *) class##_##fn; } while(0)