From 42f831a26492b66cf4a5803db5775e723ea3749c Mon Sep 17 00:00:00 2001 From: Niels Elburg Date: Fri, 9 Sep 2005 23:38:12 +0000 Subject: [PATCH] Fix overwriting of effect chain entries , fixed loading of acton file on commandline , dummy mode -d is broken git-svn-id: svn://code.dyne.org/veejay/trunk@389 eb8d1916-c9e9-0310-b8de-cf0c9472ead5 --- veejay-current/gveejay-reloaded/vj-api.c | 2 + veejay-current/libstream/vj-tag.c | 2 +- veejay-current/veejay/liblavplayvj.c | 202 +++++++++++------------ veejay-current/veejay/veejay.c | 8 +- veejay-current/veejay/vj-event.c | 10 +- veejay-current/veejay/vj-sdl.c | 1 + 6 files changed, 105 insertions(+), 120 deletions(-) diff --git a/veejay-current/gveejay-reloaded/vj-api.c b/veejay-current/gveejay-reloaded/vj-api.c index 5a720078..299cf219 100644 --- a/veejay-current/gveejay-reloaded/vj-api.c +++ b/veejay-current/gveejay-reloaded/vj-api.c @@ -3611,6 +3611,8 @@ on_effectlist_row_activated(GtkTreeView *treeview, { multi_vims(VIMS_CHAIN_ENTRY_SET_EFFECT, "%d %d %d", 0, info->uc.selected_chain_entry,gid ); + if(info->status_tokens[PLAY_MODE] == MODE_SAMPLE) + vj_kf_delete_parameter(info->uc.selected_chain_entry); info->uc.reload_hint[HINT_CHAIN] = 1; info->uc.reload_hint[HINT_ENTRY] = 1; } diff --git a/veejay-current/libstream/vj-tag.c b/veejay-current/libstream/vj-tag.c index 61e39dd4..cd12c4fd 100644 --- a/veejay-current/libstream/vj-tag.c +++ b/veejay-current/libstream/vj-tag.c @@ -168,7 +168,7 @@ int vj_tag_init(int width, int height, int pix_fmt) { int i; TagHash = hash_create(HASHCOUNT_T_MAX, int_tag_compare, int_tag_hash); - if (!TagHash) + if (!TagHash || width <= 0 || height <= 0) return -1; vj_tag_input = (vj_tag_data *) vj_malloc(sizeof(vj_tag_data)); if (vj_tag_input == NULL) { diff --git a/veejay-current/veejay/liblavplayvj.c b/veejay-current/veejay/liblavplayvj.c index 9ea76ff0..14504748 100644 --- a/veejay-current/veejay/liblavplayvj.c +++ b/veejay-current/veejay/liblavplayvj.c @@ -214,14 +214,22 @@ int veejay_get_state(veejay_t *info) { * veejay_change_state() * change the state ******************************************************/ +void breaknow() { } void veejay_change_state(veejay_t * info, int new_state) { video_playback_setup *settings = (video_playback_setup *) info->settings; settings->state = new_state; if(settings->state == LAVPLAY_STATE_STOP) { - veejay_msg(VEEJAY_MSG_WARNING, "Stopping veejay"); + veejay_msg(VEEJAY_MSG_WARNING, "Stop"); } + if(settings->state == LAVPLAY_STATE_PLAYING) { + veejay_msg(VEEJAY_MSG_WARNING, "Play"); + } + if(settings->state == LAVPLAY_STATE_PAUSED) { + veejay_msg(VEEJAY_MSG_WARNING, "Paused"); + } + } void veejay_set_sampling(veejay_t *info, subsample_mode_t m) @@ -340,9 +348,9 @@ int veejay_set_speed(veejay_t * info, int speed) vj_jack_continue( settings->current_playback_speed ); #endif - if( settings->current_playback_speed != 0 && +/* if( settings->current_playback_speed != 0 && settings->state != LAVPLAY_STATE_PLAYING) - veejay_change_state( info, LAVPLAY_STATE_PLAYING ); + veejay_change_state( info, LAVPLAY_STATE_PLAYING );*/ return 1; } @@ -421,6 +429,7 @@ int veejay_free(veejay_t * info) { if(info->settings->action_scheduler.sl ) free(info->settings->action_scheduler.sl ); + info->settings->action_scheduler.state = 0; } if( info->plugin_frame) vj_perform_free_plugin_frame(info->plugin_frame); @@ -466,7 +475,7 @@ int veejay_set_frame(veejay_t * info, long framenum) if(framenum > (info->edit_list->video_frames-1)) { veejay_msg(VEEJAY_MSG_ERROR, "Cannot set frame %ld",framenum); - return -1; +// return -1; } if(info->uc->playback_mode==VJ_PLAYBACK_MODE_SAMPLE) @@ -659,7 +668,6 @@ void veejay_set_sample(veejay_t * info, int sampleid) veejay_msg(VEEJAY_MSG_INFO, "Playing stream %d", sampleid); - veejay_msg(VEEJAY_MSG_DEBUG, "EDL = %p, New EDL = %p", info->edit_list, info->current_edit_list ); info->edit_list = info->current_edit_list; return; @@ -787,8 +795,6 @@ static int veejay_screen_update(veejay_t * info ) uint8_t *c_frame[3]; int i = 0; - - vj_perform_unlock_primary_frame(); // get the frame to output, in 420 or 422 if (info->uc->take_bg==1) @@ -1197,7 +1203,6 @@ static void *veejay_mjpeg_playback_thread(void *arg) veejay_change_state( info, LAVPLAY_STATE_STOP); } - settings->currently_processed_entry = settings->buffer_entry[settings->currently_processed_frame]; /* sync timestamp */ @@ -1285,7 +1290,6 @@ int veejay_open(veejay_t * info) veejay_msg(VEEJAY_MSG_DEBUG,"Starting software playback thread"); - if( pthread_create(&(settings->software_playback_thread), NULL, veejay_mjpeg_playback_thread, (void *) info)) { veejay_msg(VEEJAY_MSG_ERROR, @@ -1388,7 +1392,6 @@ static int veejay_mjpeg_queue_buf(veejay_t * info, int frame, settings->valid[frame] = frame_periods; pthread_cond_broadcast(&(settings->buffer_filled[frame])); pthread_mutex_unlock(&(settings->valid_mutex)); - return 1; } @@ -1478,6 +1481,7 @@ int veejay_init(veejay_t * info, int x, int y,char *arg, int def_tags) vj_event_init(); + #ifdef HAVE_XML2 if(info->load_action_file) { @@ -1508,6 +1512,19 @@ int veejay_init(veejay_t * info, int x, int y,char *arg, int def_tags) "Cannot initialize the EditList"); return -1; } + /* initialize tags (video4linux/yuv4mpeg stream ... ) */ + veejay_msg(VEEJAY_MSG_DEBUG, + "Editlist is supposed to be ready %d, %d\n", info->current_edit_list->video_width, + info->current_edit_list->video_height ); + + if (vj_tag_init(info->current_edit_list->video_width, info->current_edit_list->video_height, info->pixel_format) != 0) { + veejay_msg(VEEJAY_MSG_ERROR, "Error while initializing stream manager"); + return -1; + } + + sample_init( (info->current_edit_list->video_width * info->current_edit_list->video_height) ); + + if(!vj_perform_init(info)) { @@ -1654,32 +1671,20 @@ int veejay_init(veejay_t * info, int x, int y,char *arg, int def_tags) return -1; } - if(arg != NULL ) { -#ifdef HAVE_XML2 - veejay_msg(VEEJAY_MSG_INFO, "Loading samplelist [%s]", arg); - if (!sample_readFromFile( arg )) - { - veejay_msg(VEEJAY_MSG_ERROR, "Error loading samplelist [%s]",arg); - return -1; - } -#endif - } - else + if( info->settings->action_scheduler.sl && info->settings->action_scheduler.state ) { - // try samplelist from loaded action file, if the editlist was initialized - if( info->settings->action_scheduler.sl && info->settings->action_scheduler.state ) - { - if(sample_readFromFile( info->settings->action_scheduler.sl ) ) - veejay_msg(VEEJAY_MSG_INFO, "Loaded sample list %s from actionfile", + if(sample_readFromFile( info->settings->action_scheduler.sl ) ) + veejay_msg(VEEJAY_MSG_INFO, "Loaded sample list %s from actionfile", info->settings->action_scheduler.sl ); - } } + if( settings->action_scheduler.state ) { veejay_msg(VEEJAY_MSG_DEBUG, "Finish pending actions from configuration file ..."); veejay_finish_action_file(info,info->action_file); - } + settings->action_scheduler.state = 0; + } if( !vj_server_setup(info) ) { veejay_msg(VEEJAY_MSG_ERROR,"Setting up server"); @@ -1781,33 +1786,17 @@ int veejay_init(veejay_t * info, int x, int y,char *arg, int def_tags) } - /* After we have fired up the audio and video threads system (which - * are assisted if we're installed setuid root, we want to set the - * effective user id to the real user id - */ - if (seteuid(getuid()) < 0) { - /* fixme: get rid of sys_errlist and use sys_strerror */ - veejay_msg(VEEJAY_MSG_ERROR, - "Can't set effective user-id: %s", sys_errlist[errno]); - return -1; - } - - veejay_change_state( info, LAVPLAY_STATE_PLAYING ); - - if (!veejay_mjpeg_set_playback_rate(info, el->video_fps, - el->video_norm == - 'p' ? VIDEO_MODE_PAL : VIDEO_MODE_NTSC)) { - return -1; - } if(info->dummy->active) { int dummy_id; - if( settings->action_scheduler.state ) - dummy_id = vj_tag_size()-1; - else + /* Use dummy mode, action file could have specified something */ + if( vj_tag_size()-1 <= 0 ) dummy_id = vj_tag_new( VJ_TAG_TYPE_COLOR, "Solid", -1, info->current_edit_list,info->pixel_format,-1); + else + dummy_id = vj_tag_size()-1; + if(dummy_id > 0) { veejay_msg(VEEJAY_MSG_INFO, "Activating dummy mode (Stream %d)", dummy_id); @@ -1820,10 +1809,30 @@ int veejay_init(veejay_t * info, int x, int y,char *arg, int def_tags) } } - if (veejay_open(info) != 1) { - veejay_msg(VEEJAY_MSG_ERROR, - "Unable to initialize the threading system"); + /* After we have fired up the audio and video threads system (which + * are assisted if we're installed setuid root, we want to set the + * effective user id to the real user id + */ + if (seteuid(getuid()) < 0) { + /* fixme: get rid of sys_errlist and use sys_strerror */ + veejay_msg(VEEJAY_MSG_ERROR, + "Can't set effective user-id: %s", sys_errlist[errno]); + return -1; } + + veejay_change_state( info, LAVPLAY_STATE_PLAYING ); + + if (!veejay_mjpeg_set_playback_rate(info, el->video_fps, + el->video_norm == + 'p' ? VIDEO_MODE_PAL : VIDEO_MODE_NTSC)) { + return -1; + } + + if(veejay_open(info) != 1) { + veejay_msg(VEEJAY_MSG_ERROR, + "Unable to initialize the threading system"); + return -1; + } return 0; } @@ -2386,7 +2395,7 @@ int veejay_main(veejay_t * info) sync(); // veejay_change_state(info, LAVPLAY_STATE_PAUSED); - // veejay_msg(VEEJAY_MSG_INFO, "Starting playback thread. Giving control to main app"); + veejay_msg(VEEJAY_MSG_INFO, "Starting playback thread. Giving control to main app"); /* fork ourselves to return control to the main app */ if (pthread_create(&(settings->playback_thread), NULL, @@ -2945,7 +2954,7 @@ int veejay_save_all(veejay_t * info, char *filename, long n1, long n2) * * return value: 1 on succes, 0 on error ******************************************************/ - +// open_video_files is called BEFORE init static int veejay_open_video_files(veejay_t *info, char **files, int num_files, int force_pix_fmt, int force , char override_norm) { vj_el_frame_cache(info->seek_cache ); @@ -2957,7 +2966,13 @@ static int veejay_open_video_files(veejay_t *info, char **files, int num_files, veejay_msg(VEEJAY_MSG_DEBUG, "Note that this will effect your recorded video samples"); } - if( num_files == 0 ) + if(num_files<=0 || files == NULL) + { + veejay_msg(VEEJAY_MSG_WARNING, "Fallback to dummy - no video files given at commandline"); + info->dummy->active = 1; + } + + if( info->dummy->active ) { if( !info->dummy->norm ) info->dummy->norm = 'p'; @@ -2975,8 +2990,6 @@ static int veejay_open_video_files(veejay_t *info, char **files, int num_files, info->current_edit_list = vj_el_dummy( 0, info->auto_deinterlace, info->dummy->chroma, info->dummy->norm, info->dummy->width, info->dummy->height, info->dummy->fps ); - info->dummy->active = 1; - veejay_msg(VEEJAY_MSG_DEBUG, "Dummy: %d x %d, %s %s ", info->dummy->width,info->dummy->height, (info->dummy->norm == 'p' ? "PAL": "NTSC" ), ( force_pix_fmt == 0 ? "4:2:0" : "4:2:2" )); @@ -3045,86 +3058,57 @@ static int veejay_open_video_files(veejay_t *info, char **files, int num_files, { info->settings->output_fps = info->current_edit_list->video_fps; } +// init tags , samples ? return 1; } int veejay_open_files(veejay_t * info, char **files, int num_files, float ofps, int force,int force_pix_fmt, char override_norm) { - char *argv[1]; int ret = 0; - argv[0] = NULL; video_playback_setup *settings = (video_playback_setup *) info->settings; - /* see if action file conflicts with files given on commandline */ - if(settings->action_scheduler.state == 2 && num_files <= 0 ) - { - veejay_msg(VEEJAY_MSG_ERROR, "Start Veejay with -d and without any filename"); - return 0; - } - /* override options */ - if(settings->action_scheduler.state ) - { + if(ofps<=0.0) ofps = settings->output_fps; - force = 0; + if(force_pix_fmt<0) force_pix_fmt = info->pixel_format; - veejay_msg(VEEJAY_MSG_INFO, - "Liveset: %2.2f FPS, pixel format %s", - ofps, (force_pix_fmt == FMT_422 ? "YUV 4:2:2 (SMPTE)" : "YUV 4:2:0 (JPEG/MPEG1)" )); - } settings->output_fps = ofps; - /* load editlist from configfile - if( settings->action_scheduler.state == 2 ) + if(num_files == 0) { - veejay_msg(VEEJAY_MSG_ERROR, "Cant open editlist in configfile!"); - return 0; - } - }*/ - - if( settings->action_scheduler.state == 1 ) - { - veejay_msg(VEEJAY_MSG_INFO, - "Liveset: start in Dummy mode"); + veejay_msg(VEEJAY_MSG_DEBUG, "Trying to start without video"); ret = veejay_open_video_files( info, NULL, 0 , force_pix_fmt, force, override_norm ); } + else + { + ret = veejay_open_video_files( info, files, num_files, force_pix_fmt, force, + override_norm ); + } if(!ret) - ret = veejay_open_video_files( info, files, num_files, force_pix_fmt, force, - override_norm ); - - if( ret ) { - /* initialize tags (video4linux/yuv4mpeg stream ... ) */ - if (vj_tag_init(info->current_edit_list->video_width, info->current_edit_list->video_height, info->pixel_format) != 0) { - veejay_msg(VEEJAY_MSG_ERROR, "Error while initializing stream manager"); - return 0; - } - - sample_init( (info->current_edit_list->video_width * info->current_edit_list->video_height) ); - - /* create samples from EDL */ - if( info->uc->file_as_sample) + veejay_msg(VEEJAY_MSG_ERROR, "Failed to start veejay"); + return ret; + } + /* create samples from EDL */ + if( info->uc->file_as_sample) + { + long i,n=info->current_edit_list->num_video_files; + for(i = 0; i < n; i ++ ) { - long i,n=info->current_edit_list->num_video_files; - for(i = 0; i < n; i ++ ) + long start,end; + if(vj_el_get_file_entry( info->current_edit_list, &start,&end, i )) { - long start,end; - if(vj_el_get_file_entry( info->current_edit_list, &start,&end, i )) - { - sample_info *skel = sample_skeleton_new( start,end ); - sample_store(skel); - } - } + sample_info *skel = sample_skeleton_new( start,end ); + sample_store(skel); + } } } - - return ret; } diff --git a/veejay-current/veejay/veejay.c b/veejay-current/veejay/veejay.c index 12771ac0..38584da1 100644 --- a/veejay-current/veejay/veejay.c +++ b/veejay-current/veejay/veejay.c @@ -290,8 +290,6 @@ static int set_option(const char *name, char *value) #ifdef HAVE_XML2 } else if (strcmp(name, "action-file")==0 || strcmp(name,"l")==0) { check_val(optarg,name); - if(!veejay_load_action_file( info, (char*) optarg )) - exit(1); strcpy(info->action_file,(char*) optarg); info->load_action_file = 1; #endif @@ -424,7 +422,7 @@ static int set_option(const char *name, char *value) } else if (strcmp(name, "dummy") == 0 || strcmp(name, "d" ) == 0 ) { - + info->dummy->active = 1; // enable DUMMY MODE } else nerr++; /* unknown option - error */ @@ -671,7 +669,11 @@ int main(int argc, char **argv) return 1; } + //veejay_set_frame(info, 0); + veejay_msg(VEEJAY_MSG_DEBUG, "Starting playback"); + veejay_change_state(info, LAVPLAY_STATE_PLAYING); veejay_set_frame(info, 0); + veejay_set_speed(info, 1); while (veejay_get_state(info) != LAVPLAY_STATE_STOP) diff --git a/veejay-current/veejay/vj-event.c b/veejay-current/veejay/vj-event.c index a10b25cc..f2448466 100644 --- a/veejay-current/veejay/vj-event.c +++ b/veejay-current/veejay/vj-event.c @@ -57,7 +57,7 @@ static int _last_known_num_args = 0; -static hash_t *BundleHash; +static hash_t *BundleHash = NULL; static int vj_event_valid_mode(int mode) { switch(mode) { @@ -1900,8 +1900,9 @@ void vj_event_xml_parse_config( veejay_t *v, xmlDocPtr doc, xmlNodePtr cur ) { v->settings->action_scheduler.sl = strdup( sample_list ); veejay_msg(VEEJAY_MSG_DEBUG, "Scheduled '%s' for restart", sample_list ); + + v->settings->action_scheduler.state = 1; } - v->settings->action_scheduler.state = 1; } void vj_event_xml_parse_stream( veejay_t *v, xmlDocPtr doc, xmlNodePtr cur ) @@ -1952,10 +1953,6 @@ void vj_event_xml_new_keyb_event( void *ptr, xmlDocPtr doc, xmlNodePtr cur ) int key_mod = 0; int event_id = 0; - if( veejay_get_state( (veejay_t*) ptr ) == LAVPLAY_STATE_STOP ) - { - return; - } char msg[4096]; bzero( msg,4096 ); @@ -2061,7 +2058,6 @@ int veejay_finish_action_file( void *ptr, char *file_name ) xmlFreeDoc(doc); veejay_change_playback_mode( v, v->uc->playback_mode, v->uc->sample_id ); - return 1; } diff --git a/veejay-current/veejay/vj-sdl.c b/veejay-current/veejay/vj-sdl.c index 9d42b7e4..23f32f39 100644 --- a/veejay-current/veejay/vj-sdl.c +++ b/veejay-current/veejay/vj-sdl.c @@ -52,6 +52,7 @@ vj_sdl *vj_sdl_allocate(int width, int height, int fmt) vjsdl->sw_scale_height = 0; vjsdl->custom_geo[0] = -1; vjsdl->custom_geo[1] = -1; + vjsdl->show_cursor = 0; return vjsdl; }