コード例 #1
0
ファイル: mltcontroller.cpp プロジェクト: sagesong/shotcut
void Controller::restart()
{
    if (!m_consumer) return;
    if (m_producer && m_producer->is_valid() && m_producer->get_speed() != 0) {
        // Update the real_time property if not paused.
        m_consumer->set("real_time", realTime());
    }
    const char* position = m_consumer->frames_to_time(m_consumer->position());
    double speed = m_producer->get_speed();
    QString xml = XML();
    stop();
    if (!setProducer(new Mlt::Producer(profile(), "xml-string", xml.toUtf8().constData()))) {
#ifdef Q_OS_WIN
        play(speed);
        if (m_producer && m_producer->is_valid())
            m_producer->seek(position);
        // Windows needs an extra kick here when not paused!
        if (speed != 0.0)
            play(speed);
#else
        if (m_producer && m_producer->is_valid())
            m_producer->seek(position);
        play(speed);
#endif
    }
}
コード例 #2
0
void ImageProducerWidget::reopen(Mlt::Producer* p)
{
    int out = ui->durationSpinBox->value() - 1;
    int position = m_producer->position();

    if (out + 1 > p->get_length())
        p->set("length", out + 1);
    p->set("out", out);
    if (position > p->get_out())
        position = p->get_out();
    p->set("in", m_producer->get_in());
    if (MLT.setProducer(p)) {
        setProducer(0);
        return;
    }
    emit producerReopened();
    emit producerChanged();
    MLT.seek(position);
    setProducer(p);
}
コード例 #3
0
void DecklinkProducerWidget::on_deviceCombo_activated(int /*index*/)
{
    if (m_producer) {
        MLT.stop();
        delete m_producer;
        m_producer = 0;
        setProducer(producer(MLT.profile()));
        MLT.play();
        emit producerChanged();
    }
}
コード例 #4
0
void Controller::restart()
{
    if (!m_consumer) return;
    if (m_producer && m_producer->is_valid() && m_producer->get_speed() != 0) {
        // Update the real_time property if not paused.
        m_consumer->set("real_time", realTime());
    }
    if (m_producer && m_producer->is_valid() && Settings.playerGPU()) {
        const char* position = m_consumer->frames_to_time(m_consumer->position());
        double speed = m_producer->get_speed();
        QString xml = XML();
        close();
        if (!setProducer(new Mlt::Producer(profile(), "xml-string", xml.toUtf8().constData()))) {
            m_producer->seek(position);
            m_producer->set_speed(speed);
            m_consumer->start();
        }
    } else {
        m_consumer->stop();
        m_consumer->start();
    }
}
コード例 #5
0
bool Controller::openXML(const QString &filename)
{
    bool error = true;
    close();
    Producer* producer = new Mlt::Producer(profile(), "xml", filename.toUtf8().constData());
    if (producer->is_valid()) {
        double fps = profile().fps();
        if (!profile().is_explicit()) {
            profile().from_producer(*producer);
            profile().set_width(alignWidth(profile().width()));
        }
        if (profile().fps() != fps) {
            // reopen with the correct fps
            delete producer;
            producer = new Mlt::Producer(profile(), "xml", filename.toUtf8().constData());
        }
        producer->set(kShotcutVirtualClip, 1);
        producer->set("resource", filename.toUtf8().constData());
        setProducer(new Producer(producer));
        error = false;
    }
    delete producer;
    return error;
}
コード例 #6
0
ファイル: kthumb.cpp プロジェクト: mcfrisk/kdenlive
void KThumb::clearProducer()
{
    if (m_producer) setProducer(NULL);
}
コード例 #7
0
ファイル: 5.c プロジェクト: scoiatael/OpSysProgramming2
int main(int argc, char* const argv[])
{
  srand(time(NULL));
  int n=10, m=255 & AmountMask, p=GRAIN, c = n*m/4; 
  int gopt;
  while((gopt = getopt(argc,argv,"n:m:p:c:")) != -1) {
    switch(gopt) {
      case 'n':
        n = atoi(optarg);
        break;
      case 'm':
        m = atoi(optarg);
        break;
      case 'p':
        p = atoi(optarg);
        break;
      case 'c':
        c = atoi(optarg);
        break;
    }
  }
  if(m > (255 & AmountMask)) {
    printf("Max m is %d\n", (255 & AmountMask));
  }
  printf("n: %d (thread total nr)  m: %d (max production/consumption) p: %d (chance) c: %d (maxItems)\n", n,m,p,c);
  pthread_t threads[n];
  memset(threads, 0, sizeof(threads));
  pthread_attr_t pattr;
  CERRS(pthread_attr_init(&pattr), "pthread attr init failed");
  CERRS(pthread_attr_setdetachstate(&pattr, PTHREAD_CREATE_JOINABLE), "pthread attr setds failed");
  struct thInfo* thinfo;
  thinfo = (struct thInfo*) malloc(sizeof(struct thInfo)*n);
  memset(thinfo, 0, n*sizeof(struct thInfo));
  struct thInfoPersist* pr = (struct thInfoPersist*)malloc(sizeof(struct thInfoPersist));
  CERRS(pthread_mutex_init(&pr->buffer,NULL) != 0, "sem init failed");
  CERRS(pthread_cond_init(&pr->notEmpty,NULL) != 0, "cond init failed");
  CERRS(pthread_cond_init(&pr->notFull,NULL) != 0, "cond init failed");
  CERRS(pthread_mutex_init(&pCountLock,NULL) != 0, "mutex init failed");
  CERRS(pthread_mutex_init(&cCountLock,NULL) != 0, "mutex init failed");
  pr->maxItems = c;
  pr->itemCount = 0;
  int balance = pr->itemCount;
  cCount=0;
  pCount=0;
  for(int i=0; i < n; i++) {
    setThInfo(&thinfo[i], pr);
    setAmount(&thinfo[i].flags, rand() % m);
    if(rand() % (p+GRAIN) > GRAIN ) {
      printf("Made consumer: ");
      setConsumer(&thinfo[i].flags, 1);
      balance = balance - getAmount(&thinfo[i].flags);
    } else {
      printf("Made producer: ");
      setProducer(&thinfo[i].flags, 1);
      balance = balance + getAmount(&thinfo[i].flags);
    }
    printf("am : %u bal: %d IC: %d\n", getAmount(&thinfo[i].flags), balance, pr->itemCount);
    CERRS(pthread_create(&threads[i], &pattr, &routine, (void*) &thinfo[i]), "pthread creation failed");
  }
  for (int j=0; j < n; j++) {
//    printf("\n  joining. %d p(%d) c(%d)\n", j, pCount, cCount);
    CERRS(pthread_join(threads[j], NULL), "pthread join failed");
    printf("\nnr %d (%s) done\n", j, (isConsumer(&(thinfo[j].flags))) ? "Consumer" : "Producer");
  }
  free(thinfo);
  free(pr);
}