int fluid_samplecache_load(SFData *sf, unsigned int sample_start, unsigned int sample_end, int sample_type, int try_mlock, short **sample_data, char **sample_data24) { fluid_samplecache_entry_t *entry; int ret; fluid_mutex_lock(samplecache_mutex); entry = get_samplecache_entry(sf, sample_start, sample_end, sample_type); if (entry == NULL) { entry = new_samplecache_entry(sf, sample_start, sample_end, sample_type); if (entry == NULL) { ret = -1; goto unlock_exit; } samplecache_list = fluid_list_prepend(samplecache_list, entry); } if (try_mlock && !entry->mlocked) { /* Lock the memory to disable paging. It's okay if this fails. It * probably means that the user doesn't have the required permission. */ if (fluid_mlock(entry->sample_data, entry->sample_count * sizeof(short)) == 0) { if (entry->sample_data24 != NULL) { entry->mlocked = (fluid_mlock(entry->sample_data24, entry->sample_count) == 0); } else { entry->mlocked = TRUE; } if (!entry->mlocked) { fluid_munlock(entry->sample_data, entry->sample_count * sizeof(short)); FLUID_LOG(FLUID_WARN, "Failed to pin the sample data to RAM; swapping is possible."); } } } entry->num_references++; *sample_data = entry->sample_data; *sample_data24 = entry->sample_data24; ret = entry->sample_count; unlock_exit: fluid_mutex_unlock(samplecache_mutex); return ret; }
/** * fluid_hashtable_get_values: * @hashtable: a #fluid_hashtable_t * * Retrieves every value inside @hashtable. The returned data is * valid until @hashtable is modified. * * Return value: a #GList containing all the values inside the hash * table. The content of the list is owned by the hash table and * should not be modified or freed. Use delete_fluid_list() when done * using the list. * * Since: 2.14 */ fluid_list_t * fluid_hashtable_get_values (fluid_hashtable_t *hashtable) { fluid_hashnode_t *node; int i; fluid_list_t *retval; fluid_return_val_if_fail (hashtable != NULL, NULL); retval = NULL; for (i = 0; i < hashtable->size; i++) for (node = hashtable->nodes[i]; node; node = node->next) retval = fluid_list_prepend (retval, node->value); return retval; }