Skip to main content

ScState

Struct ScState 

Source
pub(crate) struct ScState {
    pub(crate) backend: u8,
    pub(crate) cursor_ref: bool,
    pub(crate) controls: Option<Arc<Controls>>,
    pub(crate) starting: Option<Arc<Controls>>,
    pub(crate) handle: Option<JoinHandle<()>>,
    pub(crate) cap_thread_id: Option<ThreadId>,
    pub(crate) encode_thread_id: Option<ThreadId>,
    pub(crate) encode_tid_rx: Option<Receiver<ThreadId>>,
    pub(crate) deliver_handle: Option<JoinHandle<()>>,
    pub(crate) deliver_thread_id: Option<ThreadId>,
    pub(crate) wl_display: u32,
    pub(crate) err: Option<Arc<Mutex<Option<String>>>>,
}
Expand description

Mutable per-capture state behind ScreenCapture’s mutex: the active backend, the live X11 controls and thread handle, and the capture / encode thread ids used to detect a re-entrant stop.

Fields§

§backend: u8

0 = idle, 1 = X11, 2 = Wayland.

§cursor_ref: bool

This capture holds one reference on the shared X11 cursor monitor. Set in the same locked section as backend = 1 and TAKEN in the same locked section a stop reads the backend, so acquire/release pair exactly per capture — inferring the reference from backend alone would let a stop that interleaves with a start release a reference not yet taken (leaking the monitor once the acquire lands). The GIL happens to serialize that window today; the pairing must not depend on it.

§controls: Option<Arc<Controls>>§starting: Option<Arc<Controls>>

The controls of an X11 capture whose threads already run while start_capture has not published it: its first frames can reach a consumer before the start returns, and what that consumer asks for in reply (a lost frame, a key frame, a rate) has to reach the capture. A stop or a newer start in that window ends that capture, which is then never published.

§handle: Option<JoinHandle<()>>§cap_thread_id: Option<ThreadId>§encode_thread_id: Option<ThreadId>

The internal encode thread’s id, so a re-entrant stop arriving on it is detected and doesn’t try to join a chain that includes itself.

§encode_tid_rx: Option<Receiver<ThreadId>>

Handshake receiver kept when the bounded start-time wait for the encode thread id lapsed (slow X11 setup precedes the encode-thread spawn): the id is late-resolved from here on demand, so the re-entrant-stop guard still recognizes the encode thread — with encode_thread_id stuck at None, a stop from inside the delivery callback would join the capture thread, which joins the encode thread (the caller), a deadlock cycle. The id send strictly precedes any callback running on that thread, so a try_recv at stop time cannot miss it.

§deliver_handle: Option<JoinHandle<()>>

Delivery thread: owns the GIL-bound Python callback so encode(N+1) never serializes behind deliver(N). Joined on stop; a re-entrant stop from inside the callback (which runs on this thread) must detach instead of self-joining.

§deliver_thread_id: Option<ThreadId>§wl_display: u32

The Wayland display id this instance’s capture is bound to (backend == 2).

§err: Option<Arc<Mutex<Option<String>>>>

The X11 capture thread’s exit error (backend == 1): the thread records why it died mid-run here, so capture_state can report it instead of the error scrolling past in a single stderr line. None while healthy.

Implementations§

Source§

impl ScState

Source

pub(crate) fn x11_controls(&self) -> Option<Arc<Controls>>

The X11 controls a request reaches: the published capture’s, else those of one still starting.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more