Commit a8f3cb85 authored by David Reid's avatar David Reid

Fix compilation errors with MA_NO_DEVICE_IO.

parent 563e1c52
......@@ -521,7 +521,7 @@ static ma_result ma_context_uninit__sdl(ma_context* pContext)
((MA_PFN_SDL_QuitSubSystem)pContextEx->sdl.SDL_QuitSubSystem)(MA_SDL_INIT_AUDIO);
/* Close the handle to the SDL shared object last. */
ma_dlclose(pContext, pContextEx->sdl.hSDL);
ma_dlclose(ma_context_get_log(pContext), pContextEx->sdl.hSDL);
pContextEx->sdl.hSDL = NULL;
return MA_SUCCESS;
......@@ -551,7 +551,7 @@ static ma_result ma_context_init__sdl(ma_context* pContext, const ma_context_con
/* Check if we have SDL2 installed somewhere. If not it's not usable and we need to abort. */
for (iName = 0; iName < ma_countof(pSDLNames); iName += 1) {
pContextEx->sdl.hSDL = ma_dlopen(pContext, pSDLNames[iName]);
pContextEx->sdl.hSDL = ma_dlopen(ma_context_get_log(pContext), pSDLNames[iName]);
if (pContextEx->sdl.hSDL != NULL) {
break;
}
......@@ -562,13 +562,13 @@ static ma_result ma_context_init__sdl(ma_context* pContext, const ma_context_con
}
/* Now that we have the handle to the shared object we can go ahead and load some function pointers. */
pContextEx->sdl.SDL_InitSubSystem = ma_dlsym(pContext, pContextEx->sdl.hSDL, "SDL_InitSubSystem");
pContextEx->sdl.SDL_QuitSubSystem = ma_dlsym(pContext, pContextEx->sdl.hSDL, "SDL_QuitSubSystem");
pContextEx->sdl.SDL_GetNumAudioDevices = ma_dlsym(pContext, pContextEx->sdl.hSDL, "SDL_GetNumAudioDevices");
pContextEx->sdl.SDL_GetAudioDeviceName = ma_dlsym(pContext, pContextEx->sdl.hSDL, "SDL_GetAudioDeviceName");
pContextEx->sdl.SDL_CloseAudioDevice = ma_dlsym(pContext, pContextEx->sdl.hSDL, "SDL_CloseAudioDevice");
pContextEx->sdl.SDL_OpenAudioDevice = ma_dlsym(pContext, pContextEx->sdl.hSDL, "SDL_OpenAudioDevice");
pContextEx->sdl.SDL_PauseAudioDevice = ma_dlsym(pContext, pContextEx->sdl.hSDL, "SDL_PauseAudioDevice");
pContextEx->sdl.SDL_InitSubSystem = ma_dlsym(ma_context_get_log(pContext), pContextEx->sdl.hSDL, "SDL_InitSubSystem");
pContextEx->sdl.SDL_QuitSubSystem = ma_dlsym(ma_context_get_log(pContext), pContextEx->sdl.hSDL, "SDL_QuitSubSystem");
pContextEx->sdl.SDL_GetNumAudioDevices = ma_dlsym(ma_context_get_log(pContext), pContextEx->sdl.hSDL, "SDL_GetNumAudioDevices");
pContextEx->sdl.SDL_GetAudioDeviceName = ma_dlsym(ma_context_get_log(pContext), pContextEx->sdl.hSDL, "SDL_GetAudioDeviceName");
pContextEx->sdl.SDL_CloseAudioDevice = ma_dlsym(ma_context_get_log(pContext), pContextEx->sdl.hSDL, "SDL_CloseAudioDevice");
pContextEx->sdl.SDL_OpenAudioDevice = ma_dlsym(ma_context_get_log(pContext), pContextEx->sdl.hSDL, "SDL_OpenAudioDevice");
pContextEx->sdl.SDL_PauseAudioDevice = ma_dlsym(ma_context_get_log(pContext), pContextEx->sdl.hSDL, "SDL_PauseAudioDevice");
#else
pContextEx->sdl.SDL_InitSubSystem = (ma_proc)SDL_InitSubSystem;
pContextEx->sdl.SDL_QuitSubSystem = (ma_proc)SDL_QuitSubSystem;
......@@ -581,7 +581,7 @@ static ma_result ma_context_init__sdl(ma_context* pContext, const ma_context_con
resultSDL = ((MA_PFN_SDL_InitSubSystem)pContextEx->sdl.SDL_InitSubSystem)(MA_SDL_INIT_AUDIO);
if (resultSDL != 0) {
ma_dlclose(pContext, pContextEx->sdl.hSDL);
ma_dlclose(ma_context_get_log(pContext), pContextEx->sdl.hSDL);
return MA_ERROR;
}
......
This diff is collapsed.
......@@ -37,20 +37,3 @@ ma_result ma_register_test(const char* pName, ma_test_entry_proc onEntry)
return MA_SUCCESS;
}
drwav_data_format drwav_data_format_from_minaudio_format(ma_format format, ma_uint32 channels, ma_uint32 sampleRate)
{
drwav_data_format wavFormat;
wavFormat.container = drwav_container_riff;
wavFormat.channels = channels;
wavFormat.sampleRate = sampleRate;
wavFormat.bitsPerSample = ma_get_bytes_per_sample(format) * 8;
if (format == ma_format_f32) {
wavFormat.format = DR_WAVE_FORMAT_IEEE_FLOAT;
} else {
wavFormat.format = DR_WAVE_FORMAT_PCM;
}
return wavFormat;
}
......@@ -11,12 +11,12 @@ ma_result test_noise__by_format_and_type(ma_format format, ma_noise_type type, c
printf(" %s\n", pFileName);
noiseConfig = ma_noise_config_init(format, 1, type, 0, 0.1);
result = ma_noise_init(&noiseConfig, &noise);
result = ma_noise_init(&noiseConfig, NULL, &noise);
if (result != MA_SUCCESS) {
return result;
}
encoderConfig = ma_encoder_config_init(ma_resource_format_wav, format, noiseConfig.channels, 48000);
encoderConfig = ma_encoder_config_init(ma_encoding_format_wav, format, noiseConfig.channels, 48000);
result = ma_encoder_init_file(pFileName, &encoderConfig, &encoder);
if (result != MA_SUCCESS) {
return result;
......@@ -25,8 +25,8 @@ ma_result test_noise__by_format_and_type(ma_format format, ma_noise_type type, c
/* We'll do a few seconds of data. */
for (iFrame = 0; iFrame < encoder.config.sampleRate * 10; iFrame += 1) {
ma_uint8 temp[1024];
ma_noise_read_pcm_frames(&noise, temp, 1);
ma_encoder_write_pcm_frames(&encoder, temp, 1);
ma_noise_read_pcm_frames(&noise, temp, 1, NULL);
ma_encoder_write_pcm_frames(&encoder, temp, 1, NULL);
}
ma_encoder_uninit(&encoder);
......
static drwav_data_format drwav_data_format_from_waveform_config(const ma_waveform_config* pWaveformConfig)
{
MA_ASSERT(pWaveformConfig != NULL);
return drwav_data_format_from_minaudio_format(pWaveformConfig->format, pWaveformConfig->channels, pWaveformConfig->sampleRate);
}
ma_result test_waveform__by_format_and_type(ma_format format, ma_waveform_type type, double amplitude, const char* pFileName)
{
ma_result result;
ma_waveform_config waveformConfig;
ma_waveform waveform;
drwav_data_format wavFormat;
drwav wav;
ma_encoder_config encoderConfig;
ma_encoder encoder;
ma_uint32 iFrame;
printf(" %s\n", pFileName);
......@@ -23,19 +16,22 @@ ma_result test_waveform__by_format_and_type(ma_format format, ma_waveform_type t
return result;
}
wavFormat = drwav_data_format_from_waveform_config(&waveformConfig);
if (!drwav_init_file_write(&wav, pFileName, &wavFormat, NULL)) {
return MA_ERROR; /* Could not open file for writing. */
encoderConfig = ma_encoder_config_init(ma_encoding_format_wav, waveformConfig.format, waveformConfig.channels, waveformConfig.sampleRate);
result = ma_encoder_init_file(pFileName, &encoderConfig, &encoder);
if (result != MA_SUCCESS) {
return result; /* Failed to initialize encoder. */
}
/* We'll do a few seconds of data. */
for (iFrame = 0; iFrame < wavFormat.sampleRate * 10; iFrame += 1) {
for (iFrame = 0; iFrame < waveformConfig.sampleRate * 10; iFrame += 1) {
float temp[MA_MAX_CHANNELS];
ma_waveform_read_pcm_frames(&waveform, temp, 1);
drwav_write_pcm_frames(&wav, 1, temp);
ma_waveform_read_pcm_frames(&waveform, temp, 1, NULL);
ma_encoder_write_pcm_frames(&encoder, temp, 1, NULL);
}
drwav_uninit(&wav);
ma_encoder_uninit(&encoder);
ma_waveform_uninit(&waveform);
return MA_SUCCESS;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment