diff --git a/utils/uriplaylistbin/src/uriplaylistbin/imp.rs b/utils/uriplaylistbin/src/uriplaylistbin/imp.rs index 4198c991..2513554c 100644 --- a/utils/uriplaylistbin/src/uriplaylistbin/imp.rs +++ b/utils/uriplaylistbin/src/uriplaylistbin/imp.rs @@ -101,6 +101,23 @@ impl Default for Settings { } } +enum Status { + /// all good element is working + Running, + /// the element stopped because of an error + Error, +} + +impl Status { + /// check if the element should stop proceeding + fn done(&self) -> bool { + match self { + Status::Running => false, + Status::Error => true, + } + } +} + struct State { streamsynchronizer: gst::Element, concat_audio: Vec, @@ -111,8 +128,7 @@ struct State { /// the current number of streams handled by the element streams_topology: StreamsTopology, - // true if the element stopped because of an error - errored: bool, + status: Status, // we have max one item in one of each of those states waiting_for_stream_collection: Option, @@ -138,7 +154,7 @@ impl State { streamsynchronizer, playlist: Playlist::new(uris, iterations), streams_topology: StreamsTopology::default(), - errored: false, + status: Status::Running, waiting_for_stream_collection: None, waiting_for_ss_eos: None, waiting_for_pads: None, @@ -1214,7 +1230,7 @@ impl UriPlaylistBin { let mut state_guard = self.state.lock().unwrap(); let state = state_guard.as_mut().unwrap(); - if state.errored { + if state.status.done() { return; } @@ -1606,10 +1622,10 @@ impl UriPlaylistBin { let mut state_guard = self.state.lock().unwrap(); let state = state_guard.as_mut().unwrap(); - if state.errored { + if state.status.done() { return; } - state.errored = true; + state.status = Status::Error; if let Some(blocked) = state.blocked.take() { // unblock streaming thread