当前位置: 首页>>代码示例>>C++>>正文


C++ MythTimer::elapsed方法代码示例

本文整理汇总了C++中MythTimer::elapsed方法的典型用法代码示例。如果您正苦于以下问题:C++ MythTimer::elapsed方法的具体用法?C++ MythTimer::elapsed怎么用?C++ MythTimer::elapsed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MythTimer的用法示例。


在下文中一共展示了MythTimer::elapsed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: StartPlaying

/** \fn PlayerContext::StartPlaying(int)
 *  \brief Starts player, must be called after StartRecorder().
 *  \param maxWait How long to wait for MythPlayer to start playing.
 *  \return true when successful, false otherwise.
 */
bool PlayerContext::StartPlaying(int maxWait)
{
    if (!player)
        return false;

    player->StartPlaying();

    maxWait = (maxWait <= 0) ? 20000 : maxWait;
#ifdef USING_VALGRIND
    maxWait = (1<<30);
#endif // USING_VALGRIND
    MythTimer t;
    t.start();

    while (!player->IsPlaying(50, true) && (t.elapsed() < maxWait))
        ReloadTVChain();

    if (player->IsPlaying())
    {
        VERBOSE(VB_PLAYBACK, LOC + "StartPlaying(): took "<<t.elapsed()
                <<" ms to start player.");
        return true;
    }
    else
    {
        VERBOSE(VB_IMPORTANT, LOC_ERR + "StartPlaying() "
                "Failed to start player");
        StopPlaying();
        return false;
    }
}
开发者ID:bwarden,项目名称:mythtv,代码行数:36,代码来源:playercontext.cpp

示例2: StartPlaying

/** \fn PlayerContext::StartPlaying(int)
 *  \brief Starts player, must be called after StartRecorder().
 *  \param maxWait How long to wait for MythPlayer to start playing.
 *  \return true when successful, false otherwise.
 */
bool PlayerContext::StartPlaying(int maxWait)
{
    if (!player)
        return false;

    player->StartPlaying();

    maxWait = (maxWait <= 0) ? 20000 : maxWait;
#ifdef USING_VALGRIND
    maxWait = (1<<30);
#endif // USING_VALGRIND
    MythTimer t;
    t.start();

    while (!player->IsPlaying(50, true) && (t.elapsed() < maxWait))
        ReloadTVChain();

    if (player->IsPlaying())
    {
        LOG(VB_PLAYBACK, LOG_INFO, LOC +
            QString("StartPlaying(): took %1 ms to start player.")
                .arg(t.elapsed()));
        return true;
    }
    else
    {
        LOG(VB_GENERAL, LOG_ERR, LOC + "StartPlaying() Failed to start player");
        StopPlaying();
        return false;
    }
}
开发者ID:aravilife,项目名称:mythtv-stabilize2,代码行数:36,代码来源:playercontext.cpp

示例3: progress_string

static QString progress_string(
    MythTimer &flagTime, uint64_t m_myFramesPlayed, uint64_t totalFrames)
{
    if (totalFrames == 0ULL)
    {
        return QString("%1 frames processed    \r")
            .arg(m_myFramesPlayed,7);
    }

    double elapsed = flagTime.elapsed() * 0.001;
    double flagFPS = (elapsed > 0.0) ? (m_myFramesPlayed / elapsed) : 0;

    double percentage = m_myFramesPlayed * 100.0 / totalFrames;
    percentage = (percentage > 100.0 && percentage < 101.0) ?
        100.0 : percentage;

    if (flagFPS < 10.0)
    {
        return QString("%1 fps %2%     \r")
            .arg(flagFPS,4,'f',1).arg(percentage,4,'f',1);
    }
    else
    {
        return QString("%1 fps %2%     \r")
            .arg(flagFPS,4,'f',0).arg(percentage,4,'f',1);
    }
}
开发者ID:DragonStalker,项目名称:mythtv,代码行数:27,代码来源:mythccextractorplayer.cpp

示例4: progress_string

static QString progress_string(
    MythTimer &flagTime, uint64_t m_myFramesPlayed, uint64_t totalFrames)
{
    if (totalFrames == 0ULL)
    {
        return QString("%1 frames processed    \r")
            .arg(m_myFramesPlayed,7);
    }

    static char const spin_chars[] = "/-\\|";
    static uint spin_cnt = 0;

    double elapsed = flagTime.elapsed() * 0.001;
    double flagFPS = (elapsed > 0.0) ? (m_myFramesPlayed / elapsed) : 0;

    double percentage = m_myFramesPlayed * 100.0 / totalFrames;
    percentage = (percentage > 100.0 && percentage < 101.0) ?
        100.0 : percentage;

    if (m_myFramesPlayed < totalFrames)
        return QString("%1 fps %2%      \r")
          .arg(flagFPS,4,'f', (flagFPS < 10.0 ? 1 : 0)).arg(percentage,4,'f',1);
    else
        return QString("%1 fps %2      \r")
          .arg(flagFPS,4,'f', (flagFPS < 10.0 ? 1 : 0))
          .arg(spin_chars[++spin_cnt % 4]);
}
开发者ID:tomhughes,项目名称:mythtv,代码行数:27,代码来源:mythccextractorplayer.cpp

示例5: Poll

bool DeviceReadBuffer::Poll(void) const
{
#ifdef USING_MINGW
#warning mingw DeviceReadBuffer::Poll
    VERBOSE(VB_IMPORTANT, LOC_ERR +
            "mingw DeviceReadBuffer::Poll is not implemented");
    return false;
#else
    bool retval = true;
    MythTimer timer;
    timer.start();

    while (true)
    {
        struct pollfd polls;
        polls.fd      = _stream_fd;
        polls.events  = POLLIN;
        polls.revents = 0;

        int ret = poll(&polls, 1 /*number of polls*/, 10 /*msec*/);

        if (polls.revents & (POLLHUP | POLLNVAL))
        {
            VERBOSE(VB_IMPORTANT, LOC + "poll error");
            error = true;
            return true;
        }

        if (!run || !IsOpen() || IsPauseRequested())
        {
            retval = false;
            break; // are we supposed to pause, stop, etc.
        }

        if (ret > 0)
            break; // we have data to read :)
        else if (ret < 0)
        {
            if ((EOVERFLOW == errno))
                break; // we have an error to handle

            if ((EAGAIN == errno) || (EINTR  == errno))
                continue; // errors that tell you to try again

            usleep(2500 /*2.5 ms*/);
        }
        else //  ret == 0
        {
            if ((uint)timer.elapsed() > max_poll_wait)
            {
                VERBOSE(VB_IMPORTANT, LOC_ERR + "Poll giving up");
                QMutexLocker locker(&lock);
                error = true;
                return true;
            }
        }
    }
    return retval;
#endif //!USING_MINGW
}
开发者ID:,项目名称:,代码行数:60,代码来源:

示例6: GetLiveStreamInfo

DTC::LiveStreamInfo *HTTPLiveStream::StartStream(void)
{
    if (GetDBStatus() != kHLSStatusQueued)
        return GetLiveStreamInfo();

    HTTPLiveStreamThread *streamThread =
        new HTTPLiveStreamThread(GetStreamID());
    MThreadPool::globalInstance()->startReserved(streamThread,
                                                 "HTTPLiveStream");
    MythTimer statusTimer;
    int       delay = 250000;
    statusTimer.start();

    HTTPLiveStreamStatus status = GetDBStatus();
    while ((status == kHLSStatusQueued) &&
           ((statusTimer.elapsed() / 1000) < 30))
    {
        delay = (int)(delay * 1.5);
        usleep(delay);

        status = GetDBStatus();
    }

    return GetLiveStreamInfo();
}
开发者ID:kzmi,项目名称:mythtv_isdb,代码行数:25,代码来源:httplivestream.cpp

示例7: CompareAndWait

int SchemaUpgradeWizard::CompareAndWait(const int seconds)
{
    if (Compare() > 0)  // i.e. if DB is older than expected
    {
        QString message = tr("%1 database schema is old. Waiting to see if DB "
                             "is being upgraded.").arg(m_schemaName);

        LOG(VB_GENERAL, LOG_CRIT, message);

        MSqlQuery query(MSqlQuery::InitCon(MSqlQuery::kDedicatedConnection));
        bool      backupRunning  = false;
        bool      upgradeRunning = false;

        MythTimer elapsedTimer;
        elapsedTimer.start();
        while (versionsBehind && (elapsedTimer.elapsed() < seconds * 1000))
        {
            sleep(1);

            if (IsBackupInProgress())
            {
                LOG(VB_GENERAL, LOG_CRIT,
                         "Waiting for Database Backup to complete.");
                if (!backupRunning)
                {
                    elapsedTimer.restart();
                    backupRunning = true;
                }
                continue;
            }

            if (!lockSchema(query))
            {
                LOG(VB_GENERAL, LOG_CRIT,
                         "Waiting for Database Upgrade to complete.");
                if (!upgradeRunning)
                {
                    elapsedTimer.restart();
                    upgradeRunning = true;
                }
                continue;
            }

            Compare();
            unlockSchema(query);

            if (m_expertMode)
                break;
        }

        if (versionsBehind)
            LOG(VB_GENERAL, LOG_CRIT, "Timed out waiting.");
        else
            LOG(VB_GENERAL, LOG_CRIT,
                     "Schema version was upgraded while we were waiting.");
    }
    // else DB is same version, or newer. Either way, we won't upgrade it

    return versionsBehind;
}
开发者ID:jasonblewis,项目名称:mythtv,代码行数:60,代码来源:schemawizard.cpp

