Skip to content

Commit

Permalink
Changed SDL_mixer version guard.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
k4zmu2a committed Oct 17, 2021
1 parent 787c623 commit d06aa1c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 1 addition & 9 deletions SpaceCadetPinball/Sound.cpp
@@ -1,21 +1,13 @@
#include "pch.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;
bool Sound::enabled_flag = false;
int* Sound::TimeStamps = nullptr;

bool Sound::Init(int channels, bool enableFlag)
{
#if SDL_MIXER_VERSION_ATLEAST(2, 0, 3)
Mix_Init(MIX_INIT_MID);
#else
Mix_Init(MIX_INIT_FLUIDSYNTH);
#endif
Mix_Init(MIX_INIT_MID_Proxy);
auto result = Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 2, 1024);
SetChannels(channels);
Enable(enableFlag);
Expand Down
8 changes: 8 additions & 0 deletions SpaceCadetPinball/pch.h
Expand Up @@ -34,6 +34,14 @@
#include "SDL.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
#include "imgui.h"
#include "imgui_internal.h"
Expand Down

0 comments on commit d06aa1c

Please sign in to comment.