Reactivate the mmdevapi audio client and set the event handle on reset
[openal-soft.git] / Alc / vector.h
blobde89bbe006377128c6accbc6526da4c1a1282817
1 #ifndef AL_VECTOR_H
2 #define AL_VECTOR_H
4 #include <stdlib.h>
6 #include <AL/al.h>
8 /* "Base" vector type, designed to alias with the actual vector types. */
9 typedef struct vector__s {
10 ALsizei Capacity;
11 ALsizei Size;
12 } *vector_;
14 #define DECL_VECTOR(T) typedef struct vector_##T##_s { \
15 ALsizei Capacity; \
16 ALsizei Size; \
17 T Data[]; \
18 } *vector_##T;
20 #define VECTOR_INIT(_x) (((_x) = calloc(1, sizeof(*(_x)))) != NULL)
21 #define VECTOR_DEINIT(_x) do { free(_x); _x = NULL; } while(0)
23 /* Helper to increase a vector's reserve. Do not call directly. */
24 ALboolean vector_reserve(void *ptr, size_t orig_count, size_t base_size, size_t obj_count, size_t obj_size, ALboolean exact);
25 #define VECTOR_RESERVE(_x, _c) (vector_reserve(&(_x), (_x)->Capacity, sizeof(*(_x)), (_c), sizeof((_x)->Data[0]), AL_TRUE))
27 #define VECTOR_CAPACITY(_x) ((const ALsizei)(_x)->Capacity)
28 #define VECTOR_SIZE(_x) ((const ALsizei)(_x)->Size)
30 #define VECTOR_ITER_BEGIN(_x) ((_x)->Data)
31 #define VECTOR_ITER_END(_x) ((_x)->Data + (_x)->Size)
33 #define VECTOR_PUSH_BACK(_x, _obj) (vector_reserve(&(_x), (_x)->Capacity, sizeof(*(_x)), (_x)->Size+1, sizeof((_x)->Data[0]), AL_FALSE) && \
34 (((_x)->Data[(_x)->Size++] = (_obj)),AL_TRUE))
35 #define VECTOR_POP_BACK(_x) ((void)((_x)->Size--))
37 #define VECTOR_BACK(_x) ((_x)->Data[(_x)->Size-1])
38 #define VECTOR_FRONT(_x) ((_x)->Data[0])
40 #define VECTOR_ELEM(_x, _o) ((_x)->Data[(_o)])
42 #endif /* AL_VECTOR_H */