示例8: readData

bool ZMClient::readData(unsigned char *data, int dataSize)
{
    qint64 read = 0;
    int errmsgtime = 0;
    MythTimer timer;
    timer.start();
    int elapsed;

    while (dataSize > 0)
    {
        qint64 sret = m_socket->Read(
            (char*) data + read, dataSize, 100 /*ms*/);
        if (sret > 0)
        {
            read += sret;
            dataSize -= sret;
            if (dataSize > 0)
            {
                timer.start();
            }
        }
        else if (sret < 0)
        {
            LOG(VB_GENERAL, LOG_ERR, "readData: Error, readBlock");
            m_socket->DisconnectFromHost();
            return false;
        }
        else if (!m_socket->IsConnected())
        {
            LOG(VB_GENERAL, LOG_ERR,
                "readData: Error, socket went unconnected");
            m_socket->DisconnectFromHost();
            return false;
        }
        else
        {
            elapsed = timer.elapsed();
            if (elapsed  > 10000)
            {
                if ((elapsed - errmsgtime) > 10000)
                {
                    errmsgtime = elapsed;
                    LOG(VB_GENERAL, LOG_ERR,
                        QString("m_socket->: Waiting for data: %1 %2")
                            .arg(read).arg(dataSize));
                }
            }

            if (elapsed > 100000)
            {
                LOG(VB_GENERAL, LOG_ERR, "Error, readData timeout (readBlock)");
                return false;
            }
        }
    }

    return true;
}
开发者ID:ReArtu,项目名称:mythtv,代码行数:58,代码来源:zmclient.cpp

示例9: WaitForLock

/** \fn  SignalMonitor::WaitForLock(int)
 *  \brief Wait for a StatusSignaLock(int) of true.
 *
 *   This can be called whether or not the signal
 *   monitoring thread has been started.
 *
 *  \param timeout maximum time to wait in milliseconds.
 *  \return true if signal was acquired.
 */
bool SignalMonitor::WaitForLock(int timeout)
{
    statusLock.lock();
    if (-1 == timeout)
        timeout = signalLock.GetTimeout();
    statusLock.unlock();
    if (timeout<0)
        return false;

    MythTimer t;
    t.start();
    if (running)
    {
        while (t.elapsed()<timeout && running)
        {
            Kick();
            statusLock.lock();
            bool ok = signalLock.IsGood();
            statusLock.unlock();
            if (ok)
                return true;

            usleep(50);
        }
        if (!running)
            return WaitForLock(timeout-t.elapsed());
    }
    else
    {
        while (t.elapsed()<timeout && !running)
        {
            UpdateValues();
            statusLock.lock();
            bool ok = signalLock.IsGood();
            statusLock.unlock();
            if (ok)
                return true;

            usleep(50);
        }
        if (running)
            return WaitForLock(timeout-t.elapsed());
    }
    return false;
}
开发者ID:microe,项目名称:mythtv,代码行数:54,代码来源:signalmonitor.cpp

示例10: startReserved

void MThreadPool::startReserved(
    QRunnable *runnable, QString debugName, int waitForAvailMS)
{
    QMutexLocker locker(&m_priv->m_lock);
    if (waitForAvailMS > 0 && m_priv->m_avail_threads.empty() &&
        m_priv->m_running_threads.size() >= m_priv->m_max_thread_count)
    {
        MythTimer t;
        t.start();
        int left = waitForAvailMS - t.elapsed();
        while (left > 0 && m_priv->m_avail_threads.empty() &&
               m_priv->m_running_threads.size() >= m_priv->m_max_thread_count)
        {
            m_priv->m_wait.wait(locker.mutex(), left);
            left = waitForAvailMS - t.elapsed();
        }
    }
    TryStartInternal(runnable, debugName, true);
}
开发者ID:,项目名称:,代码行数:19,代码来源:

示例11: ReadReal

void MythSocket::ReadReal(char *data, int size, int max_wait_ms, int *ret)
{
    MythTimer t; t.start();
    while ((m_tcpSocket->state() == QAbstractSocket::ConnectedState) &&
           (m_tcpSocket->bytesAvailable() < size) &&
           (t.elapsed() < max_wait_ms))
    {
        m_tcpSocket->waitForReadyRead(max(2, max_wait_ms - t.elapsed()));
    }
    *ret = m_tcpSocket->read(data, size);

    if (t.elapsed() > 50)
    {
        LOG(VB_GENERAL, LOG_INFO,
            QString("ReadReal(?, %1, %2) -> %3 took %4 ms")
            .arg(size).arg(max_wait_ms).arg(*ret)
            .arg(t.elapsed()));
    }

    m_dataAvailable.fetchAndStoreOrdered(
        (m_tcpSocket->bytesAvailable() > 0) ? 1 : 0);
}
开发者ID:ChristopherNeufeld,项目名称:mythtv,代码行数:22,代码来源:mythsocket.cpp

