void NotifyPluginConfiguration::saveState(QSettings* settings) const
{
        settings->setValue("SoundCollectionPath", Utils::PathUtils().RemoveDataPath(getSoundCollectionPath()));
	settings->setValue(QLatin1String("CurrentLanguage"), getCurrentLanguage());
	settings->setValue(QLatin1String("ObjectField"), getObjectField());
	settings->setValue(QLatin1String("DataObject"), getDataObject());
	settings->setValue(QLatin1String("Value"), getValue());
	settings->setValue(QLatin1String("ValueSpinBox"), getSpinBoxValue());
	settings->setValue(QLatin1String("Sound1"), getSound1());
	settings->setValue(QLatin1String("Sound2"), getSound2());
	settings->setValue(QLatin1String("Sound3"), getSound3());
	settings->setValue(QLatin1String("SayOrder"), getSayOrder());
	settings->setValue(QLatin1String("Repeat"), getRepeatFlag());
	settings->setValue(QLatin1String("ExpireTimeout"), getExpireTimeout());
}
Esempio n. 2
0
microtimeout_t
OutgoingDataQueue::getSchedulingTimeout(void)
{
    struct timeval send, now;
    uint32 rate;
    uint32 rem;

    for(;;) {
        // if there is no packet to send, use the default scheduling
        // timeout
        if( !sendFirst )
            return schedulingTimeout;

        uint32 stamp = sendFirst->getPacket()->getTimestamp();
        stamp -= getInitialTimestamp();
        rate = getCurrentRTPClockRate();

        // now we want to get in <code>send</code> _when_ the
        // packet is scheduled to be sent.

        // translate timestamp to timeval
        send.tv_sec = stamp / rate;
        rem = stamp % rate;
        send.tv_usec = (1000ul*rem) / (rate/1000ul); // 10^6 * rem/rate

        // add timevals. Overflow holds the inital time
        // plus the time accumulated through successive
        // overflows of timestamp. See below.
        timeradd(&send,&(sendInfo.overflowTime),&send);
        SysTime::gettimeofday(&now, NULL);

        // Problem: when timestamp overflows, time goes back.
        // We MUST ensure that _send_ is not too lower than
        // _now_, otherwise, we MUST keep how many time was
        // lost because of overflow. We assume that _send_
        // 5000 seconds lower than now suggests timestamp
        // overflow.  (Remember than the 32 bits of the
        // timestamp field are 47722 seconds under a sampling
        // clock of 90000 hz.)  This is not a perfect
        // solution. Disorderedly timestamped packets coming
        // after an overflowed one will be wrongly
        // corrected. Nevertheless, this may only corrupt a
        // handful of those packets every more than 13 hours
        // (if timestamp started from 0).
        if ( now.tv_sec - send.tv_sec > 5000) {
            timeval overflow;
            overflow.tv_sec =(~static_cast<uint32>(0)) / rate;
            overflow.tv_usec = (~static_cast<uint32>(0)) % rate *
                1000000ul / rate;
            do {
                timeradd(&send,&overflow,&send);
                timeradd(&(sendInfo.overflowTime),&overflow,
                     &(sendInfo.overflowTime));
            } while ( now.tv_sec - send.tv_sec > 5000 );
        }

        // This tries to solve the aforementioned problem
        // about disordered packets coming after an overflowed
        // one. Now we apply the reverse idea.
        if ( send.tv_sec - now.tv_sec > 20000 ) {
            timeval overflow;
            overflow.tv_sec = (~static_cast<uint32>(0)) / rate;
            overflow.tv_usec = (~static_cast<uint32>(0)) % rate *
                1000000ul / rate;
            timersub(&send,&overflow,&send);
        }

        // A: This sets a maximum timeout of 1 hour.
        if ( send.tv_sec - now.tv_sec > 3600 ) {
            return 3600000000ul;
        }
        int32 diff =
            ((send.tv_sec - now.tv_sec) * 1000000ul) +
            send.tv_usec - now.tv_usec;
        // B: wait <code>diff</code> usecs more before sending
        if ( diff >= 0 ) {
            return static_cast<microtimeout_t>(diff);
        }

        // C: the packet must be sent right now
        if ( (diff < 0) &&
             static_cast<microtimeout_t>(-diff) <= getExpireTimeout() ) {
            return 0;
        }

        // D: the packet has expired -> delete it.
        sendLock.writeLock();
        OutgoingRTPPktLink* packet = sendFirst;
        sendFirst = sendFirst->getNext();
        onExpireSend(*(packet->getPacket()));  // new virtual to notify
        delete packet;
        if ( sendFirst )
            sendFirst->setPrev(NULL);
        else
            sendLast = NULL;
        sendLock.unlock();
    }
    I( false );
    return 0;
}