From d8546dd1405879c5b551900a8c553b60458f9d1f Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Fri, 1 Sep 2023 23:46:57 +0900 Subject: [PATCH] hlssink3: Don't remove uri from playlist if playlist-length is zero Behave as documented in property description Part-of: --- net/hlssink3/src/playlist.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/net/hlssink3/src/playlist.rs b/net/hlssink3/src/playlist.rs index 6dffb054..7d790568 100644 --- a/net/hlssink3/src/playlist.rs +++ b/net/hlssink3/src/playlist.rs @@ -96,10 +96,9 @@ impl Playlist { } // Remove oldest segments if playlist is at maximum expected capacity - if self.inner.segments.len() > max_playlist_length { - for _ in 0..self.inner.segments.len() - max_playlist_length { - let _ = self.inner.segments.remove(0); - } + if max_playlist_length > 0 && self.inner.segments.len() > max_playlist_length { + let remove_len = self.inner.segments.len() - max_playlist_length; + self.inner.segments.drain(0..remove_len); } self.playlist_index += 1;