mirror of
https://github.com/ZDoom/fluidsynth.git
synced 2024-11-10 06:51:54 +00:00
Add a unit test for issue 733
This commit is contained in:
parent
17dfadbd0b
commit
03cf8e28f6
3 changed files with 100 additions and 0 deletions
|
@ -907,6 +907,10 @@ fluid_settings_get_hints(fluid_settings_t *settings, const char *name, int *hint
|
|||
* @param settings a settings object
|
||||
* @param name a setting's name
|
||||
* @return TRUE if the setting is changeable in real-time, FALSE otherwise
|
||||
*
|
||||
* @note Before using this function, make sure the @p settings object has already been used to create
|
||||
* a synthesizer, a MIDI driver, an audio driver, a MIDI player, or a command handler (depending on
|
||||
* which settings you want to query).
|
||||
*/
|
||||
int
|
||||
fluid_settings_is_realtime(fluid_settings_t *settings, const char *name)
|
||||
|
|
|
@ -12,6 +12,7 @@ ADD_FLUID_TEST(test_sfont_loading)
|
|||
ADD_FLUID_TEST(test_sample_rate_change)
|
||||
ADD_FLUID_TEST(test_preset_sample_loading)
|
||||
ADD_FLUID_TEST(test_bug_635)
|
||||
ADD_FLUID_TEST(test_settings_unregister_callback)
|
||||
ADD_FLUID_TEST(test_pointer_alignment)
|
||||
ADD_FLUID_TEST(test_seqbind_unregister)
|
||||
ADD_FLUID_TEST(test_synth_chorus_reverb)
|
||||
|
|
95
test/test_settings_unregister_callback.c
Normal file
95
test/test_settings_unregister_callback.c
Normal file
|
@ -0,0 +1,95 @@
|
|||
|
||||
#include "test.h"
|
||||
#include "fluidsynth.h"
|
||||
#include "fluidsynth_priv.h"
|
||||
#include "fluid_synth.h"
|
||||
#include <string.h>
|
||||
|
||||
static fluid_list_t* realtime_int_settings = NULL;
|
||||
static fluid_list_t* realtime_str_settings = NULL;
|
||||
static fluid_list_t* realtime_num_settings = NULL;
|
||||
|
||||
void iter_func (void *data, const char *name, int type)
|
||||
{
|
||||
if(fluid_settings_is_realtime(data, name))
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case FLUID_INT_TYPE:
|
||||
realtime_int_settings = fluid_list_prepend(realtime_int_settings, FLUID_STRDUP(name));
|
||||
break;
|
||||
case FLUID_STR_TYPE:
|
||||
realtime_str_settings = fluid_list_prepend(realtime_str_settings, FLUID_STRDUP(name));
|
||||
break;
|
||||
case FLUID_NUM_TYPE:
|
||||
realtime_num_settings = fluid_list_prepend(realtime_num_settings, FLUID_STRDUP(name));
|
||||
break;
|
||||
case FLUID_SET_TYPE:
|
||||
break;
|
||||
default:
|
||||
TEST_ASSERT(FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// this test should make sure that sample rate changed are handled correctly
|
||||
int main(void)
|
||||
{
|
||||
fluid_list_t* list;
|
||||
fluid_player_t* player;
|
||||
fluid_synth_t *synth;
|
||||
fluid_settings_t *settings = new_fluid_settings();
|
||||
TEST_ASSERT(settings != NULL);
|
||||
|
||||
synth = new_fluid_synth(settings);
|
||||
TEST_ASSERT(synth != NULL);
|
||||
|
||||
player = new_fluid_player(synth);
|
||||
TEST_ASSERT(player != NULL);
|
||||
|
||||
// see which of the objects above has registered a realtime setting
|
||||
fluid_settings_foreach(settings, settings, iter_func);
|
||||
|
||||
// delete the objects
|
||||
delete_fluid_player(player);
|
||||
delete_fluid_synth(synth);
|
||||
|
||||
// and now, start making changes to those realtime settings
|
||||
// Anything below fluidsynth 2.1.5 will crash
|
||||
|
||||
for(list = realtime_int_settings; list; list = fluid_list_next(list))
|
||||
{
|
||||
int min, max;
|
||||
char* name = fluid_list_get(list);
|
||||
TEST_SUCCESS(fluid_settings_getint_range(settings, name, &min, &max));
|
||||
TEST_SUCCESS(fluid_settings_setint(settings, name, min));
|
||||
FLUID_FREE(name);
|
||||
}
|
||||
|
||||
delete_fluid_list(realtime_int_settings);
|
||||
|
||||
for(list = realtime_num_settings; list; list = fluid_list_next(list))
|
||||
{
|
||||
double min, max;
|
||||
char* name = fluid_list_get(list);
|
||||
TEST_SUCCESS(fluid_settings_getnum_range(settings, name, &min, &max));
|
||||
TEST_SUCCESS(fluid_settings_setnum(settings, name, min));
|
||||
FLUID_FREE(name);
|
||||
}
|
||||
|
||||
delete_fluid_list(realtime_num_settings);
|
||||
|
||||
|
||||
for(list = realtime_str_settings; list; list = fluid_list_next(list))
|
||||
{
|
||||
char* name = fluid_list_get(list);
|
||||
TEST_SUCCESS(fluid_settings_setstr(settings, name, "ABCDEFG"));
|
||||
FLUID_FREE(name);
|
||||
}
|
||||
|
||||
delete_fluid_list(realtime_str_settings);
|
||||
|
||||
delete_fluid_settings(settings);
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
Loading…
Reference in a new issue