Go to the documentation of this file.
28 # define MA_NO_PULSEAUDIO
32 #define DR_FLAC_IMPLEMENTATION
34 #define DR_MP3_IMPLEMENTATION
36 #define DR_WAV_IMPLEMENTATION
41 #define MINIAUDIO_IMPLEMENTATION
44 #include "../client/client.h"
62 static UInt32 GetBytesPerSampleFrame()
64 AudioDeviceID outputDeviceID;
65 AudioStreamBasicDescription outputStreamBasicDescription;
66 AudioObjectPropertyAddress propertyAddress = {
67 kAudioHardwarePropertyDefaultOutputDevice,
68 kAudioObjectPropertyScopeOutput,
69 kAudioObjectPropertyElementMaster
72 UInt32 propertySize =
sizeof(outputDeviceID);
73 OSStatus status = AudioObjectGetPropertyData(kAudioObjectSystemObject, &propertyAddress, 0,
NULL, &propertySize, &outputDeviceID);
74 if (status != kAudioHardwareNoError) {
75 Com_Printf(
"AudioHardwareGetProperty returned %d\n", status);
79 propertySize =
sizeof(outputStreamBasicDescription);
80 propertyAddress.mSelector = kAudioDevicePropertyStreamFormat;
81 status = AudioObjectGetPropertyData(outputDeviceID, &propertyAddress, 0,
NULL, &propertySize, &outputStreamBasicDescription);
82 if (status != kAudioHardwareNoError) {
83 Com_Printf(
"AudioDeviceGetProperty: returned %d when getting kAudioDevicePropertyStreamFormat\n", status);
87 return outputStreamBasicDescription.mBytesPerFrame;
94 if (pDecoder ==
NULL) {
204 bufferSizeInFrames =
Cvar_VariableValue(
"s_chunksize") *
sizeof(float) / GetBytesPerSampleFrame();
213 static char *trackExts[] = {
"ogg",
"flac",
"mp3",
"wav" };
218 Com_sprintf(trackPath,
sizeof(trackPath),
"%s/music/track%s%i.%s", gamedir, track < 10 ?
"0" :
"", track, trackExts[trackExtIdx]);
220 }
while (result !=
MA_SUCCESS && ++trackExtIdx < 4);
249 Com_Printf(
"Failed to open %s/music/track%s%i.[ogg/flac/mp3/wav]: error %i\n",
FS_Gamedir(), track < 10 ?
"0" :
"", track, result);
265 Com_Printf(
"Failed to open playback device: error %i\n", result);
271 Com_Printf(
"Failed to start playback device: error %i\n", result);
static ma_result LoadTrack(const char *gamedir, int track)
static qboolean trackFinished
static ma_decoder decoder
static void Miniaudio_Pause(void)
void Miniaudio_Play(int track, qboolean looping)
const char * ma_get_backend_name(ma_backend backend)
ma_result ma_device_stop(ma_device *pDevice)
void Miniaudio_Shutdown(void)
ma_device_config ma_device_config_init(ma_device_type deviceType)
ma_result ma_device_start(ma_device *pDevice)
ma_device_callback_proc dataCallback
cvar_t * Cvar_Get(char *var_name, char *var_value, int flags)
ma_uint64 ma_decoder_read_pcm_frames(ma_decoder *pDecoder, void *pFramesOut, ma_uint64 frameCount)
void Cmd_RemoveCommand(char *cmd_name)
static void Miniaudio_Resume(void)
void ma_device_uninit(ma_device *pDevice)
void Cmd_AddCommand(char *cmd_name, xcommand_t function)
ma_result ma_device_init(ma_context *pContext, const ma_device_config *pConfig, ma_device *pDevice)
static cvar_t * cd_loopcount
void Miniaudio_Stop(void)
ma_result ma_decoder_init_file(const char *pFilePath, const ma_decoder_config *pConfig, ma_decoder *pDecoder)
int Q_stricmp(char *s1, char *s2)
@ ma_device_type_playback
ma_uint32 bufferSizeInFrames
ma_bool32 ma_device_is_started(ma_device *pDevice)
static qboolean playLooping
static void data_callback(ma_device *pDevice, void *pOutput, const void *pInput, ma_uint32 frameCount)
ma_result ma_decoder_uninit(ma_decoder *pDecoder)
struct ma_device ma_device
char configstrings[MAX_CONFIGSTRINGS][MAX_QPATH]
void Miniaudio_Update(void)
void Com_Printf(char *fmt,...)
int Q_strcasecmp(char *s1, char *s2)
static cvar_t * cd_looptrack
void Miniaudio_Init(void)
static void Miniaudio_f(void)
struct ma_device_config::@28 playback
void Com_sprintf(char *dest, int size, char *fmt,...)
void(APIENTRY *qglAccum)(GLenum op
ma_result ma_decoder_seek_to_pcm_frame(ma_decoder *pDecoder, ma_uint64 frameIndex)
ma_uint32 outputSampleRate
float Cvar_VariableValue(char *var_name)