Commit e43bf21d authored by Sebastian Dröge's avatar Sebastian Dröge 🍵

Add initialization safety assertions

Ensure that GStreamer is initialized before allowing to call any
functions
parent 992105b4
...@@ -6,6 +6,7 @@ min_cfg_version = "1.8" ...@@ -6,6 +6,7 @@ min_cfg_version = "1.8"
target_path = "gstreamer" target_path = "gstreamer"
work_mode = "normal" work_mode = "normal"
concurrency = "send+sync" concurrency = "send+sync"
generate_safety_asserts = true
external_libraries = [ external_libraries = [
"GLib", "GLib",
......
...@@ -27,6 +27,7 @@ glib_wrapper! { ...@@ -27,6 +27,7 @@ glib_wrapper! {
impl Bin { impl Bin {
pub fn new<'a, P: Into<Option<&'a str>>>(name: P) -> Bin { pub fn new<'a, P: Into<Option<&'a str>>>(name: P) -> Bin {
assert_initialized_main_thread!();
let name = name.into(); let name = name.into();
let name = name.to_glib_none(); let name = name.to_glib_none();
unsafe { unsafe {
......
...@@ -21,6 +21,7 @@ glib_wrapper! { ...@@ -21,6 +21,7 @@ glib_wrapper! {
impl Bus { impl Bus {
pub fn new() -> Bus { pub fn new() -> Bus {
assert_initialized_main_thread!();
unsafe { unsafe {
from_glib_full(ffi::gst_bus_new()) from_glib_full(ffi::gst_bus_new())
} }
......
...@@ -21,6 +21,7 @@ glib_wrapper! { ...@@ -21,6 +21,7 @@ glib_wrapper! {
impl DeviceMonitor { impl DeviceMonitor {
pub fn new() -> DeviceMonitor { pub fn new() -> DeviceMonitor {
assert_initialized_main_thread!();
unsafe { unsafe {
from_glib_full(ffi::gst_device_monitor_new()) from_glib_full(ffi::gst_device_monitor_new())
} }
......
...@@ -27,6 +27,7 @@ glib_wrapper! { ...@@ -27,6 +27,7 @@ glib_wrapper! {
impl DeviceProvider { impl DeviceProvider {
pub fn register<'a, P: Into<Option<&'a Plugin>>>(plugin: P, name: &str, rank: u32, type_: glib::types::Type) -> bool { pub fn register<'a, P: Into<Option<&'a Plugin>>>(plugin: P, name: &str, rank: u32, type_: glib::types::Type) -> bool {
assert_initialized_main_thread!();
let plugin = plugin.into(); let plugin = plugin.into();
let plugin = plugin.to_glib_none(); let plugin = plugin.to_glib_none();
unsafe { unsafe {
......
...@@ -18,12 +18,14 @@ glib_wrapper! { ...@@ -18,12 +18,14 @@ glib_wrapper! {
impl DeviceProviderFactory { impl DeviceProviderFactory {
pub fn find(name: &str) -> Option<DeviceProviderFactory> { pub fn find(name: &str) -> Option<DeviceProviderFactory> {
assert_initialized_main_thread!();
unsafe { unsafe {
from_glib_full(ffi::gst_device_provider_factory_find(name.to_glib_none().0)) from_glib_full(ffi::gst_device_provider_factory_find(name.to_glib_none().0))
} }
} }
pub fn get_by_name(factoryname: &str) -> Option<DeviceProvider> { pub fn get_by_name(factoryname: &str) -> Option<DeviceProvider> {
assert_initialized_main_thread!();
unsafe { unsafe {
from_glib_full(ffi::gst_device_provider_factory_get_by_name(factoryname.to_glib_none().0)) from_glib_full(ffi::gst_device_provider_factory_get_by_name(factoryname.to_glib_none().0))
} }
......
...@@ -42,6 +42,7 @@ glib_wrapper! { ...@@ -42,6 +42,7 @@ glib_wrapper! {
impl Element { impl Element {
pub fn make_from_uri<'a, P: Into<Option<&'a str>>>(type_: URIType, uri: &str, elementname: P) -> Result<Element, Error> { pub fn make_from_uri<'a, P: Into<Option<&'a str>>>(type_: URIType, uri: &str, elementname: P) -> Result<Element, Error> {
assert_initialized_main_thread!();
let elementname = elementname.into(); let elementname = elementname.into();
let elementname = elementname.to_glib_none(); let elementname = elementname.to_glib_none();
unsafe { unsafe {
...@@ -52,6 +53,7 @@ impl Element { ...@@ -52,6 +53,7 @@ impl Element {
} }
pub fn register<'a, P: Into<Option<&'a Plugin>>>(plugin: P, name: &str, rank: u32, type_: glib::types::Type) -> bool { pub fn register<'a, P: Into<Option<&'a Plugin>>>(plugin: P, name: &str, rank: u32, type_: glib::types::Type) -> bool {
assert_initialized_main_thread!();
let plugin = plugin.into(); let plugin = plugin.into();
let plugin = plugin.to_glib_none(); let plugin = plugin.to_glib_none();
unsafe { unsafe {
...@@ -60,12 +62,14 @@ impl Element { ...@@ -60,12 +62,14 @@ impl Element {
} }
pub fn state_change_return_get_name(state_ret: StateChangeReturn) -> Option<String> { pub fn state_change_return_get_name(state_ret: StateChangeReturn) -> Option<String> {
assert_initialized_main_thread!();
unsafe { unsafe {
from_glib_none(ffi::gst_element_state_change_return_get_name(state_ret.to_glib())) from_glib_none(ffi::gst_element_state_change_return_get_name(state_ret.to_glib()))
} }
} }
pub fn state_get_name(state: State) -> Option<String> { pub fn state_get_name(state: State) -> Option<String> {
assert_initialized_main_thread!();
unsafe { unsafe {
from_glib_none(ffi::gst_element_state_get_name(state.to_glib())) from_glib_none(ffi::gst_element_state_get_name(state.to_glib()))
} }
......
...@@ -95,6 +95,7 @@ impl ElementFactory { ...@@ -95,6 +95,7 @@ impl ElementFactory {
} }
pub fn find(name: &str) -> Option<ElementFactory> { pub fn find(name: &str) -> Option<ElementFactory> {
assert_initialized_main_thread!();
unsafe { unsafe {
from_glib_full(ffi::gst_element_factory_find(name.to_glib_none().0)) from_glib_full(ffi::gst_element_factory_find(name.to_glib_none().0))
} }
...@@ -109,6 +110,7 @@ impl ElementFactory { ...@@ -109,6 +110,7 @@ impl ElementFactory {
//} //}
pub fn make<'a, P: Into<Option<&'a str>>>(factoryname: &str, name: P) -> Option<Element> { pub fn make<'a, P: Into<Option<&'a str>>>(factoryname: &str, name: P) -> Option<Element> {
assert_initialized_main_thread!();
let name = name.into(); let name = name.into();
let name = name.to_glib_none(); let name = name.to_glib_none();
unsafe { unsafe {
......
...@@ -35,6 +35,7 @@ impl ToGlib for BufferingMode { ...@@ -35,6 +35,7 @@ impl ToGlib for BufferingMode {
#[doc(hidden)] #[doc(hidden)]
impl FromGlib<ffi::GstBufferingMode> for BufferingMode { impl FromGlib<ffi::GstBufferingMode> for BufferingMode {
fn from_glib(value: ffi::GstBufferingMode) -> Self { fn from_glib(value: ffi::GstBufferingMode) -> Self {
skip_assert_initialized!();
match value as i32 { match value as i32 {
0 => BufferingMode::Stream, 0 => BufferingMode::Stream,
1 => BufferingMode::Download, 1 => BufferingMode::Download,
...@@ -95,6 +96,7 @@ impl ToGlib for CoreError { ...@@ -95,6 +96,7 @@ impl ToGlib for CoreError {
#[doc(hidden)] #[doc(hidden)]
impl FromGlib<ffi::GstCoreError> for CoreError { impl FromGlib<ffi::GstCoreError> for CoreError {
fn from_glib(value: ffi::GstCoreError) -> Self { fn from_glib(value: ffi::GstCoreError) -> Self {
skip_assert_initialized!();
match value as i32 { match value as i32 {
1 => CoreError::Failed, 1 => CoreError::Failed,
2 => CoreError::TooLazy, 2 => CoreError::TooLazy,
...@@ -118,6 +120,7 @@ impl FromGlib<ffi::GstCoreError> for CoreError { ...@@ -118,6 +120,7 @@ impl FromGlib<ffi::GstCoreError> for CoreError {
impl ErrorDomain for CoreError { impl ErrorDomain for CoreError {
fn domain() -> glib_ffi::GQuark { fn domain() -> glib_ffi::GQuark {
skip_assert_initialized!();
unsafe { ffi::gst_core_error_quark() } unsafe { ffi::gst_core_error_quark() }
} }
...@@ -126,6 +129,7 @@ impl ErrorDomain for CoreError { ...@@ -126,6 +129,7 @@ impl ErrorDomain for CoreError {
} }
fn from(code: i32) -> Option<Self> { fn from(code: i32) -> Option<Self> {
skip_assert_initialized!();
match code { match code {
1 => Some(CoreError::Failed), 1 => Some(CoreError::Failed),
2 => Some(CoreError::TooLazy), 2 => Some(CoreError::TooLazy),
...@@ -193,6 +197,7 @@ impl ToGlib for FlowReturn { ...@@ -193,6 +197,7 @@ impl ToGlib for FlowReturn {
#[doc(hidden)] #[doc(hidden)]
impl FromGlib<ffi::GstFlowReturn> for FlowReturn { impl FromGlib<ffi::GstFlowReturn> for FlowReturn {
fn from_glib(value: ffi::GstFlowReturn) -> Self { fn from_glib(value: ffi::GstFlowReturn) -> Self {
skip_assert_initialized!();
match value as i32 { match value as i32 {
102 => FlowReturn::CustomSuccess2, 102 => FlowReturn::CustomSuccess2,
101 => FlowReturn::CustomSuccess1, 101 => FlowReturn::CustomSuccess1,
...@@ -244,6 +249,7 @@ impl ToGlib for Format { ...@@ -244,6 +249,7 @@ impl ToGlib for Format {
#[doc(hidden)] #[doc(hidden)]
impl FromGlib<ffi::GstFormat> for Format { impl FromGlib<ffi::GstFormat> for Format {
fn from_glib(value: ffi::GstFormat) -> Self { fn from_glib(value: ffi::GstFormat) -> Self {
skip_assert_initialized!();
match value as i32 { match value as i32 {
0 => Format::Undefined, 0 => Format::Undefined,
1 => Format::Default, 1 => Format::Default,
...@@ -290,6 +296,7 @@ impl ToGlib for LibraryError { ...@@ -290,6 +296,7 @@ impl ToGlib for LibraryError {
#[doc(hidden)] #[doc(hidden)]
impl FromGlib<ffi::GstLibraryError> for LibraryError { impl FromGlib<ffi::GstLibraryError> for LibraryError {
fn from_glib(value: ffi::GstLibraryError) -> Self { fn from_glib(value: ffi::GstLibraryError) -> Self {
skip_assert_initialized!();
match value as i32 { match value as i32 {
1 => LibraryError::Failed, 1 => LibraryError::Failed,
2 => LibraryError::TooLazy, 2 => LibraryError::TooLazy,
...@@ -305,6 +312,7 @@ impl FromGlib<ffi::GstLibraryError> for LibraryError { ...@@ -305,6 +312,7 @@ impl FromGlib<ffi::GstLibraryError> for LibraryError {
impl ErrorDomain for LibraryError { impl ErrorDomain for LibraryError {
fn domain() -> glib_ffi::GQuark { fn domain() -> glib_ffi::GQuark {
skip_assert_initialized!();
unsafe { ffi::gst_library_error_quark() } unsafe { ffi::gst_library_error_quark() }
} }
...@@ -313,6 +321,7 @@ impl ErrorDomain for LibraryError { ...@@ -313,6 +321,7 @@ impl ErrorDomain for LibraryError {
} }
fn from(code: i32) -> Option<Self> { fn from(code: i32) -> Option<Self> {
skip_assert_initialized!();
match code { match code {
1 => Some(LibraryError::Failed), 1 => Some(LibraryError::Failed),
2 => Some(LibraryError::TooLazy), 2 => Some(LibraryError::TooLazy),
...@@ -352,6 +361,7 @@ impl ToGlib for PadDirection { ...@@ -352,6 +361,7 @@ impl ToGlib for PadDirection {
#[doc(hidden)] #[doc(hidden)]
impl FromGlib<ffi::GstPadDirection> for PadDirection { impl FromGlib<ffi::GstPadDirection> for PadDirection {
fn from_glib(value: ffi::GstPadDirection) -> Self { fn from_glib(value: ffi::GstPadDirection) -> Self {
skip_assert_initialized!();
match value as i32 { match value as i32 {
0 => PadDirection::Unknown, 0 => PadDirection::Unknown,
1 => PadDirection::Src, 1 => PadDirection::Src,
...@@ -395,6 +405,7 @@ impl ToGlib for PadLinkReturn { ...@@ -395,6 +405,7 @@ impl ToGlib for PadLinkReturn {
#[doc(hidden)] #[doc(hidden)]
impl FromGlib<ffi::GstPadLinkReturn> for PadLinkReturn { impl FromGlib<ffi::GstPadLinkReturn> for PadLinkReturn {
fn from_glib(value: ffi::GstPadLinkReturn) -> Self { fn from_glib(value: ffi::GstPadLinkReturn) -> Self {
skip_assert_initialized!();
match value as i32 { match value as i32 {
0 => PadLinkReturn::Ok, 0 => PadLinkReturn::Ok,
-1 => PadLinkReturn::WrongHierarchy, -1 => PadLinkReturn::WrongHierarchy,
...@@ -444,6 +455,7 @@ impl ToGlib for ParseError { ...@@ -444,6 +455,7 @@ impl ToGlib for ParseError {
#[doc(hidden)] #[doc(hidden)]
impl FromGlib<ffi::GstParseError> for ParseError { impl FromGlib<ffi::GstParseError> for ParseError {
fn from_glib(value: ffi::GstParseError) -> Self { fn from_glib(value: ffi::GstParseError) -> Self {
skip_assert_initialized!();
match value as i32 { match value as i32 {
0 => ParseError::Syntax, 0 => ParseError::Syntax,
1 => ParseError::NoSuchElement, 1 => ParseError::NoSuchElement,
...@@ -460,6 +472,7 @@ impl FromGlib<ffi::GstParseError> for ParseError { ...@@ -460,6 +472,7 @@ impl FromGlib<ffi::GstParseError> for ParseError {
impl ErrorDomain for ParseError { impl ErrorDomain for ParseError {
fn domain() -> glib_ffi::GQuark { fn domain() -> glib_ffi::GQuark {
skip_assert_initialized!();
unsafe { ffi::gst_parse_error_quark() } unsafe { ffi::gst_parse_error_quark() }
} }
...@@ -468,6 +481,7 @@ impl ErrorDomain for ParseError { ...@@ -468,6 +481,7 @@ impl ErrorDomain for ParseError {
} }
fn from(code: i32) -> Option<Self> { fn from(code: i32) -> Option<Self> {
skip_assert_initialized!();
match code { match code {
0 => Some(ParseError::Syntax), 0 => Some(ParseError::Syntax),
1 => Some(ParseError::NoSuchElement), 1 => Some(ParseError::NoSuchElement),
...@@ -508,6 +522,7 @@ impl ToGlib for PluginError { ...@@ -508,6 +522,7 @@ impl ToGlib for PluginError {
#[doc(hidden)] #[doc(hidden)]
impl FromGlib<ffi::GstPluginError> for PluginError { impl FromGlib<ffi::GstPluginError> for PluginError {
fn from_glib(value: ffi::GstPluginError) -> Self { fn from_glib(value: ffi::GstPluginError) -> Self {
skip_assert_initialized!();
match value as i32 { match value as i32 {
0 => PluginError::Module, 0 => PluginError::Module,
1 => PluginError::Dependencies, 1 => PluginError::Dependencies,
...@@ -519,6 +534,7 @@ impl FromGlib<ffi::GstPluginError> for PluginError { ...@@ -519,6 +534,7 @@ impl FromGlib<ffi::GstPluginError> for PluginError {
impl ErrorDomain for PluginError { impl ErrorDomain for PluginError {
fn domain() -> glib_ffi::GQuark { fn domain() -> glib_ffi::GQuark {
skip_assert_initialized!();
unsafe { ffi::gst_plugin_error_quark() } unsafe { ffi::gst_plugin_error_quark() }
} }
...@@ -527,6 +543,7 @@ impl ErrorDomain for PluginError { ...@@ -527,6 +543,7 @@ impl ErrorDomain for PluginError {
} }
fn from(code: i32) -> Option<Self> { fn from(code: i32) -> Option<Self> {
skip_assert_initialized!();
match code { match code {
0 => Some(PluginError::Module), 0 => Some(PluginError::Module),
1 => Some(PluginError::Dependencies), 1 => Some(PluginError::Dependencies),
...@@ -566,6 +583,7 @@ impl ToGlib for ProgressType { ...@@ -566,6 +583,7 @@ impl ToGlib for ProgressType {
#[doc(hidden)] #[doc(hidden)]
impl FromGlib<ffi::GstProgressType> for ProgressType { impl FromGlib<ffi::GstProgressType> for ProgressType {
fn from_glib(value: ffi::GstProgressType) -> Self { fn from_glib(value: ffi::GstProgressType) -> Self {
skip_assert_initialized!();
match value as i32 { match value as i32 {
0 => ProgressType::Start, 0 => ProgressType::Start,
1 => ProgressType::Continue, 1 => ProgressType::Continue,
...@@ -629,6 +647,7 @@ impl ToGlib for ResourceError { ...@@ -629,6 +647,7 @@ impl ToGlib for ResourceError {
#[doc(hidden)] #[doc(hidden)]
impl FromGlib<ffi::GstResourceError> for ResourceError { impl FromGlib<ffi::GstResourceError> for ResourceError {
fn from_glib(value: ffi::GstResourceError) -> Self { fn from_glib(value: ffi::GstResourceError) -> Self {
skip_assert_initialized!();
match value as i32 { match value as i32 {
1 => ResourceError::Failed, 1 => ResourceError::Failed,
2 => ResourceError::TooLazy, 2 => ResourceError::TooLazy,
...@@ -653,6 +672,7 @@ impl FromGlib<ffi::GstResourceError> for ResourceError { ...@@ -653,6 +672,7 @@ impl FromGlib<ffi::GstResourceError> for ResourceError {
impl ErrorDomain for ResourceError { impl ErrorDomain for ResourceError {
fn domain() -> glib_ffi::GQuark { fn domain() -> glib_ffi::GQuark {
skip_assert_initialized!();
unsafe { ffi::gst_resource_error_quark() } unsafe { ffi::gst_resource_error_quark() }
} }
...@@ -661,6 +681,7 @@ impl ErrorDomain for ResourceError { ...@@ -661,6 +681,7 @@ impl ErrorDomain for ResourceError {
} }
fn from(code: i32) -> Option<Self> { fn from(code: i32) -> Option<Self> {
skip_assert_initialized!();
match code { match code {
1 => Some(ResourceError::Failed), 1 => Some(ResourceError::Failed),
2 => Some(ResourceError::TooLazy), 2 => Some(ResourceError::TooLazy),
...@@ -709,6 +730,7 @@ impl ToGlib for SeekType { ...@@ -709,6 +730,7 @@ impl ToGlib for SeekType {
#[doc(hidden)] #[doc(hidden)]
impl FromGlib<ffi::GstSeekType> for SeekType { impl FromGlib<ffi::GstSeekType> for SeekType {
fn from_glib(value: ffi::GstSeekType) -> Self { fn from_glib(value: ffi::GstSeekType) -> Self {
skip_assert_initialized!();
match value as i32 { match value as i32 {
0 => SeekType::None, 0 => SeekType::None,
1 => SeekType::Set, 1 => SeekType::Set,
...@@ -748,6 +770,7 @@ impl ToGlib for State { ...@@ -748,6 +770,7 @@ impl ToGlib for State {
#[doc(hidden)] #[doc(hidden)]
impl FromGlib<ffi::GstState> for State { impl FromGlib<ffi::GstState> for State {
fn from_glib(value: ffi::GstState) -> Self { fn from_glib(value: ffi::GstState) -> Self {
skip_assert_initialized!();
match value as i32 { match value as i32 {
0 => State::VoidPending, 0 => State::VoidPending,
1 => State::Null, 1 => State::Null,
...@@ -791,6 +814,7 @@ impl ToGlib for StateChange { ...@@ -791,6 +814,7 @@ impl ToGlib for StateChange {
#[doc(hidden)] #[doc(hidden)]
impl FromGlib<ffi::GstStateChange> for StateChange { impl FromGlib<ffi::GstStateChange> for StateChange {
fn from_glib(value: ffi::GstStateChange) -> Self { fn from_glib(value: ffi::GstStateChange) -> Self {
skip_assert_initialized!();
match value as i32 { match value as i32 {
10 => StateChange::NullToReady, 10 => StateChange::NullToReady,
19 => StateChange::ReadyToPaused, 19 => StateChange::ReadyToPaused,
...@@ -831,6 +855,7 @@ impl ToGlib for StateChangeReturn { ...@@ -831,6 +855,7 @@ impl ToGlib for StateChangeReturn {
#[doc(hidden)] #[doc(hidden)]
impl FromGlib<ffi::GstStateChangeReturn> for StateChangeReturn { impl FromGlib<ffi::GstStateChangeReturn> for StateChangeReturn {
fn from_glib(value: ffi::GstStateChangeReturn) -> Self { fn from_glib(value: ffi::GstStateChangeReturn) -> Self {
skip_assert_initialized!();
match value as i32 { match value as i32 {
0 => StateChangeReturn::Failure, 0 => StateChangeReturn::Failure,
1 => StateChangeReturn::Success, 1 => StateChangeReturn::Success,
...@@ -889,6 +914,7 @@ impl ToGlib for StreamError { ...@@ -889,6 +914,7 @@ impl ToGlib for StreamError {
#[doc(hidden)] #[doc(hidden)]
impl FromGlib<ffi::GstStreamError> for StreamError { impl FromGlib<ffi::GstStreamError> for StreamError {
fn from_glib(value: ffi::GstStreamError) -> Self { fn from_glib(value: ffi::GstStreamError) -> Self {
skip_assert_initialized!();
match value as i32 { match value as i32 {
1 => StreamError::Failed, 1 => StreamError::Failed,
2 => StreamError::TooLazy, 2 => StreamError::TooLazy,
...@@ -911,6 +937,7 @@ impl FromGlib<ffi::GstStreamError> for StreamError { ...@@ -911,6 +937,7 @@ impl FromGlib<ffi::GstStreamError> for StreamError {
impl ErrorDomain for StreamError { impl ErrorDomain for StreamError {
fn domain() -> glib_ffi::GQuark { fn domain() -> glib_ffi::GQuark {
skip_assert_initialized!();
unsafe { ffi::gst_stream_error_quark() } unsafe { ffi::gst_stream_error_quark() }
} }
...@@ -919,6 +946,7 @@ impl ErrorDomain for StreamError { ...@@ -919,6 +946,7 @@ impl ErrorDomain for StreamError {
} }
fn from(code: i32) -> Option<Self> { fn from(code: i32) -> Option<Self> {
skip_assert_initialized!();
match code { match code {
1 => Some(StreamError::Failed), 1 => Some(StreamError::Failed),
2 => Some(StreamError::TooLazy), 2 => Some(StreamError::TooLazy),
...@@ -973,6 +1001,7 @@ impl ToGlib for StreamStatusType { ...@@ -973,6 +1001,7 @@ impl ToGlib for StreamStatusType {
#[doc(hidden)] #[doc(hidden)]
impl FromGlib<ffi::GstStreamStatusType> for StreamStatusType { impl FromGlib<ffi::GstStreamStatusType> for StreamStatusType {
fn from_glib(value: ffi::GstStreamStatusType) -> Self { fn from_glib(value: ffi::GstStreamStatusType) -> Self {
skip_assert_initialized!();
match value as i32 { match value as i32 {
0 => StreamStatusType::Create, 0 => StreamStatusType::Create,
1 => StreamStatusType::Enter, 1 => StreamStatusType::Enter,
...@@ -1010,6 +1039,7 @@ impl ToGlib for StructureChangeType { ...@@ -1010,6 +1039,7 @@ impl ToGlib for StructureChangeType {
#[doc(hidden)] #[doc(hidden)]
impl FromGlib<ffi::GstStructureChangeType> for StructureChangeType { impl FromGlib<ffi::GstStructureChangeType> for StructureChangeType {
fn from_glib(value: ffi::GstStructureChangeType) -> Self { fn from_glib(value: ffi::GstStructureChangeType) -> Self {
skip_assert_initialized!();
match value as i32 { match value as i32 {
0 => StructureChangeType::Link, 0 => StructureChangeType::Link,
1 => StructureChangeType::Unlink, 1 => StructureChangeType::Unlink,
...@@ -1046,6 +1076,7 @@ impl ToGlib for URIError { ...@@ -1046,6 +1076,7 @@ impl ToGlib for URIError {
#[doc(hidden)] #[doc(hidden)]
impl FromGlib<ffi::GstURIError> for URIError { impl FromGlib<ffi::GstURIError> for URIError {
fn from_glib(value: ffi::GstURIError) -> Self { fn from_glib(value: ffi::GstURIError) -> Self {
skip_assert_initialized!();
match value as i32 { match value as i32 {
0 => URIError::UnsupportedProtocol, 0 => URIError::UnsupportedProtocol,
1 => URIError::BadUri, 1 => URIError::BadUri,
...@@ -1058,6 +1089,7 @@ impl FromGlib<ffi::GstURIError> for URIError { ...@@ -1058,6 +1089,7 @@ impl FromGlib<ffi::GstURIError> for URIError {
impl ErrorDomain for URIError { impl ErrorDomain for URIError {
fn domain() -> glib_ffi::GQuark { fn domain() -> glib_ffi::GQuark {
skip_assert_initialized!();
unsafe { ffi::gst_uri_error_quark() } unsafe { ffi::gst_uri_error_quark() }
} }
...@@ -1066,6 +1098,7 @@ impl ErrorDomain for URIError { ...@@ -1066,6 +1098,7 @@ impl ErrorDomain for URIError {
} }
fn from(code: i32) -> Option<Self> { fn from(code: i32) -> Option<Self> {
skip_assert_initialized!();
match code { match code {
0 => Some(URIError::UnsupportedProtocol), 0 => Some(URIError::UnsupportedProtocol),
1 => Some(URIError::BadUri), 1 => Some(URIError::BadUri),
...@@ -1102,6 +1135,7 @@ impl ToGlib for URIType { ...@@ -1102,6 +1135,7 @@ impl ToGlib for URIType {
#[doc(hidden)] #[doc(hidden)]
impl FromGlib<ffi::GstURIType> for URIType { impl FromGlib<ffi::GstURIType> for URIType {
fn from_glib(value: ffi::GstURIType) -> Self { fn from_glib(value: ffi::GstURIType) -> Self {
skip_assert_initialized!();
match value as i32 { match value as i32 {
0 => URIType::Unknown, 0 => URIType::Unknown,
1 => URIType::Sink, 1 => URIType::Sink,
......
...@@ -33,6 +33,7 @@ impl ToGlib for SeekFlags { ...@@ -33,6 +33,7 @@ impl ToGlib for SeekFlags {
#[doc(hidden)] #[doc(hidden)]
impl FromGlib<ffi::GstSeekFlags> for SeekFlags { impl FromGlib<ffi::GstSeekFlags> for SeekFlags {
fn from_glib(value: ffi::GstSeekFlags) -> SeekFlags { fn from_glib(value: ffi::GstSeekFlags) -> SeekFlags {
skip_assert_initialized!();
SeekFlags::from_bits_truncate(value.bits()) SeekFlags::from_bits_truncate(value.bits())
} }
} }
...@@ -58,6 +59,7 @@ impl ToGlib for StreamFlags { ...@@ -58,6 +59,7 @@ impl ToGlib for StreamFlags {
#[doc(hidden)] #[doc(hidden)]
impl FromGlib<ffi::GstStreamFlags> for StreamFlags { impl FromGlib<ffi::GstStreamFlags> for StreamFlags {
fn from_glib(value: ffi::GstStreamFlags) -> StreamFlags { fn from_glib(value: ffi::GstStreamFlags) -> StreamFlags {
skip_assert_initialized!();
StreamFlags::from_bits_truncate(value.bits()) StreamFlags::from_bits_truncate(value.bits())
} }
} }
...@@ -84,6 +86,7 @@ impl ToGlib for StreamType { ...@@ -84,6 +86,7 @@ impl ToGlib for StreamType {
#[doc(hidden)] #[doc(hidden)]
impl FromGlib<ffi::GstStreamType> for StreamType { impl FromGlib<ffi::GstStreamType> for StreamType {
fn from_glib(value: ffi::GstStreamType) -> StreamType { fn from_glib(value: ffi::GstStreamType) -> StreamType {
skip_assert_initialized!();
StreamType::from_bits_truncate(value.bits()) StreamType::from_bits_truncate(value.bits())
} }
} }
......
This diff is collapsed.
...@@ -18,6 +18,7 @@ glib_wrapper! { ...@@ -18,6 +18,7 @@ glib_wrapper! {
impl Object { impl Object {
pub fn check_uniqueness(list: &[Object], name: &str) -> bool { pub fn check_uniqueness(list: &[Object], name: &str) -> bool {
assert_initialized_main_thread!();
unsafe { unsafe {
from_glib(ffi::gst_object_check_uniqueness(list.to_glib_none().0, name.to_glib_none().0)) from_glib(ffi::gst_object_check_uniqueness(list.to_glib_none().0, name.to_glib_none().0))
} }
......
...@@ -34,6 +34,7 @@ glib_wrapper! { ...@@ -34,6 +34,7 @@ glib_wrapper! {
impl Pad { impl Pad {
pub fn new<'a, P: Into<Option<&'a str>>>(name: P, direction: PadDirection) -> Pad { pub fn new<'a, P: Into<Option<&'a str>>>(name: P, direction: PadDirection) -> Pad {
assert_initialized_main_thread!();
let name = name.into(); let name = name.into();
let name = name.to_glib_none(); let name = name.to_glib_none();
unsafe { unsafe {
...@@ -46,6 +47,7 @@ impl Pad { ...@@ -46,6 +47,7 @@ impl Pad {
//} //}
pub fn new_from_template<'a, P: Into<Option<&'a str>>>(templ: &PadTemplate, name: P) -> Pad { pub fn new_from_template<'a, P: Into<Option<&'a str>>>(templ: &PadTemplate, name: P) -> Pad {
skip_assert_initialized!();
let name = name.into(); let name = name.into();
let name = name.to_glib_none(); let name = name.to_glib_none();
unsafe { unsafe {
...@@ -54,6 +56,7 @@ impl Pad { ...@@ -54,6 +56,7 @@ impl Pad {
} }
pub fn link_get_name(ret: PadLinkReturn) -> Option<String> { pub fn link_get_name(ret: PadLinkReturn) -> Option<String> {
assert_initialized_main_thread!();
unsafe { unsafe {
from_glib_none(ffi::gst_pad_link_get_name(ret.to_glib())) from_glib_none(ffi::gst_pad_link_get_name(ret.to_glib()))
} }
......
...@@ -21,6 +21,7 @@ glib_wrapper! { ...@@ -21,6 +21,7 @@ glib_wrapper! {
impl Pipeline { impl Pipeline {
pub fn new<'a, P: Into<Option<&'a str>>>(name: P) -> Pipeline { pub fn new<'a, P: Into<Option<&'a str>>>(name: P) -> Pipeline {
assert_initialized_main_thread!();
let name = name.into(); let name = name.into();
let name = name.to_glib_none(); let name = name.to_glib_none();
unsafe { unsafe {
......
...@@ -98,18 +98,21 @@ impl Plugin { ...@@ -98,18 +98,21 @@ impl Plugin {
} }
pub fn list_free(list: &[Plugin]) { pub fn list_free(list: &[Plugin]) {
assert_initialized_main_thread!();
unsafe {