ntdll: Simplify the platform-specific dispatcher interface.
[wine.git] / dlls / mf / mf_private.h
blobcc270a8cf57c81c872f74f10af2eec166ded63b8
1 /*
2 * Copyright 2019 Nikolay Sivov for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "mferror.h"
20 #include "mfidl.h"
21 #include "mfapi.h"
23 #include "wine/heap.h"
24 #include "wine/debug.h"
26 static inline BOOL mf_array_reserve(void **elements, size_t *capacity, size_t count, size_t size)
28 size_t new_capacity, max_capacity;
29 void *new_elements;
31 if (count <= *capacity)
32 return TRUE;
34 max_capacity = ~(SIZE_T)0 / size;
35 if (count > max_capacity)
36 return FALSE;
38 new_capacity = max(4, *capacity);
39 while (new_capacity < count && new_capacity <= max_capacity / 2)
40 new_capacity *= 2;
41 if (new_capacity < count)
42 new_capacity = max_capacity;
44 if (!(new_elements = heap_realloc(*elements, new_capacity * size)))
45 return FALSE;
47 *elements = new_elements;
48 *capacity = new_capacity;
50 return TRUE;
53 struct activate_funcs
55 HRESULT (*create_object)(IMFAttributes *attributes, void *context, IUnknown **object);
56 void (*shutdown_object)(void *context, IUnknown *object);
57 void (*free_private)(void *context);
60 HRESULT create_activation_object(void *context, const struct activate_funcs *funcs, IMFActivate **ret) DECLSPEC_HIDDEN;
62 static inline const char *debugstr_time(LONGLONG time)
64 ULONGLONG abstime = time >= 0 ? time : -time;
65 unsigned int i = 0, j = 0;
66 char buffer[23], rev[23];
68 while (abstime || i <= 8)
70 buffer[i++] = '0' + (abstime % 10);
71 abstime /= 10;
72 if (i == 7) buffer[i++] = '.';
74 if (time < 0) buffer[i++] = '-';
76 while (i--) rev[j++] = buffer[i];
77 while (rev[j-1] == '0' && rev[j-2] != '.') --j;
78 rev[j] = 0;
80 return wine_dbg_sprintf("%s", rev);
83 extern BOOL mf_is_sample_copier_transform(IMFTransform *transform) DECLSPEC_HIDDEN;
84 extern HRESULT topology_node_get_object(IMFTopologyNode *node, REFIID riid, void **obj) DECLSPEC_HIDDEN;