示例#1
0
文件: jcr.c 项目: halgandd/bacula
void set_jcr_job_status(JCR *jcr, int JobStatus)
{
   int priority, old_priority;
   int oldJobStatus = jcr->JobStatus;
   priority = get_status_priority(JobStatus);
   old_priority = get_status_priority(oldJobStatus);
   
   Dmsg2(800, "set_jcr_job_status(%s, %c)\n", jcr->Job, JobStatus);

   /* Update wait_time depending on newJobStatus and oldJobStatus */
   update_wait_time(jcr, JobStatus);

   /*
    * For a set of errors, ... keep the current status
    *   so it isn't lost. For all others, set it.
    */
   Dmsg3(300, "jid=%u OnEntry JobStatus=%c set=%c\n", (uint32_t)jcr->JobId,
         jcr->JobStatus, JobStatus);
   if (priority >= old_priority) {
      jcr->JobStatus = JobStatus;     /* replace with new priority */
   }

   if (oldJobStatus != jcr->JobStatus) {
      Dmsg3(200, "jid=%u leave set_old_job_status=%c new_set=%c\n", (uint32_t)jcr->JobId,
         oldJobStatus, JobStatus);
//    generate_plugin_event(jcr, bEventStatusChange, NULL);
   }
}
示例#2
0
文件: smf_track.cpp 项目: iwadon/junk
void SMFTrack::play()
{
  if (data_ == NULL) {
    return;
  }
  data_cur_ = data_;
  SET_STATE(STATE_PLAYING);
  update_wait_time();
}
示例#3
0
文件: jcr.c 项目: janstadler/bareos
void JCR::setJobStatus(int newJobStatus)
{
    JCR *jcr = this;
    int priority, old_priority;
    int oldJobStatus = jcr->JobStatus;
    priority = get_status_priority(newJobStatus);
    old_priority = get_status_priority(oldJobStatus);

    Dmsg2(800, "set_jcr_job_status(%s, %c)\n", Job, newJobStatus);

    /*
     * Update wait_time depending on newJobStatus and oldJobStatus
     */
    update_wait_time(jcr, newJobStatus);

    /*
     * For a set of errors, ... keep the current status
     * so it isn't lost. For all others, set it.
     */
    Dmsg2(800, "OnEntry JobStatus=%c newJobstatus=%c\n", oldJobStatus, newJobStatus);

    /*
     * If status priority is > than proposed new status, change it.
     * If status priority == new priority and both are zero, take the new status.
     * If it is not zero, then we keep the first non-zero "error" that occurred.
     */
    if (priority > old_priority || (
                priority == 0 && old_priority == 0)) {
        Dmsg4(800, "Set new stat. old: %c,%d new: %c,%d\n",
              jcr->JobStatus, old_priority, newJobStatus, priority);
        jcr->JobStatus = newJobStatus;     /* replace with new status */
    }

    if (oldJobStatus != jcr->JobStatus) {
        Dmsg2(800, "leave setJobStatus old=%c new=%c\n", oldJobStatus, newJobStatus);
//    generate_plugin_event(jcr, bEventStatusChange, NULL);
    }
}
示例#4
0
文件: smf_track.cpp 项目: iwadon/junk
void SMFTrack::update()
{
  Instrument *inst = smf_.instrument();
  if (inst == NULL) {
    return;
  }
  if (!is_playing() || is_paused()) {
    return;
  }
  if (wait_time_ > 0) {
    --wait_time_;
    if (wait_time_ > 0) {
      return;
    }
  }
  if (data_end_ <= data_cur_) {
    return;
  }
  do {
    data_type data = *data_cur_++;
    Channel &ch = inst->channel(data & 0x0f);
#ifdef ENABLE_RUNNING_STATUS
  retry:
#endif
    switch (static_cast<unsigned char>(data)) {
#ifdef ENABLE_RUNNING_STATUS
    case 0x00 ... 0x7f:		// Running Status
      data = prev_status_byte;
      goto retry;
      //break;
#endif
    case 0x80 ... 0x8f:		// 8n kk vv   Note Off
      {
	data_type kk = *data_cur_++;
	assert(data_cur_ <= data_end_);
	data_type vv = *data_cur_++;
	assert(data_cur_ <= data_end_);
	ch.note_off(kk, vv);
      }
      break;
    case 0x90 ... 0x9f:		// 9n kk vv   Note On
      {
	data_type kk = *data_cur_++;
	assert(data_cur_ <= data_end_);
	data_type vv = *data_cur_++;
	assert(data_cur_ <= data_end_);
	ch.note_on(kk, vv);
      }
      break;
    case 0xa0 ... 0xaf:		// An kk vv   Polyphonic Pressure
      {
	data_type kk = *data_cur_++;
	assert(data_cur_ <= data_end_);
	data_type vv = *data_cur_++;
	assert(data_cur_ <= data_end_);
	ch.polyphonic_pressure(kk, vv);
      }
      break;
    case 0xb0 ... 0xbf:		// Bn cc vv   Control Change
      {
	data_type cc = *data_cur_++;
	assert(data_cur_ <= data_end_);
	data_type vv = *data_cur_++;
	assert(data_cur_ <= data_end_);
	ch.control_change(cc, vv);
      }
      break;
    case 0xc0 ... 0xcf:		// Cn pp      Program Change
      {
	data_type pp = *data_cur_++;
	assert(data_cur_ <= data_end_);
	ch.program_change(pp);
      }
      break;
    case 0xd0 ... 0xdf:		// Dn vv      Channel Pressure
      {
	data_type vv = *data_cur_++;
	assert(data_cur_ <= data_end_);
	ch.channel_pressure(vv);
      }
      break;
    case 0xe0 ... 0xef:		// En ll mm   Pitch Bend
      {
	data_type ll = *data_cur_++;
	assert(data_cur_ <= data_end_);
	data_type mm = *data_cur_++;
	assert(data_cur_ <= data_end_);
	ch.pitch_bend_change(mm * 128 + ll - 8192);
      }
      break;
    case 0xf0:	       		// F0 ... F7  SysEx
      {
	VariableLengthValue delta_time;
	VariableLengthValue::len_type vlv_len = delta_time.set_data(data_cur_, 0);
	data_cur_ += vlv_len + delta_time.value();
	assert(data_cur_ <= data_end_);
      }
    case 0xf7:			// F7 ...     SysEx
      {
	VariableLengthValue delta_time;
	VariableLengthValue::len_type vlv_len = delta_time.set_data(data_cur_, 0);
	data_cur_ += vlv_len + delta_time.value();
	assert(data_cur_ <= data_end_);
      }
      break;
    case 0xff:
      {
	data_type type = *data_cur_++;
	assert(data_cur_ <= data_end_);
	VariableLengthValue data_len;
	VariableLengthValue::len_type vlv_len = data_len.set_data(data_cur_, 0);
	data_cur_ += vlv_len;
	assert(data_cur_ <= data_end_);
	switch (type) {
	case 0x01: // FF 01 len text		Text Event
	case 0x02: // FF 02 len text		Copyright Notice
	case 0x03: // FF 03 len text		Sequence/Track Name
	case 0x04: // FF 04 len text		Instrument Name
	case 0x05: // FF 05 len text		Lyric
	case 0x06: // FF 06 len text		Marker
	case 0x07: // FF 07 len text		Cue Point
	case 0x09: // FF 09 len text		Device Name
	case 0x20: // FF 20 01 cc		MIDI Channel Prefix
	case 0x54: // FF 54 05 hr mn se fr ff	SMPTE Offset
	case 0x58: // FF 58 04 nn dd cc bb	Time Signature
	case 0x59: // FF 59 02 sf mi		Key Signature
	case 0x7f: // FF 7F len data		Sequencer Specific Meta-Event
	  // not implemented
	  data_cur_ += data_len.value();
	  assert(data_cur_ <= data_end_);
	  break;
	case 0x2f: // FF 2F 00			End of Track
#ifdef SMF_TRACK_DEBUG
	  if (data_len.value() > 0) {
	    WARN("End of Track event is too long: %u > 0", data_len.value());
	  }
#endif
	  data_cur_ += data_len.value();
	  stop();
	  break;
	case 0x51: // FF 51 03 tttttt		Set Tempo(in microseconds per MIDI quarter-note)
	  smf_.set_tempo(reinterpret_cast<const uint8_t *>(data_cur_));
	  data_cur_ += data_len.value();
	  assert(data_cur_ <= data_end_);
	  break;
	default:
	  // unsupported meta-events
#ifdef SMF_TRACK_DEBUG
	  INFO("Unimplemented meta events: type=%02x, len=%u", static_cast<uint8_t>(type), data_len.value());
#endif
	  data_cur_ += data_len.value();
	  assert(data_cur_ <= data_end_);
	  break;
	}
      }
      break;
    default:
      // unsupported events
#ifdef SMF_TRACK_DEBUG
      INFO("Unimplemented events: %02x", static_cast<uint8_t>(data));
#endif
      break;
    }
#ifdef ENABLE_RUNNING_STATUS
    prev_status_byte = data;
#endif
    if (!is_playing()) {
      break;
    }
    update_wait_time();
  } while (wait_time_ == 0);
}