double AnimationTimeline::currentTimeInternal(bool& isNull)
{
    if (!isActive()) {
        isNull = true;
        return std::numeric_limits<double>::quiet_NaN();
    }
    double result = m_playbackRate == 0
        ? zeroTime()
        : (document()->animationClock().currentTime() - zeroTime()) * m_playbackRate;
    isNull = std::isnan(result);
    return result;
}
Пример #2
0
void PlaybackWidget::setZeroTime()
{
    QTime zeroTime(0, 0, 0);
    m_elapsedTimeLabel->setText(zeroTime.toString("H:mm:ss"));
    m_totalTimeLabel->setText(zeroTime.toString("H:mm:ss"));
    m_isZeroTime = true;
}
Пример #3
0
/** The driver_wait function to work out if we have used more time then available to process one cycle.
    This is written once for either timespec (HAVE_CLOCK_GETTIME) or jack_time_t, see the unified_jack_time.h file.

    This function manages the time now and the next expected time to return. The return happens once per block of time (period_size).

    The general idea of *_driver_wait is to do the following :
    a] Mark the time now if this is the first time through or if an overrun previously happened.
    b] If an overrun is detected (we have exceeded the maximum time held in our audio buffers) then indicate.
    c] If we are late but not dangerously, then keep going.
    d] If we are early then sleep a little to allow clients enough time to process.

    The effect of 'c]' and 'd]' is to create time pumping. Theoretically we will always be either a little over or under time, and it will be difficult to match audio block
    time exactly. This doesn't matter if the time pumping is a small fraction of our block time. This means that the clients will have slightly more or less then audio block
    time to process.
*/
static jack_nframes_t iio_driver_wait(iio_driver_t *driver, int extra_fd, int *status, float *delayed_usecs) {
	jack_nframes_t nframes = driver->period_size;
    //Debugger<<"iio_driver_wait\n";
    *delayed_usecs = 0;
    *status = 0;

    timeType now; getNow(&now); // the time right now

	if (compareTimesLt(NEXT_TIME, now)) { // NEXT_TIME < now  ... this is a problem as the next time should be >= now
        //printf("iio_driver_wait NOT good\n");
        if (compareTimeZero(NEXT_TIME)) { /* first time through */
            //DebuggerLocal<<"iio_driver_first time - OK\n";
            //printf("first time through\n\n\n");
			getNow(&NEXT_TIME); // reset the next time to now, will be incremented later
        } else if (timeDiffUsComp(now, driver->next_wakeup, driver->maxDelayUSecs)) { /* xrun = (now - NEXT_TIME) > maxDelayTime */
            ////Debugger<<"NEXT_TIME "<<NEXT_TIME<<" now "<<now<<endl;
            jack_error("**** iio: xrun of %ju usec", timeDiffUs(now, NEXT_TIME));
            nframes=0; // indicated the xrun
            zeroTime(&NEXT_TIME);  // reset the next time to zero because of the overrun, we don't know when to start again.
            //*status=-1; // xruns are fatal
        } else /* late, but handled by our "buffer" */
            ;
	} else { // now sleep to ensure we give the clients enough time to process
        *status = nanoSleep(NEXT_TIME, delayed_usecs);
        //printf("iio_driver_wait all good\n");
    }

    if (nframes!=0) // if there is no xrun, then indicate the next expected time to land in this funciton.
        NEXT_TIME=addTimes(NEXT_TIME, driver->wait_time);

	driver->last_wait_ust = driver->engine->get_microseconds ();
	driver->engine->transport_cycle_start (driver->engine, driver->last_wait_ust);

	return nframes;
}
Пример #4
0
static int iio_driver_start (iio_driver_t *driver) {
    printf("iio_driver_start::   enabling IIO : enable(true)\n");

    zeroTime(&NEXT_TIME); // driver->next_wakeup.tv_sec = 0; which is the same as driver->next_time = 0;

    return 0;
}
Пример #5
0
void PIRIntervalometerForm::on_startPushButton_clicked()
{
  if (intervalTimer)
  {
    delete intervalTimer;
    intervalTimer = 0;
  }

  QTime zeroTime(0,0,0,0);
  intervalValue = zeroTime.msecsTo(ui->intervalTimeEdit->time());
  if (intervalValue < 1000)
  {
    ui->numberLeftLabel->setText("0");
    return;
  }

  int pauseBeforeStart = zeroTime.msecsTo(ui->pauseTimeEdit->time());
  exposureCount = ui->quantitySpinBox->value();

  QString tempString;
  ui->numberLeftLabel->setText(tempString.setNum(exposureCount));

  if (pauseBeforeStart > 0)
  {
    QTimer::singleShot(
      pauseBeforeStart,
      this,
      SLOT(startIntervalometer()));
  }
  else
  {
    startIntervalometer();
  }
}
Пример #6
0
void PresentationAudioWidget::setZeroTime()
{
    QTime zeroTime(0, 0, 0);
    m_elapsedTimeLabel->setText(zeroTime.toString(QString::fromLatin1("H:mm:ss")));
    m_totalTimeLabel->setText(zeroTime.toString(QString::fromLatin1("H:mm:ss")));
    d->isZeroTime = true;
}
Пример #7
0
double AnimationTimeline::currentTimeInternal(bool& isNull)
{
    if (!m_document) {
        isNull = true;
        return std::numeric_limits<double>::quiet_NaN();
    }
    double result = m_document->animationClock().currentTime() - zeroTime();
    isNull = std::isnan(result);
    return result;
}
Пример #8
0
double AnimationTimeline::currentTimeInternal(bool& isNull)
{
    if (!m_document) {
        isNull = true;
        return std::numeric_limits<double>::quiet_NaN();
    }
    // New currentTime = currentTime when the playback rate was last changed + time delta since then * playback rate
    double delta = document()->animationClock().currentTime() - m_documentCurrentTimeSnapshot;
    double result = m_documentCurrentTimeSnapshot - zeroTime() + delta * playbackRate();
    isNull = std::isnan(result);
    return result;
}
Пример #9
0
ShTimeStream::ShTimeStream(std::string id, boost::chrono::steady_clock::time_point creationTime, ShTimeStream *parent,
                           TimeSlice initialTimeSlice) :
    id(id),
    creationTime(creationTime),
    currentTime(creationTime),
    mostFutureTime(creationTime),
    parent(parent),
    initialTimeSlice(initialTimeSlice)
{
    if(ShTimeStream::root == 0) // Begin with empty events
    {
        ShTimeStream::root = this;
        isRoot = true;
        std::cout << "ROOT TIME STREAM!!!" << std::endl;

        boost::chrono::steady_clock::time_point zeroTime(boost::chrono::milliseconds(0));
        ShNetwork::algo_pair emptyGen = std::make_pair(ShNetwork::Empty, 0);

        // initialize islands to empty at 00:00
        for(int i = 0; i < ShIslandGrid::NUM_ISLANDS; ++i) // Populate initial events
        {
            TerrainStepsEvent* stepEvent = new TerrainStepsEvent(i, emptyGen, zeroTime);
            TerrainHeightsEvent* heightEvent = new TerrainHeightsEvent(i, emptyGen, zeroTime);

            timeEvents.push_back(stepEvent);
            timeEvents.push_back(heightEvent);
            this->initialTimeSlice.islandSteps[i] = stepEvent;
            this->initialTimeSlice.islandHeights[i] = heightEvent;
        }
    }

    else
    {
        isRoot = false;

        for(int i = 0; i < ShIslandGrid::NUM_ISLANDS; ++i) // populate initial events
        {
            timeEvents.push_back(new TerrainStepsEvent(*(this->initialTimeSlice.islandSteps.at(i))));
            timeEvents.push_back(new TerrainHeightsEvent(*(this->initialTimeSlice.islandHeights.at(i))));
        }

        std::cout << "NEW TIME STREAM!!!!!" << std::endl;
    }

    ShGlobals::addTimeStream(id, this);
    //ShNetwork::sendCreateTimeStream(id.c_str(), creationTime.time_since_epoch().count());
    //std::cout << "Steam ID: " << id << std::endl;

    updateTimeVars(creationTime);
    currentEventIter = timeEvents.begin();
}
Пример #10
0
MediaTime MediaTime::operator*(int32_t rhs) const
{
    if (isInvalid())
        return invalidTime();

    if (isIndefinite())
        return indefiniteTime();

    if (!rhs)
        return zeroTime();

    if (isPositiveInfinite()) {
        if (rhs > 0)
            return positiveInfiniteTime();
        return negativeInfiniteTime();
    }

    if (isNegativeInfinite()) {
        if (rhs > 0)
            return negativeInfiniteTime();
        return positiveInfiniteTime();
    }

    MediaTime a = *this;

    if (a.hasDoubleValue()) {
        a.m_timeValueAsDouble *= rhs;
        return a;
    }

    while (!safeMultiply(a.m_timeValue, rhs, a.m_timeValue)) {
        if (a.m_timeScale == 1)
            return signum(a.m_timeValue) == signum(rhs) ? positiveInfiniteTime() : negativeInfiniteTime();
        a.setTimeScale(a.m_timeScale / 2);
    }

    return a;
}
Пример #11
0
MediaTime::operator bool() const
{
    return compare(zeroTime()) != EqualTo;
}
Пример #12
0
bool MediaTime::operator!() const
{
    return compare(zeroTime()) == EqualTo;
}