Backwards compatibility with older libopenmpt versions than 0.5

This commit is contained in:
GrimReaperFloof 2021-05-24 16:52:30 +02:00
parent 9e407f5989
commit dc5b9d989b
2 changed files with 11 additions and 0 deletions

View File

@ -18,6 +18,7 @@
*/
#include "OpenmptDecoderPlugin.hxx"
#include "decoder/Features.h"
#include "ModCommon.hxx"
#include "../DecoderAPI.hxx"
#include "input/InputStream.hxx"
@ -43,7 +44,9 @@ static bool openmpt_override_mptm_interp_filter;
static int openmpt_volume_ramping;
static bool openmpt_sync_samples;
static bool openmpt_emulate_amiga;
#ifdef HAVE_LIBOPENMPT_VERSION_0_5
static std::string_view openmpt_emulate_amiga_type;
#endif
static bool
openmpt_decoder_init(const ConfigBlock &block)
@ -54,7 +57,9 @@ openmpt_decoder_init(const ConfigBlock &block)
openmpt_volume_ramping = block.GetBlockValue("volume_ramping", -1);
openmpt_sync_samples = block.GetBlockValue("sync_samples", true);
openmpt_emulate_amiga = block.GetBlockValue("emulate_amiga", true);
#ifdef HAVE_LIBOPENMPT_VERSION_0_5
openmpt_emulate_amiga_type = block.GetBlockValue("emulate_amiga_type", "auto");
#endif
return true;
}
@ -83,9 +88,14 @@ mod_decode(DecoderClient &client, InputStream &is)
mod.set_render_param(mod.RENDER_INTERPOLATIONFILTER_LENGTH, 0);
}
mod.set_render_param(mod.RENDER_VOLUMERAMPING_STRENGTH, openmpt_volume_ramping);
#ifdef HAVE_LIBOPENMPT_VERSION_0_5
mod.ctl_set_boolean("seek.sync_samples", openmpt_sync_samples);
mod.ctl_set_boolean("render.resampler.emulate_amiga", openmpt_emulate_amiga);
mod.ctl_set_text("render.resampler.emulate_amiga_type", openmpt_emulate_amiga_type);
#else
mod.ctl_set("seek.sync_samples", std::to_string(openmpt_sync_samples));
mod.ctl_set("render.resampler.emulate_amiga", std::to_string(openmpt_emulate_amiga));
#endif
static constexpr AudioFormat audio_format(OPENMPT_SAMPLE_RATE, SampleFormat::FLOAT, 2);
assert(audio_format.IsValid());

View File

@ -110,6 +110,7 @@ endif
libopenmpt_dep = dependency('libopenmpt', required: get_option('openmpt'))
decoder_features.set('ENABLE_OPENMPT', libopenmpt_dep.found())
decoder_features.set('HAVE_LIBOPENMPT_VERSION_0_5', libopenmpt_dep.version().version_compare('>= 0.5'))
if libopenmpt_dep.found()
decoder_plugins_sources += [
'OpenmptDecoderPlugin.cxx',