mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
module-rtp-sink: Send all remaining packets when stopping
Don't close rtp_fd until all packets have been sent by the timer, if the timer is running when the stream is stopped.
This commit is contained in:
parent
4cea8eb01f
commit
64d75b6b2e
2 changed files with 36 additions and 7 deletions
|
|
@ -224,9 +224,15 @@ static void rtp_audio_flush_packets(struct impl *impl, uint32_t num_packets)
|
|||
avail = spa_ringbuffer_get_read_index(&impl->ring, ×tamp);
|
||||
tosend = impl->psamples;
|
||||
if (avail < tosend)
|
||||
goto done;
|
||||
|
||||
num_packets = SPA_MIN(num_packets, (uint32_t)(avail / tosend));
|
||||
if (impl->started)
|
||||
goto done;
|
||||
else {
|
||||
/* send last packet before emitting state_changed */
|
||||
tosend = avail;
|
||||
num_packets = 1;
|
||||
}
|
||||
else
|
||||
num_packets = SPA_MIN(num_packets, (uint32_t)(avail / tosend));
|
||||
|
||||
stride = impl->stride;
|
||||
|
||||
|
|
@ -264,8 +270,19 @@ static void rtp_audio_flush_packets(struct impl *impl, uint32_t num_packets)
|
|||
}
|
||||
spa_ringbuffer_read_update(&impl->ring, timestamp);
|
||||
done:
|
||||
if (avail < tosend && impl->timer_running)
|
||||
set_timer(impl, 0, 0);
|
||||
if (impl->timer_running) {
|
||||
if (impl->started) {
|
||||
if (avail < tosend) {
|
||||
set_timer(impl, 0, 0);
|
||||
}
|
||||
} else if (avail <= 0) {
|
||||
bool started = false;
|
||||
|
||||
/* the stream has been stopped and all packets have been sent */
|
||||
set_timer(impl, 0, 0);
|
||||
pw_loop_invoke(impl->main_loop, do_emit_state_changed, SPA_ID_INVALID, &started, sizeof started, false, impl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void rtp_audio_flush_timeout(struct impl *impl, uint64_t expirations)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue