From c043aaf493c53a192645ece545a926ec94e62be0 Mon Sep 17 00:00:00 2001 From: c0ntrol Date: Sat, 15 Jun 2019 19:54:38 +0200 Subject: [PATCH] count size of hash when value changes --- .../veejay-server/libsample/sampleadm.c | 20 ++++++++++++------- .../veejay-server/libstream/vj-tag.c | 11 ++++++++-- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/veejay-current/veejay-server/libsample/sampleadm.c b/veejay-current/veejay-server/libsample/sampleadm.c index 1bf5b7e2..8b43c3df 100644 --- a/veejay-current/veejay-server/libsample/sampleadm.c +++ b/veejay-current/veejay-server/libsample/sampleadm.c @@ -71,7 +71,8 @@ #define VJ_IMAGE_EFFECT_MAX vj_effect_get_max_i() #define VJ_VIDEO_EFFECT_MIN vj_effect_get_min_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 next_avail_num = 0; /* available sample id */ 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() { -// return this_sample_id; - return (unsigned int) hash_count( SampleHash ); + if(recount_hash) { + sample_count = (unsigned int) hash_count( SampleHash ); + recount_hash = 0; + } + return sample_count; } int sample_highest() @@ -384,6 +388,8 @@ sample_info *sample_skeleton_new(long startFrame, long endFrame) si->macro = vj_macro_new(); + recount_hash = 1; + return si; } @@ -503,10 +509,6 @@ int sample_copy(int sample_id) 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]; if (copy->effect_chain[i] == NULL) @@ -529,6 +531,8 @@ int sample_copy(int sample_id) if (sample_store(copy) != 0) return 0; + recount_hash = 1; + return copy->sample_id; } @@ -1077,6 +1081,8 @@ int sample_del(int sample_id) free(si); + recount_hash = 1; + return 1; } diff --git a/veejay-current/veejay-server/libstream/vj-tag.c b/veejay-current/veejay-server/libstream/vj-tag.c index 265e7959..29a9d1cc 100644 --- a/veejay-current/veejay-server/libstream/vj-tag.c +++ b/veejay-current/veejay-server/libstream/vj-tag.c @@ -61,6 +61,8 @@ #define SOURCE_NAME_LEN 255 #include +static int recount_hash = 1; +static unsigned int sample_count = 0; static veejay_t *_tag_info = NULL; static hash_t *TagHash = NULL; static int this_tag_id = 0; @@ -168,8 +170,11 @@ int vj_tag_highest_valid_id() unsigned int vj_tag_size() { -// return this_tag_id; - return (unsigned int) hash_count( TagHash ); + if(recount_hash) { + sample_count = (unsigned int) hash_count( TagHash ); + recount_hash = 0; + } + return sample_count; } 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_cache[ tag->id ] = (void*) tag; + recount_hash = 1; return (int)(tag->id); } @@ -1383,6 +1389,7 @@ int vj_tag_del(int id) next_avail_tag++; tag_cache[ id ] = NULL; + recount_hash = 1; return 1; }