Browse Source

Include mini_al directly, no separate module

Ray 6 years ago
parent
commit
944a388b1b

+ 6 - 6
examples/others/raudio_standalone.c

@@ -5,17 +5,17 @@
 *   NOTE: This example does not require any graphic device, it can run directly on console.
 *
 *   DEPENDENCIES:
-*       mini_al.h    - Audio device management lib (http://kcat.strangesoft.net/openal.html)
+*       mini_al.h    - Audio device management lib (https://github.com/dr-soft/mini_al)
 *       stb_vorbis.h - Ogg audio files loading (http://www.nothings.org/stb_vorbis/)
+*       dr_mp3.h     - MP3 audio file loading (https://github.com/mackron/dr_libs)
+*       dr_flac.h    - FLAC audio file loading (https://github.com/mackron/dr_libs)
 *       jar_xm.h     - XM module file loading
 *       jar_mod.h    - MOD audio file loading
-*       dr_flac.h    - FLAC audio file loading
 *
 *   COMPILATION:
-*       gcc -c ..\..\src\external\mini_al.c -Wall -I.
-*       gcc -o audio_standalone.exe audio_standalone.c ..\..\src\raudio.c mini_al.o  /
-*           -I..\..\src -I..\..\src\external -L. -Wall -std=c99  / 
-*           -DAUDIO_STANDALONE -DSUPPORT_FILEFORMAT_WAV -DSUPPORT_FILEFORMAT_OGG
+*       gcc -o raudio_standalone.exe raudio_standalone.c ..\..\src\raudio.c /
+*           -I..\..\src -I..\..\src\external -L. -Wall -std=c99 -DRAUDIO_STANDALONE / 
+*           -DSUPPORT_FILEFORMAT_WAV -DSUPPORT_FILEFORMAT_OGG -DSUPPORT_FILEFORMAT_MP3
 *
 *   LICENSE: zlib/libpng
 *

+ 1 - 2
projects/Geany/raylib_compile_sources.bat

@@ -24,13 +24,12 @@ gcc -O2 -c textures.c -std=c99 -Wall -DPLATFORM_DESKTOP
 gcc -O2 -c text.c -std=c99 -Wall -DPLATFORM_DESKTOP
 gcc -O2 -c models.c -std=c99 -Wall -DPLATFORM_DESKTOP
 gcc -O2 -c raudio.c -std=c99 -Wall -DPLATFORM_DESKTOP
-gcc -O2 -c external/mini_al.c -Wall -I.
 gcc -O2 -c utils.c -std=c99 -Wall -DPLATFORM_DESKTOP
 
 :: .
 :: . > Generate raylib library
 :: ------------------------------
-ar rcs libraylib.a core.o rglfw.o shapes.o textures.o text.o models.o raudio.o mini_al.o utils.o
+ar rcs libraylib.a core.o rglfw.o shapes.o textures.o text.o models.o raudio.o utils.o
 :: .
 :: > Installing raylib library
 :: -----------------------------

BIN
projects/Notepad++/npes_saved_mingw.txt


BIN
projects/Notepad++/npes_saved_tcc.txt


+ 2 - 2
projects/VS2015/raylib/raylib.vcxproj

@@ -232,9 +232,8 @@
     <Text Include="ReadMe.txt" />
   </ItemGroup>
   <ItemGroup>
-    <ClCompile Include="..\..\..\src\audio.c" />
+    <ClCompile Include="..\..\..\src\raudio.c" />
     <ClCompile Include="..\..\..\src\core.c" />
-    <ClCompile Include="..\..\..\src\external\mini_al.c" />
     <ClCompile Include="..\..\..\src\models.c" />
     <ClCompile Include="..\..\..\src\rglfw.c" />
     <ClCompile Include="..\..\..\src\shapes.c" />
@@ -247,6 +246,7 @@
     <ClInclude Include="..\..\..\src\external\glad.h" />
     <ClInclude Include="..\..\..\src\external\jar_mod.h" />
     <ClInclude Include="..\..\..\src\external\jar_xm.h" />
+    <ClInclude Include="..\..\..\src\external\mini_al.h" />
     <ClInclude Include="..\..\..\src\external\stb_image.h" />
     <ClInclude Include="..\..\..\src\external\stb_image_resize.h" />
     <ClInclude Include="..\..\..\src\external\stb_image_write.h" />

+ 1 - 2
projects/VS2017/raylib/raylib.vcxproj

@@ -159,9 +159,8 @@
     <Text Include="ReadMe.txt" />
   </ItemGroup>
   <ItemGroup>
-    <ClCompile Include="..\..\..\src\audio.c" />
+    <ClCompile Include="..\..\..\src\raudio.c" />
     <ClCompile Include="..\..\..\src\core.c" />
-    <ClCompile Include="..\..\..\src\external\mini_al.c" />
     <ClCompile Include="..\..\..\src\models.c" />
     <ClCompile Include="..\..\..\src\rglfw.c" />
     <ClCompile Include="..\..\..\src\shapes.c" />

+ 0 - 2
src/CMakeLists.txt

@@ -45,9 +45,7 @@ endif()
 add_definitions("-DRAYLIB_CMAKE=1")
 
 if(USE_AUDIO)
-  file(GLOB mini_al external/mini_al.c)
   MESSAGE(STATUS "Audio Backend: mini_al")
-  set(sources ${raylib_sources} ${mini_al})
 else()
   MESSAGE(STATUS "Audio Backend: None (-DUSE_AUDIO=OFF)")
   set(INCLUDE_AUDIO_MODULE 0)

+ 0 - 5
src/Makefile

@@ -404,7 +404,6 @@ endif
 
 ifeq ($(INCLUDE_AUDIO_MODULE),TRUE)
     OBJS += raudio.o
-    OBJS += mini_al.o
 endif
 
 ifeq ($(PLATFORM),PLATFORM_ANDROID)
@@ -532,10 +531,6 @@ models.o : models.c raylib.h rlgl.h raymath.h
 raudio.o : raudio.c raylib.h
 	$(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM)
 
-# Compile mini_al audio library
-mini_al.o : external/mini_al.c external/mini_al.h
-	$(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM)
-
 # Compile utils module
 utils.o : utils.c utils.h
 	$(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -D$(PLATFORM)

+ 0 - 8
src/external/mini_al.c

@@ -1,8 +0,0 @@
-// The implementation of mini_al needs to #include windows.h which means it needs to go into
-// it's own translation unit. Not doing this will cause conflicts with CloseWindow(), etc.
-#define MINI_AL_IMPLEMENTATION
-#define MAL_NO_JACK
-#define MAL_NO_OPENAL
-#define MAL_NO_SDL
-//#define MAL_NO_NULL
-#include "mini_al.h"

+ 72 - 0
src/external/mini_al.h

@@ -2775,7 +2775,79 @@ mal_uint64 mal_sine_wave_read_ex(mal_sine_wave* pSineWave, mal_uint64 frameCount
 #endif
 
 #ifdef MAL_WIN32
+
+// @raysan5: To avoid conflicting windows.h symbols with raylib, so flags are defined
+// WARNING: Those flags avoid inclusion of some Win32 headers that could be required 
+// by user at some point and won't be included...
+//-------------------------------------------------------------------------------------
+
+// If defined, the following flags inhibit definition of the indicated items.
+#define NOGDICAPMASKS     // CC_*, LC_*, PC_*, CP_*, TC_*, RC_
+#define NOVIRTUALKEYCODES // VK_*
+#define NOWINMESSAGES     // WM_*, EM_*, LB_*, CB_*
+#define NOWINSTYLES       // WS_*, CS_*, ES_*, LBS_*, SBS_*, CBS_*
+#define NOSYSMETRICS      // SM_*
+#define NOMENUS           // MF_*
+#define NOICONS           // IDI_*
+#define NOKEYSTATES       // MK_*
+#define NOSYSCOMMANDS     // SC_*
+#define NORASTEROPS       // Binary and Tertiary raster ops
+#define NOSHOWWINDOW      // SW_*
+#define OEMRESOURCE       // OEM Resource values
+#define NOATOM            // Atom Manager routines
+#define NOCLIPBOARD       // Clipboard routines
+#define NOCOLOR           // Screen colors
+#define NOCTLMGR          // Control and Dialog routines
+#define NODRAWTEXT        // DrawText() and DT_*
+#define NOGDI             // All GDI defines and routines
+#define NOKERNEL          // All KERNEL defines and routines
+#define NOUSER            // All USER defines and routines
+//#define NONLS             // All NLS defines and routines
+#define NOMB              // MB_* and MessageBox()
+#define NOMEMMGR          // GMEM_*, LMEM_*, GHND, LHND, associated routines
+#define NOMETAFILE        // typedef METAFILEPICT
+#define NOMINMAX          // Macros min(a,b) and max(a,b)
+#define NOMSG             // typedef MSG and associated routines
+#define NOOPENFILE        // OpenFile(), OemToAnsi, AnsiToOem, and OF_*
+#define NOSCROLL          // SB_* and scrolling routines
+#define NOSERVICE         // All Service Controller routines, SERVICE_ equates, etc.
+#define NOSOUND           // Sound driver routines
+#define NOTEXTMETRIC      // typedef TEXTMETRIC and associated routines
+#define NOWH              // SetWindowsHook and WH_*
+#define NOWINOFFSETS      // GWL_*, GCL_*, associated routines
+#define NOCOMM            // COMM driver routines
+#define NOKANJI           // Kanji support stuff.
+#define NOHELP            // Help engine interface.
+#define NOPROFILER        // Profiler interface.
+#define NODEFERWINDOWPOS  // DeferWindowPos routines
+#define NOMCX             // Modem Configuration Extensions
+
+// Type required before windows.h inclusion
+typedef struct tagMSG *LPMSG;
+
 #include <windows.h>
+
+// Type required by some unused function...
+typedef struct tagBITMAPINFOHEADER {
+  DWORD biSize;
+  LONG  biWidth;
+  LONG  biHeight;
+  WORD  biPlanes;
+  WORD  biBitCount;
+  DWORD biCompression;
+  DWORD biSizeImage;
+  LONG  biXPelsPerMeter;
+  LONG  biYPelsPerMeter;
+  DWORD biClrUsed;
+  DWORD biClrImportant;
+} BITMAPINFOHEADER, *PBITMAPINFOHEADER;
+
+// @raysan5: Some required types defined for TinyC compiler
+#if defined(__TINYC__)
+    #include "propidl.h"
+#endif
+//----------------------------------------------------------------------------------
+
 #else
 #include <stdlib.h> // For malloc()/free()
 #include <string.h> // For memset()

BIN
src/libraylib.a


+ 15 - 8
src/raudio.c

@@ -26,12 +26,12 @@
 *       supported by default, to remove support, just comment unrequired #define in this module
 *
 *   DEPENDENCIES:
-*       mini_al     - Audio device/context management (https://github.com/dr-soft/mini_al)
-*       stb_vorbis  - OGG audio files loading (http://www.nothings.org/stb_vorbis/)
-*       jar_xm      - XM module file loading
-*       jar_mod     - MOD audio file loading
-*       dr_flac     - FLAC audio file loading
-*       dr_mp3      - MP3 audio file loading
+*       mini_al.h    - Audio device management lib (https://github.com/dr-soft/mini_al)
+*       stb_vorbis.h - Ogg audio files loading (http://www.nothings.org/stb_vorbis/)
+*       dr_mp3.h     - MP3 audio file loading (https://github.com/mackron/dr_libs)
+*       dr_flac.h    - FLAC audio file loading (https://github.com/mackron/dr_libs)
+*       jar_xm.h     - XM module file loading
+*       jar_mod.h    - MOD audio file loading
 *
 *   CONTRIBUTORS:
 *       David Reid (github: @mackron) (Nov. 2017):
@@ -77,9 +77,12 @@
     #include "utils.h"          // Required for: fopen() Android mapping
 #endif
 
+#define MAL_NO_SDL
+#define MAL_NO_JACK
+#define MAL_NO_OPENAL
+#define MINI_AL_IMPLEMENTATION
 #include "external/mini_al.h"   // mini_al audio library
-                                // NOTE: Cannot be implement here because it conflicts with
-                                // Win32 APIs: Rectangle, CloseWindow(), ShowCursor(), PlaySoundA()
+#undef PlaySound                // Win32 API: windows.h > mmsystem.h defines PlaySound macro
 
 #include <stdlib.h>             // Required for: malloc(), free()
 #include <string.h>             // Required for: strcmp(), strncmp()
@@ -915,9 +918,13 @@ void ExportWaveAsCode(Wave wave, const char *fileName)
     fprintf(txtFile, "//                                                                              //\n");
     fprintf(txtFile, "//////////////////////////////////////////////////////////////////////////////////\n\n");
 
+#if !defined(RAUDIO_STANDALONE)
     // Get file name from path and convert variable name to uppercase
     strcpy(varFileName, GetFileNameWithoutExt(fileName));
     for (int i = 0; varFileName[i] != '\0'; i++) if (varFileName[i] >= 'a' && varFileName[i] <= 'z') { varFileName[i] = varFileName[i] - 32; }
+#else
+    strcpy(varFileName, fileName);
+#endif
 
     fprintf(txtFile, "// Wave data information\n");
     fprintf(txtFile, "#define %s_SAMPLE_COUNT     %i\n", varFileName, wave.sampleCount);

+ 6 - 6
src/raudio.h

@@ -11,12 +11,12 @@
 *       - Manage raw audio context
 *
 *   DEPENDENCIES:
-*       mini_al     - Audio device/context management (https://github.com/dr-soft/mini_al)
-*       stb_vorbis  - OGG audio files loading (http://www.nothings.org/stb_vorbis/)
-*       jar_xm      - XM module file loading
-*       jar_mod     - MOD audio file loading
-*       dr_flac     - FLAC audio file loading
-*       dr_mp3      - MP3 audio file loading
+*       mini_al.h    - Audio device management lib (https://github.com/dr-soft/mini_al)
+*       stb_vorbis.h - Ogg audio files loading (http://www.nothings.org/stb_vorbis/)
+*       dr_mp3.h     - MP3 audio file loading (https://github.com/mackron/dr_libs)
+*       dr_flac.h    - FLAC audio file loading (https://github.com/mackron/dr_libs)
+*       jar_xm.h     - XM module file loading
+*       jar_mod.h    - MOD audio file loading
 *
 *   CONTRIBUTORS:
 *       David Reid (github: @mackron) (Nov. 2017):