count size of hash when value changes

This commit is contained in:
c0ntrol
2019-06-15 19:54:38 +02:00
parent 3c94ceff78
commit c043aaf493
2 changed files with 22 additions and 9 deletions

View File

@@ -71,7 +71,8 @@
#define VJ_IMAGE_EFFECT_MAX vj_effect_get_max_i() #define VJ_IMAGE_EFFECT_MAX vj_effect_get_max_i()
#define VJ_VIDEO_EFFECT_MIN vj_effect_get_min_v() #define VJ_VIDEO_EFFECT_MIN vj_effect_get_min_v()
#define VJ_VIDEO_EFFECT_MAX vj_effect_get_max_v() #define VJ_VIDEO_EFFECT_MAX vj_effect_get_max_v()
static int recount_hash = 1;
static unsigned int sample_count = 0;
static int this_sample_id = 0; /* next available sample id */ static int this_sample_id = 0; /* next available sample id */
static int next_avail_num = 0; /* available sample id */ static int next_avail_num = 0; /* available sample id */
static int initialized = 0; /* whether we are initialized or not */ static int initialized = 0; /* whether we are initialized or not */
@@ -89,8 +90,11 @@ extern int veejay_sprintf( char *s, size_t size, const char *format, ... );
unsigned int sample_size() unsigned int sample_size()
{ {
// return this_sample_id; if(recount_hash) {
return (unsigned int) hash_count( SampleHash ); sample_count = (unsigned int) hash_count( SampleHash );
recount_hash = 0;
}
return sample_count;
} }
int sample_highest() int sample_highest()
@@ -384,6 +388,8 @@ sample_info *sample_skeleton_new(long startFrame, long endFrame)
si->macro = vj_macro_new(); si->macro = vj_macro_new();
recount_hash = 1;
return si; return si;
} }
@@ -503,10 +509,6 @@ int sample_copy(int sample_id)
for (i = 0; i < SAMPLE_MAX_EFFECTS; i++) for (i = 0; i < SAMPLE_MAX_EFFECTS; i++)
{ {
// copy->effect_chain[i] =
// (sample_eff_chain *) vj_malloc(sizeof(sample_eff_chain));
//
copy->effect_chain[i] = &b[i]; copy->effect_chain[i] = &b[i];
if (copy->effect_chain[i] == NULL) if (copy->effect_chain[i] == NULL)
@@ -529,6 +531,8 @@ int sample_copy(int sample_id)
if (sample_store(copy) != 0) if (sample_store(copy) != 0)
return 0; return 0;
recount_hash = 1;
return copy->sample_id; return copy->sample_id;
} }
@@ -1077,6 +1081,8 @@ int sample_del(int sample_id)
free(si); free(si);
recount_hash = 1;
return 1; return 1;
} }

View File

@@ -61,6 +61,8 @@
#define SOURCE_NAME_LEN 255 #define SOURCE_NAME_LEN 255
#include <libplugger/plugload.h> #include <libplugger/plugload.h>
static int recount_hash = 1;
static unsigned int sample_count = 0;
static veejay_t *_tag_info = NULL; static veejay_t *_tag_info = NULL;
static hash_t *TagHash = NULL; static hash_t *TagHash = NULL;
static int this_tag_id = 0; static int this_tag_id = 0;
@@ -168,8 +170,11 @@ int vj_tag_highest_valid_id()
unsigned int vj_tag_size() unsigned int vj_tag_size()
{ {
// return this_tag_id; if(recount_hash) {
return (unsigned int) hash_count( TagHash ); sample_count = (unsigned int) hash_count( TagHash );
recount_hash = 0;
}
return sample_count;
} }
void vj_tag_set_veejay_t(void *info) { void vj_tag_set_veejay_t(void *info) {
@@ -1170,6 +1175,7 @@ int vj_tag_new(int type, char *filename, int stream_nr, editlist * el, int pix_f
tag->macro = vj_macro_new(); tag->macro = vj_macro_new();
tag_cache[ tag->id ] = (void*) tag; tag_cache[ tag->id ] = (void*) tag;
recount_hash = 1;
return (int)(tag->id); return (int)(tag->id);
} }
@@ -1383,6 +1389,7 @@ int vj_tag_del(int id)
next_avail_tag++; next_avail_tag++;
tag_cache[ id ] = NULL; tag_cache[ id ] = NULL;
recount_hash = 1;
return 1; return 1;
} }