From 4dcc44687aa8a59eb89dfeef32f002ab9b3fbf14 Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Wed, 10 Apr 2024 11:05:48 +1000 Subject: [PATCH] cea608overlay: move Send impl lower in the stack Try to avoid hiding another non-Send object in the State struct. Part-of: --- video/closedcaption/src/cea608overlay/imp.rs | 5 ----- video/closedcaption/src/cea608utils.rs | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/video/closedcaption/src/cea608overlay/imp.rs b/video/closedcaption/src/cea608overlay/imp.rs index eece0f4b..1bb075d4 100644 --- a/video/closedcaption/src/cea608overlay/imp.rs +++ b/video/closedcaption/src/cea608overlay/imp.rs @@ -55,11 +55,6 @@ struct State { last_cc_pts: Option, } -// SAFETY: Required because `pango::Layout` is not `Send` but the whole `State` needs to be. -// We ensure that no additional references to the layout are ever created, which makes it safe -// to send it to other threads as long as only a single thread uses it concurrently. -unsafe impl Send for State {} - impl Default for State { fn default() -> Self { Self { diff --git a/video/closedcaption/src/cea608utils.rs b/video/closedcaption/src/cea608utils.rs index a930e548..9e714f4d 100644 --- a/video/closedcaption/src/cea608utils.rs +++ b/video/closedcaption/src/cea608utils.rs @@ -479,6 +479,11 @@ fn pango_foreground_color_from_608(color: Color) -> pango::AttrColor { pango::AttrColor::new_foreground(r, g, b) } +// SAFETY: Required because `pango::Layout` is not `Send` but the whole `Cea608Renderer` needs to be. +// We ensure that no additional references to the layout are ever created, which makes it safe +// to send it to other threads as long as only a single thread uses it concurrently. +unsafe impl Send for Cea608Renderer {} + pub struct Cea608Renderer { frame: Cea608Frame, state: Cea608State,