void start_time_redraw_tick(struct ev_loop* main_loop) { if (time_redraw_tick) { ev_periodic_set(time_redraw_tick, 0., 1.0, 0); ev_periodic_again(main_loop, time_redraw_tick); } else { if (!(time_redraw_tick = calloc(sizeof(struct ev_periodic), 1))) { return; } ev_periodic_init(time_redraw_tick, time_redraw_cb, 0., 1., 0); ev_periodic_start(main_loop, time_redraw_tick); } }
void flux_periodic_watcher_reset (flux_watcher_t *w, double next, double interval, flux_reschedule_f reschedule_cb) { struct f_periodic *fp = w->impl; struct ev_loop *loop = w->r->loop; assert (w->signature == PERIODIC_SIG); fp->reschedule_cb = reschedule_cb; ev_periodic_set (&fp->evp, next, interval, reschedule_cb ? periodic_reschedule_cb : NULL); ev_periodic_again (loop, &fp->evp); }
void start_time_redraw_tick(struct ev_loop* main_loop) { if (time_redraw_tick) { ev_periodic_set(time_redraw_tick, 1.0, 60., 0); ev_periodic_again(main_loop, time_redraw_tick); } else { /* When there is no memory, we just don’t have a timeout. We cannot * exit() here, since that would effectively unlock the screen. */ if (!(time_redraw_tick = calloc(sizeof(struct ev_periodic), 1))) return; ev_periodic_init(time_redraw_tick,time_redraw_cb, 1.0, 60., 0); ev_periodic_start(main_loop, time_redraw_tick); } }
/** * Send pending RTP packets to a session. * * @param loop eventloop * @param w contains the session the RTP session for which to send the packets * @todo implement a saner ratecontrol */ static void rtp_write_cb(struct ev_loop *loop, ev_periodic *w, ATTR_UNUSED int revents) { RTP_session *session = w->data; Resource *resource = session->track->parent; MParserBuffer *buffer = NULL; ev_tstamp next_time = w->offset; #ifdef HAVE_METADATA if (session->metadata) cpd_send(session, now); #endif /* If there is no buffer, it means that either the producer * has been stopped (as we reached the end of stream) or that * there is no data for the consumer to read. If that's the * case we just give control back to the main loop for now. */ if ( bq_consumer_stopped(session->consumer) ) { /* If the producer has been stopped, we send the * finishing packets and go away. */ fnc_log(FNC_LOG_INFO, "[rtp] Stream Finished"); rtcp_send_sr(session, BYE); return; } /* Check whether we have enough extra frames to send. If we have * no extra frames we have a problem, since we're going to send * one packet at least. */ if (resource->eor) fnc_log(FNC_LOG_INFO, "[%s] end of resource %d packets to be fetched", session->track->properties.encoding_name, bq_consumer_unseen(session->consumer)); /* Get the current buffer, if there is enough data */ if ( !(buffer = bq_consumer_get(session->consumer)) ) { /* We wait a bit of time to get the data but before it is * expired. */ if (resource->eor) { fnc_log(FNC_LOG_INFO, "[rtp] Stream Finished"); rtcp_send_sr(session, BYE); return; } next_time += 0.01; // assumed to be enough } else { MParserBuffer *next; double delivery = buffer->delivery; double timestamp = buffer->timestamp; double duration = buffer->duration; gboolean marker = buffer->marker; rtp_packet_send(session, buffer); if (session->pkt_count % 29 == 1) rtcp_send_sr(session, SDES); if (bq_consumer_move(session->consumer)) { next = bq_consumer_get(session->consumer); if(delivery != next->delivery) { if (session->track->properties.media_source == MS_live) next_time += next->delivery - delivery; else next_time = session->range->playback_time - session->range->begin_time + next->delivery; } } else { if (marker) next_time += duration; } fnc_log(FNC_LOG_VERBOSE, "[%s] Now: %5.4f, cur %5.4f[%5.4f][%5.4f], next %5.4f %s\n", session->track->properties.encoding_name, ev_now(loop) - session->range->playback_time, delivery, timestamp, duration, next_time - session->range->playback_time, marker? "M" : " "); } ev_periodic_set(w, next_time, 0, NULL); ev_periodic_again(loop, w); rtp_session_fill(session); }
static PyObject * PeriodicBase_reset(PeriodicBase *self) { ev_periodic_again(((Watcher *)self)->loop->loop, &self->periodic); Py_RETURN_NONE; }