示例12: Cleanup

void MThread::Cleanup(void)
{
    QMutexLocker locker(&s_all_threads_lock);
    QSet<MThread*> badGuys;
    QSet<MThread*>::const_iterator it;
    for (it = s_all_threads.begin(); it != s_all_threads.end(); ++it)
    {
        if ((*it)->isRunning())
        {
            badGuys.insert(*it);
            (*it)->exit(1);
        }
    }

    if (badGuys.empty())
        return;

    // logging has been stopped so we need to use iostream...
    cerr<<"Error: Not all threads were shut down properly: "<<endl;
    for (it = badGuys.begin(); it != badGuys.end(); ++it)
    {
        cerr<<"Thread "<<qPrintable((*it)->objectName())
            <<" is still running"<<endl;
    }
    cerr<<endl;

    static const int kTimeout = 5000;
    MythTimer t;
    t.start();
    for (it = badGuys.begin();
         it != badGuys.end() && t.elapsed() < kTimeout; ++it)
    {
        int left = kTimeout - t.elapsed();
        if (left > 0)
            (*it)->wait(left);
    }
}
开发者ID:DaveDaCoda,项目名称:mythtv,代码行数:37,代码来源:mthread.cpp

示例13: WaitForPause

/** \fn RecorderBase::WaitForPause(int)
 *  \brief WaitForPause blocks until recorder is actually paused,
 *         or timeout milliseconds elapse.
 *  \param timeout number of milliseconds to wait defaults to 1000.
 *  \return true iff pause happened within timeout period.
 */
bool RecorderBase::WaitForPause(int timeout)
{
    MythTimer t;
    t.start();

    QMutexLocker locker(&pauseLock);
    while (!IsPaused(true) && request_pause)
    {
        int wait = timeout - t.elapsed();
        if (wait <= 0)
            return false;
        pauseWait.wait(&pauseLock, wait);
    }
    return true;
}
开发者ID:gdenning,项目名称:mythtv,代码行数:21,代码来源:recorderbase.cpp

示例14: WaitForUsed

/** \fn DeviceReadBuffer::WaitForUsed(uint,uint) const
 *  \param needed Number of bytes we want to read
 *  \param max_wait Number of milliseconds to wait for the needed data
 *  \return bytes available for reading
 */
uint DeviceReadBuffer::WaitForUsed(uint needed, uint max_wait) const
{
    MythTimer timer;
    timer.start();

    QMutexLocker locker(&lock);
    size_t avail = used;
    while ((needed > avail) && isRunning() &&
           !request_pause && !error && !eof &&
           (timer.elapsed() < (int)max_wait))
    {
        dataWait.wait(locker.mutex(), 10);
        avail = used;
    }
    return avail;
}
开发者ID:,项目名称:,代码行数:21,代码来源:

示例15: query

DTC::LiveStreamInfo *HTTPLiveStream::StopStream(int id)
{
    MSqlQuery query(MSqlQuery::InitCon());
    query.prepare(
        "UPDATE livestream "
        "SET status = :STATUS "
        "WHERE id = :STREAMID; ");
    query.bindValue(":STATUS", (int)kHLSStatusStopping);
    query.bindValue(":STREAMID", id);

    if (!query.exec())
    {
        LOG(VB_GENERAL, LOG_ERR, SLOC +
            QString("Unable to remove mark stream stopped for stream %1.")
                    .arg(id));
        return NULL;
    }

    HTTPLiveStream *hls = new HTTPLiveStream(id);
    if (!hls)
        return NULL;

    MythTimer statusTimer;
    int       delay = 250000;
    statusTimer.start();

    HTTPLiveStreamStatus status = hls->GetDBStatus();
    while ((status != kHLSStatusStopped) &&
           (status != kHLSStatusCompleted) &&
           (status != kHLSStatusErrored) &&
           ((statusTimer.elapsed() / 1000) < 30))
    {
        delay = (int)(delay * 1.5);
        usleep(delay);

        status = hls->GetDBStatus();
    }

    hls->LoadFromDB();
    DTC::LiveStreamInfo *pLiveStreamInfo = hls->GetLiveStreamInfo();

    delete hls;
    return pLiveStreamInfo;
}
开发者ID:,项目名称:,代码行数:44,代码来源:


注:本文中的MythTimer::elapsed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。