Logo Search packages:      
Sourcecode: pulseaudio version File versions

int pa_stream_get_time ( pa_stream s,
pa_usec_t r_usec 
)

Return the current playback/recording time. This is based on the data in the timing info structure returned by pa_stream_get_timing_info(). This function will usually only return new data if a timing info update has been recieved. Only if timing interpolation has been requested (PA_STREAM_INTERPOLATE_TIMING) the data from the last timing update is used for an estimation of the current playback/recording time based on the local time that passed since the timing info structure has been acquired. The time value returned by this function is guaranteed to increase monotonically. (that means: the returned value is always greater or equal to the value returned on the last call) This behaviour can be disabled by using PA_STREAM_NOT_MONOTONOUS. This may be desirable to deal better with bad estimations of transport latencies, but may have strange effects if the application is not able to deal with time going 'backwards'.

Definition at line 1875 of file stream.c.

References PA_ERR_BADSTATE, PA_ERR_NODATA, PA_STREAM_PLAYBACK, PA_STREAM_READY, PA_STREAM_RECORD, and PA_STREAM_UPLOAD.

                                                        {
    pa_usec_t usec;

    pa_assert(s);
    pa_assert(PA_REFCNT_VALUE(s) >= 1);

    PA_CHECK_VALIDITY(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE);
    PA_CHECK_VALIDITY(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE);
    PA_CHECK_VALIDITY(s->context, s->timing_info_valid, PA_ERR_NODATA);
    PA_CHECK_VALIDITY(s->context, s->direction != PA_STREAM_PLAYBACK || !s->timing_info.read_index_corrupt, PA_ERR_NODATA);
    PA_CHECK_VALIDITY(s->context, s->direction != PA_STREAM_RECORD || !s->timing_info.write_index_corrupt, PA_ERR_NODATA);

    if (s->smoother)
        usec = pa_smoother_get(s->smoother, pa_rtclock_usec());
    else
        usec = calc_time(s, FALSE);

    /* Make sure the time runs monotonically */
    if (!(s->flags & PA_STREAM_NOT_MONOTONOUS)) {
        if (usec < s->previous_time)
            usec = s->previous_time;
        else
            s->previous_time = usec;
    }

    if (r_usec)
        *r_usec = usec;

    return 0;
}


Generated by  Doxygen 1.6.0   Back to index