#include "internal.h"
-#define LATENCY_IPOL_INTERVAL_USEC (10000L)
+#define LATENCY_IPOL_INTERVAL_USEC (100000L)
pa_stream *pa_stream_new(pa_context *c, const char *name, const pa_sample_spec *ss, const pa_channel_map *map) {
pa_stream *s;
s->corked = 0;
- s->ipol_usec_valid = 0;
- s->ipol_timestamp.tv_sec = 0;
- s->ipol_timestamp.tv_usec = 0;
+ s->cached_time_valid = 0;
s->auto_timing_update_event = NULL;
s->auto_timing_update_requested = 0;
if ((s->direction == PA_STREAM_PLAYBACK && r) ||
(s->direction == PA_STREAM_RECORD && w))
- s->ipol_usec_valid = 0;
+ s->cached_time_valid = 0;
request_auto_timing_update(s, 1);
}
i->read_index -= pa_memblockq_get_length(o->stream->record_memblockq);
}
- o->stream->ipol_timestamp = now;
- o->stream->ipol_usec_valid = 0;
+ o->stream->cached_time_valid = 0;
}
o->stream->auto_timing_update_requested = 0;
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->flags & PA_STREAM_INTERPOLATE_TIMING && s->ipol_usec_valid)
- usec = s->ipol_usec;
+ if (s->cached_time_valid)
+ /* We alredy calculated the time value for this timing info, so let's reuse it */
+ usec = s->cached_time;
else {
if (s->direction == PA_STREAM_PLAYBACK) {
/* The last byte that was written into the output device
}
}
- if (s->flags & PA_STREAM_INTERPOLATE_TIMING) {
- s->ipol_usec = usec;
- s->ipol_usec_valid = 1;
- }
+ s->cached_time = usec;
+ s->cached_time_valid = 1;
}
/* Interpolate if requested */
* current */
if (!s->corked) {
struct timeval now;
-
- usec += pa_timeval_diff(pa_gettimeofday(&now), &s->ipol_timestamp);
- s->ipol_timestamp = now;
+ usec += pa_timeval_diff(pa_gettimeofday(&now), &s->timing_info.timestamp);
}
}