Logo Search packages:      
Sourcecode: pulseaudio version File versions

struct timeval* pa_timeval_sub ( struct timeval *  tv,
pa_usec_t  v 
) [read]

Subtract the specified time inmicroseconds to the specified timeval structure.

Since:
0.9.11

Definition at line 162 of file timeval.c.

References PA_USEC_PER_SEC.

                                                                {
    time_t secs;
    pa_assert(tv);

    secs = (time_t) (v/PA_USEC_PER_SEC);

    if (PA_UNLIKELY(tv->tv_sec < secs))
        goto underflow;

    tv->tv_sec -= secs;
    v -= (pa_usec_t) secs * PA_USEC_PER_SEC;

    if (tv->tv_usec >= (suseconds_t) v)
        tv->tv_usec -= (suseconds_t) v;
    else {

        if (PA_UNLIKELY(tv->tv_sec <= 0))
            goto underflow;

        tv->tv_sec --;
        tv->tv_usec += (suseconds_t) (PA_USEC_PER_SEC - v);
    }

    return tv;

underflow:
    tv->tv_sec = 0;
    tv->tv_usec = 0;
    return tv;
}


Generated by  Doxygen 1.6.0   Back to index