togglerecord: document mutexes hold when calling ToggleRecord methods

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1935>
This commit is contained in:
Guillaume Desmottes 2024-11-22 13:20:07 +01:00 committed by GStreamer Marge Bot
parent 6e0d6c1a5a
commit 7a336cf8ad

View file

@ -347,6 +347,7 @@ static CAT: LazyLock<gst::DebugCategory> = LazyLock::new(|| {
}); });
impl ToggleRecord { impl ToggleRecord {
// called while holding stream.state
fn block_if_upstream_not_live( fn block_if_upstream_not_live(
&self, &self,
pad: &gst::Pad, pad: &gst::Pad,
@ -405,6 +406,7 @@ impl ToggleRecord {
} }
} }
// called without lock
fn handle_main_stream<T: HandleData>( fn handle_main_stream<T: HandleData>(
&self, &self,
pad: &gst::Pad, pad: &gst::Pad,
@ -693,6 +695,7 @@ impl ToggleRecord {
} }
#[allow(clippy::blocks_in_conditions)] #[allow(clippy::blocks_in_conditions)]
// called without lock
fn handle_secondary_stream<T: HandleData>( fn handle_secondary_stream<T: HandleData>(
&self, &self,
pad: &gst::Pad, pad: &gst::Pad,
@ -838,6 +841,8 @@ impl ToggleRecord {
obj = pad, obj = pad,
"Main stream EOS and recording never started", "Main stream EOS and recording never started",
); );
drop(main_state);
return Ok(HandleResult::Eos(self.check_and_update_eos( return Ok(HandleResult::Eos(self.check_and_update_eos(
pad, pad,
stream, stream,
@ -1179,6 +1184,8 @@ impl ToggleRecord {
} }
// should be called only if main stream is in eos state // should be called only if main stream is in eos state
// Called while holding stream.state on either the primary or a secondary stream (stream_state)
// and self.state (rec_state).
fn check_and_update_eos( fn check_and_update_eos(
&self, &self,
pad: &gst::Pad, pad: &gst::Pad,
@ -1222,6 +1229,8 @@ impl ToggleRecord {
} }
// should be called only if main stream stops being in eos state // should be called only if main stream stops being in eos state
// Called while holding stream.state on either the primary or a secondary stream (stream_state)
// and self.state (rec_state).
fn check_and_update_stream_start( fn check_and_update_stream_start(
&self, &self,
pad: &gst::Pad, pad: &gst::Pad,
@ -1261,6 +1270,7 @@ impl ToggleRecord {
false false
} }
// called without lock
fn sink_chain( fn sink_chain(
&self, &self,
pad: &gst::Pad, pad: &gst::Pad,
@ -1405,6 +1415,7 @@ impl ToggleRecord {
stream.srcpad.push(buffer) stream.srcpad.push(buffer)
} }
// called without lock
fn sink_event(&self, pad: &gst::Pad, mut event: gst::Event) -> bool { fn sink_event(&self, pad: &gst::Pad, mut event: gst::Event) -> bool {
use gst::EventView; use gst::EventView;
@ -1584,6 +1595,7 @@ impl ToggleRecord {
let main_is_eos = main_state let main_is_eos = main_state
.as_ref() .as_ref()
.map_or(true, |main_state| main_state.eos); .map_or(true, |main_state| main_state.eos);
drop(main_state);
if main_is_eos { if main_is_eos {
let mut rec_state = self.state.lock(); let mut rec_state = self.state.lock();
@ -1653,6 +1665,7 @@ impl ToggleRecord {
} }
} }
// called without lock
fn sink_query(&self, pad: &gst::Pad, query: &mut gst::QueryRef) -> bool { fn sink_query(&self, pad: &gst::Pad, query: &mut gst::QueryRef) -> bool {
let stream = match self.pads.lock().get(pad) { let stream = match self.pads.lock().get(pad) {
None => { None => {
@ -1683,6 +1696,7 @@ impl ToggleRecord {
success success
} }
// called without lock
fn src_event(&self, pad: &gst::Pad, mut event: gst::Event) -> bool { fn src_event(&self, pad: &gst::Pad, mut event: gst::Event) -> bool {
use gst::EventView; use gst::EventView;
@ -1718,6 +1732,7 @@ impl ToggleRecord {
} }
} }
// called without lock
fn src_query(&self, pad: &gst::Pad, query: &mut gst::QueryRef) -> bool { fn src_query(&self, pad: &gst::Pad, query: &mut gst::QueryRef) -> bool {
use gst::QueryViewMut; use gst::QueryViewMut;
@ -1845,6 +1860,7 @@ impl ToggleRecord {
} }
} }
// called without lock
fn iterate_internal_links(&self, pad: &gst::Pad) -> gst::Iterator<gst::Pad> { fn iterate_internal_links(&self, pad: &gst::Pad) -> gst::Iterator<gst::Pad> {
let stream = match self.pads.lock().get(pad) { let stream = match self.pads.lock().get(pad) {
None => { None => {