PA_MODULE_AUTHOR("Lennart Poettering");
PA_MODULE_DESCRIPTION(_("Clocked NULL sink"));
PA_MODULE_VERSION(PACKAGE_VERSION);
-PA_MODULE_LOAD_ONCE(FALSE);
+PA_MODULE_LOAD_ONCE(false);
PA_MODULE_USAGE(
"sink_name=<name of sink> "
"sink_properties=<properties for the sink> "
pa_assert(u);
- /* Figure out how much we shall rewind and reset the counter */
rewind_nbytes = u->sink->thread_info.rewind_nbytes;
- u->sink->thread_info.rewind_nbytes = 0;
- pa_assert(rewind_nbytes > 0);
+ if (!PA_SINK_IS_OPENED(u->sink->thread_info.state) || rewind_nbytes <= 0)
+ goto do_nothing;
+
pa_log_debug("Requested to rewind %lu bytes.", (unsigned long) rewind_nbytes);
if (u->timestamp <= now)
queued. Hence: at maximum read this many bytes from the sink
inputs. */
- /* Fill the buffer up the the latency size */
+ /* Fill the buffer up the latency size */
while (u->timestamp < now + u->block_usec) {
pa_memchunk chunk;
u->timestamp = pa_rtclock_now();
for (;;) {
+ pa_usec_t now = 0;
int ret;
- /* Render some data and drop it immediately */
- if (PA_SINK_IS_OPENED(u->sink->thread_info.state)) {
- pa_usec_t now;
-
+ if (PA_SINK_IS_OPENED(u->sink->thread_info.state))
now = pa_rtclock_now();
- if (u->sink->thread_info.rewind_requested) {
- if (u->sink->thread_info.rewind_nbytes > 0)
- process_rewind(u, now);
- else
- pa_sink_process_rewind(u->sink, 0);
- }
+ if (PA_UNLIKELY(u->sink->thread_info.rewind_requested))
+ process_rewind(u, now);
+ /* Render some data and drop it immediately */
+ if (PA_SINK_IS_OPENED(u->sink->thread_info.state)) {
if (u->timestamp <= now)
process_render(u, now);
pa_rtpoll_set_timer_disabled(u->rtpoll);
/* Hmm, nothing to do. Let's sleep */
- if ((ret = pa_rtpoll_run(u->rtpoll, TRUE)) < 0)
+ if ((ret = pa_rtpoll_run(u->rtpoll, true)) < 0)
goto fail;
if (ret == 0)
goto fail;
}
+ pa_sink_set_latency_range(u->sink, 0, BLOCK_USEC);
+
pa_sink_put(u->sink);
pa_modargs_free(ma);