diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2022-11-28 19:44:04 +0300 |
---|---|---|
committer | GStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org> | 2022-11-29 15:18:25 +0300 |
commit | 76eeaffbb2c35453dd86f4d36a5bc0aedbc54dad (patch) | |
tree | 9fd61cb71802c0fbc186323b1b145f4e60cea2e0 /text | |
parent | 5bbe0eab259c18f8dd5915ef7fb6fd0748cf3956 (diff) |
textwrap: Don't panic on empty buffers
Simply don't calculate with any duration per word for this buffer.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/990>
Diffstat (limited to 'text')
-rw-r--r-- | text/wrap/src/gsttextwrap/imp.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/text/wrap/src/gsttextwrap/imp.rs b/text/wrap/src/gsttextwrap/imp.rs index 1820a92c..9578e582 100644 --- a/text/wrap/src/gsttextwrap/imp.rs +++ b/text/wrap/src/gsttextwrap/imp.rs @@ -176,8 +176,8 @@ impl TextWrap { state.end_ts = None; } - let duration_per_word: gst::ClockTime = - duration / data.split_whitespace().count() as u64; + let num_words = data.split_whitespace().count() as u64; + let duration_per_word = (num_words != 0).then(|| duration / num_words); if state.start_ts.is_none() { state.start_ts = buffer.pts(); |