fluidsynth/test/test_jack_obtaining_synth.c
Tom M 3610372ae5
Workaround for jack sample rate mismatch (#607)
During the creation of a jack audio driver, it is checked whether the sample-rate of the settings object matches jack's rate. If not, it was adjusted previously via fluid_synth_set_sample_rate(). Due to the deprecation of that function and removal of real-time capability of the synth.sample-rate setting, a regression was introduced in 5fbddcecc3 causing the synth's sample-rate to be not updated.

This workaround obtains the synth via the settings instance and for now calls the deprecated sample-rate set function.
2020-01-19 15:36:15 +01:00

34 lines
1.1 KiB
C

#include "test.h"
#include "fluidsynth.h"
#include "fluid_adriver.h"
// The jack driver may need the synth instance to adjust the sample-rate in case it mismatches with
// the sample-rate of the jack driver. However, new_fluid_audio_driver2() does not receive a synth pointer.
// Thus looking up the synth instance must be done via the settings object.
int main(void)
{
#if JACK_SUPPORT
fluid_synth_t *obtained_synth;
fluid_synth_t *expected_synth;
fluid_settings_t *settings = new_fluid_settings();
TEST_ASSERT(settings != NULL);
expected_synth = new_fluid_synth(settings);
TEST_ASSERT(expected_synth != NULL);
TEST_SUCCESS(fluid_jack_obtain_synth(settings, &obtained_synth));
TEST_ASSERT(obtained_synth == expected_synth);
delete_fluid_synth(obtained_synth);
delete_fluid_settings(settings);
obtained_synth = expected_synth = NULL;
settings = new_fluid_settings();
TEST_ASSERT(settings != NULL);
TEST_ASSERT(fluid_jack_obtain_synth(settings, &obtained_synth) == FLUID_FAILED);
delete_fluid_settings(settings);
#endif
return EXIT_SUCCESS;
}