From 5dcdd5e3583f32c8bffb5a1892e318747070f5d8 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Sat, 4 Apr 2009 22:56:38 +0300 Subject: perl -p -i -e 's/pa_rtclock_usec/pa_rtclock_now/g' `find . -name '*.[ch]'` --- src/modules/alsa/alsa-sink.c | 12 ++++++------ src/modules/alsa/alsa-source.c | 12 ++++++------ src/modules/bluetooth/module-bluetooth-device.c | 18 +++++++++--------- src/modules/module-combine.c | 12 ++++++------ src/modules/module-esound-sink.c | 10 +++++----- src/modules/module-null-sink.c | 8 ++++---- src/modules/module-sine-source.c | 8 ++++---- src/modules/module-solaris.c | 2 +- src/modules/module-tunnel.c | 12 ++++++------ src/modules/raop/module-raop-sink.c | 10 +++++----- src/modules/rtp/module-rtp-recv.c | 2 +- 11 files changed, 53 insertions(+), 53 deletions(-) (limited to 'src/modules') diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c index 281371f7..37ebe541 100644 --- a/src/modules/alsa/alsa-sink.c +++ b/src/modules/alsa/alsa-sink.c @@ -707,7 +707,7 @@ static void update_smoother(struct userdata *u) { /* Hmm, if the timestamp is 0, then it wasn't set and we take the current time */ if (now1 <= 0) - now1 = pa_rtclock_usec(); + now1 = pa_rtclock_now(); now2 = pa_bytes_to_usec((uint64_t) position, &u->sink->sample_spec); @@ -721,7 +721,7 @@ static pa_usec_t sink_get_latency(struct userdata *u) { pa_assert(u); - now1 = pa_rtclock_usec(); + now1 = pa_rtclock_now(); now2 = pa_smoother_get(u->smoother, now1); delay = (int64_t) pa_bytes_to_usec(u->write_count, &u->sink->sample_spec) - (int64_t) now2; @@ -752,7 +752,7 @@ static int suspend(struct userdata *u) { pa_assert(u); pa_assert(u->pcm_handle); - pa_smoother_pause(u->smoother, pa_rtclock_usec()); + pa_smoother_pause(u->smoother, pa_rtclock_now()); /* Let's suspend -- we don't call snd_pcm_drain() here since that might * take awfully long with our long buffer sizes today. */ @@ -1246,7 +1246,7 @@ static void thread_func(void *userdata) { pa_log_info("Starting playback."); snd_pcm_start(u->pcm_handle); - pa_smoother_resume(u->smoother, pa_rtclock_usec(), TRUE); + pa_smoother_resume(u->smoother, pa_rtclock_now(), TRUE); } update_smoother(u); @@ -1275,7 +1275,7 @@ static void thread_func(void *userdata) { /* Convert from the sound card time domain to the * system time domain */ - cusec = pa_smoother_translate(u->smoother, pa_rtclock_usec(), sleep_usec); + cusec = pa_smoother_translate(u->smoother, pa_rtclock_now(), sleep_usec); /* pa_log_debug("Waking up in %0.2fms (system clock).", (double) cusec / PA_USEC_PER_MSEC); */ @@ -1581,7 +1581,7 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca TRUE, TRUE, 5, - pa_rtclock_usec(), + pa_rtclock_now(), TRUE); dev_id = pa_modargs_get_value( diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c index 4be27eb0..32510654 100644 --- a/src/modules/alsa/alsa-source.c +++ b/src/modules/alsa/alsa-source.c @@ -669,7 +669,7 @@ static void update_smoother(struct userdata *u) { /* Hmm, if the timestamp is 0, then it wasn't set and we take the current time */ if (now1 <= 0) - now1 = pa_rtclock_usec(); + now1 = pa_rtclock_now(); now2 = pa_bytes_to_usec(position, &u->source->sample_spec); @@ -682,7 +682,7 @@ static pa_usec_t source_get_latency(struct userdata *u) { pa_assert(u); - now1 = pa_rtclock_usec(); + now1 = pa_rtclock_now(); now2 = pa_smoother_get(u->smoother, now1); delay = (int64_t) now2 - (int64_t) pa_bytes_to_usec(u->read_count, &u->source->sample_spec); @@ -707,7 +707,7 @@ static int suspend(struct userdata *u) { pa_assert(u); pa_assert(u->pcm_handle); - pa_smoother_pause(u->smoother, pa_rtclock_usec()); + pa_smoother_pause(u->smoother, pa_rtclock_now()); /* Let's suspend */ snd_pcm_close(u->pcm_handle); @@ -833,7 +833,7 @@ static int unsuspend(struct userdata *u) { /* FIXME: We need to reload the volume somehow */ snd_pcm_start(u->pcm_handle); - pa_smoother_resume(u->smoother, pa_rtclock_usec(), TRUE); + pa_smoother_resume(u->smoother, pa_rtclock_now(), TRUE); pa_log_info("Resumed successfully..."); @@ -1131,7 +1131,7 @@ static void thread_func(void *userdata) { /* Convert from the sound card time domain to the * system time domain */ - cusec = pa_smoother_translate(u->smoother, pa_rtclock_usec(), sleep_usec); + cusec = pa_smoother_translate(u->smoother, pa_rtclock_now(), sleep_usec); /* pa_log_debug("Waking up in %0.2fms (system clock).", (double) cusec / PA_USEC_PER_MSEC); */ @@ -1431,7 +1431,7 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p TRUE, TRUE, 5, - pa_rtclock_usec(), + pa_rtclock_now(), FALSE); dev_id = pa_modargs_get_value( diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c index 6bcd0b80..e0d4e481 100644 --- a/src/modules/bluetooth/module-bluetooth-device.c +++ b/src/modules/bluetooth/module-bluetooth-device.c @@ -773,7 +773,7 @@ static int start_stream_fd(struct userdata *u) { TRUE, TRUE, 10, - pa_rtclock_usec(), + pa_rtclock_now(), TRUE); return 0; @@ -867,14 +867,14 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse if (u->read_smoother) { pa_usec_t wi, ri; - ri = pa_smoother_get(u->read_smoother, pa_rtclock_usec()); + ri = pa_smoother_get(u->read_smoother, pa_rtclock_now()); wi = pa_bytes_to_usec(u->write_index + u->block_size, &u->sample_spec); *((pa_usec_t*) data) = wi > ri ? wi - ri : 0; } else { pa_usec_t ri, wi; - ri = pa_rtclock_usec() - u->started_at; + ri = pa_rtclock_now() - u->started_at; wi = pa_bytes_to_usec(u->write_index, &u->sample_spec); *((pa_usec_t*) data) = wi > ri ? wi - ri : 0; @@ -912,7 +912,7 @@ static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t off stop_stream_fd(u); if (u->read_smoother) - pa_smoother_pause(u->read_smoother, pa_rtclock_usec()); + pa_smoother_pause(u->read_smoother, pa_rtclock_now()); break; case PA_SOURCE_IDLE: @@ -939,7 +939,7 @@ static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t off case PA_SOURCE_MESSAGE_GET_LATENCY: { pa_usec_t wi, ri; - wi = pa_smoother_get(u->read_smoother, pa_rtclock_usec()); + wi = pa_smoother_get(u->read_smoother, pa_rtclock_now()); ri = pa_bytes_to_usec(u->read_index, &u->sample_spec); *((pa_usec_t*) data) = (wi > ri ? wi - ri : 0) + u->source->fixed_latency; @@ -1086,7 +1086,7 @@ static int hsp_process_push(struct userdata *u) { if (!found_tstamp) { pa_log_warn("Couldn't find SO_TIMESTAMP data in auxiliary recvmsg() data!"); - tstamp = pa_rtclock_usec(); + tstamp = pa_rtclock_now(); } pa_smoother_put(u->read_smoother, tstamp, pa_bytes_to_usec(u->read_index, &u->sample_spec)); @@ -1309,7 +1309,7 @@ static void thread_func(void *userdata) { /* Hmm, there is no input stream we could synchronize * to. So let's do things by time */ - time_passed = pa_rtclock_usec() - u->started_at; + time_passed = pa_rtclock_now() - u->started_at; audio_sent = pa_bytes_to_usec(u->write_index, &u->sample_spec); if (audio_sent <= time_passed) { @@ -1341,7 +1341,7 @@ static void thread_func(void *userdata) { int n_written; if (u->write_index <= 0) - u->started_at = pa_rtclock_usec(); + u->started_at = pa_rtclock_now(); if (u->profile == PROFILE_A2DP) { if ((n_written = a2dp_process_render(u)) < 0) @@ -1361,7 +1361,7 @@ static void thread_func(void *userdata) { /* Hmm, there is no input stream we could synchronize * to. So let's estimate when we need to wake up the latest */ - time_passed = pa_rtclock_usec() - u->started_at; + time_passed = pa_rtclock_now() - u->started_at; next_write_at = pa_bytes_to_usec(u->write_index, &u->sample_spec); sleep_for = time_passed < next_write_at ? next_write_at - time_passed : 0; diff --git a/src/modules/module-combine.c b/src/modules/module-combine.c index 725faa0c..69dc530b 100644 --- a/src/modules/module-combine.c +++ b/src/modules/module-combine.c @@ -282,7 +282,7 @@ static void thread_func(void *userdata) { pa_thread_mq_install(&u->thread_mq); pa_rtpoll_install(u->rtpoll); - u->thread_info.timestamp = pa_rtclock_usec(); + u->thread_info.timestamp = pa_rtclock_now(); u->thread_info.in_null_mode = FALSE; for (;;) { @@ -296,7 +296,7 @@ static void thread_func(void *userdata) { if (PA_SINK_IS_OPENED(u->sink->thread_info.state) && !u->thread_info.active_outputs) { pa_usec_t now; - now = pa_rtclock_usec(); + now = pa_rtclock_now(); if (!u->thread_info.in_null_mode || u->thread_info.timestamp <= now) process_render_null(u, now); @@ -664,16 +664,16 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse pa_atomic_store(&u->thread_info.running, PA_PTR_TO_UINT(data) == PA_SINK_RUNNING); if (PA_PTR_TO_UINT(data) == PA_SINK_SUSPENDED) - pa_smoother_pause(u->thread_info.smoother, pa_rtclock_usec()); + pa_smoother_pause(u->thread_info.smoother, pa_rtclock_now()); else - pa_smoother_resume(u->thread_info.smoother, pa_rtclock_usec(), TRUE); + pa_smoother_resume(u->thread_info.smoother, pa_rtclock_now(), TRUE); break; case PA_SINK_MESSAGE_GET_LATENCY: { pa_usec_t x, y, c, *delay = data; - x = pa_rtclock_usec(); + x = pa_rtclock_now(); y = pa_smoother_get(u->thread_info.smoother, x); c = pa_bytes_to_usec(u->thread_info.counter, &u->sink->sample_spec); @@ -730,7 +730,7 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse case SINK_MESSAGE_UPDATE_LATENCY: { pa_usec_t x, y, latency = (pa_usec_t) offset; - x = pa_rtclock_usec(); + x = pa_rtclock_now(); y = pa_bytes_to_usec(u->thread_info.counter, &u->sink->sample_spec); if (y > latency) diff --git a/src/modules/module-esound-sink.c b/src/modules/module-esound-sink.c index 8cb25c51..d631da03 100644 --- a/src/modules/module-esound-sink.c +++ b/src/modules/module-esound-sink.c @@ -145,14 +145,14 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse case PA_SINK_SUSPENDED: pa_assert(PA_SINK_IS_OPENED(u->sink->thread_info.state)); - pa_smoother_pause(u->smoother, pa_rtclock_usec()); + pa_smoother_pause(u->smoother, pa_rtclock_now()); break; case PA_SINK_IDLE: case PA_SINK_RUNNING: if (u->sink->thread_info.state == PA_SINK_SUSPENDED) - pa_smoother_resume(u->smoother, pa_rtclock_usec(), TRUE); + pa_smoother_resume(u->smoother, pa_rtclock_now(), TRUE); break; @@ -167,7 +167,7 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse case PA_SINK_MESSAGE_GET_LATENCY: { pa_usec_t w, r; - r = pa_smoother_get(u->smoother, pa_rtclock_usec()); + r = pa_smoother_get(u->smoother, pa_rtclock_now()); w = pa_bytes_to_usec((uint64_t) u->offset + u->memchunk.length, &u->sink->sample_spec); *((pa_usec_t*) data) = w > r ? w - r : 0; @@ -202,7 +202,7 @@ static void thread_func(void *userdata) { pa_thread_mq_install(&u->thread_mq); pa_rtpoll_install(u->rtpoll); - pa_smoother_set_time_offset(u->smoother, pa_rtclock_usec()); + pa_smoother_set_time_offset(u->smoother, pa_rtclock_now()); for (;;) { int ret; @@ -295,7 +295,7 @@ static void thread_func(void *userdata) { else usec = 0; - pa_smoother_put(u->smoother, pa_rtclock_usec(), usec); + pa_smoother_put(u->smoother, pa_rtclock_now(), usec); } /* Hmm, nothing to do. Let's sleep */ diff --git a/src/modules/module-null-sink.c b/src/modules/module-null-sink.c index 30a99ca7..8981d52d 100644 --- a/src/modules/module-null-sink.c +++ b/src/modules/module-null-sink.c @@ -101,14 +101,14 @@ static int sink_process_msg( case PA_SINK_MESSAGE_SET_STATE: if (PA_PTR_TO_UINT(data) == PA_SINK_RUNNING) - u->timestamp = pa_rtclock_usec(); + u->timestamp = pa_rtclock_now(); break; case PA_SINK_MESSAGE_GET_LATENCY: { pa_usec_t now; - now = pa_rtclock_usec(); + now = pa_rtclock_now(); *((pa_usec_t*) data) = u->timestamp > now ? u->timestamp - now : 0ULL; return 0; @@ -210,7 +210,7 @@ static void thread_func(void *userdata) { pa_thread_mq_install(&u->thread_mq); pa_rtpoll_install(u->rtpoll); - u->timestamp = pa_rtclock_usec(); + u->timestamp = pa_rtclock_now(); for (;;) { int ret; @@ -219,7 +219,7 @@ static void thread_func(void *userdata) { if (PA_SINK_IS_OPENED(u->sink->thread_info.state)) { pa_usec_t now; - now = pa_rtclock_usec(); + now = pa_rtclock_now(); if (u->sink->thread_info.rewind_requested) { if (u->sink->thread_info.rewind_nbytes > 0) diff --git a/src/modules/module-sine-source.c b/src/modules/module-sine-source.c index 14a04e47..9be4e195 100644 --- a/src/modules/module-sine-source.c +++ b/src/modules/module-sine-source.c @@ -101,14 +101,14 @@ static int source_process_msg( case PA_SOURCE_MESSAGE_SET_STATE: if (PA_PTR_TO_UINT(data) == PA_SOURCE_RUNNING) - u->timestamp = pa_rtclock_usec(); + u->timestamp = pa_rtclock_now(); break; case PA_SOURCE_MESSAGE_GET_LATENCY: { pa_usec_t now, left_to_fill; - now = pa_rtclock_usec(); + now = pa_rtclock_now(); left_to_fill = u->timestamp > now ? u->timestamp - now : 0ULL; *((pa_usec_t*) data) = u->block_usec > left_to_fill ? u->block_usec - left_to_fill : 0ULL; @@ -168,7 +168,7 @@ static void thread_func(void *userdata) { pa_thread_mq_install(&u->thread_mq); pa_rtpoll_install(u->rtpoll); - u->timestamp = pa_rtclock_usec(); + u->timestamp = pa_rtclock_now(); for (;;) { int ret; @@ -176,7 +176,7 @@ static void thread_func(void *userdata) { if (PA_SOURCE_IS_OPENED(u->source->thread_info.state)) { pa_usec_t now; - now = pa_rtclock_usec(); + now = pa_rtclock_now(); if (u->timestamp <= now) process_render(u, now); diff --git a/src/modules/module-solaris.c b/src/modules/module-solaris.c index 5cfa97a7..08fe6f58 100644 --- a/src/modules/module-solaris.c +++ b/src/modules/module-solaris.c @@ -641,7 +641,7 @@ static void thread_func(void *userdata) { * Since we cannot modify the size of the output buffer we fake it * by not filling it more than u->buffer_size. */ - xtime0 = pa_rtclock_usec(); + xtime0 = pa_rtclock_now(); buffered_bytes = get_playback_buffered_bytes(u); if (buffered_bytes >= (uint64_t)u->buffer_size) break; diff --git a/src/modules/module-tunnel.c b/src/modules/module-tunnel.c index c493d9bb..60498ad7 100644 --- a/src/modules/module-tunnel.c +++ b/src/modules/module-tunnel.c @@ -395,7 +395,7 @@ static void check_smoother_status(struct userdata *u, pa_bool_t past) { pa_assert(u); - x = pa_rtclock_usec(); + x = pa_rtclock_now(); /* Correct by the time the requested issued needs to travel to the * other side. This is a valid thread-safe access, because the @@ -500,7 +500,7 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse pa_usec_t yl, yr, *usec = data; yl = pa_bytes_to_usec((uint64_t) u->counter, &u->sink->sample_spec); - yr = pa_smoother_get(u->smoother, pa_rtclock_usec()); + yr = pa_smoother_get(u->smoother, pa_rtclock_now()); *usec = yl > yr ? yl - yr : 0; return 0; @@ -533,7 +533,7 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse else y = 0; - pa_smoother_put(u->smoother, pa_rtclock_usec(), y); + pa_smoother_put(u->smoother, pa_rtclock_now(), y); /* We can access this freely here, since the main thread is waiting for us */ u->thread_transport_usec = u->transport_usec; @@ -607,7 +607,7 @@ static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t off pa_usec_t yr, yl, *usec = data; yl = pa_bytes_to_usec((uint64_t) u->counter, &PA_SOURCE(o)->sample_spec); - yr = pa_smoother_get(u->smoother, pa_rtclock_usec()); + yr = pa_smoother_get(u->smoother, pa_rtclock_now()); *usec = yr > yl ? yr - yl : 0; return 0; @@ -633,7 +633,7 @@ static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t off y = pa_bytes_to_usec((uint64_t) u->counter, &u->source->sample_spec); y += (pa_usec_t) offset; - pa_smoother_put(u->smoother, pa_rtclock_usec(), y); + pa_smoother_put(u->smoother, pa_rtclock_now(), y); /* We can access this freely here, since the main thread is waiting for us */ u->thread_transport_usec = u->transport_usec; @@ -1825,7 +1825,7 @@ int pa__init(pa_module*m) { TRUE, TRUE, 10, - pa_rtclock_usec(), + pa_rtclock_now(), FALSE); u->ctag = 1; u->device_index = u->channel = PA_INVALID_INDEX; diff --git a/src/modules/raop/module-raop-sink.c b/src/modules/raop/module-raop-sink.c index 54de42c2..0e6b9d42 100644 --- a/src/modules/raop/module-raop-sink.c +++ b/src/modules/raop/module-raop-sink.c @@ -181,7 +181,7 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse case PA_SINK_SUSPENDED: pa_assert(PA_SINK_IS_OPENED(u->sink->thread_info.state)); - pa_smoother_pause(u->smoother, pa_rtclock_usec()); + pa_smoother_pause(u->smoother, pa_rtclock_now()); /* Issue a FLUSH if we are connected */ if (u->fd >= 0) { @@ -193,7 +193,7 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse case PA_SINK_RUNNING: if (u->sink->thread_info.state == PA_SINK_SUSPENDED) { - pa_smoother_resume(u->smoother, pa_rtclock_usec(), TRUE); + pa_smoother_resume(u->smoother, pa_rtclock_now(), TRUE); /* The connection can be closed when idle, so check to see if we need to reestablish it */ @@ -216,7 +216,7 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse case PA_SINK_MESSAGE_GET_LATENCY: { pa_usec_t w, r; - r = pa_smoother_get(u->smoother, pa_rtclock_usec()); + r = pa_smoother_get(u->smoother, pa_rtclock_now()); w = pa_bytes_to_usec((u->offset - u->encoding_overhead + (u->encoded_memchunk.length / u->encoding_ratio)), &u->sink->sample_spec); *((pa_usec_t*) data) = w > r ? w - r : 0; @@ -325,7 +325,7 @@ static void thread_func(void *userdata) { pa_thread_mq_install(&u->thread_mq); pa_rtpoll_install(u->rtpoll); - pa_smoother_set_time_offset(u->smoother, pa_rtclock_usec()); + pa_smoother_set_time_offset(u->smoother, pa_rtclock_now()); /* Create a chunk of memory that is our encoded silence sample. */ pa_memchunk_reset(&silence); @@ -465,7 +465,7 @@ static void thread_func(void *userdata) { else usec = 0; - pa_smoother_put(u->smoother, pa_rtclock_usec(), usec); + pa_smoother_put(u->smoother, pa_rtclock_now(), usec); } /* Hmm, nothing to do. Let's sleep */ diff --git a/src/modules/rtp/module-rtp-recv.c b/src/modules/rtp/module-rtp-recv.c index b86923fb..5a935922 100644 --- a/src/modules/rtp/module-rtp-recv.c +++ b/src/modules/rtp/module-rtp-recv.c @@ -193,7 +193,7 @@ static void sink_input_suspend_within_thread(pa_sink_input* i, pa_bool_t b) { pa_assert_se(s = i->userdata); if (b) { - pa_smoother_pause(s->smoother, pa_rtclock_usec()); + pa_smoother_pause(s->smoother, pa_rtclock_now()); pa_memblockq_flush_read(s->memblockq); } else s->first_packet = FALSE; -- cgit From 125c52889626b2ac408ecbcc8ea85575f5808e07 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Sat, 4 Apr 2009 23:19:53 +0300 Subject: pulse: move pa_rtclock_now in pulsecommon --- src/modules/alsa/alsa-sink.c | 9 +++++---- src/modules/alsa/alsa-source.c | 9 +++++---- src/modules/alsa/module-alsa-source.c | 2 +- src/modules/bluetooth/module-bluetooth-device.c | 9 +++++---- src/modules/module-combine.c | 3 ++- src/modules/module-esound-sink.c | 5 +++-- src/modules/module-null-sink.c | 3 ++- src/modules/module-sine-source.c | 5 +++-- src/modules/module-tunnel.c | 3 ++- src/modules/raop/module-raop-sink.c | 5 +++-- src/modules/rtp/module-rtp-recv.c | 3 ++- 11 files changed, 33 insertions(+), 23 deletions(-) (limited to 'src/modules') diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c index 37ebe541..9116a69f 100644 --- a/src/modules/alsa/alsa-sink.c +++ b/src/modules/alsa/alsa-sink.c @@ -32,16 +32,18 @@ #include #endif -#include -#include -#include #include +#include +#include +#include +#include #include #include #include #include #include +#include #include #include #include @@ -50,7 +52,6 @@ #include #include #include -#include #include #include diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c index 32510654..ede9306f 100644 --- a/src/modules/alsa/alsa-source.c +++ b/src/modules/alsa/alsa-source.c @@ -28,10 +28,11 @@ #include -#include -#include -#include #include +#include +#include +#include +#include #include #include @@ -39,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -48,7 +50,6 @@ #include #include #include -#include #include diff --git a/src/modules/alsa/module-alsa-source.c b/src/modules/alsa/module-alsa-source.c index de8bcd0b..23da4185 100644 --- a/src/modules/alsa/module-alsa-source.c +++ b/src/modules/alsa/module-alsa-source.c @@ -37,6 +37,7 @@ #include #include +#include #include #include #include @@ -51,7 +52,6 @@ #include #include #include -#include #include "alsa-util.h" #include "alsa-source.h" diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c index e0d4e481..68ac3acc 100644 --- a/src/modules/bluetooth/module-bluetooth-device.c +++ b/src/modules/bluetooth/module-bluetooth-device.c @@ -30,13 +30,15 @@ #include #include -#include -#include -#include #include +#include +#include +#include +#include #include #include +#include #include #include #include @@ -44,7 +46,6 @@ #include #include #include -#include #include #include diff --git a/src/modules/module-combine.c b/src/modules/module-combine.c index 69dc530b..6ca7cd99 100644 --- a/src/modules/module-combine.c +++ b/src/modules/module-combine.c @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -36,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -43,7 +45,6 @@ #include #include #include -#include #include #include diff --git a/src/modules/module-esound-sink.c b/src/modules/module-esound-sink.c index d631da03..2df8a0e8 100644 --- a/src/modules/module-esound-sink.c +++ b/src/modules/module-esound-sink.c @@ -41,13 +41,15 @@ #include #endif -#include +#include #include +#include #include #include #include #include +#include #include #include #include @@ -57,7 +59,6 @@ #include #include #include -#include #include #include "module-esound-sink-symdef.h" diff --git a/src/modules/module-null-sink.c b/src/modules/module-null-sink.c index 8981d52d..2669776d 100644 --- a/src/modules/module-null-sink.c +++ b/src/modules/module-null-sink.c @@ -32,12 +32,14 @@ #include #include +#include #include #include #include #include #include +#include #include #include #include @@ -45,7 +47,6 @@ #include #include #include -#include #include "module-null-sink-symdef.h" diff --git a/src/modules/module-sine-source.c b/src/modules/module-sine-source.c index 9be4e195..33be66f5 100644 --- a/src/modules/module-sine-source.c +++ b/src/modules/module-sine-source.c @@ -34,19 +34,20 @@ #include #include -#include +#include #include +#include #include #include #include +#include #include #include #include #include #include #include -#include #include "module-sine-source-symdef.h" diff --git a/src/modules/module-tunnel.c b/src/modules/module-tunnel.c index 60498ad7..ec4808f0 100644 --- a/src/modules/module-tunnel.c +++ b/src/modules/module-tunnel.c @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -50,7 +51,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/modules/raop/module-raop-sink.c b/src/modules/raop/module-raop-sink.c index 0e6b9d42..c226b0c3 100644 --- a/src/modules/raop/module-raop-sink.c +++ b/src/modules/raop/module-raop-sink.c @@ -42,13 +42,15 @@ #include #endif -#include +#include #include +#include #include #include #include #include +#include #include #include #include @@ -57,7 +59,6 @@ #include #include #include -#include #include #include "module-raop-sink-symdef.h" diff --git a/src/modules/rtp/module-rtp-recv.c b/src/modules/rtp/module-rtp-recv.c index 5a935922..84cf07de 100644 --- a/src/modules/rtp/module-rtp-recv.c +++ b/src/modules/rtp/module-rtp-recv.c @@ -33,6 +33,7 @@ #include #include +#include #include #include @@ -43,13 +44,13 @@ #include #include #include +#include #include #include #include #include #include #include -#include #include #include #include -- cgit From 0955e3d45b6e992308e2d51fcbf28a9f9376f788 Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Sun, 5 Apr 2009 02:13:43 +0300 Subject: Base mainloop on pa_rtclock_now() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move the mainloop to monotonic based time events. Introduces 4 helper functions: pa_{context,core}_rttime_{new,restart}(), that fill correctly a timeval with the rtclock flag set if the mainloop supports it. Both mainloop-test and mainloop-test-glib works with rt and timeval based time events. PulseAudio and clients should be fully functional. This patch has received several iterations, and this one as been largely untested. Signed-off-by: Marc-André Lureau --- src/modules/module-card-restore.c | 12 ++++-------- src/modules/module-combine.c | 15 ++++----------- src/modules/module-default-device-restore.c | 13 +++++-------- src/modules/module-device-restore.c | 12 ++++-------- src/modules/module-esound-sink.c | 2 +- src/modules/module-stream-restore.c | 11 ++++------- src/modules/module-suspend-on-idle.c | 19 +++++++++---------- src/modules/module-tunnel.c | 18 ++++++------------ src/modules/module-waveout.c | 4 ++-- src/modules/raop/raop_client.c | 2 +- src/modules/rtp/module-rtp-recv.c | 15 +++++---------- src/modules/rtp/module-rtp-send.c | 14 ++++---------- src/modules/rtp/rtsp_client.c | 2 +- 13 files changed, 50 insertions(+), 89 deletions(-) (limited to 'src/modules') diff --git a/src/modules/module-card-restore.c b/src/modules/module-card-restore.c index 85583b2c..6b057b4c 100644 --- a/src/modules/module-card-restore.c +++ b/src/modules/module-card-restore.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -53,7 +54,7 @@ PA_MODULE_DESCRIPTION("Automatically restore profile of cards"); PA_MODULE_VERSION(PACKAGE_VERSION); PA_MODULE_LOAD_ONCE(TRUE); -#define SAVE_INTERVAL 10 +#define SAVE_INTERVAL (10 * PA_USEC_PER_SEC) static const char* const valid_modargs[] = { NULL @@ -75,12 +76,11 @@ struct entry { char profile[PA_NAME_MAX]; } PA_GCC_PACKED ; -static void save_time_callback(pa_mainloop_api*a, pa_time_event* e, const struct timeval *tv, void *userdata) { +static void save_time_callback(pa_mainloop_api*a, pa_time_event* e, const struct timeval *t, void *userdata) { struct userdata *u = userdata; pa_assert(a); pa_assert(e); - pa_assert(tv); pa_assert(u); pa_assert(e == u->save_time_event); @@ -132,14 +132,10 @@ fail: } static void trigger_save(struct userdata *u) { - struct timeval tv; - if (u->save_time_event) return; - pa_gettimeofday(&tv); - tv.tv_sec += SAVE_INTERVAL; - u->save_time_event = u->core->mainloop->time_new(u->core->mainloop, &tv, save_time_callback, u); + u->save_time_event = pa_core_rttime_new(u->core, pa_rtclock_now() + SAVE_INTERVAL, save_time_callback, u); } static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint32_t idx, void *userdata) { diff --git a/src/modules/module-combine.c b/src/modules/module-combine.c index 6ca7cd99..757dbda4 100644 --- a/src/modules/module-combine.c +++ b/src/modules/module-combine.c @@ -225,9 +225,8 @@ static void adjust_rates(struct userdata *u) { pa_asyncmsgq_send(u->sink->asyncmsgq, PA_MSGOBJECT(u->sink), SINK_MESSAGE_UPDATE_LATENCY, NULL, (int64_t) avg_total_latency, NULL); } -static void time_callback(pa_mainloop_api*a, pa_time_event* e, const struct timeval *tv, void *userdata) { +static void time_callback(pa_mainloop_api *a, pa_time_event *e, const struct timeval *t, void *userdata) { struct userdata *u = userdata; - struct timeval n; pa_assert(u); pa_assert(a); @@ -235,9 +234,7 @@ static void time_callback(pa_mainloop_api*a, pa_time_event* e, const struct time adjust_rates(u); - pa_gettimeofday(&n); - n.tv_sec += (time_t) u->adjust_time; - u->sink->core->mainloop->time_restart(e, &n); + pa_core_rttime_restart(u->core, e, pa_rtclock_now() + u->adjust_time * PA_USEC_PER_SEC); } static void process_render_null(struct userdata *u, pa_usec_t now) { @@ -1171,12 +1168,8 @@ int pa__init(pa_module*m) { if (o->sink_input) pa_sink_input_put(o->sink_input); - if (u->adjust_time > 0) { - struct timeval tv; - pa_gettimeofday(&tv); - tv.tv_sec += (time_t) u->adjust_time; - u->time_event = m->core->mainloop->time_new(m->core->mainloop, &tv, time_callback, u); - } + if (u->adjust_time > 0) + u->time_event = pa_core_rttime_new(m->core, pa_rtclock_now() + u->adjust_time * PA_USEC_PER_SEC, time_callback, u); pa_modargs_free(ma); diff --git a/src/modules/module-default-device-restore.c b/src/modules/module-default-device-restore.c index 0092d1c7..27ae60e5 100644 --- a/src/modules/module-default-device-restore.c +++ b/src/modules/module-default-device-restore.c @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -42,7 +43,7 @@ PA_MODULE_DESCRIPTION("Automatically restore the default sink and source"); PA_MODULE_VERSION(PACKAGE_VERSION); PA_MODULE_LOAD_ONCE(TRUE); -#define DEFAULT_SAVE_INTERVAL 5 +#define SAVE_INTERVAL (5 * PA_USEC_PER_SEC) struct userdata { pa_core *core; @@ -127,7 +128,7 @@ static void save(struct userdata *u) { u->modified = FALSE; } -static void time_cb(pa_mainloop_api *a, pa_time_event *e, const struct timeval *tv, void *userdata) { +static void time_cb(pa_mainloop_api *a, pa_time_event *e, const struct timeval *t, void *userdata) { struct userdata *u = userdata; pa_assert(u); @@ -146,12 +147,8 @@ static void subscribe_cb(pa_core *c, pa_subscription_event_type_t t, uint32_t id u->modified = TRUE; - if (!u->time_event) { - struct timeval tv; - pa_gettimeofday(&tv); - pa_timeval_add(&tv, DEFAULT_SAVE_INTERVAL*PA_USEC_PER_SEC); - u->time_event = u->core->mainloop->time_new(u->core->mainloop, &tv, time_cb, u); - } + if (!u->time_event) + u->time_event = pa_core_rttime_new(u->core, pa_rtclock_now() + SAVE_INTERVAL, time_cb, u); } int pa__init(pa_module *m) { diff --git a/src/modules/module-device-restore.c b/src/modules/module-device-restore.c index a2745b88..8c15d454 100644 --- a/src/modules/module-device-restore.c +++ b/src/modules/module-device-restore.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -58,7 +59,7 @@ PA_MODULE_USAGE( "restore_volume= " "restore_muted="); -#define SAVE_INTERVAL 10 +#define SAVE_INTERVAL (10 * PA_USEC_PER_SEC) static const char* const valid_modargs[] = { "restore_volume", @@ -95,12 +96,11 @@ struct entry { char port[PA_NAME_MAX]; } PA_GCC_PACKED; -static void save_time_callback(pa_mainloop_api*a, pa_time_event* e, const struct timeval *tv, void *userdata) { +static void save_time_callback(pa_mainloop_api*a, pa_time_event* e, const struct timeval *t, void *userdata) { struct userdata *u = userdata; pa_assert(a); pa_assert(e); - pa_assert(tv); pa_assert(u); pa_assert(e == u->save_time_event); @@ -162,14 +162,10 @@ fail: } static void trigger_save(struct userdata *u) { - struct timeval tv; - if (u->save_time_event) return; - pa_gettimeofday(&tv); - tv.tv_sec += SAVE_INTERVAL; - u->save_time_event = u->core->mainloop->time_new(u->core->mainloop, &tv, save_time_callback, u); + u->save_time_event = pa_core_rttime_new(u->core, pa_rtclock_now() + SAVE_INTERVAL, save_time_callback, u); } static pa_bool_t entries_equal(const struct entry *a, const struct entry *b) { diff --git a/src/modules/module-esound-sink.c b/src/modules/module-esound-sink.c index 2df8a0e8..b26b465d 100644 --- a/src/modules/module-esound-sink.c +++ b/src/modules/module-esound-sink.c @@ -609,7 +609,7 @@ int pa__init(pa_module*m) { pa_sink_set_asyncmsgq(u->sink, u->thread_mq.inq); pa_sink_set_rtpoll(u->sink, u->rtpoll); - if (!(u->client = pa_socket_client_new_string(u->core->mainloop, espeaker, ESD_DEFAULT_PORT))) { + if (!(u->client = pa_socket_client_new_string(u->core->mainloop, TRUE, espeaker, ESD_DEFAULT_PORT))) { pa_log("Failed to connect to server."); goto fail; } diff --git a/src/modules/module-stream-restore.c b/src/modules/module-stream-restore.c index f2aea27b..99c69f66 100644 --- a/src/modules/module-stream-restore.c +++ b/src/modules/module-stream-restore.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -61,7 +62,7 @@ PA_MODULE_USAGE( "restore_volume= " "restore_muted="); -#define SAVE_INTERVAL 10 +#define SAVE_INTERVAL (10 * PA_USEC_PER_SEC) #define IDENTIFICATION_PROPERTY "module-stream-restore.id" static const char* const valid_modargs[] = { @@ -111,12 +112,11 @@ enum { SUBCOMMAND_EVENT }; -static void save_time_callback(pa_mainloop_api*a, pa_time_event* e, const struct timeval *tv, void *userdata) { +static void save_time_callback(pa_mainloop_api*a, pa_time_event* e, const struct timeval *t, void *userdata) { struct userdata *u = userdata; pa_assert(a); pa_assert(e); - pa_assert(tv); pa_assert(u); pa_assert(e == u->save_time_event); @@ -210,7 +210,6 @@ fail: } static void trigger_save(struct userdata *u) { - struct timeval tv; pa_native_connection *c; uint32_t idx; @@ -230,9 +229,7 @@ static void trigger_save(struct userdata *u) { if (u->save_time_event) return; - pa_gettimeofday(&tv); - tv.tv_sec += SAVE_INTERVAL; - u->save_time_event = u->core->mainloop->time_new(u->core->mainloop, &tv, save_time_callback, u); + u->save_time_event = pa_core_rttime_new(u->core, pa_rtclock_now() + SAVE_INTERVAL, save_time_callback, u); } static pa_bool_t entries_equal(const struct entry *a, const struct entry *b) { diff --git a/src/modules/module-suspend-on-idle.c b/src/modules/module-suspend-on-idle.c index c5b78911..70a7b049 100644 --- a/src/modules/module-suspend-on-idle.c +++ b/src/modules/module-suspend-on-idle.c @@ -25,6 +25,7 @@ #include #include +#include #include #include @@ -75,11 +76,11 @@ struct device_info { struct userdata *userdata; pa_sink *sink; pa_source *source; - struct timeval last_use; + pa_usec_t last_use; pa_time_event *time_event; }; -static void timeout_cb(pa_mainloop_api*a, pa_time_event* e, const struct timeval *tv, void *userdata) { +static void timeout_cb(pa_mainloop_api*a, pa_time_event* e, const struct timeval *t, void *userdata) { struct device_info *d = userdata; pa_assert(d); @@ -98,22 +99,20 @@ static void timeout_cb(pa_mainloop_api*a, pa_time_event* e, const struct timeval } static void restart(struct device_info *d) { - struct timeval tv; + pa_usec_t now; const char *s; uint32_t timeout; + pa_assert(d); pa_assert(d->sink || d->source); - pa_gettimeofday(&tv); - d->last_use = tv; + d->last_use = now = pa_rtclock_now(); s = pa_proplist_gets(d->sink ? d->sink->proplist : d->source->proplist, "module-suspend-on-idle.timeout"); if (!s || pa_atou(s, &timeout) < 0) - timeout = d->userdata->timeout; - - pa_timeval_add(&tv, timeout * PA_USEC_PER_SEC); + timeout = d->userdata->timeout; - d->userdata->core->mainloop->time_restart(d->time_event, &tv); + pa_core_rttime_restart(d->userdata->core, d->time_event, now + timeout * PA_USEC_PER_SEC); if (d->sink) pa_log_debug("Sink %s becomes idle, timeout in %u seconds.", d->sink->name, timeout); @@ -338,7 +337,7 @@ static pa_hook_result_t device_new_hook_cb(pa_core *c, pa_object *o, struct user d->userdata = u; d->source = source ? pa_source_ref(source) : NULL; d->sink = sink ? pa_sink_ref(sink) : NULL; - d->time_event = c->mainloop->time_new(c->mainloop, NULL, timeout_cb, d); + d->time_event = pa_core_rttime_new(c, PA_USEC_INVALID, timeout_cb, d); pa_hashmap_put(u->device_infos, o, d); if ((d->sink && pa_sink_check_suspend(d->sink) <= 0) || diff --git a/src/modules/module-tunnel.c b/src/modules/module-tunnel.c index ec4808f0..ce37bf47 100644 --- a/src/modules/module-tunnel.c +++ b/src/modules/module-tunnel.c @@ -113,7 +113,7 @@ static const char* const valid_modargs[] = { #define DEFAULT_TIMEOUT 5 -#define LATENCY_INTERVAL 10 +#define LATENCY_INTERVAL (10*PA_USEC_PER_SEC) #define MIN_NETWORK_LATENCY_USEC (8*PA_USEC_PER_MSEC) @@ -879,9 +879,8 @@ static void request_latency(struct userdata *u) { } /* Called from main context */ -static void timeout_callback(pa_mainloop_api *m, pa_time_event*e, const struct timeval *tv, void *userdata) { +static void timeout_callback(pa_mainloop_api *m, pa_time_event *e, const struct timeval *t, void *userdata) { struct userdata *u = userdata; - struct timeval ntv; pa_assert(m); pa_assert(e); @@ -889,9 +888,7 @@ static void timeout_callback(pa_mainloop_api *m, pa_time_event*e, const struct request_latency(u); - pa_gettimeofday(&ntv); - ntv.tv_sec += LATENCY_INTERVAL; - m->time_restart(e, &ntv); + pa_core_rttime_restart(u->core, e, pa_rtclock_now() + LATENCY_INTERVAL); } /* Called from main context */ @@ -1358,7 +1355,6 @@ static void start_subscribe(struct userdata *u) { /* Called from main context */ static void create_stream_callback(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) { struct userdata *u = userdata; - struct timeval ntv; #ifdef TUNNEL_SINK uint32_t bytes; #endif @@ -1440,9 +1436,7 @@ static void create_stream_callback(pa_pdispatch *pd, uint32_t command, uint32_t request_info(u); pa_assert(!u->time_event); - pa_gettimeofday(&ntv); - ntv.tv_sec += LATENCY_INTERVAL; - u->time_event = u->core->mainloop->time_new(u->core->mainloop, &ntv, timeout_callback, u); + u->time_event = pa_core_rttime_new(u->core, pa_rtclock_now() + LATENCY_INTERVAL, timeout_callback, u); request_latency(u); @@ -1707,7 +1701,7 @@ static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata } u->pstream = pa_pstream_new(u->core->mainloop, io, u->core->mempool); - u->pdispatch = pa_pdispatch_new(u->core->mainloop, command_table, PA_COMMAND_MAX); + u->pdispatch = pa_pdispatch_new(u->core->mainloop, TRUE, command_table, PA_COMMAND_MAX); pa_pstream_set_die_callback(u->pstream, pstream_die_callback, u); pa_pstream_set_recieve_packet_callback(u->pstream, pstream_packet_callback, u); @@ -1854,7 +1848,7 @@ int pa__init(pa_module*m) { goto fail; } - if (!(u->client = pa_socket_client_new_string(m->core->mainloop, u->server_name, PA_NATIVE_DEFAULT_PORT))) { + if (!(u->client = pa_socket_client_new_string(m->core->mainloop, TRUE, u->server_name, PA_NATIVE_DEFAULT_PORT))) { pa_log("Failed to connect to server '%s'", u->server_name); goto fail; } diff --git a/src/modules/module-waveout.c b/src/modules/module-waveout.c index 2d35828d..d1b9f2ff 100644 --- a/src/modules/module-waveout.c +++ b/src/modules/module-waveout.c @@ -256,7 +256,7 @@ static void poll_cb(pa_mainloop_api*a, pa_time_event *e, const struct timeval *t pa_gettimeofday(&ntv); pa_timeval_add(&ntv, u->poll_timeout); - a->time_restart(e, &ntv); + a->rtclock_time_restart(e, &ntv); } static void defer_cb(pa_mainloop_api*a, pa_defer_event *e, void *userdata) { @@ -549,7 +549,7 @@ int pa__init(pa_core *c, pa_module*m) { pa_gettimeofday(&tv); pa_timeval_add(&tv, u->poll_timeout); - u->event = c->mainloop->time_new(c->mainloop, &tv, poll_cb, u); + u->event = c->mainloop->rtclock_time_new(c->mainloop, &tv, poll_cb, u); assert(u->event); u->defer = c->mainloop->defer_new(c->mainloop, defer_cb, u); diff --git a/src/modules/raop/raop_client.c b/src/modules/raop/raop_client.c index b3f243c3..c4b02371 100644 --- a/src/modules/raop/raop_client.c +++ b/src/modules/raop/raop_client.c @@ -331,7 +331,7 @@ static void rtsp_cb(pa_rtsp_client *rtsp, pa_rtsp_state state, pa_headerlist* he uint32_t port = pa_rtsp_serverport(c->rtsp); pa_log_debug("RAOP: RECORDED"); - if (!(c->sc = pa_socket_client_new_string(c->core->mainloop, c->host, port))) { + if (!(c->sc = pa_socket_client_new_string(c->core->mainloop, TRUE, c->host, port))) { pa_log("failed to connect to server '%s:%d'", c->host, port); return; } diff --git a/src/modules/rtp/module-rtp-recv.c b/src/modules/rtp/module-rtp-recv.c index 84cf07de..5caf8272 100644 --- a/src/modules/rtp/module-rtp-recv.c +++ b/src/modules/rtp/module-rtp-recv.c @@ -113,6 +113,7 @@ struct session { struct userdata { pa_module *module; + pa_core *core; pa_sap_context sap_context; pa_io_event* sap_event; @@ -622,15 +623,13 @@ static void sap_event_cb(pa_mainloop_api *m, pa_io_event *e, int fd, pa_io_event } } -static void check_death_event_cb(pa_mainloop_api *m, pa_time_event *t, const struct timeval *ptv, void *userdata) { +static void check_death_event_cb(pa_mainloop_api *m, pa_time_event *t, const struct timeval *tv, void *userdata) { struct session *s, *n; struct userdata *u = userdata; struct timeval now; - struct timeval tv; pa_assert(m); pa_assert(t); - pa_assert(ptv); pa_assert(u); pa_rtclock_get(&now); @@ -648,9 +647,7 @@ static void check_death_event_cb(pa_mainloop_api *m, pa_time_event *t, const str } /* Restart timer */ - pa_gettimeofday(&tv); - pa_timeval_add(&tv, DEATH_TIMEOUT*PA_USEC_PER_SEC); - m->time_restart(t, &tv); + pa_core_rttime_restart(u->module->core, t, pa_rtclock_now() + DEATH_TIMEOUT * PA_USEC_PER_SEC); } int pa__init(pa_module*m) { @@ -664,7 +661,6 @@ int pa__init(pa_module*m) { socklen_t salen; const char *sap_address; int fd = -1; - struct timeval tv; pa_assert(m); @@ -697,6 +693,7 @@ int pa__init(pa_module*m) { m->userdata = u = pa_xnew(struct userdata, 1); u->module = m; + u->core = m->core; u->sink_name = pa_xstrdup(pa_modargs_get_value(ma, "sink", NULL)); u->sap_event = m->core->mainloop->io_new(m->core->mainloop, fd, PA_IO_EVENT_INPUT, sap_event_cb, u); @@ -706,9 +703,7 @@ int pa__init(pa_module*m) { u->n_sessions = 0; u->by_origin = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func); - pa_gettimeofday(&tv); - pa_timeval_add(&tv, DEATH_TIMEOUT * PA_USEC_PER_SEC); - u->check_death_event = m->core->mainloop->time_new(m->core->mainloop, &tv, check_death_event_cb, u); + u->check_death_event = pa_core_rttime_new(m->core, pa_rtclock_now() + DEATH_TIMEOUT * PA_USEC_PER_SEC, check_death_event_cb, u); pa_modargs_free(ma); diff --git a/src/modules/rtp/module-rtp-send.c b/src/modules/rtp/module-rtp-send.c index 39ee4d75..f147364d 100644 --- a/src/modules/rtp/module-rtp-send.c +++ b/src/modules/rtp/module-rtp-send.c @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -77,7 +78,7 @@ PA_MODULE_USAGE( #define DEFAULT_DESTINATION "224.0.0.56" #define MEMBLOCKQ_MAXLENGTH (1024*170) #define DEFAULT_MTU 1280 -#define SAP_INTERVAL 5 +#define SAP_INTERVAL (5*PA_USEC_PER_SEC) static const char* const valid_modargs[] = { "source", @@ -151,18 +152,14 @@ static void source_output_kill(pa_source_output* o) { static void sap_event_cb(pa_mainloop_api *m, pa_time_event *t, const struct timeval *tv, void *userdata) { struct userdata *u = userdata; - struct timeval next; pa_assert(m); pa_assert(t); - pa_assert(tv); pa_assert(u); pa_sap_send(&u->sap_context, 0); - pa_gettimeofday(&next); - pa_timeval_add(&next, SAP_INTERVAL * PA_USEC_PER_SEC); - m->time_restart(t, &next); + pa_core_rttime_restart(u->module->core, t, pa_rtclock_now() + SAP_INTERVAL); } int pa__init(pa_module*m) { @@ -186,7 +183,6 @@ int pa__init(pa_module*m) { char *p; int r, j; socklen_t k; - struct timeval tv; char hn[128], *n; pa_bool_t loop = FALSE; pa_source_output_new_data data; @@ -395,9 +391,7 @@ int pa__init(pa_module*m) { pa_sap_send(&u->sap_context, 0); - pa_gettimeofday(&tv); - pa_timeval_add(&tv, SAP_INTERVAL * PA_USEC_PER_SEC); - u->sap_event = m->core->mainloop->time_new(m->core->mainloop, &tv, sap_event_cb, u); + u->sap_event = pa_core_rttime_new(m->core, pa_rtclock_now() + SAP_INTERVAL, sap_event_cb, u); pa_source_output_put(u->source_output); diff --git a/src/modules/rtp/rtsp_client.c b/src/modules/rtp/rtsp_client.c index cb037de6..72d304e8 100644 --- a/src/modules/rtp/rtsp_client.c +++ b/src/modules/rtp/rtsp_client.c @@ -333,7 +333,7 @@ int pa_rtsp_connect(pa_rtsp_client *c) { pa_xfree(c->session); c->session = NULL; - if (!(c->sc = pa_socket_client_new_string(c->mainloop, c->hostname, c->port))) { + if (!(c->sc = pa_socket_client_new_string(c->mainloop, TRUE, c->hostname, c->port))) { pa_log("failed to connect to server '%s:%d'", c->hostname, c->port); return -1; } -- cgit