mirror of
https://github.com/game-stop/veejay.git
synced 2026-01-04 22:15:29 +01:00
Added update scheduler for reloaded
git-svn-id: svn://code.dyne.org/veejay/trunk@1058 eb8d1916-c9e9-0310-b8de-cf0c9472ead5
This commit is contained in:
@@ -135,6 +135,43 @@ static int set_option( const char *name, char *value )
|
||||
return err;
|
||||
}
|
||||
static volatile gulong g_trap_free_size = 0;
|
||||
static struct timeval time_last_;
|
||||
|
||||
static char **cargv = NULL;
|
||||
|
||||
|
||||
gboolean gveejay_idle(gpointer data)
|
||||
{
|
||||
if(gveejay_running())
|
||||
{
|
||||
is_alive();
|
||||
if( gveejay_time_to_sync( get_ui_info() ) )
|
||||
{
|
||||
veejay_update_multitrack( get_ui_info() );
|
||||
update_gveejay();
|
||||
}
|
||||
}
|
||||
if( gveejay_restart() )
|
||||
{
|
||||
if( execvp( cargv[0], cargv ) == -1 )
|
||||
veejay_msg(VEEJAY_MSG_ERROR, "Unable to restart");
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void clone_args( char *argv[], int argc )
|
||||
{
|
||||
int i = 0;
|
||||
if( argc <= 0 )
|
||||
return;
|
||||
|
||||
cargv = (char**) malloc(sizeof(char*) * (argc+1) );
|
||||
memset( cargv, 0, sizeof(char*) * (argc+1));
|
||||
for( i = 0; i < argc ; i ++ )
|
||||
cargv[i] = strdup( argv[i] );
|
||||
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
char option[2];
|
||||
@@ -143,6 +180,8 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
if(!argc) usage(argv[0]);
|
||||
|
||||
clone_args( argv, argc );
|
||||
|
||||
// default host to connect to
|
||||
sprintf(hostname, "127.0.0.1");
|
||||
|
||||
@@ -198,30 +237,12 @@ int main(int argc, char *argv[]) {
|
||||
gveejay_preview(preview);
|
||||
}
|
||||
|
||||
while(gveejay_running())
|
||||
{
|
||||
is_alive();
|
||||
if( gtk_events_pending() )
|
||||
gtk_main_iteration();
|
||||
else
|
||||
{
|
||||
veejay_update_multitrack( get_ui_info() );
|
||||
/*
|
||||
if(veejay_tick()) {
|
||||
veejay_update_multitrack( get_ui_info() );
|
||||
}*/
|
||||
//g_usleep( 1000 );
|
||||
if(!update_gveejay())
|
||||
g_usleep(100 * vj_gui_sleep_time());
|
||||
}
|
||||
}
|
||||
vj_gui_free();
|
||||
gtk_idle_add_priority( GTK_PRIORITY_DEFAULT,
|
||||
gveejay_idle,
|
||||
NULL );
|
||||
|
||||
if( gveejay_restart() )
|
||||
{
|
||||
if( execvp( argv[0], argv ) == -1 )
|
||||
veejay_msg(VEEJAY_MSG_ERROR, "Unable to restart %s", argv[0]);
|
||||
}
|
||||
memset( &time_last_, 0, sizeof(struct timeval));
|
||||
gtk_main();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -435,6 +435,7 @@ typedef struct
|
||||
int preview_locked;
|
||||
void *midi;
|
||||
int threaded;
|
||||
struct timeval time_last;
|
||||
} vj_gui_t;
|
||||
|
||||
enum
|
||||
@@ -1818,12 +1819,10 @@ gboolean gveejay_quit( GtkWidget *widget, gpointer user_data)
|
||||
if( prompt_dialog("Quit gveejay", "Are you sure?" ) == GTK_RESPONSE_REJECT)
|
||||
return TRUE;
|
||||
}
|
||||
// multitrack_quit( info->mt );
|
||||
|
||||
info->watch.w_state = STATE_DISCONNECT;
|
||||
// vj_gui_free();
|
||||
|
||||
running_g_ = 0;
|
||||
gtk_main_quit();
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@@ -4994,8 +4993,9 @@ void find_user_themes(int theme)
|
||||
if( sloppy < 0 )
|
||||
{
|
||||
veejay_msg(VEEJAY_MSG_WARNING, "Theme config '%s' not found, creating default.", path );
|
||||
veejay_msg(VEEJAY_MSG_WARNING, "Please setup symbolic links from %s/theme/{themename}" );
|
||||
veejay_msg(VEEJAY_MSG_WARNING, " to %s/.veejay/theme/{themename}",GVEEJAY_DATADIR, path);
|
||||
veejay_msg(VEEJAY_MSG_WARNING, "Please setup symbolic links from %s/theme/", GVEEJAY_DATADIR );
|
||||
veejay_msg(VEEJAY_MSG_WARNING, " to %s/.veejay/theme/",home);
|
||||
veejay_msg(VEEJAY_MSG_WARNING, "and set the name of the theme in theme.config" );
|
||||
set_default_theme();
|
||||
int wd= open( path, O_WRONLY );
|
||||
if(wd)
|
||||
@@ -5142,7 +5142,48 @@ GdkPixbuf *vj_gdk_pixbuf_scale_simple( const GdkPixbuf *src, int dw, int dh, Gdk
|
||||
return res;
|
||||
}
|
||||
|
||||
void veejay_update_multitrack( void *data )
|
||||
|
||||
int gveejay_time_to_sync( vj_gui_t *ui )
|
||||
{
|
||||
struct timeval time_now;
|
||||
gettimeofday( &time_now, 0 );
|
||||
|
||||
double diff = time_now.tv_sec - ui->time_last.tv_sec +
|
||||
(time_now.tv_usec - ui->time_last.tv_usec ) * 1.e-6;
|
||||
float fps = 0.0;
|
||||
|
||||
struct timespec nsecsleep;
|
||||
|
||||
if ( ui->watch.state == STATE_PLAYING && ui->watch.p_state == 0 )
|
||||
{
|
||||
fps = ui->el.fps;
|
||||
float spvf = 1.0 / fps;
|
||||
if( diff > spvf ) {
|
||||
ui->time_last.tv_sec = time_now.tv_sec;
|
||||
ui->time_last.tv_usec = time_now.tv_usec;
|
||||
return 1;
|
||||
}
|
||||
int usec = 0;
|
||||
int uspf = (int)(1000000.0 / fps);
|
||||
usec = time_now.tv_usec - ui->time_last.tv_usec;
|
||||
if( usec < 0 )
|
||||
usec += 1000000;
|
||||
if( time_now.tv_sec > ui->time_last.tv_sec + 1 )
|
||||
usec = 1000000;
|
||||
if( (uspf - usec) < (1000000 / 100))
|
||||
return 0;
|
||||
nsecsleep.tv_nsec = (uspf - usec - 1000000 / 100 ) * 1000;
|
||||
nsecsleep.tv_sec = 0;
|
||||
nanosleep( &nsecsleep, NULL );
|
||||
return 0;
|
||||
}
|
||||
nsecsleep.tv_nsec = 1000000;
|
||||
nsecsleep.tv_sec = 0;
|
||||
nanosleep( &nsecsleep, NULL );
|
||||
return 0;
|
||||
}
|
||||
|
||||
int veejay_update_multitrack( void *data )
|
||||
{
|
||||
vj_gui_t *gui = (vj_gui_t*) data;
|
||||
sync_info *s = multitrack_sync( gui->mt );
|
||||
@@ -5167,7 +5208,7 @@ void veejay_update_multitrack( void *data )
|
||||
free(s->widths);
|
||||
free(s->heights);
|
||||
free(s);
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
info->status_lock = 1;
|
||||
info->uc.playmode = gui->status_tokens[ PLAY_MODE ];
|
||||
@@ -5221,6 +5262,7 @@ void veejay_update_multitrack( void *data )
|
||||
free(s->widths);
|
||||
free(s->heights);
|
||||
free(s);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void update_status_accessibility(int old_pm, int new_pm)
|
||||
@@ -6172,7 +6214,7 @@ void vj_gui_init(char *glade_file, int launcher, char *hostname, int port_num,
|
||||
}
|
||||
|
||||
info->midi = vj_midi_new( info->main_window );
|
||||
|
||||
gettimeofday( &(info->time_last) , 0 );
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -55,5 +55,5 @@ char *get_gveejay_dir();
|
||||
int gveejay_restart();
|
||||
int gveejay_update();
|
||||
int update_gveejay();
|
||||
void veejay_update_multitrack( void *data );
|
||||
int veejay_update_multitrack( void *data );
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user