changeset 56:208a9ed20087

Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
author Eric Wing <ewing@anscamobile.com>
date Tue, 29 May 2012 19:43:23 -0700
parents 8b4f80233969
children 79503033cf53
files Isolated/ALmixer_RWops.c Isolated/ALmixer_RWops.h Isolated/SimpleMutex.h Isolated/SimpleThread.h Isolated/SoundDecoder.h Isolated/tErrorLib.h
diffstat 6 files changed, 101 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/Isolated/ALmixer_RWops.c	Tue May 29 19:41:59 2012 -0700
+++ b/Isolated/ALmixer_RWops.c	Tue May 29 19:43:23 2012 -0700
@@ -8,7 +8,7 @@
 
 /* (Note this is different than stdio's seek. This returns ftell.)
  */
-static int stdio_seek(ALmixer_RWops* the_context, long offset, int whence)
+static long stdio_seek(ALmixer_RWops* the_context, long offset, int whence)
 {
 	if(0 == fseek(the_context->hidden.stdio.fp, offset, whence))
 	{
--- a/Isolated/ALmixer_RWops.h	Tue May 29 19:41:59 2012 -0700
+++ b/Isolated/ALmixer_RWops.h	Tue May 29 19:43:23 2012 -0700
@@ -46,7 +46,7 @@
 		 *  Returns the final offset in the data source.
 		 *  (Note this is different than stdio's seek. This returns ftell.)
 		 */
-		int (ALMIXER_RWOPS_CALL *seek)(struct ALmixer_RWops* the_context, long offset, int whence);
+		long (ALMIXER_RWOPS_CALL *seek)(struct ALmixer_RWops* the_context, long offset, int whence);
 
 		/** Read up to 'nitems' objects each of size 'size' from the data
 		 *  source to the area pointed at by 'ptr'.
@@ -78,8 +78,8 @@
 				struct
 				{
 					void *data;
-					int size;
-					int left;
+					size_t size;
+					size_t left;
 				} buffer;
 			} win32io;
 #endif
--- a/Isolated/SimpleMutex.h	Tue May 29 19:41:59 2012 -0700
+++ b/Isolated/SimpleMutex.h	Tue May 29 19:43:23 2012 -0700
@@ -6,14 +6,37 @@
 #ifdef __cplusplus
 extern "C" {
 #endif
-	
+
+	#if defined(_WIN32)
+		#if defined(SIMPLE_MUTEX_BUILD_LIBRARY)
+			#define SIMPLE_MUTEX_DECLSPEC __declspec(dllexport)
+		#else
+			#define SIMPLE_MUTEX_DECLSPEC __declspec(dllimport)
+		#endif
+	#else
+		#if defined(SIMPLE_MUTEX_BUILD_LIBRARY)
+			#if defined (__GNUC__) && __GNUC__ >= 4
+				#define SIMPLE_MUTEX_DECLSPEC __attribute__((visibility("default")))
+			#else
+				#define SIMPLE_MUTEX_DECLSPEC
+			#endif
+		#else
+			#define SIMPLE_MUTEX_DECLSPEC
+		#endif
+	#endif
+
+	#if defined(_WIN32)
+		#define SIMPLE_MUTEX_CALL __cdecl
+	#else
+		#define SIMPLE_MUTEX_CALL
+	#endif
 
 typedef struct SimpleMutex SimpleMutex;
 
-SimpleMutex* SimpleMutex_CreateMutex(void);
-void SimpleMutex_DestroyMutex(SimpleMutex* simple_mutex);
-int SimpleMutex_LockMutex(SimpleMutex* simple_mutex);
-void SimpleMutex_UnlockMutex(SimpleMutex* simple_mutex);
+extern SIMPLE_MUTEX_DECLSPEC SimpleMutex* SIMPLE_MUTEX_CALL SimpleMutex_CreateMutex(void);
+extern SIMPLE_MUTEX_DECLSPEC void SIMPLE_MUTEX_CALL SimpleMutex_DestroyMutex(SimpleMutex* simple_mutex);
+extern SIMPLE_MUTEX_DECLSPEC int SIMPLE_MUTEX_CALL SimpleMutex_LockMutex(SimpleMutex* simple_mutex);
+extern SIMPLE_MUTEX_DECLSPEC void SIMPLE_MUTEX_CALL SimpleMutex_UnlockMutex(SimpleMutex* simple_mutex);
 
 
 /* Ends C function definitions when using C++ */
--- a/Isolated/SimpleThread.h	Tue May 29 19:41:59 2012 -0700
+++ b/Isolated/SimpleThread.h	Tue May 29 19:43:23 2012 -0700
@@ -5,21 +5,45 @@
 extern "C" {
 #endif
 	
+	#if defined(_WIN32)
+		#if defined(SIMPLE_THREAD_BUILD_LIBRARY)
+			#define SIMPLE_THREAD_DECLSPEC __declspec(dllexport)
+		#else
+			#define SIMPLE_THREAD_DECLSPEC __declspec(dllimport)
+		#endif
+	#else
+		#if defined(SIMPLE_THREAD_BUILD_LIBRARY)
+			#if defined (__GNUC__) && __GNUC__ >= 4
+				#define SIMPLE_THREAD_DECLSPEC __attribute__((visibility("default")))
+			#else
+				#define SIMPLE_THREAD_DECLSPEC
+			#endif
+		#else
+			#define SIMPLE_THREAD_DECLSPEC
+		#endif
+	#endif
+
+	#if defined(_WIN32)
+		#define SIMPLE_THREAD_CALL __cdecl
+	#else
+		#define SIMPLE_THREAD_CALL
+	#endif
+
 #include <stddef.h>
 
 typedef struct SimpleThread SimpleThread;
 
 
-SimpleThread* SimpleThread_CreateThread(int (*user_function)(void*), void* user_data);
+extern SIMPLE_THREAD_DECLSPEC SimpleThread* SIMPLE_THREAD_CALL SimpleThread_CreateThread(int (*user_function)(void*), void* user_data);
 
-size_t SimpleThread_GetCurrentThreadID(void);
-size_t SimpleThread_GetThreadID(SimpleThread* simple_thread);
+extern SIMPLE_THREAD_DECLSPEC size_t SIMPLE_THREAD_CALL SimpleThread_GetCurrentThreadID(void);
+extern SIMPLE_THREAD_DECLSPEC size_t SIMPLE_THREAD_CALL SimpleThread_GetThreadID(SimpleThread* simple_thread);
 
-void SimpleThread_WaitThread(SimpleThread* simple_thread, int* thread_status);
+extern SIMPLE_THREAD_DECLSPEC void SIMPLE_THREAD_CALL SimpleThread_WaitThread(SimpleThread* simple_thread, int* thread_status);
 
 
-int SimpleThread_GetThreadPriority(SimpleThread* simple_thread);
-void SimpleThread_SetThreadPriority(SimpleThread* simple_thread, int priority_level);
+extern SIMPLE_THREAD_DECLSPEC int SIMPLE_THREAD_CALL SimpleThread_GetThreadPriority(SimpleThread* simple_thread);
+extern SIMPLE_THREAD_DECLSPEC void SIMPLE_THREAD_CALL SimpleThread_SetThreadPriority(SimpleThread* simple_thread, int priority_level);
 
 /* Ends C function definitions when using C++ */
 #ifdef __cplusplus
--- a/Isolated/SoundDecoder.h	Tue May 29 19:41:59 2012 -0700
+++ b/Isolated/SoundDecoder.h	Tue May 29 19:43:23 2012 -0700
@@ -11,7 +11,30 @@
 extern "C" {
 #endif
 	
+	#if defined(_WIN32)
+		#if defined(SOUND_DECODER_BUILD_LIBRARY)
+			#define SOUND_DECODER_DECLSPEC __declspec(dllexport)
+		#else
+			#define SOUND_DECODER_DECLSPEC __declspec(dllimport)
+		#endif
+	#else
+		#if defined(SOUND_DECODER_BUILD_LIBRARY)
+			#if defined (__GNUC__) && __GNUC__ >= 4
+				#define SOUND_DECODER_DECLSPEC __attribute__((visibility("default")))
+			#else
+				#define SOUND_DECODER_DECLSPEC
+			#endif
+		#else
+			#define SOUND_DECODER_DECLSPEC
+		#endif
+	#endif
 
+	#if defined(_WIN32)
+		#define SOUND_DECODER_CALL __cdecl
+	#else
+		#define SOUND_DECODER_CALL
+	#endif
+	
 #include <stdint.h>
 #include <stddef.h>
 
@@ -132,62 +155,62 @@
 
 #define SOUND_VERSION SOUNDDECODER_VERSION
 
-void SoundDecoder_GetLinkedVersion(SoundDecoder_Version *ver);
+extern SOUND_DECODER_DECLSPEC void SOUND_DECODER_CALL SoundDecoder_GetLinkedVersion(SoundDecoder_Version *ver);
 #define Sound_GetLinkedVersion SoundDecoder_GetLinkedVersion
 
-int SoundDecoder_Init(void);
+extern SOUND_DECODER_DECLSPEC int SOUND_DECODER_CALL SoundDecoder_Init(void);
 #define Sound_Init SoundDecoder_Init
 
-void SoundDecoder_Quit(void);
+extern SOUND_DECODER_DECLSPEC void SOUND_DECODER_CALL SoundDecoder_Quit(void);
 #define Sound_Quit SoundDecoder_Quit
 
 
-const SoundDecoder_DecoderInfo** SoundDecoder_AvailableDecoders(void);
+extern SOUND_DECODER_DECLSPEC const SOUND_DECODER_CALL SoundDecoder_DecoderInfo** SoundDecoder_AvailableDecoders(void);
 #define Sound_AvailableDecoders SoundDecoder_AvailableDecoders
 
 
-const char* SoundDecoder_GetError(void);
+extern SOUND_DECODER_DECLSPEC const char* SOUND_DECODER_CALL SoundDecoder_GetError(void);
 #define Sound_GetError SoundDecoder_GetError
 
 
-void SoundDecoder_ClearError(void);
+extern SOUND_DECODER_DECLSPEC void SOUND_DECODER_CALL SoundDecoder_ClearError(void);
 #define Sound_ClearError SoundDecoder_ClearError
 
 
 
-SoundDecoder_Sample* SoundDecoder_NewSample(
+extern SOUND_DECODER_DECLSPEC SoundDecoder_Sample* SOUND_DECODER_CALL SoundDecoder_NewSample(
 	struct ALmixer_RWops* rw_ops,
 	const char* ext,
 	SoundDecoder_AudioInfo* desired,
 	size_t buffer_size);
 #define Sound_NewSample SoundDecoder_NewSample
 
-SoundDecoder_Sample* SoundDecoder_NewSampleFromFile(const char* file_name,
+extern SOUND_DECODER_DECLSPEC SoundDecoder_Sample* SOUND_DECODER_CALL SoundDecoder_NewSampleFromFile(const char* file_name,
 	SoundDecoder_AudioInfo* desired,
 	size_t bufferSize);
 #define Sound_NewSampleFromFile SoundDecoder_NewSampleFromFile
 
 
-void SoundDecoder_FreeSample(SoundDecoder_Sample* sound_sample);
+extern SOUND_DECODER_DECLSPEC void SOUND_DECODER_CALL SoundDecoder_FreeSample(SoundDecoder_Sample* sound_sample);
 #define Sound_FreeSample SoundDecoder_FreeSample
 
 
-ptrdiff_t SoundDecoder_GetDuration(SoundDecoder_Sample* sound_sample);
+extern SOUND_DECODER_DECLSPEC ptrdiff_t SOUND_DECODER_CALL SoundDecoder_GetDuration(SoundDecoder_Sample* sound_sample);
 #define Sound_GetDuration SoundDecoder_GetDuration
 
-int SoundDecoder_SetBufferSize(SoundDecoder_Sample* sound_sample, size_t new_buffer_size);
+extern SOUND_DECODER_DECLSPEC int SOUND_DECODER_CALL SoundDecoder_SetBufferSize(SoundDecoder_Sample* sound_sample, size_t new_buffer_size);
 #define Sound_SetBufferSize SoundDecoder_SetBufferSize
 
-size_t SoundDecoder_Decode(SoundDecoder_Sample* sound_sample);
+extern SOUND_DECODER_DECLSPEC size_t SOUND_DECODER_CALL SoundDecoder_Decode(SoundDecoder_Sample* sound_sample);
 #define Sound_Decode SoundDecoder_Decode
 
-size_t SoundDecoder_DecodeAll(SoundDecoder_Sample* sound_sample);
+extern SOUND_DECODER_DECLSPEC size_t SOUND_DECODER_CALL SoundDecoder_DecodeAll(SoundDecoder_Sample* sound_sample);
 #define Sound_DecodeAll SoundDecoder_DecodeAll
 
-int SoundDecoder_Rewind(SoundDecoder_Sample* sound_sample);
+extern SOUND_DECODER_DECLSPEC int SOUND_DECODER_CALL SoundDecoder_Rewind(SoundDecoder_Sample* sound_sample);
 #define Sound_Rewind SoundDecoder_Rewind
 
-int SoundDecoder_Seek(SoundDecoder_Sample* sound_sample, size_t ms);
+extern SOUND_DECODER_DECLSPEC int SOUND_DECODER_CALL SoundDecoder_Seek(SoundDecoder_Sample* sound_sample, size_t ms);
 #define Sound_Seek SoundDecoder_Seek
 
 
--- a/Isolated/tErrorLib.h	Tue May 29 19:41:59 2012 -0700
+++ b/Isolated/tErrorLib.h	Tue May 29 19:43:23 2012 -0700
@@ -279,7 +279,7 @@
 		#define TERROR_DECLSPEC __declspec(dllimport)
 	#endif
 #else
-	#if defined(ALMIXER_BUILD_LIBRARY)
+	#if defined(TERROR_BUILD_LIBRARY)
 		#if defined (__GNUC__) && __GNUC__ >= 4
 			#define TERROR_DECLSPEC __attribute__((visibility("default")))
 		#else