Exemple #1
0
void BACKUP_call_very_often(void){
  static bool has_inited = false;
  if (has_inited==false){
    RT_BACKUP_reset_timer();
    has_inited=true;
  }

  static bool is_playing = false;
  
  Player_State player_state = ATOMIC_GET(pc->player_state);
  
  if (!is_playing && player_state==PLAYER_STATE_PLAYING){
    is_playing = true;
    g_curr_playing_start_time = TIME_get_ms();
  }

  if (is_playing && player_state==PLAYER_STATE_STOPPED){
    is_playing = false;
    double added_playing_duration = TIME_get_ms() - g_curr_playing_start_time;
    g_curr_playing_duration += added_playing_duration;
  }

  if (is_playing)
    return;
  
  //printf("duration: %f\n",get_unbackuped_duration() / 1000.0);
  
  if (get_unbackuped_duration()  > get_backup_interval_ms()){
    make_backup();
    RT_BACKUP_reset_timer();
  }
}
Exemple #2
0
// Use this function if it is important that we don't return too early.
void OS_WaitAtLeast(int milliseconds) {
    double start_time = TIME_get_ms();

    OS_WaitForAShortTime(milliseconds);

    while( (TIME_get_ms()-start_time) < milliseconds)
        OS_WaitForAShortTime(10);
}
void BACKUP_call_very_often(void){
  if (MIXER_is_saving())
    return;

  if (g_radium_runs_custom_exec)
    return;
  
  static bool has_inited = false;
  if (has_inited==false){
    RT_BACKUP_reset_timer();
    has_inited=true;
  }

  if (!editor_has_keyboard_focus()) // If showing popup menu, editing text widgets, etc. we don't want to disturb the user.
    return;

  if (QApplication::mouseButtons() != Qt::NoButton) // Wait until user doesn't use the mouse.
    return;
  
  static bool is_playing = false;
  
  Player_State player_state = ATOMIC_GET(pc->player_state);
  
  if (!is_playing && player_state==PLAYER_STATE_PLAYING){
    is_playing = true;
    g_curr_playing_start_time = TIME_get_ms();
  }

  if (is_playing && player_state==PLAYER_STATE_STOPPED){
    is_playing = false;
    double added_playing_duration = TIME_get_ms() - g_curr_playing_start_time;
    g_curr_playing_duration += added_playing_duration;
  }

  if (!doSaveBackupWhilePlaying())
    if (is_playing)
      return;
  
  //printf("duration: %f\n",get_unbackuped_duration() / 1000.0);

  if (SampleRecorder_Get_Num_Instances() > 0)
    return;
  
  if (get_unbackuped_duration()  > get_backup_interval_ms()){
    make_backup();
    RT_BACKUP_reset_timer();
  }
}
static double get_unbackuped_duration(void){
  double total = TIME_get_ms() - g_time;
  if (doSaveBackupWhilePlaying())
      return total;
  else
    return total - g_curr_playing_duration;
}
Exemple #5
0
void Undo_Block(
	struct Tracker_Windows *window,
	struct WBlocks *wblock,
	struct WTracks *wtrack,
	int realline
){
  static struct WBlocks *last_wblock;
  static struct WTracks *last_wtrack;
  static int last_realline;

  static double last_undo_block_time = -1000;
  double time_now = TIME_get_ms();
  
  //printf("last: %d, now: %d, diff: %d\n",(int)last_undo_block_time,(int)time_now,(int)(time_now-last_undo_block_time));

  if( (time_now-last_undo_block_time) > 1000*3 // more than 3 seconds.
      || wblock!=last_wblock
      || wtrack!=last_wtrack
      || realline!=last_realline
      || Undo_get_last_function()!=Undo_Do_Block)
    Undo_Add(
             window->l.num,
             wblock->l.num,
             wtrack->l.num,
             realline,
             CB_CopyBlock(wblock),
             Undo_Do_Block
             );

  last_undo_block_time = time_now;
  last_wblock=wblock;
  last_wtrack=wtrack;
  last_realline=realline;
}
    bool maybe_release(void){
      if (_num_seqblock_users==0 && (TIME_get_ms()-_time_when_num_seqblock_users_decreased_to_0) > 1000){
        delete this;
        return true;
      }

      return false;
    }
 int dec_users(void){
   R_ASSERT_RETURN_IF_FALSE2(_num_seqblock_users>0, 0);
   
   _num_seqblock_users--;
   
   if (_num_seqblock_users==0)
     _time_when_num_seqblock_users_decreased_to_0 = TIME_get_ms();
   
   return _num_seqblock_users;
 }
