Commit dd0554be authored by David Reid's avatar David Reid

Don't omit backend-specific attributes in structures.

The rationale behind this commit is to ensure the size of each data
structure remains consistent regardless of which backends are enabled
and disabled. This is important for mini_al because it publicly exposes
every struct.
parent 02788795
...@@ -42,9 +42,9 @@ ...@@ -42,9 +42,9 @@
// //
// You can then #include this file in other parts of the program as you would with any other header file. // You can then #include this file in other parts of the program as you would with any other header file.
// //
// The implementation of this library will try #including necessary headers for each backend. If you do not have // The implementation of this library will try #include-ing necessary headers for each backend. If you do not have
// the development packages for any particular backend you can disable it by #define-ing the appropriate MAL_NO_* // the development packages for any particular backend you can disable it by #define-ing the appropriate MAL_NO_*
// option. // option before #include-ing the implementation.
// //
// //
// Building (Windows) // Building (Windows)
...@@ -329,22 +329,11 @@ typedef enum ...@@ -329,22 +329,11 @@ typedef enum
typedef union typedef union
{ {
// Just look at this shit... // Just look at this shit...
#if defined(MAL_ENABLE_OPENSLES)
mal_uint32 id32; // OpenSL|ES uses a 32-bit unsigned integer for identification. mal_uint32 id32; // OpenSL|ES uses a 32-bit unsigned integer for identification.
#endif
#if defined(MAL_ENABLE_ALSA)
char str[32]; // ALSA uses a name string for identification. char str[32]; // ALSA uses a name string for identification.
#endif
#if defined(MAL_ENABLE_DSOUND)
mal_uint8 guid[16]; // DirectSound uses a GUID for identification. mal_uint8 guid[16]; // DirectSound uses a GUID for identification.
#endif
#if defined(MAL_ENABLE_WASAPI)
wchar_t wstr[64]; // WASAPI uses a wchar_t string for identification which is also annoyingly long... wchar_t wstr[64]; // WASAPI uses a wchar_t string for identification which is also annoyingly long...
#endif
#if defined(MAL_ENABLE_OPENAL)
char openal[256]; // OpenAL uses human-readable device names as the ID which is so flippin' stupid... char openal[256]; // OpenAL uses human-readable device names as the ID which is so flippin' stupid...
#endif
int null; // <-- Just to ensure compilation works when no backends are enabled.
} mal_device_id; } mal_device_id;
typedef struct typedef struct
...@@ -377,36 +366,27 @@ typedef struct ...@@ -377,36 +366,27 @@ typedef struct
union union
{ {
#ifdef MAL_ENABLE_WASAPI
struct struct
{ {
/*IMMDeviceEnumerator**/ mal_ptr pDeviceEnumerator; /*IMMDeviceEnumerator**/ mal_ptr pDeviceEnumerator;
mal_bool32 needCoUninit; // Whether or not COM needs to be uninitialized. mal_bool32 needCoUninit; // Whether or not COM needs to be uninitialized.
} wasapi; } wasapi;
#endif
#ifdef MAL_ENABLE_DSOUND
struct struct
{ {
/*HMODULE*/ mal_handle hDSoundDLL; /*HMODULE*/ mal_handle hDSoundDLL;
} dsound; } dsound;
#endif
#ifdef MAL_ENABLE_ALSA
struct struct
{ {
int _unused; int _unused;
} alsa; } alsa;
#endif
#ifdef MAL_ENABLE_OPENSLES
struct struct
{ {
int _unused; int _unused;
} sles; } sles;
#endif
#ifdef MAL_ENABLE_OPENAL
struct struct
{ {
/*HMODULE*/ mal_handle hOpenAL; // OpenAL32.dll, etc. /*HMODULE*/ mal_handle hOpenAL; // OpenAL32.dll, etc.
...@@ -491,16 +471,11 @@ typedef struct ...@@ -491,16 +471,11 @@ typedef struct
mal_uint32 isFloat32Supported; mal_uint32 isFloat32Supported;
} openal; } openal;
#endif
#ifdef MAL_ENABLE_NULL
struct struct
{ {
int _unused; int _unused;
} null_device; } null_device;
#endif
int _unused; // Only used to ensure mini_al compiles when all backends have been disabled.
}; };
} mal_context; } mal_context;
...@@ -531,7 +506,6 @@ struct mal_device ...@@ -531,7 +506,6 @@ struct mal_device
union union
{ {
#ifdef MAL_ENABLE_WASAPI
struct struct
{ {
/*IMMDevice**/ mal_ptr pDevice; /*IMMDevice**/ mal_ptr pDevice;
...@@ -542,9 +516,7 @@ struct mal_device ...@@ -542,9 +516,7 @@ struct mal_device
mal_bool32 needCoUninit; // Whether or not COM needs to be uninitialized. mal_bool32 needCoUninit; // Whether or not COM needs to be uninitialized.
mal_bool32 breakFromMainLoop; mal_bool32 breakFromMainLoop;
} wasapi; } wasapi;
#endif
#ifdef MAL_ENABLE_DSOUND
struct struct
{ {
/*HMODULE*/ mal_handle hDSoundDLL; /*HMODULE*/ mal_handle hDSoundDLL;
...@@ -559,9 +531,7 @@ struct mal_device ...@@ -559,9 +531,7 @@ struct mal_device
mal_uint32 lastProcessedFrame; // This is circular. mal_uint32 lastProcessedFrame; // This is circular.
mal_bool32 breakFromMainLoop; mal_bool32 breakFromMainLoop;
} dsound; } dsound;
#endif
#ifdef MAL_ENABLE_ALSA
struct struct
{ {
/*snd_pcm_t**/ mal_ptr pPCM; /*snd_pcm_t**/ mal_ptr pPCM;
...@@ -569,9 +539,7 @@ struct mal_device ...@@ -569,9 +539,7 @@ struct mal_device
mal_bool32 breakFromMainLoop; mal_bool32 breakFromMainLoop;
void* pIntermediaryBuffer; void* pIntermediaryBuffer;
} alsa; } alsa;
#endif
#ifdef MAL_ENABLE_OPENSLES
struct struct
{ {
/*SLObjectItf*/ mal_ptr pOutputMixObj; /*SLObjectItf*/ mal_ptr pOutputMixObj;
...@@ -585,9 +553,7 @@ struct mal_device ...@@ -585,9 +553,7 @@ struct mal_device
mal_uint32 currentBufferIndex; mal_uint32 currentBufferIndex;
mal_uint8* pBuffer; // This is malloc()'d and is used for storing audio data. Typed as mal_uint8 for easy offsetting. mal_uint8* pBuffer; // This is malloc()'d and is used for storing audio data. Typed as mal_uint8 for easy offsetting.
} sles; } sles;
#endif
#ifdef MAL_ENABLE_OPENAL
struct struct
{ {
/*ALCcontext**/ mal_ptr pContextALC; /*ALCcontext**/ mal_ptr pContextALC;
...@@ -600,9 +566,7 @@ struct mal_device ...@@ -600,9 +566,7 @@ struct mal_device
mal_uint32 iNextBuffer; // The next buffer to unenqueue and then re-enqueue as new data is read. mal_uint32 iNextBuffer; // The next buffer to unenqueue and then re-enqueue as new data is read.
mal_bool32 breakFromMainLoop; mal_bool32 breakFromMainLoop;
} openal; } openal;
#endif
#ifdef MAL_ENABLE_NULL
struct struct
{ {
mal_timer timer; mal_timer timer;
...@@ -610,9 +574,6 @@ struct mal_device ...@@ -610,9 +574,6 @@ struct mal_device
mal_bool32 breakFromMainLoop; mal_bool32 breakFromMainLoop;
mal_uint8* pBuffer; // This is malloc()'d and is used as the destination for reading from the client. Typed as mal_uint8 for easy offsetting. mal_uint8* pBuffer; // This is malloc()'d and is used as the destination for reading from the client. Typed as mal_uint8 for easy offsetting.
} null_device; } null_device;
#endif
int _unused; // Only used to ensure mini_al compiles when all backends have been disabled.
}; };
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment