diff --git a/veejay-current/veejay-client/configure.ac b/veejay-current/veejay-client/configure.ac index ed302e6a..38449f42 100644 --- a/veejay-current/veejay-client/configure.ac +++ b/veejay-current/veejay-client/configure.ac @@ -1,12 +1,12 @@ dnl Process this file with autoconf to produce a configure script. dnl AC_INIT -AC_INIT([reloaded],[1.5.3],[nwelburg@gmail.com]) +AC_INIT([reloaded],[1.5.5],[nwelburg@gmail.com]) AC_PREREQ(2.57) AC_CONFIG_SRCDIR([src/gveejay.c]) RELOADED_MAJOR_VERSION=1 RELOADED_MINOR_VERSION=5 -RELOADED_MICRO_VERSION=2 +RELOADED_MICRO_VERSION=5 RELOADED_VERSION=$VEEJAY_MAJOR_VERSION.$VEEJAY_MINOR_VERSION.$VEEJAY_MICRO_VERSION RELOADED_CODENAME="Reloaded - build $RELOADED_MAJOR_VERSION $RELOADED_MINOR_VERSION $RELOADED_MICRO_VERSION" AC_CONFIG_HEADERS([config.h]) diff --git a/veejay-current/veejay-client/src/callback.c b/veejay-current/veejay-client/src/callback.c index a75afe07..1e091f95 100644 --- a/veejay-current/veejay-client/src/callback.c +++ b/veejay-current/veejay-client/src/callback.c @@ -824,7 +824,7 @@ void on_spin_samplespeed_value_changed(GtkWidget *widget, gpointer user_data) gint value = (gint) gtk_spin_button_get_value( GTK_SPIN_BUTTON(widget) ); value *= info->play_direction; multi_vims( VIMS_SAMPLE_SET_SPEED, "%d %d",0, value ); - vj_midi_learning_vims_spin( info->midi, "samplespeed", VIMS_SAMPLE_SET_SPEED ); + vj_midi_learning_vims_complex( info->midi, "spin_samplespeed", VIMS_SAMPLE_SET_SPEED,0,2 ); vj_msg(VEEJAY_MSG_INFO, "Change video playback speed to %d", value ); } diff --git a/veejay-current/veejay-client/src/vj-api.c b/veejay-current/veejay-client/src/vj-api.c index da6831d4..5f8cc906 100644 --- a/veejay-current/veejay-client/src/vj-api.c +++ b/veejay-current/veejay-client/src/vj-api.c @@ -6393,8 +6393,8 @@ void vj_gui_free() } info = NULL; - vevo_port_free( fx_list_ ); - vevo_port_free( bankport_ ); + vpf( fx_list_ ); + vpf( bankport_ ); } void vj_gui_style_setup() diff --git a/veejay-current/veejay-client/src/vj-midi.c b/veejay-current/veejay-client/src/vj-midi.c index bfb8a147..70c5fff5 100644 --- a/veejay-current/veejay-client/src/vj-midi.c +++ b/veejay-current/veejay-client/src/vj-midi.c @@ -189,6 +189,11 @@ void vj_midi_load(void *vv, const char *filename) char widget[100]; char message[512]; int extra = 0; + + veejay_memset( key,0,sizeof(key)); + veejay_memset( widget,0,sizeof(widget)); + veejay_memset( message,0,sizeof(message)); + if(sscanf( value, "%s %d %s \"%[^\"]", key, &extra, widget, message ) == 4 ) { veejay_memset( value,0,sizeof(value)); @@ -207,9 +212,6 @@ void vj_midi_load(void *vv, const char *filename) free(cur); } int error = vevo_property_set( v->vims, key, 1, VEVO_ATOM_TYPE_VOIDPTR, &d); - veejay_memset( key,0,sizeof(key)); - veejay_memset( widget,0,sizeof(widget)); - veejay_memset( message,0,sizeof(message)); count ++; } @@ -366,7 +368,7 @@ static void queue_vims_event( vmidi_t *v, int *data ) return; } - snprintf(key,sizeof(key), "%03d%03d", data[0],data[1] ); + snprintf(key,sizeof(key), "%03d%03d", data[0],data[1] ); //@ event key is midi event type + midi control/param id dvims_t *d = NULL; int error = vevo_property_get( v->vims, key, 0, &d); @@ -384,6 +386,7 @@ static void queue_vims_event( vmidi_t *v, int *data ) { GtkAdjustment *a = gtk_range_get_adjustment( GTK_RANGE( glade_xml_get_widget_( v->mw, d->widget ) ) ); + min = a->lower; max = a->upper; } @@ -395,19 +398,20 @@ static void queue_vims_event( vmidi_t *v, int *data ) break; } +#ifdef STRICT_CHECKING + veejay_msg(VEEJAY_MSG_DEBUG, "bounds are %g - %g (type=%d)",min,max,d->extra ); +#endif + if( data[0] == SND_SEQ_EVENT_PITCHBEND ) { - tmp = 16384.0 / max; - val = data[2] + 8192; - if( val > 0 ) - val = val / tmp; +// val = ((max-min)/16384.0)*data[2] + min; //@ scale min-max to -8192-8192 + val = ( (data[2]/16384.0f) * (max-min) ); + } else if( data[0] == SND_SEQ_EVENT_CONTROLLER || data[0] == SND_SEQ_EVENT_KEYPRESS ) { - tmp = 127.0 / max; - val = data[2]; - if( val > 0 ) - val = val / tmp; + val = ((max-min)/127.0) * data[2] + min; + veejay_msg(VEEJAY_MSG_INFO, "Keypress/Ctrl: %d val = %g, min=%g,max=%g",data[2],val,min,max); } else { vj_msg(VEEJAY_MSG_INFO, "MIDI: what's this ? %x,%x,%x",data[0],data[1],data[2]); return; @@ -415,6 +419,18 @@ static void queue_vims_event( vmidi_t *v, int *data ) char vims_msg[255]; snprintf(vims_msg,sizeof(vims_msg), "%s %d;", d->msg, (int) val ); + + /* use control/param as sample_id */ + int tmpv[3]; + if ( sscanf(vims_msg, "%03d:%d %d;",&tmpv[0],&tmpv[1],&tmpv[2]) == 3 ) + { + if(tmpv[1] == 0 && tmpv[0] >= 100 && tmpv[0] < 200) //@ VIMS: sample events, replace 0 (current_id) for control/param number + { + snprintf(vims_msg,sizeof(vims_msg),"%03d:%d %d;", tmpv[0], data[1], (int)val); + veejay_msg(VEEJAY_MSG_DEBUG, "(midi) using control/param %d as sample identifer",data[1]); + } + } + msg_vims( vims_msg ); vj_msg(VEEJAY_MSG_INFO, "MIDI %x:%x, %x -> vims %s", data[0], data[1],data[2], vims_msg); } @@ -431,9 +447,10 @@ static void queue_vims_event( vmidi_t *v, int *data ) } } -static void vj_midi_action( vmidi_t *v ) +static int vj_midi_action( vmidi_t *v ) { snd_seq_event_t *ev; + int ret = 0; int data[4] = { 0,0,0,0}; snd_seq_event_input( v->sequencer, &ev ); @@ -446,30 +463,39 @@ static void vj_midi_action( vmidi_t *v ) { /* controller: channel <0-N>, */ case SND_SEQ_EVENT_CONTROLLER: - data[1] = ev->data.control.channel; + //data[1] = ev->data.control.channel; + data[1] = ev->data.control.channel*256+ev->data.control.param; // OB: added chan+param as identifier data[2] = ev->data.control.value; + ret=1; + veejay_msg(VEEJAY_MSG_DEBUG, "SND_SEQ_EVENT_CONTROLLER: %d %d",data[1],data[2]); break; case SND_SEQ_EVENT_PITCHBEND: data[1] = ev->data.control.channel; data[2] = ev->data.control.value; + veejay_msg(VEEJAY_MSG_DEBUG, "SND_SEQ_EVENT_PITCHBEND: %d %d",data[1],data[2]); break; case SND_SEQ_EVENT_NOTEON: data[2] = ev->data.control.channel; data[1] = ev->data.note.note; + veejay_msg(VEEJAY_MSG_DEBUG, "SND_SEQ_EVENT_NOTEON: %d %d",data[1],data[2]); break; case SND_SEQ_EVENT_NOTEOFF: data[2] = ev->data.control.channel; data[1] = ev->data.note.note; + veejay_msg(VEEJAY_MSG_DEBUG, "SND_SEQ_EVENT_NOTEOFF: %d %d",data[1],data[2]); break; case SND_SEQ_EVENT_KEYPRESS: data[1] = ev->data.control.channel; data[2] = ev->data.note.velocity; + veejay_msg(VEEJAY_MSG_DEBUG, "SND_SEQ_EVENT_KEYPRESS: %d %d",data[1],data[2]); break; case SND_SEQ_EVENT_PGMCHANGE: data[1] = ev->data.control.param; data[2] = ev->data.control.value; + veejay_msg(VEEJAY_MSG_DEBUG, "SND_SEQ_EVENT_PGMCHANGE: %d %d", data[1],data[2]); break; default: + veejay_msg(VEEJAY_MSG_DEBUG, "UNKNOWN MIDI EVENT"); data[1] = -1; data[2] = -1; break; @@ -478,17 +504,24 @@ static void vj_midi_action( vmidi_t *v ) queue_vims_event( v, data ); snd_seq_free_event( ev ); + return ret; // OB: added return for multi pop of ctrl + } int vj_midi_handle_events(void *vv) { + int n_msg = 0; vmidi_t *v = (vmidi_t*) vv; if(!v->active) return 0; - if( poll( v->pfd, v->npfd, 5 ) > 0 ) + while( poll( v->pfd, v->npfd, 0 ) > 0 ) { - vj_midi_action( v ); - return 1; + n_msg ++; + if(vj_midi_action( v )) + continue; + break; } + if(n_msg>0) + veejay_msg(VEEJAY_MSG_INFO, "MIDI: %d events received", n_msg); return 0; } diff --git a/veejay-current/veejay-server/configure.ac b/veejay-current/veejay-server/configure.ac index f5ccd0d2..3b4c85c6 100644 --- a/veejay-current/veejay-server/configure.ac +++ b/veejay-current/veejay-server/configure.ac @@ -1,12 +1,12 @@ dnl Process this file with autoconf to produce a configure script. dnl AC_INIT -AC_INIT([veejay],[1.5.3],[veejay-users@lists.sourceforge.net]) +AC_INIT([veejay],[1.5.5],[veejay-users@lists.sourceforge.net]) AC_PREREQ(2.57) AC_CONFIG_SRCDIR([veejay/veejay.c]) VEEJAY_MAJOR_VERSION=1 VEEJAY_MINOR_VERSION=5 -VEEJAY_MICRO_VERSION=3 +VEEJAY_MICRO_VERSION=5 VEEJAY_VERSION=$VEEJAY_MAJOR_VERSION.$VEEJAY_MINOR_VERSION.$VEEJAY_MICRO_VERSION VEEJAY_CODENAME="Veejay Classic - build $VEEJAY_MINOR_VERSION $VEEJAY_MICRO_VERSION" AC_CONFIG_HEADERS([config.h]) @@ -988,7 +988,6 @@ dnl Output a Makefile or two and the lib/header descriptor script dnl AC_CONFIG_FILES([ Makefile -default.apspec mjpegtools/Makefile aclib/Makefile libOSC/Makefile diff --git a/veejay-current/veejay-server/libsample/sampleadm.c b/veejay-current/veejay-server/libsample/sampleadm.c index 77ad6ca2..ec071677 100644 --- a/veejay-current/veejay-server/libsample/sampleadm.c +++ b/veejay-current/veejay-server/libsample/sampleadm.c @@ -576,18 +576,15 @@ int sample_get_short_info(int sample_id, int *start, int *end, int *loop, int *s *start = si->marker_start; *end = si->marker_end; } - else { + else { *start = si->first_frame; *end = si->last_frame; } - *speed = si->speed; - *loop = si->looptype; + *speed = si->speed; + *loop = si->looptype; return 0; } - *start = 0; - *end = 0; - *loop = 0; - *speed = 0; + return -1; } @@ -893,7 +890,7 @@ int sample_del(int sample_id) for(i=0; i < SAMPLE_MAX_EFFECTS; i++) { if( si->effect_chain[i]->kf ) - vevo_port_free( si->effect_chain[i]->kf ); + vpf( si->effect_chain[i]->kf ); } //@ *sample_eff_chain -> &addr[0] if( si->effect_chain[0] ) @@ -1896,7 +1893,7 @@ int sample_chain_reset_kf( int s1, int entry ) if(!sample) return 0; sample->effect_chain[entry]->kf_status = 0; if(sample->effect_chain[entry]->kf) - vevo_port_free(sample->effect_chain[entry]->kf ); + vpf(sample->effect_chain[entry]->kf ); sample->effect_chain[entry]->kf = vpn(VEVO_ANONYMOUS_PORT ); return 1; } @@ -2136,7 +2133,7 @@ int sample_chain_clear(int s1) sample->effect_chain[i]->volume = 0; sample->effect_chain[i]->a_flag = 0; if( sample->effect_chain[i]->kf ) - vevo_port_free( sample->effect_chain[i]->kf ); + vpf( sample->effect_chain[i]->kf ); sample->effect_chain[i]->kf = vpn(VEVO_ANONYMOUS_PORT); int src_type = sample->effect_chain[i]->source_type; int id = sample->effect_chain[i]->channel; @@ -2239,7 +2236,7 @@ int sample_chain_remove(int s1, int position) sample->effect_chain[position]->a_flag = 0; if( sample->effect_chain[position]->kf ) - vevo_port_free( sample->effect_chain[position]->kf ); + vpf( sample->effect_chain[position]->kf ); sample->effect_chain[position]->kf = vpn( VEVO_ANONYMOUS_PORT ); int src_type = sample->effect_chain[position]->source_type; diff --git a/veejay-current/veejay-server/libstream/v4lvideo.c b/veejay-current/veejay-server/libstream/v4lvideo.c index e4249da7..73859e5f 100644 --- a/veejay-current/veejay-server/libstream/v4lvideo.c +++ b/veejay-current/veejay-server/libstream/v4lvideo.c @@ -663,7 +663,9 @@ static int __v4lvideo_init( v4lvideo_t *v, char *file, int channel, int norm, in void v4lvideo_set_paused(void *vv, int pause) { v4lvideo_template_t *v = (v4lvideo_template_t*) vv; + lock_(v); v->pause = pause; + unlock_(v); } int v4lvideo_is_paused(void *vv ) @@ -759,6 +761,7 @@ static void *v4lvideo_grabber_thread( void * vv ) pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); v4lvideo_template_t *i = (v4lvideo_template_t*) vv; v4lvideo_t *v = (v4lvideo_t*) vj_calloc(sizeof(v4lvideo_t)); + lock_(i); i->v4l = (void*) v; if( __v4lvideo_init( v, i->filename, i->channel, i->norm,i->frequency, i->width, i->height, i->palette ) < 0 ) { @@ -769,13 +772,16 @@ static void *v4lvideo_grabber_thread( void * vv ) veejay_msg(0,"%s: Giving up, unable to open %s, channel %d, norm %x, %dx%d palette %x", __FUNCTION__, i->filename , i->channel, i->norm, i->width, i->height, i->palette ); #endif + unlock_(i); pthread_exit(NULL); return NULL; } + unlock_(i); + veejay_msg(VEEJAY_MSG_INFO, "Capture device looks ready to go!"); v4lprint( &(v->vd)); - + /* if( __v4lvideo_grabstart( v ) != 0 ) { veejay_msg(0, "Unable to start grabbing from device '%s'", i->filename); pthread_exit(NULL); @@ -808,6 +814,7 @@ PAUSED: veejay_msg(VEEJAY_MSG_DEBUG, "Trying to start capturing."); __v4lvideo_grabstart(v); unlock_(i); + usleep( 20000 ); goto RESTART; } } @@ -816,9 +823,11 @@ PAUSED: if(v->grabbing) { flag = v4lvideo_syncframe(v); + lock_(i); if(flag==0) { __v4lvideo_copy_framebuffer_to( v,i, dstY, dstU, dstV ); } + unlock_(i); if(flag == -1) { if( retry == 0 ) { @@ -935,11 +944,12 @@ int v4lvideo_grabframe( void *vv ) int v4lvideo_copy_framebuffer_to( void *vv, uint8_t *dstY, uint8_t *dstU, uint8_t *dstV ) { v4lvideo_template_t *v = (v4lvideo_template_t*) vv; + lock_(v); if(!v->status) { + unlock_(v); return -1; } - lock_(v); if(!v->v4l ) { unlock_(v); return 0; @@ -991,11 +1001,11 @@ static void __v4lvideo_copy_framebuffer_to(v4lvideo_t *v1, v4lvideo_template_t * if(!v1->scaler) v1->scaler = yuv_init_swscaler( srcf,dstf,&(v1->sws_templ), yuv_sws_get_cpu_flags()); - lock_(v2); + //lock_(v2); yuv_convert_and_scale( v1->scaler, srcf, dstf ); v1->has_video = 1; - unlock_(v2); + //unlock_(v2); } else if ( v1->native == 2 ) { src = v4lgetaddress(&(v1->vd)); @@ -1021,11 +1031,11 @@ static void __v4lvideo_copy_framebuffer_to(v4lvideo_t *v1, v4lvideo_template_t * srcf->data[0] = tmp[0]; srcf->data[1] = tmp[1]; srcf->data[2] = tmp[2]; - lock_(v2); + // lock_(v2); yuv_convert_and_scale( v1->scaler, srcf, dstf ); v1->has_video = 1; - unlock_(v2); + // unlock_(v2); } else { VJFrame *srcf = v1->info->src; VJFrame *dstf = v1->info->dst; @@ -1049,11 +1059,11 @@ static void __v4lvideo_copy_framebuffer_to(v4lvideo_t *v1, v4lvideo_template_t * v1->scaler = yuv_init_swscaler( srcf,dstf,&(v1->sws_templ), yuv_sws_get_cpu_flags()); - lock_(v2); + //lock_(v2); yuv_convert_and_scale_from_rgb( v1->scaler, srcf, dstf ); v1->has_video = 1; - unlock_(v2); + //unlock_(v2); // } } // v1->has_video = 1; diff --git a/veejay-current/veejay-server/libstream/vj-tag.c b/veejay-current/veejay-server/libstream/vj-tag.c index 36889522..ee7f66af 100644 --- a/veejay-current/veejay-server/libstream/vj-tag.c +++ b/veejay-current/veejay-server/libstream/vj-tag.c @@ -1178,7 +1178,7 @@ int vj_tag_del(int id) for(i=0; i < SAMPLE_MAX_EFFECTS; i++) { - vevo_port_free( tag->effect_chain[i]->kf ); + vpf( tag->effect_chain[i]->kf ); } tag_node = hash_lookup(TagHash, (void *) tag->id); if(tag_node) @@ -1907,7 +1907,7 @@ int vj_tag_chain_reset_kf( int s1, int entry ) if (!tag) return -1; tag->effect_chain[entry]->kf_status = 0; if(tag->effect_chain[entry]->kf) - vevo_port_free( tag->effect_chain[entry]->kf); + vpf( tag->effect_chain[entry]->kf); tag->effect_chain[entry]->kf = vpn( VEVO_ANONYMOUS_PORT ); return 1; } @@ -2560,7 +2560,7 @@ int vj_tag_chain_remove(int t1, int index) vj_effect_deactivate( tag->effect_chain[index]->effect_id, tag->effect_chain[index]->fx_instance ); if( tag->effect_chain[index]->kf ) - vevo_port_free(tag->effect_chain[index]->kf ); + vpf(tag->effect_chain[index]->kf ); tag->effect_chain[index]->kf = vpn(VEVO_ANONYMOUS_PORT); } @@ -4061,7 +4061,7 @@ void tagCreateStream(xmlNodePtr node, vj_tag *tag, void *font, void *vp) if(tag->extra ) { sprintf(buffer, "%s", (char*)tag->extra ); - xmlNewChild(node, NULL,(const xmlChar) "extra_data", (const xmlChar*) buffer ); + xmlNewChild(node, NULL,(const xmlChar*) "extra_data", (const xmlChar*) buffer ); } sprintf(buffer, "%d", tag->color_r ); xmlNewChild(node,NULL,(const xmlChar*) "red", (const xmlChar*) buffer ); diff --git a/veejay-current/veejay-server/libstream/vj-unicap.c b/veejay-current/veejay-server/libstream/vj-unicap.c index 26178cae..6e0f98c3 100644 --- a/veejay-current/veejay-server/libstream/vj-unicap.c +++ b/veejay-current/veejay-server/libstream/vj-unicap.c @@ -53,6 +53,7 @@ typedef struct pthread_attr_t attr; uint8_t *priv_buf; int state; + int errors; int deviceID; int sizes[3]; int active; @@ -1433,9 +1434,16 @@ static void *unicap_reader_thread(void *data) if(vj_unicap_grab_a_frame( data )==0) { veejay_msg(VEEJAY_MSG_ERROR, "Unable to grab a frame from capture device %d", v->deviceID); - v->state = 0; + v->errors = (v->errors + 1) % 5; + if( v->errors == 4 ) { + veejay_msg(VEEJAY_MSG_ERROR, "Stopping capture device."); + v->state = 0; + } else { + unicap_delay(5000); + } + } else { + v->errors = 0; } - // unicap_delay( s ); } } diff --git a/veejay-current/veejay-server/libvevo/Makefile.am b/veejay-current/veejay-server/libvevo/Makefile.am index 527ce7ce..052323fa 100644 --- a/veejay-current/veejay-server/libvevo/Makefile.am +++ b/veejay-current/veejay-server/libvevo/Makefile.am @@ -7,4 +7,3 @@ pkginclude_HEADERS = libvevo.h lowlevel.h pool.h vevo.h noinst_LTLIBRARIES = $(VEVO_LIB_FILE) libvevo_la_SOURCES = pool.c vevo.c - diff --git a/veejay-current/veejay-server/libvevo/libvevo.h b/veejay-current/veejay-server/libvevo/libvevo.h index 90622a4c..d141b57b 100644 --- a/veejay-current/veejay-server/libvevo/libvevo.h +++ b/veejay-current/veejay-server/libvevo/libvevo.h @@ -32,7 +32,6 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include - typedef void vevo_port_t; #ifndef FALSE @@ -42,11 +41,6 @@ typedef void vevo_port_t; #define TRUE 1 #endif -#ifdef STRICT_CHECKING -#define vpn(type) vevo_port_new( type, __FUNCTION__ , __LINE__ ) -#else -#define vpn(type) vevo_port_new( type ) -#endif int vevo_property_num_elements( vevo_port_t *p, const char *key); @@ -55,18 +49,27 @@ int vevo_property_atom_type( vevo_port_t *p, const char *key); size_t vevo_property_element_size( vevo_port_t * p, const char *key, const int idx); #ifdef STRICT_CHECKING -vevo_port_t *vevo_port_new( int port_type, const char *func, int line_no ); +vevo_port_t *vevo_port_new( int port_type, const char *func,const int line_no ); +void vevo_port_free( vevo_port_t *port, const char *func, const int line_no ); #else vevo_port_t *vevo_port_new(int port_type); +void vevo_port_free( vevo_port_t *port ); #endif + +#ifdef STRICT_CHECKING +#define vpn(type) vevo_port_new( type, __FUNCTION__ , __LINE__ ) +#define vpf( port ) vevo_port_free( port, __FUNCTION__, __LINE__ ) +#else +#define vpn(type) vevo_port_new( type ) +#define vpf( port ) vevo_port_free( port ) +#endif + int vevo_property_soft_reference(vevo_port_t * p, const char *key); void vevo_strict_init(); int vevo_port_verify( vevo_port_t *port ); -void vevo_port_free( vevo_port_t *port ); - int vevo_property_set(vevo_port_t * p, const char *key, int atom_type, int num_elements, void *src); int vevo_union_ports( void *port_a, void *port_b, int filter_type ); @@ -77,8 +80,6 @@ char **vevo_list_properties(vevo_port_t * p); void vevo_port_recursive_free(vevo_port_t *p ); -void vevo_port_dump( vevo_port_t *p ); - char *vevo_format_kind( vevo_port_t *port, const char *key ); char *vevo_format_property( vevo_port_t *port, const char *key ); @@ -87,9 +88,9 @@ void vevo_report_stats(); int vevo_property_del(vevo_port_t * p, const char *key ); -char **vevo_port_deepen_namespace( void *port, char *path); +//char **vevo_port_deepen_namespace( void *port, char *path); -char **vevo_port_recurse_namespace( vevo_port_t *port, const char *base ); +void *vevo_port_recurse_namespace( vevo_port_t *port, const char *base ); void *vevo_port_register( vevo_port_t *in, vevo_port_t *ref ); @@ -109,12 +110,35 @@ char *vevo_sprintf_property_value( vevo_port_t *port, const char *key); char *vevo_property_get_string( void *port, const char *key ); +char *vevo_property_get_utf8string( void *port, const char *key ); + void vevo_strict_init(); +int vevo_property_call(vevo_port_t * p, const char *key, void *ctx, int32_t type, int32_t value ); + +int vevo_property_call_get( vevo_port_t *p, const char *key, void *ctx ); + +int vevo_property_clone( void *port, void *to_port, const char *key, const char *as_key ); + +int vevo_property_protect( vevo_port_t *p, const char *key ); + +void vevo_port_dump( void *p, int lvl ); + +int +vevo_property_set_f(vevo_port_t * p, + const char *key, + int atom_type, int num_elements, void (*set_func)() , int (*get_func)() ); + + + +int vevo_port_get_total_size( vevo_port_t *port ); + +#define VEVO_ATOM_TYPE_FUNCPTR 11 #define VEVO_ATOM_TYPE_VOIDPTR 65 #define VEVO_ATOM_TYPE_INT 1 #define VEVO_ATOM_TYPE_DOUBLE 2 #define VEVO_ATOM_TYPE_STRING 4 +#define VEVO_ATOM_TYPE_UTF8STRING 8 #define VEVO_ATOM_TYPE_BOOL 3 #define VEVO_ATOM_TYPE_PORTPTR 66 #define VEVO_ATOM_TYPE_HIDDEN 50 diff --git a/veejay-current/veejay-server/libvevo/pool.c b/veejay-current/veejay-server/libvevo/pool.c index 456cbed7..313db6f1 100644 --- a/veejay-current/veejay-server/libvevo/pool.c +++ b/veejay-current/veejay-server/libvevo/pool.c @@ -1,34 +1,4 @@ /* -Copyright (c) 2004-2005 N.Elburg - -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. -3. The name of the author may not be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - - /** \defgroup mem_pool Efficient Object Caching - * - * To reduce the overhead of malloc/free when allocating and freeing many small objects * I keep a linked list of Spaces. Each Space holds a continuous * memory area that is of size ROUNDS_PER_MAG * sizeof(type). This area is divided * into ROUND_PER_MAG chunks. The malloc() replacement pops a round from the stack, @@ -72,6 +42,9 @@ typedef struct { space_t **spaces; /*!< array of spaces */ space_t *space; /*!< single space */ +#ifdef STRICT_CHECKING + int msize; +#endif } pool_t; //!Allocate a new space of a fixed size @@ -88,8 +61,8 @@ static space_t *alloc_space( size_t bs ) #ifdef STRICT_CHECKING assert( s != NULL ); #endif - s->area = vj_malloc(bs * ROUNDS_PER_MAG); - s->mag = vj_malloc( sizeof(void*) * (ROUNDS_PER_MAG + 1) ); + s->area = vj_calloc(bs * ROUNDS_PER_MAG); + s->mag = vj_calloc( sizeof(void*) * (ROUNDS_PER_MAG + 1) ); p = s->area; for( k = 0; k <= ROUNDS_PER_MAG ;k ++ ) { @@ -101,6 +74,16 @@ static space_t *alloc_space( size_t bs ) return s; } +int vevo_pool_size( void *p ) +{ +#ifdef STRICT_CHECKING + pool_t *pool = (pool_t*) p; + return pool->msize; +#else + return 0; +#endif +} + //! Allocate a new pool with spaces of various fixed sizes /*! \param prop_size size in bytes of vevo_property_t @@ -127,6 +110,19 @@ void *vevo_pool_init(size_t prop_size,size_t stor_size, size_t atom_size, size_t p->spaces[Matom] = alloc_space( atom_size ); p->spaces[Midx] = alloc_space( index_size ); p->spaces[Mend] = NULL; +#ifdef STRICT_CHECKING + + p->msize = sizeof(space_t*) * Msize; + p->msize += sizeof(int32_t); + p->msize += sizeof(double); + p->msize += sizeof(void*); + p->msize += sizeof(uint64_t); + p->msize += prop_size; + p->msize += stor_size; + p->msize += atom_size; + p->msize += index_size; + p->msize += sizeof(pool_t); +#endif return (void*)p; } @@ -140,6 +136,10 @@ void *vevo_pool_slice_init( size_t node_size ) pool_t *p = (pool_t*) malloc(sizeof(pool_t)); p->spaces = NULL; p->space = alloc_space( node_size ); +#ifdef STRICT_CHECKING + p->msize += node_size; + p->msize += sizeof(pool_t); +#endif return p; } @@ -218,6 +218,7 @@ void vevo_pool_destroy( void *p ) } free( nS ); free( pool ); + p = NULL; } //! Destroy a pool and the space it holds. Frees all used memory @@ -239,6 +240,7 @@ void vevo_pool_slice_destroy( void *p ) } free( pool->space ); free( pool ); + p = NULL; } //! Get a pointer to the starting address of an unused block. Pops a round from the magazine and creates a new space if magazine is empty. diff --git a/veejay-current/veejay-server/libvevo/pool.h b/veejay-current/veejay-server/libvevo/pool.h index fd252670..0e8c4d9c 100644 --- a/veejay-current/veejay-server/libvevo/pool.h +++ b/veejay-current/veejay-server/libvevo/pool.h @@ -24,8 +24,8 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - #ifndef POOLM +#include #define POOLM #define ROUNDS_PER_MAG 16 @@ -39,6 +39,10 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define M64b 7 #define Mend 8 +#ifdef STRICT_CHECKING +int vevo_pool_size(void *pool); +#endif + void *vevo_pool_alloc( void *pool, size_t bs, unsigned int k ); void vevo_pool_free( void *pool, void *ptr, unsigned int k ); void *vevo_pool_init(size_t property_size, size_t stor_size, size_t atom_size, size_t index_size); diff --git a/veejay-current/veejay-server/libvevo/vevo.c b/veejay-current/veejay-server/libvevo/vevo.c index e952460b..43fc41cd 100644 --- a/veejay-current/veejay-server/libvevo/vevo.c +++ b/veejay-current/veejay-server/libvevo/vevo.c @@ -47,6 +47,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * Types of values: * -# int32_t VEVO_ATOM_TYPE_INT * -# char* VEVO_ATOM_TYPE_STRING + * -# gchar* VEVO_ATOM_TYPE_UTF8STRING * -# void* VEVO_ATOM_TYPE_VOIDPTR * -# void* VEVO_ATOM_TYPE_PORTPTR * -# int32_t VEVO_ATOM_TYPE_BOOLEAN @@ -89,14 +90,21 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include + #include #include #include #include +//#include //@ for g_locale_to_utf8 and g_locale_from_utf8 #ifdef STRICT_CHECKING #include +#define VEVO_DBG #endif +//#ifdef VEVO_DBG +//#define VVERBOSE 1 +//#endif + #include #define PORT_TYPE_PLUGIN_INFO 1 #define PORT_TYPE_FILTER_CLASS 2 @@ -113,9 +121,15 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * the atom_t structure */ + +typedef void (*vevo_set_func)(void *ctx, int32_t type, int32_t value ); +typedef int (*vevo_get_func)(void *ctx ); + typedef struct { int type; - void *value; + void *value; + int (*get_func)(); + void(*set_func)(); size_t size; } atom_t; @@ -181,6 +195,11 @@ static vevo_port_t *port_ref_ = NULL; #endif*/ static size_t atom_sizes_[100]; +#ifdef STRICT_CHECKING +static void *trackports = NULL; +static int hastrackports = 0; +#endif + //! Check if an object is soft referenced /*! \param p port @@ -312,8 +331,10 @@ static port_index_t *port_node_new(__vevo_port_t *port,const char *key, uint32_t static void port_node_free(__vevo_port_t *port,port_index_t * node) { if (node) { - if (node->key) - free((void *) node->key); + if (node->key) { + free(node->key); + node->key=NULL; + } // free(node); vevo_pool_free_node( port->pool,(void*)node ); } @@ -362,6 +383,11 @@ static void port_node_append(vevo_port_t * p, const char *key, for (i = 0; i < d->num_elements; i++)\ d->elements.array[i] = vevo_put_atom(port, &value[i], v ); } + +#define atom_store_at__(value,at) {\ + vevo_free_atom(port, d->elements.array[at]);\ + d->elements.array[at] = vevo_put_atom(port, value, v ); } + //! \define array_load__ get a value from an array of atom #define array_load__(value) {\ for( i = 0; i < t->num_elements ; i ++ )\ @@ -456,13 +482,37 @@ static int vevo_property_finalize(vevo_port_t * p, const char *key) if ((node = property_exists(port, hash_key)) != NULL) { vevo_storage_t *stor = (vevo_storage_t *) hnode_get(node); stor->flags |= VEVO_PROPERTY_READONLY; - hnode_t *new_node = hnode_create((void *) stor); - hnode_put(new_node, (void *) hash_key); - hnode_destroy(new_node); + // hnode_t *new_node = hnode_create((void *) stor); + // hnode_put(new_node, (void *) hash_key); + // hnode_destroy(new_node); return VEVO_NO_ERROR; } } - return VEVO_NO_ERROR; + return VEVO_ERROR_NOSUCH_PROPERTY; +} + +int vevo_property_protect( vevo_port_t *p, const char *key ) +{ + __vevo_port_t *port = (__vevo_port_t *) p; + uint32_t hash_key = hash_key_code(key); + if (!port->table) { + vevo_property_t *node = NULL; + if ((node = prop_node_get(port, hash_key)) != NULL) { + node->st->flags |= VEVO_PROPERTY_PROTECTED; + return VEVO_NO_ERROR; + } + } else { + hnode_t *node = NULL; + if ((node = property_exists(port, hash_key)) != NULL) { + vevo_storage_t *stor = (vevo_storage_t *) hnode_get(node); + stor->flags |= VEVO_PROPERTY_PROTECTED; + // hnode_t *new_node = hnode_create((void *) stor); + // hnode_put(new_node, (void *) hash_key); + // hnode_destroy(new_node); + return VEVO_NO_ERROR; + } + } + return VEVO_ERROR_NOSUCH_PROPERTY; } static int vevo_property_exists( vevo_port_t *p, const char *key) @@ -545,7 +595,6 @@ static int atom_get_value(vevo_storage_t * t, int idx, void *dst) assert(t != NULL); #endif atom_t *atom = NULL; - if (t->num_elements == 1 && idx == 0) { atom = t->elements.atom; @@ -580,21 +629,25 @@ static int atom_get_value(vevo_storage_t * t, int idx, void *dst) if( dst == NULL ) return VEVO_NO_ERROR; - - if (t->atom_type != VEVO_ATOM_TYPE_STRING) { -#ifdef STRICT_CHECKING - assert( atom->size > 0 ); -#endif - memcpy(dst, atom->value, atom->size); - } else { + + if( t->atom_type == VEVO_ATOM_TYPE_STRING || t->atom_type == VEVO_ATOM_TYPE_UTF8STRING ) { char **ptr = (char **) dst; char *p = *ptr; #ifdef STRICT_CHECKING - assert( (atom->size-1) > 0 ); + assert( atom->size > 0 ); #endif - memcpy(p, atom->value, (atom->size - 1)); - p[atom->size - 1] = '\0'; - } + veejay_memcpy(p, atom->value, atom->size); + } else if( t->atom_type != VEVO_ATOM_TYPE_FUNCPTR ) { +#ifdef STRICT_CHECKING + assert( atom->size > 0 ); +#endif + veejay_memcpy(dst, atom->value, atom->size); + } else { +#ifdef STRICT_CHECKING + veejay_msg(VEEJAY_MSG_WARNING, "vevo_property_get called on getter function ?!"); +#endif + } + return VEVO_NO_ERROR; } @@ -616,6 +669,7 @@ static size_t vevo_atom_size(int atom_type) \param atom_size byte size of atom \return atom_t new atom */ + static atom_t *vevo_new_atom(__vevo_port_t * port, int atom_type, size_t atom_size) { @@ -625,9 +679,14 @@ static atom_t *vevo_new_atom(__vevo_port_t * port, int atom_type, #endif atom->size = atom_size; atom->type = atom_type; - if(atom_type == VEVO_ATOM_TYPE_STRING ) - atom->value = (atom_size > 0 ?(void*)malloc(atom_size):NULL); - else + + if( atom_size == 0 ) + return atom; + + if(atom_type == VEVO_ATOM_TYPE_STRING || atom_type == VEVO_ATOM_TYPE_UTF8STRING ) + { + atom->value = (atom_size > 0 ?(void*)vj_malloc(atom_size):NULL);//@ FIXME: strings do not come from pool + }else { if(atom_type == VEVO_ATOM_TYPE_DOUBLE ) { atom->value = (atom_size > 0 ? (void*) vevo_pool_alloc_dbl(double,port->pool ): NULL); } else if( atom_type == VEVO_ATOM_TYPE_VOIDPTR || atom_type == VEVO_ATOM_TYPE_PORTPTR ) { @@ -673,10 +732,12 @@ static void vevo_free_atom(__vevo_port_t *port,atom_t * atom) vevo_pool_free_64b( port->pool,atom->value ); break; case VEVO_ATOM_TYPE_STRING: + case VEVO_ATOM_TYPE_UTF8STRING: free( atom->value ); break; } - vevo_pool_free_atom( port->pool, atom ); + atom->value = NULL; + vevo_pool_free_atom( port->pool, atom ); } atom = NULL; } @@ -693,12 +754,14 @@ static atom_t *vevo_put_atom(__vevo_port_t * port, void *dst, atom_t *atom = NULL; size_t atom_size = vevo_atom_size(atom_type); - if (atom_type == VEVO_ATOM_TYPE_STRING) { + if (atom_type == VEVO_ATOM_TYPE_STRING || atom_type == VEVO_ATOM_TYPE_UTF8STRING) { char **s = (char **) dst; - atom_size = strlen(*s) + 1; + char *data = (char*) *s; + atom_size = strlen(data) + 1; atom = vevo_new_atom(port, atom_type, atom_size); - if (atom_size > 0) - memcpy(atom->value, *s, (atom_size - 1)); + if (atom_size > 0) { + veejay_memcpy(atom->value, data, atom_size); + } } else { #ifdef STRICT_CHECKING @@ -713,7 +776,7 @@ static atom_t *vevo_put_atom(__vevo_port_t * port, void *dst, if (!atom) return NULL; #endif - memcpy(atom->value, dst, atom_size); + veejay_memcpy(atom->value, dst, atom_size); } return atom; } @@ -737,57 +800,96 @@ storage_put_atom_value(__vevo_port_t * port, void *src, int n, if (n > 0) assert((src != NULL)); #endif - if (d->num_elements >= 0) { - if (d->num_elements >= 0 && d->num_elements <= 1) { + + + //@ overwrite + if (d->num_elements == 0 || d->num_elements == 1) { + //@ single atoms #ifdef STRICT_CHECKING - if( d->num_elements == 1 ) - assert( d->elements.atom != NULL ); - if( d->num_elements == 0 ) - assert( d->elements.atom == NULL ); + if( d->num_elements == 1 ) + assert( d->elements.atom != NULL ); + if( d->num_elements == 0 ) + assert( d->elements.atom == NULL ); #endif if (d->elements.atom) - vevo_free_atom(port,d->elements.atom); + vevo_free_atom(port,d->elements.atom); } else if (d->num_elements > 1) { - if (d->elements.array) { - for (i = 0; i < d->num_elements; i++) - vevo_free_atom(port,d->elements.array[i]); - free(d->elements.array); + if (d->elements.array) { + for (i = 0; i < d->num_elements; i++) + { +#ifdef STRICT_CHECKING + assert( d->elements.array[i] != NULL ); +#endif + vevo_free_atom(port,d->elements.array[i]); + } + free(d->elements.array); } - } } +#ifdef STRICT_CHECKING + else { + assert( d->num_elements >= 0 ); + } +#endif + +#ifdef STRICT_CHECKING + if( d->num_elements > 1 && n > 0 ) + assert( n == d->num_elements ); +#endif d->atom_type = v; d->num_elements = n; switch (n) { - case 0: - d->elements.atom = vevo_new_atom(port, v, vevo_atom_size(v)); - break; - case 1: - d->elements.atom = vevo_put_atom(port, src, v); - break; + case 0: + d->elements.atom = vevo_new_atom(port, v, vevo_atom_size(v)); + break; + case 1: + d->elements.atom = vevo_put_atom(port, src, v); + break; default: - d->elements.array = (atom_t **) malloc(sizeof(atom_t *) * n); - if (d->atom_type == VEVO_ATOM_TYPE_DOUBLE) { - double *value = (double *) src; - atom_store__(value); - } else { - if (d->atom_type == VEVO_ATOM_TYPE_INT - || d->atom_type == VEVO_ATOM_TYPE_BOOL) { - int32_t *value = (int *) src; - atom_store__(value); - } else if(d->atom_type == VEVO_ATOM_TYPE_UINT64) { - uint64_t *value = (uint64_t*) src; - atom_store__(value); + d->elements.array = (atom_t **) vj_malloc(sizeof(atom_t *) * n); + if (d->atom_type == VEVO_ATOM_TYPE_DOUBLE) { + double *value = (double *) src; + atom_store__(value); + } else { + if (d->atom_type == VEVO_ATOM_TYPE_INT|| d->atom_type == VEVO_ATOM_TYPE_BOOL) { + int32_t *value = (int *) src; + atom_store__(value); + } else if(d->atom_type == VEVO_ATOM_TYPE_UINT64) { + uint64_t *value = (uint64_t*) src; + atom_store__(value); } else { - void **value = (void **) src; - atom_store__(value); + void **value = (void **) src; + atom_store__(value); } - } - break; + } + break; } } +static void +storage_put_atom_func(__vevo_port_t * port, void (*set_func)(),int (*get_func)(), vevo_storage_t * d, int v) +{ + int i; + + if( set_func == NULL && get_func == NULL ) + { + vevo_free_atom(port,d->elements.atom); + d->elements.atom = NULL; + } + + d->atom_type = v; + d->num_elements = 1; + d->elements.atom = vevo_new_atom(port, v, 0); + + d->elements.atom->set_func = set_func; + d->elements.atom->get_func = get_func; + + //memcpy(set_func,d->elements.atom->set_func, sizeof( vevo_set_func )); + //memcpy(get_func,d->elements.atom->get_func, sizeof( vevo_get_func )); +} + + //! Construct a new vevo_storage_t object /*! \param port Port @@ -930,6 +1032,93 @@ int vevo_property_atom_type(vevo_port_t * p, const char *key) return -1; } + +static int vevo_storage_size( vevo_storage_t *stor ) { + int atom_type; /*!< atom type */ + union { /*! \union elements one or more atoms */ + atom_t *atom; + atom_t **array; + } elements; + int num_elements; /*!< number of atoms */ + + int i; + if( stor->num_elements == 0 ) + return 0; + if( stor->num_elements == 1 ) + return stor->elements.atom->size; + int msize = 0; + for( i = 0; i < stor->num_elements; i ++ ) { + msize += stor->elements.array[i]->size; + } + return msize; +} + +int vevo_property_atom_size(vevo_port_t * p, const char *key) +{ +#ifdef STRICT_CHECKING + assert(p != NULL); + assert(key != NULL); +#endif + __vevo_port_t *port = (__vevo_port_t *) p; +#ifdef STRICT_CHECKING + assert(port != NULL); +#endif + uint32_t hash_key = hash_key_code(key); + + if (!port->table) { + vevo_property_t *node; + if ((node = prop_node_get(port, hash_key)) != NULL) { + return vevo_storage_size( node->st ); + } + else { + hnode_t *node = NULL; +#ifdef STRICT_CHECKING + assert(port->table != NULL); +#endif + + if ((node = property_exists(port, hash_key)) != NULL) { + vevo_storage_t *stor = (vevo_storage_t *) hnode_get(node); + if (stor) { + return vevo_storage_size( stor ); + } + } + + } + } + return -1; +} +static int vevo_property_is_protected(vevo_port_t * p, const char *key) +{ +#ifdef STRICT_CHECKING + assert(p != NULL); + assert(key != NULL); +#endif + __vevo_port_t *port = (__vevo_port_t *) p; +#ifdef STRICT_CHECKING + assert(port != NULL); +#endif + uint32_t hash_key = hash_key_code(key); + + if (!port->table) { + vevo_property_t *node; + if ((node = prop_node_get(port, hash_key)) != NULL) + return ( node->st->flags & VEVO_PROPERTY_PROTECTED ); + } else { + hnode_t *node = NULL; +#ifdef STRICT_CHECKING + assert(port->table != NULL); +// assert(hash_verify(port->table) != 0); +#endif + + if ((node = property_exists(port, hash_key)) != NULL) { + vevo_storage_t *stor = (vevo_storage_t *) hnode_get(node); + if (stor) + return (stor->flags & VEVO_PROPERTY_PROTECTED); + } + } + return VEVO_NO_ERROR; +} + //! Return size of an Atom at a given index /*! \param p Port @@ -938,13 +1127,11 @@ int vevo_property_atom_type(vevo_port_t * p, const char *key) \return Byte size of value at Index */ size_t -vevo_property_element_size(vevo_port_t * p, const char *key, - const int idx) +vevo_property_element_size(vevo_port_t * p, const char *key, const int idx ) { #ifdef STRICT_CHECKING assert(p != NULL); assert(key != NULL); - assert(idx >= 0); #endif __vevo_port_t *port = (__vevo_port_t *) p; uint32_t hash_key = hash_key_code(key); @@ -954,15 +1141,11 @@ vevo_property_element_size(vevo_port_t * p, const char *key, if (!port->table) { vevo_property_t *node; if ((node = prop_node_get(port, hash_key)) != NULL) { -#ifdef STRICT_CHECKING - if (idx > 0) - assert(idx < node->st->num_elements); -#endif if (node->st->num_elements == 1) - return node->st->elements.atom->size; + return node->st->elements.atom->size; else if (node->st->num_elements > 1) - return node->st->elements.array[idx]->size; - return 0; + return node->st->elements.array[idx]->size; + return 0; } } else { hnode_t *node = NULL; @@ -972,13 +1155,14 @@ vevo_property_element_size(vevo_port_t * p, const char *key, assert(idx <= stor->num_elements); #endif //todo: sum all element sizes for index of -1 - if (stor->num_elements == 1) { - return stor->elements.atom->size; + if (stor->num_elements == 1) { + return stor->elements.atom->size; } else if (stor->num_elements > 1) { - return stor->elements.array[idx]->size; - } else { - if (stor->num_elements == 0) - return 0; + return stor->elements.array[idx]->size; + } + else { + if (stor->num_elements == 0) + return 0; } } } @@ -1007,6 +1191,8 @@ vevo_port_t *vevo_port_new(int port_type) port->table = hash_create(HASHCOUNT_T_MAX, key_compare, int_hash); vevo_port_finalize (port, port_type ); + + return (vevo_port_t *) port; } #else @@ -1028,11 +1214,30 @@ vevo_port_t *vevo_port_new(int port_type, const char *func, int line_num) port->table = hash_create(HASHCOUNT_T_MAX, key_compare, int_hash); vevo_port_finalize (port, port_type ); - +#ifdef VVERBOSE + veejay_msg( VEEJAY_MSG_INFO, "New port %p (%d) from %s:%d", port,port_type,func,line_num); +#endif /* char har[1024]; sprintf(har,"%s::%d", func,line_num ); vevo_property_set( port, har, VEVO_ATOM_TYPE_HIDDEN,0,NULL); - */ + */ + +#ifdef STRICT_CHECKING + if( hastrackports == 0 ) { + hastrackports = 1; + trackports = vpn(1331); + } + + if( trackports != NULL && port_type != 1331) { + char key[64]; + char har[1024]; + char *str = &har[0]; + memset(har,0,sizeof(har)); + snprintf(har,sizeof(har), "%s::%d",func,line_num); + snprintf(key,64, "%p", port ); + assert( vevo_property_set( trackports, key,VEVO_ATOM_TYPE_STRING,1,&str ) == VEVO_NO_ERROR ); + } +#endif return (vevo_port_t *) port; } @@ -1051,6 +1256,7 @@ void vevo_strict_init() atom_sizes_[2] = sizeof(double); atom_sizes_[3] = sizeof(int32_t); atom_sizes_[4] = sizeof(char*); +// atom_sizes_[8] = sizeof(gchar*); atom_sizes_[5] = sizeof(uint64_t); atom_sizes_[65] = sizeof(void*); atom_sizes_[66] = sizeof(vevo_port_t*); @@ -1060,10 +1266,41 @@ void vevo_strict_init() /*! \param p (local) Port to destroy */ +#ifdef STRICT_CHECKING +static int vevo_port_free_(vevo_port_t *p ) +#else static void vevo_port_free_(vevo_port_t * p) +#endif { __vevo_port_t *port = (__vevo_port_t *) p; +#ifdef STRICT_CHECKING + int msize = 0; +#endif +#ifdef STRICT_CHECKING + char key[64]; + snprintf(key,64, "%p", port ); + char *val = vevo_property_get_string( trackports, key ); + int err = vevo_property_get( trackports, key, 0, NULL ); + if ( err == VEVO_ERROR_PROPERTY_EMPTY ) { + veejay_msg(0, "port %s was already freed. (%s)", key,val ); + } + else if ( err == VEVO_ERROR_NOSUCH_PROPERTY ) { + + char tkey[64]; + snprintf(tkey, 64, "%p", trackports ); + if(strcasecmp(tkey,key) != 0 ) { + veejay_msg(0, "port %s is not a port (not allocated by vpn). (%s)", key,val); + } + } else if ( err == VEVO_NO_ERROR ) { + vevo_property_set( trackports, key,VEVO_ATOM_TYPE_STRING, 0, NULL ); + } else { + veejay_msg(0, "unknown error code %d on port %s. (%s)", err,key,val ); + } + if(val) free(val); +#endif + + if (port->table) { if (!hash_isempty((hash_t *) port->table)) { hscan_t scan; @@ -1077,6 +1314,7 @@ static void vevo_port_free_(vevo_port_t * p) assert(stor != NULL); assert(node != NULL); assert((const char *) hnode_getkey(node) != NULL); + msize += vevo_storage_size( stor ); #endif vevo_free_storage(port,stor); } @@ -1090,6 +1328,9 @@ static void vevo_port_free_(vevo_port_t * p) vevo_property_t *n; while (l != NULL) { n = l->next; +#ifdef STRICT_CHECKING + msize += vevo_storage_size( l->st ); +#endif vevo_free_storage(port,l->st); prop_node_free(port,l); l = n; @@ -1103,11 +1344,14 @@ static void vevo_port_free_(vevo_port_t * p) port_node_free(port,l); l = n; } - + vevo_pool_destroy( port->pool ); free(port); p = port = NULL; +#ifdef STRICT_CHECKING + return msize; +#endif } //! Verify if Vevo has allocated a given Port @@ -1153,8 +1397,11 @@ int vevo_port_verify( vevo_port_t *port ) /*! \param p Port to destroy */ - +#ifdef STRICT_CHECKING +void vevo_port_free( vevo_port_t *port, const char *func, const int line_no ) +#else void vevo_port_free( vevo_port_t *port ) +#endif { if(!port) { @@ -1198,7 +1445,13 @@ void vevo_port_free( vevo_port_t *port ) } #else */ +#ifdef STRICT_CHECKING +// void *ptr = port; +// int nfreed = vevo_port_free_(port); +// veejay_msg(VEEJAY_MSG_DEBUG, "%s:%p freed %d bytes (created by %s:%d)",__FUNCTION__,ptr, nfreed,func,line_no); +#else vevo_port_free_(port ); +#endif /* #endif */ @@ -1259,8 +1512,8 @@ vevo_property_set(vevo_port_t * p, assert( src != p ); if( num_elements > 0 ) assert( src != NULL ); assert( key != NULL ); - if( atom_type != VEVO_ATOM_TYPE_HIDDEN ) - assert( vevo_atom_size(atom_type) > 0 ); + // if( atom_type != VEVO_ATOM_TYPE_HIDDEN ) + assert( vevo_atom_size(atom_type) > 0 ); #endif __vevo_port_t *port = (__vevo_port_t *) p; uint32_t hash_key = hash_key_code(key); @@ -1277,6 +1530,107 @@ vevo_property_set(vevo_port_t * p, return VEVO_ERROR_WRONG_ATOM_TYPE; if (pnode->st->flags & VEVO_PROPERTY_READONLY) { +#ifdef VVERBOSE + veejay_msg(VEEJAY_MSG_INFO, "Port %p property %s is read-only!",p,key); +#endif + return VEVO_ERROR_PROPERTY_READONLY; + } +#endif + vevo_free_storage(port,pnode->st); + //prop_node_free(pnode); + new = 0; + node = (void *) pnode; + } + } else { + hnode_t *old_node = NULL; + if ((old_node = property_exists(port, hash_key)) != NULL) { + vevo_storage_t *oldstor = + (vevo_storage_t *) hnode_get(old_node); +#ifdef STRICT_CHECKING + if (oldstor->atom_type != atom_type) + return VEVO_ERROR_WRONG_ATOM_TYPE; + + if (oldstor->flags & VEVO_PROPERTY_READONLY) + return VEVO_ERROR_PROPERTY_READONLY; +#endif + vevo_free_storage(port,oldstor); + + hash_delete((hash_t *) port->table, old_node); + hnode_destroy(old_node); + new = 0; + } + } + + vevo_storage_t *stor = vevo_new_storage(port); + storage_put_atom_value(port, src, num_elements, stor, atom_type); + + if (new) { + port_node_append(port, key, hash_key); + + if(!port->table) { + node = (void *) prop_node_append(port, hash_key, stor); + } + } +#ifdef STRICT_CHECKING + assert(stor != NULL); +#endif + + if (!port->table) { +#ifdef STRICT_CHECKING + assert(node != NULL); +#endif + if (!new) { + vevo_property_t *current = (vevo_property_t *) node; + current->st = stor; + } + } else { + hnode_t *node2 = hnode_create(stor); + +#ifdef STRICT_CHECKING + assert(node2 != NULL); + assert(!hash_isfull((hash_t *) port->table)); + assert(!property_exists(port, hash_key)); +#endif + + hash_insert((hash_t *) port->table, node2, (const void *) hash_key); + } + +#ifdef VVERBOSE + veejay_msg(VEEJAY_MSG_INFO, "Port %p <- set property %s", port, key ); +#endif + + return VEVO_NO_ERROR; +} + + +int +vevo_property_set_f(vevo_port_t * p, + const char *key, + int atom_type, int num_elements, void (*set_func)(), int (*get_func)() ) +{ +#ifdef STRICT_CHECKING + assert(p != NULL); + //@ no self referencing + assert( key != NULL ); +#endif + __vevo_port_t *port = (__vevo_port_t *) p; + uint32_t hash_key = hash_key_code(key); + int new = 1; + void *node = NULL; +#ifdef STRICT_CHECKING + assert( port != NULL ); +#endif + if (!port->table) { + vevo_property_t *pnode = NULL; + if ((pnode = prop_node_get(port, hash_key)) != NULL) { +#ifdef STRICT_CHECKING + if (pnode->st->atom_type != atom_type) + return VEVO_ERROR_WRONG_ATOM_TYPE; + if (pnode->st->flags & VEVO_PROPERTY_READONLY) + { +#ifdef VVERBOSE + veejay_msg(VEEJAY_MSG_INFO, "Port %p property %s is read-only!",p,key); +#endif return VEVO_ERROR_PROPERTY_READONLY; } #endif @@ -1306,13 +1660,13 @@ vevo_property_set(vevo_port_t * p, } vevo_storage_t *stor = vevo_new_storage(port); - storage_put_atom_value(port, src, num_elements, stor, atom_type); + storage_put_atom_func(port, set_func,get_func, stor, atom_type); if (new) { - port_node_append(port, key, hash_key); - if (!port->table) - node = (void *) prop_node_append(port, hash_key, stor); - } + port_node_append(port, key, hash_key); + if (!port->table) + node = (void *) prop_node_append(port, hash_key, stor); + } #ifdef STRICT_CHECKING assert(stor != NULL); #endif @@ -1338,9 +1692,15 @@ vevo_property_set(vevo_port_t * p, (const void *) hash_key); } +#ifdef VVERBOSE + veejay_msg(VEEJAY_MSG_INFO, "Port %p <- set property %s", port, key ); +#endif + return VEVO_NO_ERROR; } + + //! Get a value from a Property /*! \param p Port @@ -1366,6 +1726,9 @@ vevo_property_get(vevo_port_t * p, const char *key, int idx, void *dst) // if (dst == NULL) // return VEVO_NO_ERROR; // else +#ifdef VVERBOSE + veejay_msg(VEEJAY_MSG_INFO ,"Port %p -> get property %s[%d]",port,key,idx ); +#endif return atom_get_value(node->st, idx, dst); } } else { @@ -1374,14 +1737,113 @@ vevo_property_get(vevo_port_t * p, const char *key, int idx, void *dst) // if (dst == NULL) // return VEVO_NO_ERROR; // else +#ifdef VVERBOSE + veejay_msg(VEEJAY_MSG_INFO ,"Port %p -> get property %s[%d]", port,key,idx ); +#endif + return atom_get_value((vevo_storage_t *) hnode_get(node), idx, dst); } } +#ifdef VVERBOSE + veejay_msg(VEEJAY_MSG_INFO ,"Port %p -> no such property %s[%d]", port,key,idx ); +#endif return VEVO_ERROR_NOSUCH_PROPERTY; } +int +vevo_property_call(vevo_port_t * p, const char *key, void *ctx, int32_t type, int32_t value ) +{ +#ifdef STRICT_CHECKING + assert(p != NULL); + assert( key != NULL ); +#endif + __vevo_port_t *port = (__vevo_port_t *) p; + uint32_t hash_key = hash_key_code(key); + + if (!port->table) { + vevo_property_t *node = NULL; + if ((node = prop_node_get(port, hash_key)) != NULL) { + // if (dst == NULL) + // return VEVO_NO_ERROR; + // else +#ifdef VVERBOSE + veejay_msg(VEEJAY_MSG_INFO ,"Port %p -> call property %s",port,key ); +#endif + vevo_storage_t *s = node->st; + vevo_set_func vvfunc = (vevo_set_func) s->elements.atom->set_func; + vvfunc( ctx,type, value ); + return 1; + } + } else { + hnode_t *node = NULL; + if ((node = property_exists(port, hash_key)) != NULL) { + // if (dst == NULL) + // return VEVO_NO_ERROR; + // else +#ifdef VVERBOSE + veejay_msg(VEEJAY_MSG_INFO ,"Port %p -> call property %s", port,key ); +#endif + vevo_storage_t *s = (vevo_storage_t*) hnode_get(node); + vevo_set_func vvfunc = (vevo_set_func) s->elements.atom->set_func; + vvfunc( ctx,type, value ); + return 1; + } + } +#ifdef VVERBOSE + veejay_msg(VEEJAY_MSG_INFO ,"Port %p -> no such property %s", port,key ); +#endif + + return VEVO_ERROR_NOSUCH_PROPERTY; +} + +int +vevo_property_call_get(vevo_port_t * p, const char *key, void *ctx ) +{ +#ifdef STRICT_CHECKING + assert(p != NULL); + assert( key != NULL ); +#endif + __vevo_port_t *port = (__vevo_port_t *) p; + uint32_t hash_key = hash_key_code(key); + + if (!port->table) { + vevo_property_t *node = NULL; + if ((node = prop_node_get(port, hash_key)) != NULL) { + // if (dst == NULL) + // return VEVO_NO_ERROR; + // else +#ifdef VVERBOSE + veejay_msg(VEEJAY_MSG_INFO ,"Port %p -> call property %s",port,key ); +#endif + vevo_storage_t *s = node->st; + vevo_get_func vvfunc = (vevo_get_func) s->elements.atom->get_func; + return vvfunc( ctx ); + } + } else { + hnode_t *node = NULL; + if ((node = property_exists(port, hash_key)) != NULL) { + // if (dst == NULL) + // return VEVO_NO_ERROR; + // else +#ifdef VVERBOSE + veejay_msg(VEEJAY_MSG_INFO ,"Port %p -> call property %s", port,key ); +#endif + vevo_storage_t *s = (vevo_storage_t*) hnode_get(node); + vevo_get_func vvfunc = (vevo_get_func) s->elements.atom->get_func; + return vvfunc( ctx ); + } + } +#ifdef VVERBOSE + veejay_msg(VEEJAY_MSG_INFO ,"Port %p -> no such property %s", port,key ); +#endif + + return 0; +} + + + //! List all properties in a Port /*! \param p Port @@ -1419,8 +1881,8 @@ char **vevo_list_properties(vevo_port_t * p) #endif port_index_t *l = port->index; while (l != NULL) { - l = l->next; - n++; + l = l->next; + n++; } #ifdef STRICT_CHECKING @@ -1436,25 +1898,32 @@ char **vevo_list_properties(vevo_port_t * p) l = (port_index_t *) port->index; i = 0; + +#ifdef VVERBOSE + veejay_msg(VEEJAY_MSG_INFO, "Property list of port %p",port ); +#endif while (l != NULL) { #ifdef STRICT_CHECKING - if( vevo_property_atom_type( p, l->key ) != VEVO_ATOM_TYPE_HIDDEN ) - { +// if( vevo_property_atom_type( p, l->key ) != VEVO_ATOM_TYPE_HIDDEN ) +// { #endif list[i] = (char *) strdup(l->key); -#ifdef STRICT_CHECING - assert(list[i] != NULL); +#ifdef VVERBOSE + veejay_msg(VEEJAY_MSG_INFO, "\t%s", list[i]); #endif - i++; +#ifdef STRICT_CHECING + assert(list[i] != NULL); +#endif + i++; #ifdef STRICT_CHECKING - } +// } #endif - l = l->next; + l = l->next; //i++; } - list[i] = NULL; + list[i] = NULL; return list; } @@ -1528,7 +1997,11 @@ static int vevo_scan_for_atom( vevo_port_t *p, int atype ) \param atype Atom type \return List of vevo_storage_t */ +#ifdef STRICT_CHECKING +static vevo_storage_t **vevo_list_nodes_( vevo_port_t *p, int atype, int *msize ) +#else static vevo_storage_t **vevo_list_nodes_(vevo_port_t * p, int atype) +#endif { __vevo_port_t *port = (__vevo_port_t *) p; if(!p) return NULL; @@ -1548,12 +2021,16 @@ static vevo_storage_t **vevo_list_nodes_(vevo_port_t * p, int atype) while((node=hash_scan_next(&scan)) != NULL) { s = hnode_get(node); +#ifdef STRICT_CHECKING + if( msize ) ( *msize += vevo_storage_size( s ) ); +#endif if( (s && s->atom_type == atype) || atype == 0) { int type = 0; int ec = atom_get_value(s, 0, &type); - if( ec == VEVO_NO_ERROR && !s->softlink ) + if( ec == VEVO_NO_ERROR && !s->softlink ) { list[i++] = s; + } } } } @@ -1566,20 +2043,16 @@ static vevo_storage_t **vevo_list_nodes_(vevo_port_t * p, int atype) { n = l->next; s = l->st; - +#ifdef STRICT_CHECKING + if( msize ) { *msize += vevo_storage_size(s); } +#endif if( s->atom_type == atype || atype == 0 ) { int type = 0; int ec = atom_get_value(l->st, 0, &type); - /* if( (type != PORT_TYPE_FILTER_CLASS || - type != PORT_TYPE_CHANNEL_TEMPLATE || - type != PORT_TYPE_PARAMETER_TEMPLATE || - type != PORT_TYPE_PLUGIN_INFO ) && - ec != VEVO_ERROR_PROPERTY_EMPTY && - !(s->flags & VEVO_PROPERTY_SOFTREF)) - */ - if( ec == VEVO_NO_ERROR && !s->softlink ) + if( ec == VEVO_NO_ERROR && !s->softlink ) { list[i++] = s; + } } l = n; } @@ -1593,7 +2066,22 @@ static vevo_storage_t **vevo_list_nodes_(vevo_port_t * p, int atype) //! Report statistics and free bookkeeping information void vevo_report_stats() { -/* +#ifdef STRICT_CHECKING + char **items = vevo_list_properties( trackports ); + int i; + for( i = 0; items[i] != NULL; i ++ ) { + char *key = items[i]; + char *ref = vevo_property_get_string( trackports, key ); + if(ref ) veejay_msg(0, "never freed: %s, %s", key,ref ); + if( ref) free(ref); + free(items[i]); + } + free(items); + + vevo_port_free( trackports,__FUNCTION__,__LINE__ ); +#endif + /* +#ifdef VVERBOSE #ifdef STRICT_CHECKING if( port_ref_ ) { @@ -1602,6 +2090,7 @@ void vevo_report_stats() veejay_msg(0,"%d VEVO ports are still referenced",errs); vevo_port_free( port_ref_ ); } +#endif #endif*/ } @@ -1744,6 +2233,52 @@ int vevo_special_union_ports( void *port_a, void *port_b ) /**! \param port Port to destroy */ + + +#ifdef STRICT_CHECKING +int vevo_port_get_total_size_( vevo_port_t *port, int *n_ports ) +{ + char **items = vevo_list_properties( port ); + if( items == NULL ) + return 0; + int i; + int msize = 0; + for( i = 0; items[i] != NULL ; i ++ ) { + msize += vevo_property_atom_size( port, items[i] ); + if( vevo_property_atom_type(port, items[i]) == VEVO_ATOM_TYPE_PORTPTR ) { + void *child_port = NULL; + if(vevo_property_get( port, items[i], 0, &child_port ) == VEVO_NO_ERROR ) { + msize += vevo_port_get_total_size_( child_port, n_ports); + } + } + free(items[i]); + } + free(items); + + __vevo_port_t *p = (__vevo_port_t*) port; + if( p->pool ) { + msize += vevo_pool_size(p->pool); + } + + *n_ports ++; + return msize; +} +int vevo_port_get_total_size( vevo_port_t *port ) +{ + int n_ports = 0; + int total = vevo_port_get_total_size_( port, &n_ports ); + veejay_msg(VEEJAY_MSG_DEBUG, "\tPort %p holds %2.2f Kb memory",port, ( (float) total / 1024.0f )); + return total; +} + + +#else +int vevo_port_get_total_size( vevo_port_t *port ) +{ + return 0; +} +#endif + void vevo_port_recursive_free( vevo_port_t *port ) { if(!port) @@ -1757,10 +2292,15 @@ void vevo_port_recursive_free( vevo_port_t *port ) assert( sor != NULL ); #endif int i; +#ifdef STRICT_CHECKING + int msize = 0; + vevo_storage_t **item = vevo_list_nodes_( sor, VEVO_ATOM_TYPE_PORTPTR, &msize ); +#else vevo_storage_t **item = vevo_list_nodes_( sor, VEVO_ATOM_TYPE_PORTPTR ); +#endif if(!item) { - vevo_port_free(sor); + vevo_port_free_(sor); #ifdef STRICT_CHECKING assert( 0 ); #endif @@ -1781,14 +2321,14 @@ void vevo_port_recursive_free( vevo_port_t *port ) assert(sub_port != NULL); n_freed++; #endif - vevo_port_free( sub_port ); + vevo_port_free_( sub_port ); } } free(item); - vevo_port_free( sor ); + vevo_port_free_( sor ); } - +/* char **vevo_port_deepen_namespace( void *port, char *path) { #ifdef STRICT_CHECKING @@ -1814,6 +2354,10 @@ char **vevo_port_deepen_namespace( void *port, char *path) for( k = 0; top_level[k] != NULL ; k ++ ) { + if( vevo_property_is_protected( port, top_level[k] ) ) { + continue; + } + int atom_type = vevo_property_atom_type( port, top_level[k] ); if( atom_type != VEVO_ATOM_TYPE_VOIDPTR && atom_type != VEVO_ATOM_TYPE_PORTPTR ) { @@ -1829,92 +2373,86 @@ char **vevo_port_deepen_namespace( void *port, char *path) res[n] = NULL; return res; } - -char **vevo_port_recurse_namespace( vevo_port_t *port, const char *base ) - +*/ +/* +static void vevo_port_do_recursion( vevo_port_t *port, vevo_port_t *namespace, const char *base ) { - char **top_level = vevo_list_properties(port); if(!top_level) - return NULL; + return; + int k; - int num = 0; - for( k = 0; top_level[k] != NULL ; k ++ ) - { - int atom_type = vevo_property_atom_type( port, top_level[k] ); - if( atom_type == VEVO_ATOM_TYPE_PORTPTR ) - { - void *p = NULL; - int error = vevo_property_get( port, top_level[k],0,&p ); - if( error == VEVO_NO_ERROR ) - { -#ifdef STRICT_CHECKING - assert( p != NULL ); -#endif - num += vevo_num_properties(p); - } - } - else if (atom_type != VEVO_ATOM_TYPE_VOIDPTR) - num++; - } - -#ifdef STRICT_CHECKING - assert( num > 0 ); -#endif - - char **namespace = (char**) vj_malloc(sizeof(char*) * (num+1) ); -#ifdef STRICT_CHECKING - assert( namespace != NULL ); -#endif - memset(namespace, 0,sizeof(char*) * (num+1)); + int error; - int methods = 0; - int error; - for( k = 0; top_level[k] != NULL ; k ++ ) - { -#ifdef STRICT_CHECKING - assert( methods <= num ); -#endif - int atom_type = vevo_property_atom_type( port, top_level[k] ); - char path[256]; + error = vevo_property_set( namespace, base, LIVIDO_ATOM_TYPE_VOIDPTR, 0 , NULL ); - sprintf(path, "%s", base); - - if( atom_type == VEVO_ATOM_TYPE_PORTPTR ) - { - void *exp = NULL; - error = vevo_property_get( port, top_level[k],0,&exp ); + for( k = 0; top_level[k] != NULL ; k ++ ) { + int atom_type = vevo_property_atom_type( port, top_level[k] ); + //@ skip private properties + if( atom_type == VEVO_ATOM_TYPE_VOIDPTR ) { + free(top_level[k]); + continue; + } + //@ skip protected properties + if( vevo_property_is_protected( port, top_level[k] ) ) { + free(top_level[k]); + continue; + } + + if( atom_type != VEVO_ATOM_TYPE_PORTPTR ) { + //@ create path node + + char *path = vj_calloc(sizeof(char) * 256 ); + char *pathptr = vvstrcat( path, base ); + pathptr = vvstrcat( pathptr, "/" ); + char *pathnode= vvstr_valid_osc_name( top_level[k] ); + pathptr = vvstrcat( pathptr, pathnode ); + free(pathnode); + error = vevo_property_set( namespace, path, LIVIDO_ATOM_TYPE_VOIDPTR, 0 , NULL ); #ifdef STRICT_CHECKING assert( error == VEVO_NO_ERROR ); -#endif - strcat( path, "/" ); - strcat( path, top_level[k] ); +#endif + free(path); + } else { + void *child_port = NULL; + error = vevo_property_get( port, top_level[k],0, &child_port ); - char **ns = vevo_port_deepen_namespace( exp, path ); - if( ns ) - { - int j; - for( j = 0; ns[j] != NULL ; j ++ ) - { - namespace[methods] = strdup( ns[j]); - methods++; - free(ns[j]); - } - free(ns); - } - } - else if( atom_type != VEVO_ATOM_TYPE_VOIDPTR ) - { - strcat( path, "/" ); - strcat( path, top_level[k] ); - namespace[ methods ] = strdup( path ); - methods ++; + char *path = vj_calloc(sizeof(char) * 256 ); + char *pathptr = vvstrcat( path, base ); + pathptr = vvstrcat( pathptr, "/"); + char *pathnode= vvstr_valid_osc_name( top_level[k] ); + pathptr = vvstrcat( pathptr,pathnode ); + free(pathnode); + + error = vevo_property_set( namespace, path, LIVIDO_ATOM_TYPE_VOIDPTR, 0 , NULL ); +#ifdef STRICT_CHECKING + assert( error == VEVO_NO_ERROR ); +#endif + + vevo_port_do_recursion( child_port, namespace, path ); + + free(path); + } + free(top_level[k]); } free(top_level); - return namespace; } + + +void *vevo_port_recurse_namespace( vevo_port_t *port, const char *base ) +{ + void *ns = vpn( VEVO_ANONYMOUS_PORT ); + + vevo_port_do_recursion( port, ns, base ); + + return ns; +} + +*/ +//@ FIXME: method to recursivly iterate a port and all subports to size-up all data, vevo_port_get_total_size() + //! Flatten all ports and return list of ports to be destroyed /*! \param sorted_port Reference Port @@ -1924,8 +2462,11 @@ static void vevo_port_recurse_free( vevo_port_t *sorted_port, vevo_port_t *p ) { #ifdef STRICT_CHECKING assert( p != NULL ); -#endif + int msize = 0; + vevo_storage_t **item = vevo_list_nodes_( p, VEVO_ATOM_TYPE_PORTPTR,&msize ); +#else vevo_storage_t **item = vevo_list_nodes_( p, VEVO_ATOM_TYPE_PORTPTR ); +#endif if(!item) { free(item); @@ -2024,7 +2565,7 @@ static int vevo_port_ref_verify( vevo_port_t *p) } static char *vevo_property_get_str( vevo_port_t *port, const char *key ) { - size_t len = vevo_property_element_size( port, key, 0 ); + size_t len = vevo_property_element_size( port, key,0 ); char *ret = NULL; if(len<=0) return NULL; ret = (char*) malloc(sizeof(char) * len ); @@ -2054,6 +2595,9 @@ static char *vevo_format_inline_property( vevo_port_t *port, int n_elem, int typ case VEVO_ATOM_TYPE_DOUBLE: token[0] = 'g'; break; + case VEVO_ATOM_TYPE_UTF8STRING: + token[0] = 'S'; + break; } @@ -2062,8 +2606,13 @@ static char *vevo_format_inline_property( vevo_port_t *port, int n_elem, int typ int len = n_elem * strlen(token) + 1; res = (char*) calloc(1, sizeof(char) * len ); int i; - for( i =0; i < n_elem; i ++ ) - strncat( res,token,strlen(token) ); + /*for( i =0; i < n_elem; i ++ ) { + while( *res ) *res ++; + while( *res++ = *token++ ); + res--; + } FIXME: test me + */ + strncat( res,token,strlen(token) ); } return res; } @@ -2101,6 +2650,9 @@ char *vevo_format_property( vevo_port_t *port, const char *key ) break; case VEVO_ATOM_TYPE_PORTPTR: token[0] = 'p'; + break; + case VEVO_ATOM_TYPE_UTF8STRING: + token[0] = 'S'; break; default: token[0] = 'g'; @@ -2148,6 +2700,9 @@ char *vevo_format_kind( vevo_port_t *port, const char *key ) case VEVO_ATOM_TYPE_PORTPTR: token[0] = 'p'; break; + case VEVO_ATOM_TYPE_UTF8STRING: + token[0] = 'S'; + break; default: token[0] = 'g'; break; @@ -2283,6 +2838,23 @@ int vevo_sscanf_property( vevo_port_t *port, const char *s) if( format == NULL ) return done; + + if( atom == VEVO_ATOM_TYPE_FUNCPTR ) { + void *drv = NULL; + int err = vevo_property_get( port, "driver", 0, &drv ); + if( drv == NULL || err != VEVO_NO_ERROR ) { + veejay_msg(0, "No context for property '%s'", s ); + return 0; + } + + int32_t v; + if( sscanf( value, "%d", &v ) ) { + vevo_property_call( port, key, drv, v,v ); + return 1; + } + return 0; + } + if(atom==-1) atom = VEVO_ATOM_TYPE_DOUBLE; //@ if a property does not exist, DOUBLE is assumed @@ -2419,19 +2991,23 @@ char **vevo_sprintf_port( vevo_port_t *port ) char *vevo_sprintf_property_value( vevo_port_t *port, const char *key) { char tmp[512]; + char val[64]; int n = vevo_property_num_elements( port, key ); - if( n <= 0 ) - return NULL; + if( n <= 0 ) { + return strdup(""); + } + int i; int size = 0; int atom = vevo_property_atom_type( port , key ); - bzero(tmp,512); - + memset(tmp,0,sizeof(tmp)); + memset(val,0,sizeof(val)); + if(atom == VEVO_ATOM_TYPE_INT || atom == VEVO_ATOM_TYPE_BOOL) { - int *a = (int*) malloc(sizeof(int) * n ); - for( i = 0; i < n ; i ++ ) + int *a = (int*) vj_calloc(sizeof(int) * n ); + for( i = 0; i < n ; i ++ ) { if( vevo_property_get( port, key, i, &(a[i]) ) != VEVO_NO_ERROR) { free(a); @@ -2439,16 +3015,16 @@ char *vevo_sprintf_property_value( vevo_port_t *port, const char *key) } else { - char val[16]; - sprintf(val, "%4d", a[i]); + sprintf(val, "'%d'", a[i]); strcat( tmp, val ); strcat( tmp, " "); } + } free(a); } else if (atom == VEVO_ATOM_TYPE_DOUBLE ) { - double *a = (double*) malloc(sizeof(double) * n ); - for( i = 0; i < n; i ++ ) + double *a = (double*) vj_calloc(sizeof(double) * n ); + for( i = 0; i < n; i ++ ) { if( vevo_property_get( port, key, i , &(a[i])) != VEVO_NO_ERROR) { free(a); @@ -2456,15 +3032,39 @@ char *vevo_sprintf_property_value( vevo_port_t *port, const char *key) } else { - char val[16]; - sprintf(val, "%04.2g", a[i]); + sprintf(val, "'%g'", a[i]); strcat( tmp, val ); strcat( tmp, " " ); } + } free(a); - } else + } else if ( atom == VEVO_ATOM_TYPE_UINT64 ) { + uint64_t *a = (uint64_t*) vj_calloc(sizeof(uint64_t)*n); + for( i = 0; i < n; i ++ ) { + if( vevo_property_get(port,key,i, &(a[i])) != VEVO_NO_ERROR ) { + free(a); + return NULL; + } + else { + sprintf(val, "'%lld'", a[i]); + strcat(tmp,val); + strcat(tmp," "); + } + } + free(a); + } + else if ( atom == VEVO_ATOM_TYPE_STRING || atom == VEVO_ATOM_TYPE_UTF8STRING ) { + size_t len = vevo_property_element_size( port, key ,0); + if( len > 0 ) { + char *strv = vevo_property_get_string(port,key); + strcat(tmp, strv ); + strcat(tmp, " "); + free(strv); + } + } else + { return NULL; - + } return strdup( tmp ); } @@ -2525,6 +3125,7 @@ char *vevo_sprintf_property( vevo_port_t *port, const char *key ) nerr ++; break; case 's': + case 'S': str_val = vevo_property_get_str( port, key ); if(str_val) { @@ -2704,21 +3305,62 @@ int vevo_property_from_string( vevo_port_t *port, const char *s, const char *key char *vevo_property_get_string( void *port, const char *key ) { - size_t len = vevo_property_element_size( port, key, 0 ); + size_t len = vevo_property_element_size( port, key,0 ); char *ret = NULL; if(len<=0) return NULL; if( vevo_property_get( port, key,0,NULL ) != VEVO_NO_ERROR ) return NULL; - + int at = vevo_property_atom_type( port, key ); + #ifdef STRICT_CHECKING - assert( vevo_property_atom_type( port, key ) == VEVO_ATOM_TYPE_STRING ); + assert( at == VEVO_ATOM_TYPE_STRING || at == VEVO_ATOM_TYPE_UTF8STRING ); #endif ret = (char*) vj_malloc(sizeof(char) * len ); vevo_property_get( port, key, 0, &ret ); + + //@ string stored in utf8 +//n if( at == VEVO_ATOM_TYPE_UTF8STRING ) { +// gsize in,out; +// gchar *lcstr = g_locale_from_utf8( ret, len, &in, &out, NULL ); +// free(ret); +// return lcstr; +// } + return ret; } +char *vevo_property_get_utf8string( void *port, const char *key ) +{ +/* size_t len = vevo_property_element_size( port, key ,0); + char *ret = NULL; + if(len<=0) return NULL; + + if( vevo_property_get( port, key,0,NULL ) != VEVO_NO_ERROR ) + return NULL; + + int at = vevo_property_atom_type(port,key); + +#ifdef STRICT_CHECKING + assert( at == VEVO_ATOM_TYPE_STRING|| at == VEVO_ATOM_TYPE_UTF8STRING ); +#endif + ret = (char*) vj_malloc(sizeof(char) * len ); + vevo_property_get( port, key, 0, &ret ); + + if( at == VEVO_ATOM_TYPE_STRING ) + { + gsize in = 0; + gsize out = 0; + gchar *utf8_str = g_locale_to_utf8( (const gchar*) ret, len, &in, &out, NULL ); + free(ret); + return (char*) utf8_str; + + } + return ret; */ + return NULL; +} + + int vevo_property_del(vevo_port_t * p, @@ -2764,3 +3406,343 @@ vevo_property_del(vevo_port_t * p, return VEVO_NO_ERROR; } +char *vevo_tabs( int lvl ) { + char tmp[32]; + int i; + for( i = 0; i < lvl; i ++ ) + tmp[i] = '\t'; + tmp[lvl] = '\0'; + return strdup(tmp); +} + +static struct { //@ FIXME move to specific locations, use a register to register new port types and names + int id; + char *name; + +} port_types[] = +{ + { 1, "Livido Plugin Info" }, + { 2, "Livido Filter Class" }, + { 3, "Livido Instance" }, + { 4, "Livido Channel Template" }, + { 5, "Livido Parameter Template" }, + { 6, "Livido Channel" }, + { 7, "Livido Parameter" }, + { 8, "Livido GUI" }, + {10, "FreeFrame Port" }, + {11, "FreeFrame Parameter" }, + {20, "Frei0r Port"}, + {21, "Frei0r Parameter"}, + {30, "VEVO Livido Port"}, + {31, "VEVO Livido Parameter Port"}, + {100,"VEVO Illegal List"}, + {321,"VEVO Event Port"}, + {32, "VEVO Veejay FX"}, + {40, "VEVO Cache"}, + {1040, "VEVO Port Reference"}, + {2035, "VEVO Sample Port"}, + {2036, "VEVO Sample Bank Port"}, + {33, "VEVO Veejay FX Instance"}, + {-1, "VEVO Anonymous Port"}, + {0, NULL } +}; + +static char * vevo_identify_port( int type ) { + int i; + for( i = 0; port_types[i].name != NULL ; i ++ ) { + if( type == port_types[i].id ) + return port_types[i].name; + } + return "Illegal or unknown port type"; +} + +void vevo_port_dump( void *p, int lvl ) +{ + char **keys = vevo_list_properties(p); + int k; + + if( keys == NULL ) { + veejay_msg(0, "Port %p is empty",p); + return; + } + + void *voidval = NULL; + char *value = NULL; + int err = 0; + + char *tabs = NULL; + if( lvl > 0 ) + tabs = vevo_tabs( lvl ); + +#ifdef STRICT_CHECKING + veejay_msg(VEEJAY_MSG_DEBUG, "%s%p (%d bytes)", (tabs == NULL ? "/" : tabs ), p, + vevo_port_get_total_size(p)); +#else + veejay_msg( VEEJAY_MSG_DEBUG, "%s%p", (tabs == NULL ? "/" : tabs ), p ); +#endif + + for( k = 0; keys[k] != NULL; k ++ ) { + + if( strncasecmp( keys[k], "type",4 ) == 0 ) { + int tval = 0; + err = vevo_property_get( p, keys[k],0,&tval ); + veejay_msg(VEEJAY_MSG_DEBUG, "%s %s %s", + (tabs==NULL ? "->" : tabs ), keys[k], vevo_identify_port(tval)); + free( keys[k] ); + continue; + } + + int at = vevo_property_atom_type(p,keys[k]); + switch(at) { + case VEVO_ATOM_TYPE_PORTPTR: + err = vevo_property_get(p, keys[k], 0, &voidval ); + if( err == VEVO_NO_ERROR ) { + veejay_msg(VEEJAY_MSG_DEBUG, "%s %s:", + (tabs == NULL ? "->" : tabs ), keys[k]); + vevo_port_dump(voidval, lvl + 1); + } else { + veejay_msg(VEEJAY_MSG_DEBUG, "%s error code %d", + keys[k], err ); + } + break; + case VEVO_ATOM_TYPE_VOIDPTR: + err = vevo_property_get( p, keys[k], 0, &voidval ); + if( err == VEVO_NO_ERROR ) { + veejay_msg(VEEJAY_MSG_DEBUG, "%s %s VOID*", + (tabs==NULL ? "->" : tabs ), keys[k]); + } else { + veejay_msg(VEEJAY_MSG_DEBUG, "%s %s error code %d", + (tabs==NULL ? "->" : tabs ), keys[k],err); + } + break; + default: + value = vevo_sprintf_property_value( p, keys[k] ); + if( value == NULL ) { + veejay_msg(VEEJAY_MSG_DEBUG, "%s %s no value", + (tabs == NULL ? "->" : tabs), keys[k] ); + } else { + veejay_msg(VEEJAY_MSG_DEBUG, "%s %s (%d elements) %s", + (tabs == NULL ? "->" : tabs ), keys[k], + vevo_property_num_elements( p,keys[k]), + value ); + free(value); + } + break; + } + free(keys[k]); + } + if(tabs) free(tabs); + free(keys); + +} + +int vevo_property_clone( void *port, void *to_port, const char *key, const char *as_key ) +{ + const int n = vevo_property_num_elements(port, key); + const int t = vevo_property_atom_type( port, key ); + int i; + if( n <= 0 ) { + if( n == 0 ) + return VEVO_ERROR_PROPERTY_EMPTY; + return VEVO_ERROR_NOSUCH_ELEMENT; + } + + switch(t) { + case VEVO_ATOM_TYPE_INT: + case VEVO_ATOM_TYPE_BOOL: + { + int32_t *tmp = (int32_t*) malloc(sizeof(int32_t) * n ); + for(i = 0; i < n; i ++ ) { + if( vevo_property_get( port, key, i, &(tmp[i])) != VEVO_NO_ERROR ) { +#ifdef STRICT_CHECKING + veejay_msg(VEEJAY_MSG_DEBUG, "%s: %s -> %s element %d does not exist but reported size is %d elements", + __FUNCTION__, + key, + as_key, + i, + n ); +#endif + free(tmp); + return VEVO_ERROR_NOSUCH_ELEMENT; + } + } + if( n > 0 ) { + if( vevo_property_set( to_port, as_key, t, n, &tmp ) != VEVO_NO_ERROR ) { +#ifdef STRICT_CHECKING + veejay_msg(VEEJAY_MSG_DEBUG, "%s: %s -> %s unable to store %d elements (%d bytes)", __FUNCTION__, key,as_key, n, (n*sizeof(int32_t))); +#endif + free(tmp); + return VEVO_ERROR_MEMORY_ALLOCATION; + } + } else if (n == 0 ) { + vevo_property_set( to_port, as_key, t, 0, NULL ); + } + free(tmp); + } + break; + case VEVO_ATOM_TYPE_DOUBLE: + { + double *tmp = (double*) malloc(sizeof(double) * n ); + for(i = 0; i < n; i ++ ) { + if( vevo_property_get( port, key, i, &(tmp[i])) != VEVO_NO_ERROR ) { +#ifdef STRICT_CHECKING + veejay_msg(VEEJAY_MSG_DEBUG, "%s: %s -> %s element %d does not exist but reported size is %d elements", + __FUNCTION__, + key, + as_key, + i, + n ); +#endif + free(tmp); + return VEVO_ERROR_NOSUCH_ELEMENT; + } + } + + if( n > 0 ) { + if( vevo_property_set( to_port, as_key, t, n, &tmp ) != VEVO_NO_ERROR ) { +#ifdef STRICT_CHECKING + veejay_msg(VEEJAY_MSG_DEBUG, "%s: %s -> %s unable to store %d elements (%d bytes)", __FUNCTION__, key,as_key, n, (n*sizeof(double))); +#endif + free(tmp); + return VEVO_ERROR_MEMORY_ALLOCATION; + } + } else if ( n == 0 ) { + vevo_property_set(to_port, as_key, t, 0, NULL ); + } + free(tmp); + } + break; + case VEVO_ATOM_TYPE_UINT64: + { + uint64_t *tmp = (uint64_t*) malloc(sizeof(uint64_t) * n ); + for(i = 0; i < n; i ++ ) { + if( vevo_property_get( port, key, i, &(tmp[i])) != VEVO_NO_ERROR ) { +#ifdef STRICT_CHECKING + veejay_msg(VEEJAY_MSG_DEBUG, "%s: %s -> %s element %d does not exist but reported size is %d elements", + __FUNCTION__, + key, + as_key, + i, + n ); +#endif + free(tmp); + return VEVO_ERROR_NOSUCH_ELEMENT; + } + } + + if( n > 0 ) { + if( vevo_property_set( to_port, as_key, t, n, &tmp ) != VEVO_NO_ERROR ) { +#ifdef STRICT_CHECKING + veejay_msg(VEEJAY_MSG_DEBUG, "%s: %s -> %s unable to store %d elements (%d bytes)", __FUNCTION__, key,as_key, n, (n*sizeof(double))); +#endif + free(tmp); + return VEVO_ERROR_MEMORY_ALLOCATION; + } + } else if ( n == 0 ) { + vevo_property_set(to_port, as_key, t, 0, NULL ); + } + free(tmp); + } + break; + + case VEVO_ATOM_TYPE_STRING: + case VEVO_ATOM_TYPE_UTF8STRING: + { + if( n == 1 ) { + char *src = vevo_property_get_string( port, key ); + if( vevo_property_set(to_port, as_key, t, 1,&src ) != VEVO_NO_ERROR ) { +#ifdef STRICT_CHECKING + veejay_msg(VEEJAY_MSG_DEBUG, "%s: %s -> %s unable to store string '%s'", + __FUNCTION__, key,as_key,src ); +#endif + free(src); + return VEVO_ERROR_MEMORY_ALLOCATION; + } + } +#ifdef STRICT_CHECKING + else if ( n > 1 ) { + assert( n <= 0 ); // array of strings support + } +#endif + else if ( n == 0 ) { + if( vevo_property_set(to_port,as_key,t,0,NULL ) != VEVO_NO_ERROR ) { + return VEVO_ERROR_PROPERTY_EMPTY; + } + } + } + break; + default: +#ifdef STRICT_CHECKING + veejay_msg(VEEJAY_MSG_DEBUG, "%s: %s cannot be cloned.",__FUNCTION__,key ); +#endif + break; + + } + + + return VEVO_NO_ERROR; +} + +/* +void vevo_dom_dump( void *p, FILE *file ) +{ + char **keys = vevo_list_properties(p); + int k; + + if( keys == NULL ) { + veejay_msg(0, "Port %p is empty",p); + return; + } + + void *voidval = NULL; + char *value = NULL; + int err = 0; + + char *tabs = NULL; + + if( lvl == 0 || file == NULL ) { + file = fopen( "rw" ,"/tmp/port1.xml" ); + } + + for( k = 0; keys[k] != NULL; k ++ ) { + if( strncasecmp( keys[k], "type",4 ) == 0 ) { + int tval = 0; + err = vevo_property_get( p, keys[k],0,&tval ); + fprintf( file,"

%s

", vevo_identify_port(tval)); + continue; + } + + int at = vevo_property_atom_type(p,keys[k]); + switch(at) { + case VEVO_ATOM_TYPE_PORTPTR: + err = vevo_property_get(p, keys[k], 0, &voidval ); + if( err == VEVO_NO_ERROR ) { + fprintf(file,"
  • %s
  • ", keys[k] ); + vevo_dom_dump(voidval, file); + fprintf(file,"
"); + } else { + fprintf(file,"
  • %s with error %s
  • ", keys[k] ); + } + break; + case VEVO_ATOM_TYPE_VOIDPTR: + err = vevo_property_get( p, keys[k], 0, &voidval ); + if( err == VEVO_NO_ERROR ) { + fprintf( file, "
  • private
  • "); + + } else { + fprintf( file, "
  • private with error %s
  • ",keys[k]); + } + break; + default: + value = vevo_sprintf_property_value( p, keys[k] ); + fpritnf( file, "
  • %s%s
  • ",keys[k],value); + break; + } + free(keys[k]); + } + if(tabs) free(tabs); + free(keys); + + if( lvl == 0 ) + fclose(file); +}*/ diff --git a/veejay-current/veejay-server/libvevo/vevo.h b/veejay-current/veejay-server/libvevo/vevo.h index 33b636a4..73ce2b91 100644 --- a/veejay-current/veejay-server/libvevo/vevo.h +++ b/veejay-current/veejay-server/libvevo/vevo.h @@ -67,7 +67,7 @@ typedef void livido_port_t; #define LIVIDO_ATOM_TYPE_INT VEVO_ATOM_TYPE_INT #define LIVIDO_ATOM_TYPE_DOUBLE VEVO_ATOM_TYPE_DOUBLE #define LIVIDO_ATOM_TYPE_BOOLEAN VEVO_ATOM_TYPE_BOOL -#define LIVIDO_ATOM_TYPE_STRING VEVO_ATOM_TYPE_STRING +#define LIVIDO_ATOM_TYPE_STRING VEVO_ATOM_TYPE_UTF8STRING #define LIVIDO_ATOM_TYPE_VOIDPTR VEVO_ATOM_TYPE_VOIDPTR #define LIVIDO_ATOM_TYPE_PORTPTR VEVO_ATOM_TYPE_PORTPTR diff --git a/veejay-current/veejay-server/libyuv/yuvconv.c b/veejay-current/veejay-server/libyuv/yuvconv.c index ed50eb22..2495de3c 100644 --- a/veejay-current/veejay-server/libyuv/yuvconv.c +++ b/veejay-current/veejay-server/libyuv/yuvconv.c @@ -275,6 +275,58 @@ void yuv_init_lib(int extra_flags, int auto_ccir_jpeg, int default_zoomer) put( PIX_FMT_GRAY8, IMG_Y8 ); } +void yuv_plane_sizes( VJFrame *src, int *p1, int *p2, int *p3, int *p4 ) +{ + + switch(src->format) { + case PIX_FMT_YUV420P: + case PIX_FMT_YUVJ420P: + *p1 = src->len; + *p2 = src->len / 4; + *p3 = src->len / 4; + *p4 = 0; + break; + case PIX_FMT_YUV422P: + case PIX_FMT_YUVJ422P: + case PIX_FMT_YUVJ444P: + case PIX_FMT_YUV444P: + + if(p1 != NULL) { + *p1 = src->len; + } + if(p2 != NULL) { + *p2 = src->uv_len; + } + if(p3 != NULL) { + *p3 = src->uv_len; + } + + if(p4 != NULL) { + *p4 = 0; + } + + break; + default: + if(p1 != NULL) { + *p1 = src->len; + } + if(p2 != NULL) { + *p2 = 0; + } + if(p3 != NULL) { + *p3 = 0; + } + + if(p4 != NULL) { + *p4 = 0; + } + + break; + } + return 0; +} + + VJFrame *yuv_yuv_template( uint8_t *Y, uint8_t *U, uint8_t *V, int w, int h, int fmt ) { VJFrame *f = (VJFrame*) vj_calloc(sizeof(VJFrame)); diff --git a/veejay-current/veejay-server/libyuv/yuvconv.h b/veejay-current/veejay-server/libyuv/yuvconv.h index 90b1a4ad..037615c5 100644 --- a/veejay-current/veejay-server/libyuv/yuvconv.h +++ b/veejay-current/veejay-server/libyuv/yuvconv.h @@ -63,6 +63,8 @@ void yuv422_to_yuyv( uint8_t *yuv422[3], uint8_t *dst, int w, int h ); // scene detection int luminance_mean(uint8_t * frame[], int w, int h); +void yuv_plane_sizes( VJFrame *src, int *p1, int *p2, int *p3, int *p4 ); + /* software scaler from ffmpeg project: */ typedef struct diff --git a/veejay-current/veejay-server/veejay/liblavplayvj.c b/veejay-current/veejay-server/veejay/liblavplayvj.c index dc45d5fa..651818d9 100644 --- a/veejay-current/veejay-server/veejay/liblavplayvj.c +++ b/veejay-current/veejay-server/veejay/liblavplayvj.c @@ -2020,6 +2020,7 @@ int veejay_init(veejay_t * info, int x, int y,char *arg, int def_tags) driver = 0; } + if (vj_tag_init(el->video_width, el->video_height, info->pixel_format,driver) != 0) { veejay_msg(VEEJAY_MSG_ERROR, "Error while initializing Stream Manager"); return -1; diff --git a/veejay-current/veejay-server/veejay/vj-event.c b/veejay-current/veejay-server/veejay/vj-event.c index 7b581804..c5a0a67c 100644 --- a/veejay-current/veejay-server/veejay/vj-event.c +++ b/veejay-current/veejay-server/veejay/vj-event.c @@ -619,7 +619,7 @@ static void reset_macro_(void) strokes, current_macro_ ); free(items); } - vevo_port_free(macro_port_); + vpf(macro_port_); macro_bank_[ current_macro_ ] = NULL; macro_port_ = NULL; } diff --git a/veejay-current/veejay-server/veejay/vj-eventman.c b/veejay-current/veejay-server/veejay/vj-eventman.c index 79cb03b4..9dd61cbc 100644 --- a/veejay-current/veejay-server/veejay/vj-eventman.c +++ b/veejay-current/veejay-server/veejay/vj-eventman.c @@ -374,7 +374,7 @@ void vj_event_vevo_free(void) return; for( i = 0 ; i < MAX_INDEX ; i ++ ) - if( index_map_[i] ) vevo_port_free( index_map_[i] ); + if( index_map_[i] ) vpf( index_map_[i] ); free(index_map_); } diff --git a/veejay-current/veejay-server/veejay/vj-font.c b/veejay-current/veejay-server/veejay/vj-font.c index c0692db8..73478c2b 100644 --- a/veejay-current/veejay-server/veejay/vj-font.c +++ b/veejay-current/veejay-server/veejay/vj-font.c @@ -1456,7 +1456,7 @@ void vj_font_dictionary_destroy( void *font, void *dict ) { char **items = vevo_list_properties(dict ); if(!items) { - vevo_port_free(dict); + vpf(dict); return; } @@ -1474,7 +1474,7 @@ void vj_font_dictionary_destroy( void *font, void *dict ) free(items[i]); } free(items); - vevo_port_free( dict ); + vpf( dict ); } diff --git a/veejay-current/veejay-server/veejay/vj-osc.c b/veejay-current/veejay-server/veejay/vj-osc.c index 7aa1acc5..64c283fa 100644 --- a/veejay-current/veejay-server/veejay/vj-osc.c +++ b/veejay-current/veejay-server/veejay/vj-osc.c @@ -218,7 +218,7 @@ void vj_osc_free(void *d) free(addr); //if(c->osc_args) free(c->osc_args); if(c->leaves) free(c->leaves); - if(c->index) vevo_port_free(c->index); + if(c->index) (c->index); if(c) free(c); c = NULL; @@ -298,21 +298,21 @@ static void osc_add_client(void *context, int arglen, const void *vargs, OSCTime if(vevo_property_set( osc_clients[free_id], "lo", VEVO_ATOM_TYPE_VOIDPTR,1, &t ) != VEVO_NO_ERROR ) { veejay_msg(0, "Unable to add lo_address to vevo port."); - vevo_port_free( osc_clients[free_id] ); + ( osc_clients[free_id] ); osc_clients[free_id] = NULL; return; } if(vevo_property_set( osc_clients[free_id], "cmd", VEVO_ATOM_TYPE_STRING, 1, &cmd ) != VEVO_NO_ERROR ) { veejay_msg(0, "Unable to store command '%s'", cmd ); - vevo_port_free(osc_clients[free_id]); + (osc_clients[free_id]); osc_clients[free_id]=NULL; return; } if( vevo_property_set( osc_clients[free_id], "connection", VEVO_ATOM_TYPE_STRING,1,&nptr ) != VEVO_NO_ERROR ) { veejay_msg(0, "Unable to store connection string."); - vevo_port_free(osc_clients[free_id]); + (osc_clients[free_id]); osc_clients[free_id] = NULL; return; } @@ -426,7 +426,7 @@ static void osc_iterate_clients() int res = osc_client_status_send( clnt, cmd ); if( res == 0 ) { - vevo_port_free( port ); + ( port ); osc_clients[i] = NULL; veejay_msg(VEEJAY_MSG_WARNING,"Failed to send %s",cmd); } diff --git a/veejay-current/veejay-server/veejay/vj-perform.c b/veejay-current/veejay-server/veejay/vj-perform.c index 7460cf8c..889322f1 100644 --- a/veejay-current/veejay-server/veejay/vj-perform.c +++ b/veejay-current/veejay-server/veejay/vj-perform.c @@ -320,15 +320,15 @@ static int vj_perform_increase_sample_frame(veejay_t * info, long num) int start,end,looptype,speed; int ret_val = 1; - if(num == 0 ) return 1; - if(sample_get_short_info(info->uc->sample_id,&start,&end,&looptype,&speed)!=0) return -1; settings->current_playback_speed = speed; int cur_sfd = sample_get_framedups( info->uc->sample_id ); int max_sfd = sample_get_framedup( info->uc->sample_id ); - cur_sfd ++; + + if( num ) + cur_sfd ++; if( max_sfd > 0 ) { if( cur_sfd >= max_sfd ) @@ -342,13 +342,16 @@ static int vj_perform_increase_sample_frame(veejay_t * info, long num) } settings->current_frame_num += num; + if( num == 0 ) + return 1; + if (speed >= 0) { /* forward play */ if(looptype==3) { int range = end - start; - int num = start + ((int) ( (double)range * rand()/(RAND_MAX))); - settings->current_frame_num = num; + int n2 = start + ((int) ( (double)range * rand()/(RAND_MAX))); + settings->current_frame_num = n2; } if (settings->current_frame_num > end || settings->current_frame_num < start) { @@ -390,11 +393,11 @@ static int vj_perform_increase_sample_frame(veejay_t * info, long num) } } } else { /* reverse play */ - if( looptype == 3 ) + if( looptype == 3) { int range = end - start; - int num = end - ((int) ( (double)range*rand()/(RAND_MAX))); - settings->current_frame_num = num; + int n2 = end - ((int) ( (double)range*rand()/(RAND_MAX))); + settings->current_frame_num = n2; } if (settings->current_frame_num < start || settings->current_frame_num >= end ) { @@ -1346,14 +1349,13 @@ static int vj_perform_get_subframe(veejay_t * info, int sub_sample, /* offset + start >= end */ if(sample_b[3] >= 0) /* sub sample plays forward */ { - if( settings->current_playback_speed != 0) - offset += sample_b[3]; /* speed */ + offset += sample_b[3]; /* speed */ if( sample_b[2] == 3 ) offset = sample_b[0] + ( (int) ( (double) len_b * rand()/RAND_MAX) ); /* offset reached sample end */ - if( offset > len_b ) + if( offset > len_b ) { if(sample_b[2] == 2) /* sample is in pingpong loop */ { @@ -1381,8 +1383,7 @@ static int vj_perform_get_subframe(veejay_t * info, int sub_sample, } else { /* sub sample plays reverse */ - if(settings->current_playback_speed != 0) - offset += sample_b[3]; /* speed */ + offset += sample_b[3]; /* speed */ if( sample_b[2] == 3 ) offset = sample_b[0] + ( (int) ( (double) len_b * rand()/RAND_MAX));