Don't require pre-declaring vector types
This commit is contained in:
+6
-9
@@ -7,13 +7,13 @@
|
||||
|
||||
|
||||
typedef char al_string_char_type;
|
||||
DECL_VECTOR(al_string_char_type)
|
||||
TYPEDEF_VECTOR(al_string_char_type, al_string)
|
||||
|
||||
typedef vector_al_string_char_type al_string;
|
||||
typedef const_vector_al_string_char_type const_al_string;
|
||||
|
||||
#define AL_STRING_INIT(_x) VECTOR_INIT(_x)
|
||||
#define AL_STRING_DEINIT(_x) VECTOR_DEINIT(_x)
|
||||
inline void al_string_deinit(al_string *str)
|
||||
{ VECTOR_DEINIT(*str); }
|
||||
#define AL_STRING_INIT(_x) do { (_x) = (al_string)NULL; } while(0)
|
||||
#define AL_STRING_INIT_STATIC() ((al_string)NULL)
|
||||
#define AL_STRING_DEINIT(_x) al_string_deinit(&(_x));
|
||||
|
||||
inline ALsizei al_string_length(const_al_string str)
|
||||
{ return VECTOR_SIZE(str); }
|
||||
@@ -42,7 +42,4 @@ void al_string_append_range(al_string *str, const al_string_char_type *from, con
|
||||
void al_string_copy_wcstr(al_string *str, const wchar_t *from);
|
||||
#endif
|
||||
|
||||
|
||||
DECL_VECTOR(al_string)
|
||||
|
||||
#endif /* ALSTRING_H */
|
||||
|
||||
+1
-1
@@ -230,7 +230,7 @@ typedef struct {
|
||||
al_string name;
|
||||
al_string device_name;
|
||||
} DevMap;
|
||||
DECL_VECTOR(DevMap)
|
||||
TYPEDEF_VECTOR(DevMap, vector_DevMap)
|
||||
|
||||
static vector_DevMap PlaybackDevices;
|
||||
static vector_DevMap CaptureDevices;
|
||||
|
||||
@@ -109,10 +109,10 @@ typedef struct {
|
||||
al_string name;
|
||||
GUID guid;
|
||||
} DevMap;
|
||||
DECL_VECTOR(DevMap)
|
||||
TYPEDEF_VECTOR(DevMap, vector_DevMap)
|
||||
|
||||
vector_DevMap PlaybackDevices;
|
||||
vector_DevMap CaptureDevices;
|
||||
static vector_DevMap PlaybackDevices;
|
||||
static vector_DevMap CaptureDevices;
|
||||
|
||||
static void clear_devlist(vector_DevMap *list)
|
||||
{
|
||||
|
||||
@@ -65,7 +65,7 @@ typedef struct {
|
||||
al_string name;
|
||||
WCHAR *devid;
|
||||
} DevMap;
|
||||
DECL_VECTOR(DevMap)
|
||||
TYPEDEF_VECTOR(DevMap, vector_DevMap)
|
||||
|
||||
static void clear_devlist(vector_DevMap *list)
|
||||
{
|
||||
|
||||
@@ -458,7 +458,7 @@ typedef struct {
|
||||
al_string name;
|
||||
al_string device_name;
|
||||
} DevMap;
|
||||
DECL_VECTOR(DevMap)
|
||||
TYPEDEF_VECTOR(DevMap, vector_DevMap)
|
||||
|
||||
static vector_DevMap PlaybackDevices;
|
||||
static vector_DevMap CaptureDevices;
|
||||
|
||||
@@ -55,17 +55,13 @@ typedef struct {
|
||||
} WinMMData;
|
||||
|
||||
|
||||
TYPEDEF_VECTOR(al_string, vector_al_string)
|
||||
static vector_al_string PlaybackDevices;
|
||||
static vector_al_string CaptureDevices;
|
||||
|
||||
static void clear_devlist(vector_al_string *list)
|
||||
{
|
||||
al_string *iter, *end;
|
||||
|
||||
iter = VECTOR_ITER_BEGIN(*list);
|
||||
end = VECTOR_ITER_END(*list);
|
||||
for(;iter != end;iter++)
|
||||
AL_STRING_DEINIT(*iter);
|
||||
VECTOR_FOR_EACH(al_string, *list, al_string_deinit);
|
||||
VECTOR_RESIZE(*list, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -653,6 +653,7 @@ ALboolean vector_insert(void *ptr, size_t base_size, size_t obj_size, void *ins_
|
||||
}
|
||||
|
||||
|
||||
extern inline void al_string_deinit(al_string *str);
|
||||
extern inline ALsizei al_string_length(const_al_string str);
|
||||
extern inline ALboolean al_string_empty(const_al_string str);
|
||||
extern inline const al_string_char_type *al_string_get_cstr(const_al_string str);
|
||||
|
||||
+2
-5
@@ -307,12 +307,9 @@ static void RiffHdr_read(RiffHdr *self, Reader *stream)
|
||||
}
|
||||
|
||||
|
||||
DECL_VECTOR(Generator)
|
||||
DECL_VECTOR(Modulator)
|
||||
|
||||
typedef struct GenModList {
|
||||
vector_Generator gens;
|
||||
vector_Modulator mods;
|
||||
VECTOR(Generator) gens;
|
||||
VECTOR(Modulator) mods;
|
||||
} GenModList;
|
||||
|
||||
static void GenModList_Construct(GenModList *self)
|
||||
|
||||
+14
-6
@@ -11,15 +11,23 @@ typedef struct vector__s {
|
||||
ALsizei Size;
|
||||
} *vector_;
|
||||
|
||||
#define DECL_VECTOR(T) typedef struct vector_##T##_s { \
|
||||
#define TYPEDEF_VECTOR(T, N) typedef struct { \
|
||||
ALsizei Capacity; \
|
||||
ALsizei Size; \
|
||||
T Data[]; \
|
||||
} *vector_##T; \
|
||||
typedef const struct vector_##T##_s *const_vector_##T;
|
||||
} _##N; \
|
||||
typedef _##N* N; \
|
||||
typedef const _##N* const_##N;
|
||||
|
||||
#define VECTOR_INIT(_x) do { (_x) = NULL; } while(0)
|
||||
#define VECTOR_DEINIT(_x) do { free((_x)); (_x) = NULL; } while(0)
|
||||
#define VECTOR(T) struct { \
|
||||
ALsizei Capacity; \
|
||||
ALsizei Size; \
|
||||
T Data[]; \
|
||||
}*
|
||||
|
||||
#define VECTOR_INIT(_x) do { (_x) = NULL; } while(0)
|
||||
#define VECTOR_INIT_STATIC() NULL
|
||||
#define VECTOR_DEINIT(_x) do { free((_x)); (_x) = NULL; } while(0)
|
||||
|
||||
/* Helper to increase a vector's reserve. Do not call directly. */
|
||||
ALboolean vector_reserve(void *ptr, size_t base_size, size_t obj_count, size_t obj_size, ALboolean exact);
|
||||
@@ -63,7 +71,7 @@ ALboolean vector_insert(void *ptr, size_t base_size, size_t obj_size, void *ins_
|
||||
_t *_iter = VECTOR_ITER_BEGIN((_x)); \
|
||||
_t *_end = VECTOR_ITER_END((_x)); \
|
||||
for(;_iter != _end;++_iter) \
|
||||
(_f)(_iter); \
|
||||
_f(_iter); \
|
||||
} while(0)
|
||||
|
||||
#endif /* AL_VECTOR_H */
|
||||
|
||||
@@ -720,10 +720,6 @@ struct ALCdevice_struct
|
||||
#define MIXER_THREAD_NAME "alsoft-mixer"
|
||||
|
||||
|
||||
typedef struct ALeffectslot *ALeffectslotPtr;
|
||||
DECL_VECTOR(ALeffectslotPtr)
|
||||
|
||||
|
||||
struct ALCcontext_struct
|
||||
{
|
||||
RefCount ref;
|
||||
@@ -749,7 +745,7 @@ struct ALCcontext_struct
|
||||
ALsizei ActiveSourceCount;
|
||||
ALsizei MaxActiveSources;
|
||||
|
||||
vector_ALeffectslotPtr ActiveAuxSlots;
|
||||
VECTOR(struct ALeffectslot*) ActiveAuxSlots;
|
||||
|
||||
ALCdevice *Device;
|
||||
const ALCchar *ExtensionList;
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
extern inline struct ALeffectslot *LookupEffectSlot(ALCcontext *context, ALuint id);
|
||||
extern inline struct ALeffectslot *RemoveEffectSlot(ALCcontext *context, ALuint id);
|
||||
|
||||
static ALenum AddEffectSlotArray(ALCcontext *Context, const_vector_ALeffectslotPtr slots);
|
||||
static ALenum AddEffectSlotArray(ALCcontext *Context, ALeffectslot **start, ALsizei count);
|
||||
static void RemoveEffectSlotArray(ALCcontext *Context, const ALeffectslot *slot);
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ static inline ALeffectStateFactory *getFactoryByType(ALenum type)
|
||||
AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots)
|
||||
{
|
||||
ALCcontext *context;
|
||||
vector_ALeffectslotPtr slotvec;
|
||||
VECTOR(ALeffectslot*) slotvec;
|
||||
ALsizei cur;
|
||||
ALenum err;
|
||||
|
||||
@@ -94,7 +94,7 @@ AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslo
|
||||
|
||||
effectslots[cur] = slot->id;
|
||||
}
|
||||
err = AddEffectSlotArray(context, slotvec);
|
||||
err = AddEffectSlotArray(context, VECTOR_ITER_BEGIN(slotvec), n);
|
||||
if(err != AL_NO_ERROR)
|
||||
{
|
||||
alDeleteAuxiliaryEffectSlots(cur, effectslots);
|
||||
@@ -385,13 +385,12 @@ done:
|
||||
}
|
||||
|
||||
|
||||
static ALenum AddEffectSlotArray(ALCcontext *context, const_vector_ALeffectslotPtr slots)
|
||||
static ALenum AddEffectSlotArray(ALCcontext *context, ALeffectslot **start, ALsizei count)
|
||||
{
|
||||
ALenum err = AL_NO_ERROR;
|
||||
|
||||
LockContext(context);
|
||||
if(!VECTOR_INSERT(context->ActiveAuxSlots, VECTOR_ITER_END(context->ActiveAuxSlots),
|
||||
VECTOR_ITER_BEGIN(slots), VECTOR_ITER_END(slots)))
|
||||
if(!VECTOR_INSERT(context->ActiveAuxSlots, VECTOR_ITER_END(context->ActiveAuxSlots), start, start+count))
|
||||
err = AL_OUT_OF_MEMORY;
|
||||
UnlockContext(context);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user