Exemple #8
0
static void show_message(int type, char *message){
  static double last_ignore = -3000.0; // don't want to ignore errors the first two seconds.
  static bool ignore_rest_of_the_program = false;

  char *typestring = type==IS_ERROR?"Error":"Warning";

  if(ignore_rest_of_the_program==true)
    return;

  if(TIME_get_ms()-last_ignore < 2000)
    return;

  char full_message[1000];
  sprintf(full_message,"%s: %s", typestring, message);

#if 0 // Always use SYSTEM_show_message.
  vector_t v = {0};
  VECTOR_push_back(&v, "continue");
  VECTOR_push_back(&v, "quit");
  VECTOR_push_back(&v, "ignore warnings and errors for two seconds");
  VECTOR_push_back(&v, "ignore warnings and errors for the rest of the program");
  
  int ret = GFX_Message(&v, full_message);
  if (ret==-1)
    ret = SYSTEM_show_message(full_message);
#else
  int ret = SYSTEM_show_message(full_message);
#endif
      
  switch(ret){
  case 0: break;
  case 1: {
    char *hello = NULL;
    hello[0] = 50;
    abort();
  }
  case 2: last_ignore=TIME_get_ms(); break;
  case 3: ignore_rest_of_the_program=true; break;
  }
}
//static void crash(int sig){
static void crash(int sig, siginfo_t *siginfo, void *secret) {

  //fprintf(stderr,"\n\nCrashreporter got signal %d. genpid: %d, this pid: %d. Sending message to external process\n\n",sig,(int)siginfo->si_pid,(int)getpid());

  
  static int num_crash_reports=0;

  static double start_time = -1.0;
  double now_time = TIME_get_ms();

  if(start_time<=0.0)
    start_time=now_time;

  if(crash_already_reported()==false){

    if(fork()==0){
      char temp[64];
      sprintf(temp,"signum: %d\n", sig);
      CRASHREPORTER_send_message_with_backtrace(temp, CT_CRASH,now_time);
      num_crash_reports++;

      abort();
    }
  }

#if defined(FOR_LINUX)
  msleep(1000*3);
#else
  msleep(500); // Just wait half second on mac.
#endif
  
  CRASHREPORTER_close();

#if defined(FOR_LINUX)
  
  _Exit(1); // We don't get system crashlog on OSX when doing this.

#else
  
  abort();
  
  if((now_time-start_time) > 3000 || num_crash_reports>3){
    CRASHREPORTER_close();
    abort();
  }
#endif
  
  /*
  if(num_crash_reports>10)
    pthread_exit(NULL);
  */
}
Exemple #10
0
static void T2_thread_func(QOffscreenSurface *offscreen, QOpenGLContext *offscreen_context){
  
  if (offscreen->isValid()==false){
    GFX_Message2(NULL, true, "Invalid offscreen surface. Unable to paint.\n");
    return;
  }

  QSurface *qsurface = offscreen;

  if (offscreen_context->isValid()==false){
    GFX_Message2(NULL, true, "Invalid offscreen OpenGL Context. Unable to paint.\n");
    return;
  }

  while(true){

    T1_data *t1_data = t1_to_t2_queue.get();
    if (t1_data->stop_me){
      return;
    }
  
    T2_data *t2_data;

    offscreen_context->makeCurrent(qsurface);{

      while(t3_to_t2_queue.size() > 0){
        T2_data *old_t2_data = t3_to_t2_queue.get();
        delete old_t2_data;
      }
      
      t2_data = new T2_data(t1_data->painting_data, t1_data->background_color);

#if TEST_TIME
      double start = TIME_get_ms();
#endif

      GE_draw_vl(t2_data);
      
#if TEST_TIME
      printf("      GE_draw: %f\n", TIME_get_ms() - start);
#endif
      
    }offscreen_context->doneCurrent();
    
    delete t1_data;

    t2_to_t3_queue.T1_put(t2_data);
    t2_to_t3_queue.T1_wait_for_T2_to_pick_up();    

    T2_data *old_t2_data = t3_to_t2_queue.get(); // [ref 1]

    if (old_t2_data != NULL){
      offscreen_context->makeCurrent(qsurface);{      
        delete old_t2_data;
      }offscreen_context->doneCurrent();
    }
    //printf("gl: %f\n",GL_get_vblank());
    
    //    if (is_playing())
    //  msleep(GL_get_vblank() * 10); // Sleep a little bit to avoid putting too much pressure on the gfx card this frame.
  }
}
Exemple #11
0
static void RT_BACKUP_reset_timer(void){
  g_time = TIME_get_ms();
  g_curr_playing_start_time = 0;
  g_curr_playing_duration = 0;
}
Exemple #12
0
static double get_unbackuped_duration(void){
  double total = TIME_get_ms() - g_time;
  return total - g_curr_playing_duration;
}