Browse Source

Fix minor errors with the OpenAL backend.

pull/413/head
David Reid 8 years ago
parent
commit
322d868841
1 changed files with 22 additions and 21 deletions
  1. +22
    -21
      src/audio.c

+ 22
- 21
src/audio.c View File

@ -82,9 +82,9 @@
#include "utils.h" // Required for: fopen() Android mapping #include "utils.h" // Required for: fopen() Android mapping
#endif #endif
o">//#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.
o">//#else
cp">#include "external/mini_al.h" // Implemented in mini_al.c. Cannot implement this here because it conflicts with Win32 APIs such as CloseWindow(), etc.
cp">#if !defined(USE_MINI_AL) || USE_MINI_AL == 0
#if defined(__APPLE__) #if defined(__APPLE__)
#include "OpenAL/al.h" // OpenAL basic header #include "OpenAL/al.h" // OpenAL basic header
#include "OpenAL/alc.h" // OpenAL context header (like OpenGL, OpenAL requires a context to work) #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_FLOAT32 - Support for 32bit float samples
// OpenAL extension: AL_EXT_MCFORMATS - Support for multi-channel formats (Quad, 5.1, 6.1, 7.1) // OpenAL extension: AL_EXT_MCFORMATS - Support for multi-channel formats (Quad, 5.1, 6.1, 7.1)
o">//#endif
cp">#endif
#include <stdlib.h> // Required for: malloc(), free() #include <stdlib.h> // Required for: malloc(), free()
#include <string.h> // Required for: strcmp(), strncmp() #include <string.h> // Required for: strcmp(), strncmp()
@ -176,22 +176,6 @@ typedef struct MusicData {
unsigned int samplesLeft; // Number of samples left to end unsigned int samplesLeft; // Number of samples left to end
} MusicData; } 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) #if defined(AUDIO_STANDALONE)
typedef enum { LOG_INFO = 0, LOG_ERROR, LOG_WARNING, LOG_DEBUG, LOG_OTHER } TraceLogType; typedef enum { LOG_INFO = 0, LOG_ERROR, LOG_WARNING, LOG_DEBUG, LOG_OTHER } TraceLogType;
#endif #endif
@ -245,6 +229,22 @@ struct SoundData
mal_uint8 data[1]; // Raw audio data. 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_context context;
static mal_device device; static mal_device device;
static mal_bool32 isAudioInitialized = MAL_FALSE; static mal_bool32 isAudioInitialized = MAL_FALSE;
@ -1594,7 +1594,7 @@ float GetMusicTimePlayed(Music music)
return secondsPlayed; return secondsPlayed;
} }
#if USE_MINI_AL
static mal_uint32 UpdateAudioStream_OnDSPRead(mal_dsp* pDSP, mal_uint32 frameCount, void* pFramesOut, void* pUserData) static mal_uint32 UpdateAudioStream_OnDSPRead(mal_dsp* pDSP, mal_uint32 frameCount, void* pFramesOut, void* pUserData)
{ {
AudioStreamData* internalData = (AudioStreamData*)pUserData; AudioStreamData* internalData = (AudioStreamData*)pUserData;
@ -1652,6 +1652,7 @@ static mal_uint32 UpdateAudioStream_OnDSPRead(mal_dsp* pDSP, mal_uint32 frameCou
return frameCount; return frameCount;
} }
#endif
// Init audio stream (to stream audio pcm data) // Init audio stream (to stream audio pcm data)
AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize, unsigned int channels) AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize, unsigned int channels)

Loading…
Cancel
Save