summaryrefslogtreecommitdiffhomepage
path: root/src/audio.c
diff options
context:
space:
mode:
authorDavid Reid <[email protected]>2017-11-14 21:44:57 +1000
committerDavid Reid <[email protected]>2017-11-14 21:44:57 +1000
commit322d868841493e1da6455a7153b4930b284c46df (patch)
tree52a39d3647a5d0bd9b0f4e68881fe7148fc6fa18 /src/audio.c
parent88d2810fa3d6c87eeec673c54788a6f39e15f77a (diff)
downloadraylib-322d868841493e1da6455a7153b4930b284c46df.tar.gz
raylib-322d868841493e1da6455a7153b4930b284c46df.zip
Fix minor errors with the OpenAL backend.
Diffstat (limited to 'src/audio.c')
-rw-r--r--src/audio.c43
1 files changed, 22 insertions, 21 deletions
diff --git a/src/audio.c b/src/audio.c
index 48e33d19..f159222d 100644
--- a/src/audio.c
+++ b/src/audio.c
@@ -82,9 +82,9 @@
#include "utils.h" // Required for: fopen() Android mapping
#endif
-//#if USE_MINI_AL
- #include "external/mini_al.h" // Implemented in mini_al.c. Cannot implement this here because it conflicts with Win32 APIs such as CloseWindow(), etc.
-//#else
+#include "external/mini_al.h" // Implemented in mini_al.c. Cannot implement this here because it conflicts with Win32 APIs such as CloseWindow(), etc.
+
+#if !defined(USE_MINI_AL) || USE_MINI_AL == 0
#if defined(__APPLE__)
#include "OpenAL/al.h" // OpenAL basic header
#include "OpenAL/alc.h" // OpenAL context header (like OpenGL, OpenAL requires a context to work)
@@ -96,7 +96,7 @@
// OpenAL extension: AL_EXT_FLOAT32 - Support for 32bit float samples
// OpenAL extension: AL_EXT_MCFORMATS - Support for multi-channel formats (Quad, 5.1, 6.1, 7.1)
-//#endif
+#endif
#include <stdlib.h> // Required for: malloc(), free()
#include <string.h> // Required for: strcmp(), strncmp()
@@ -176,22 +176,6 @@ typedef struct MusicData {
unsigned int samplesLeft; // Number of samples left to end
} MusicData;
-// AudioStreamData
-typedef struct AudioStreamData AudioStreamData;
-struct AudioStreamData {
- mal_dsp dsp; // AudioStream data needs to flow through a persistent conversion pipeline. Not doing this will result in glitches between buffer updates.
- float volume;
- float pitch;
- bool playing;
- bool paused;
- bool isSubBufferProcessed[2];
- unsigned int frameCursorPos;
- unsigned int bufferSizeInFrames;
- AudioStreamData* next;
- AudioStreamData* prev;
- unsigned char buffer[1];
-};
-
#if defined(AUDIO_STANDALONE)
typedef enum { LOG_INFO = 0, LOG_ERROR, LOG_WARNING, LOG_DEBUG, LOG_OTHER } TraceLogType;
#endif
@@ -245,6 +229,22 @@ struct SoundData
mal_uint8 data[1]; // Raw audio data.
};
+// AudioStreamData
+typedef struct AudioStreamData AudioStreamData;
+struct AudioStreamData {
+ mal_dsp dsp; // AudioStream data needs to flow through a persistent conversion pipeline. Not doing this will result in glitches between buffer updates.
+ float volume;
+ float pitch;
+ bool playing;
+ bool paused;
+ bool isSubBufferProcessed[2];
+ unsigned int frameCursorPos;
+ unsigned int bufferSizeInFrames;
+ AudioStreamData* next;
+ AudioStreamData* prev;
+ unsigned char buffer[1];
+};
+
static mal_context context;
static mal_device device;
static mal_bool32 isAudioInitialized = MAL_FALSE;
@@ -1594,7 +1594,7 @@ float GetMusicTimePlayed(Music music)
return secondsPlayed;
}
-
+#if USE_MINI_AL
static mal_uint32 UpdateAudioStream_OnDSPRead(mal_dsp* pDSP, mal_uint32 frameCount, void* pFramesOut, void* pUserData)
{
AudioStreamData* internalData = (AudioStreamData*)pUserData;
@@ -1652,6 +1652,7 @@ static mal_uint32 UpdateAudioStream_OnDSPRead(mal_dsp* pDSP, mal_uint32 frameCou
return frameCount;
}
+#endif
// Init audio stream (to stream audio pcm data)
AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize, unsigned int channels)