1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//! Safe RAII ownership of a raw `*mut AVFilterGraph`.
//!
//! [`FilterGraph`] owns a libavfilter graph allocated by `avfilter_graph_alloc`
//! and frees it — along with every filter context it contains — via
//! `avfilter_graph_free` on [`Drop`]. It mirrors [`crate::raw::FormatContext`]:
//! move-only, single owner, single free, so the graph is released exactly once
//! on every return path. This replaces the hand-balanced `avfilter_graph_free`
//! calls that had to be repeated before each early return — and were missed on
//! some `?` paths, leaking the graph.
//!
//! Naming: this is the raw owning handle. It deliberately shares the short name
//! `FilterGraph` with the raw-module convention (drop the `AV` prefix, like
//! `FormatContext`), and is therefore distinct from the domain descriptor
//! [`crate::core::context::filter_graph::FilterGraph`]. Consumers that see both
//! refer to this one path-qualified as `raw::FilterGraph`.
// Compiled even under docsrs: the filter worker's slot and `cleanup_filtergraph`
// (which have no docsrs stub) name `Option<FilterGraph>` there. Under docsrs the
// real allocators are `#[cfg(not(docsrs))]`, so `alloc`/`as_ptr` are never
// called and would warn — suppress that (docsrs only; the normal build still
// catches real dead code).
use ;
/// Sole owner of a `*mut AVFilterGraph`.
///
/// Move-only (no `Clone`/`Copy`): the compiler therefore guarantees a single
/// owner and thus a single [`Drop`], which is what makes the "no double-free /
/// no leak" argument hold by construction. Ownership is transferred by moving
/// the value; there is no path that copies the raw pointer into a second owner.
pub
// SAFETY: the graph is only dereferenced from the thread that owns the
// `FilterGraph`. The crate moves the value between threads (e.g. into the filter
// worker) but never shares it, and installs no thread-affine state that would
// make the move unsound. `Send` only, never `Sync` — concurrent access to the
// underlying graph would be unsound.
unsafe