fluidsynth/src/utils/fluid_hash.h

132 lines
5.1 KiB
C
Raw Normal View History

2003-03-11 16:56:45 +00:00
/* GLIB - Library of useful routines for C programming
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02110-1301, USA.
2003-03-11 16:56:45 +00:00
*/
/*
* Modified by the GLib Team and others 1997-2000. See the AUTHORS
* file for a list of people on the GLib Team. See the ChangeLog
* files for a list of changes. These files are distributed with
* GLib at ftp://ftp.gtk.org/pub/gtk/.
2003-03-11 16:56:45 +00:00
*/
/*
* Adapted for FluidSynth use by Josh Green <jgreen@users.sourceforge.net>
* September 8, 2009 from glib 2.18.4
*
* - Self contained (no dependencies on glib)
2003-03-11 16:56:45 +00:00
* - changed names to fluid_hashtable_...
*/
#ifndef _FLUID_HASH_H
#define _FLUID_HASH_H
#include "fluidsynth_priv.h"
#include "fluid_list.h"
#include "fluid_sys.h"
/* Extracted from gtypes.h */
typedef void (*fluid_destroy_notify_t)(void *data);
typedef unsigned int (*fluid_hash_func_t)(const void *key);
typedef int (*fluid_equal_func_t)(const void *a, const void *b);
/* End gtypes.h extraction */
typedef int (*fluid_hr_func_t)(void *key, void *value, void *user_data);
typedef struct _fluid_hashtable_iter_t fluid_hashtable_iter_t;
typedef struct _fluid_hashnode_t fluid_hashnode_t;
struct _fluid_hashnode_t
{
void *key;
void *value;
fluid_hashnode_t *next;
unsigned int key_hash;
};
2003-03-11 16:56:45 +00:00
struct _fluid_hashtable_t
{
int size;
int nnodes;
fluid_hashnode_t **nodes;
fluid_hash_func_t hash_func;
fluid_equal_func_t key_equal_func;
fluid_atomic_int_t ref_count;
fluid_destroy_notify_t key_destroy_func;
fluid_destroy_notify_t value_destroy_func;
Added public API functions: fluid_synth_sysex, fluid_synth_activate_key_tuning, fluid_synth_activate_octave_tuning, fluid_synth_tune_notes, fluid_synth_activate_tuning and fluid_synth_deactivate_tuning. Added audio.realtime, audio.realtime-prio, midi.realtime and midi.realtime-prio (only ALSA updated to use them at this point). Fixed bug in new_fluid_channel() where tuning field was not initialized. fluid_settings.h had wrong field order in prototypes for fluid_settings_register_num and fluid_settings_register_int. Added multi core support: "synth.cpu-cores" setting, fluid_synth_core_thread_func() and many core_ variables to fluid_synth_t. Switched fluid_mutex_t back to a normal non-recursive mutex and added fluid_rec_mutex_t. Added fluid_cond_t thread synchronization stuff. Added fluid_cond_mutex_t which is a dynamically allocated regular mutex for use with fluid_cond_t. fluid_settings_t and fluid_synth_t are now using fluid_rec_mutex_t (same as before, just name change). Added platform specific fluid_thread_self_set_prio() functions to fluid_sys.c for activating high priority for the calling thread. Modified new_fluid_thread() to take a prio and prio_level parameters. Added missing fluid_atomic_pointer_set(). fluid_voice_write() changed to only take a voice audio buffer to render to, mixing is done separately with new fluid_voice_mix(). fluid_voice_write() now returns the count of samples rendered. fluid_voice_effects() split into fluid_voice_filter() and fluid_voice_mix(). Added dsp_buf_count field to fluid_voice_t to keep track of last count of samples rendered to dsp_buf. fluid_voice_get_channel() converted to a macro. Added FLUID_DEFAULT_AUDIO_RT_PRIO and FLUID_DEFAULT_MIDI_RT_PRIO in fluidsynth_priv.h, set to 90 and 80 respectively which get used for audio.realtime-prio and midi.realtime-prio (was 90 and 90 before).
2009-09-29 21:40:28 +00:00
fluid_rec_mutex_t mutex; // Optionally used in other modules (fluid_settings.c for example)
};
2003-03-11 16:56:45 +00:00
struct _fluid_hashtable_iter_t
{
/*< private >*/
void * dummy1;
void * dummy2;
void * dummy3;
int dummy4;
int dummy5; // Bool
void * dummy6;
};
2003-03-11 16:56:45 +00:00
fluid_hashtable_t* new_fluid_hashtable (fluid_hash_func_t hash_func,
fluid_equal_func_t key_equal_func);
fluid_hashtable_t* new_fluid_hashtable_full (fluid_hash_func_t hash_func,
fluid_equal_func_t key_equal_func,
fluid_destroy_notify_t key_destroy_func,
fluid_destroy_notify_t value_destroy_func);
void delete_fluid_hashtable(fluid_hashtable_t *hashtable);
2003-03-11 16:56:45 +00:00
void fluid_hashtable_iter_init (fluid_hashtable_iter_t *iter, fluid_hashtable_t *hashtable);
int fluid_hashtable_iter_next (fluid_hashtable_iter_t *iter, void **key, void **value);
fluid_hashtable_t *fluid_hashtable_iter_get_hash_table (fluid_hashtable_iter_t *iter);
void fluid_hashtable_iter_remove (fluid_hashtable_iter_t *iter);
void fluid_hashtable_iter_steal (fluid_hashtable_iter_t *iter);
2003-03-11 16:56:45 +00:00
fluid_hashtable_t* fluid_hashtable_ref (fluid_hashtable_t *hashtable);
void fluid_hashtable_unref (fluid_hashtable_t *hashtable);
2003-03-11 16:56:45 +00:00
void *fluid_hashtable_lookup (fluid_hashtable_t *hashtable, const void *key);
int fluid_hashtable_lookup_extended (fluid_hashtable_t *hashtable, const void *lookup_key,
void **orig_key, void **value);
2003-03-11 16:56:45 +00:00
void fluid_hashtable_insert (fluid_hashtable_t *hashtable, void *key, void *value);
void fluid_hashtable_replace (fluid_hashtable_t *hashtable, void *key, void *value);
2003-03-11 16:56:45 +00:00
int fluid_hashtable_remove (fluid_hashtable_t *hashtable, const void *key);
int fluid_hashtable_steal (fluid_hashtable_t *hashtable, const void *key);
void fluid_hashtable_remove_all (fluid_hashtable_t *hashtable);
void fluid_hashtable_steal_all (fluid_hashtable_t *hashtable);
unsigned int fluid_hashtable_foreach_steal (fluid_hashtable_t *hashtable,
fluid_hr_func_t func, void *user_data);
void fluid_hashtable_foreach (fluid_hashtable_t *hashtable, fluid_hr_func_t func,
void *user_data);
void *fluid_hashtable_find (fluid_hashtable_t *hashtable, fluid_hr_func_t predicate,
void *user_data);
unsigned int fluid_hashtable_size (fluid_hashtable_t *hashtable);
fluid_list_t *fluid_hashtable_get_keys (fluid_hashtable_t *hashtable);
fluid_list_t *fluid_hashtable_get_values (fluid_hashtable_t *hashtable);
2003-03-11 16:56:45 +00:00
int fluid_str_equal (const void *v1, const void *v2);
unsigned int fluid_str_hash (const void *v);
int fluid_direct_equal (const void *v1, const void *v2);
unsigned int fluid_direct_hash (const void *v);
int fluid_int_equal (const void *v1, const void *v2);
unsigned int fluid_int_hash (const void *v);
2003-03-11 16:56:45 +00:00
#endif /* _FLUID_HASH_H */