mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-16 07:00:00 -05:00
modules: handle NULL stream when getting time
The stream can be destroyed when requesting the time, fall back to MONOTONIC time then. Fixes #4970
This commit is contained in:
parent
954f76d107
commit
dabd2af828
1 changed files with 17 additions and 3 deletions
|
|
@ -259,6 +259,19 @@ struct impl {
|
|||
bool waiting;
|
||||
};
|
||||
|
||||
static inline uint64_t get_time_ns(struct impl *impl)
|
||||
{
|
||||
uint64_t res;
|
||||
if (impl->stream) {
|
||||
res = rtp_stream_get_nsec(impl->stream);
|
||||
} else {
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
res = SPA_TIMESPEC_TO_NSEC(&ts);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
static int do_start(struct spa_loop *loop, bool async, uint32_t seq, const void *data,
|
||||
size_t size, void *user_data)
|
||||
{
|
||||
|
|
@ -288,9 +301,10 @@ on_rtp_io(void *data, int fd, uint32_t mask)
|
|||
int suppressed;
|
||||
uint64_t current_time;
|
||||
|
||||
current_time = rtp_stream_get_nsec(impl->stream);
|
||||
current_time = get_time_ns(impl);
|
||||
|
||||
if (mask & SPA_IO_IN) {
|
||||
|
||||
if ((len = recv(fd, impl->buffer, impl->buffer_size, 0)) < 0)
|
||||
goto receive_error;
|
||||
|
||||
|
|
@ -395,7 +409,7 @@ static int rejoin_igmp_group(struct spa_loop *loop, bool async, uint32_t seq,
|
|||
}
|
||||
}
|
||||
|
||||
current_time = rtp_stream_get_nsec(impl->stream);
|
||||
current_time = get_time_ns(impl);
|
||||
SPA_ATOMIC_STORE(impl->last_packet_time, current_time);
|
||||
|
||||
return res;
|
||||
|
|
@ -420,7 +434,7 @@ static void on_igmp_recovery_timer_event(void *data)
|
|||
* silently kicked out of the IGMP group (which causes data
|
||||
* to no longer arrive, thus leading to these states). */
|
||||
|
||||
current_time = rtp_stream_get_nsec(impl->stream);
|
||||
current_time = get_time_ns(impl);
|
||||
last_packet_time = SPA_ATOMIC_LOAD(impl->last_packet_time);
|
||||
elapsed_seconds = (current_time - last_packet_time) / SPA_NSEC_PER_SEC;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue