Changed SDL_mixer version guard.

SDL_MIXER_COMPILEDVERSION is not in Windows release of mixer v2.0.1, so it is back to basics with SDL_MIXER_PATCHLEVEL.
MIX_INIT_FLUIDSYNTH was renamed in 2.0.2, according to headers from Windows releases.
Ref PR #42, #46
This commit is contained in:
Muzychenko Andrey 2021-10-17 12:00:30 +03:00
parent 787c623cfe
commit d06aa1c736
2 changed files with 9 additions and 9 deletions

View File

@ -1,21 +1,13 @@
#include "pch.h" #include "pch.h"
#include "Sound.h" #include "Sound.h"
#ifndef SDL_MIXER_VERSION_ATLEAST
#define SDL_MIXER_VERSION_ATLEAST(X, Y, Z) (SDL_MIXER_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z))
#endif
int Sound::num_channels; int Sound::num_channels;
bool Sound::enabled_flag = false; bool Sound::enabled_flag = false;
int* Sound::TimeStamps = nullptr; int* Sound::TimeStamps = nullptr;
bool Sound::Init(int channels, bool enableFlag) bool Sound::Init(int channels, bool enableFlag)
{ {
#if SDL_MIXER_VERSION_ATLEAST(2, 0, 3) Mix_Init(MIX_INIT_MID_Proxy);
Mix_Init(MIX_INIT_MID);
#else
Mix_Init(MIX_INIT_FLUIDSYNTH);
#endif
auto result = Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 2, 1024); auto result = Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 2, 1024);
SetChannels(channels); SetChannels(channels);
Enable(enableFlag); Enable(enableFlag);

View File

@ -34,6 +34,14 @@
#include "SDL.h" #include "SDL.h"
#include <SDL_mixer.h> #include <SDL_mixer.h>
// MIX_INIT_FLUIDSYNTH was renamed to MIX_INIT_MID in SDL_mixer v2.0.2
constexpr int MIX_INIT_MID_Proxy =
#if SDL_MIXER_PATCHLEVEL >= 2
MIX_INIT_MID;
#else
MIX_INIT_FLUIDSYNTH;
#endif
//https://github.com/ocornut/imgui 7b913db1ce9dd2fd98e5790aa59974dd4496be3b //https://github.com/ocornut/imgui 7b913db1ce9dd2fd98e5790aa59974dd4496be3b
#include "imgui.h" #include "imgui.h"
#include "imgui_internal.h" #include "imgui_internal.h"