threadshare/udpsink: don't error out when socket can't be prepared for protocol

Instead, error out at chain time if a client with the unavailable
protocol (eg IPv6) has been added.
This commit is contained in:
Mathieu Duponchelle 2020-01-15 22:31:20 +01:00 committed by Sebastian Dröge
parent b8f8705c47
commit bcbf862ded

View file

@ -527,6 +527,14 @@ impl UdpSink {
); );
gst::FlowError::Error gst::FlowError::Error
})?; })?;
} else {
gst_element_error!(
element,
gst::StreamError::Failed,
("I/O error"),
["No socket available for sending to {}", client]
);
return Err(gst::FlowError::Error);
} }
} }
@ -617,13 +625,21 @@ impl UdpSink {
net2::UdpBuilder::new_v6() net2::UdpBuilder::new_v6()
} else { } else {
net2::UdpBuilder::new_v4() net2::UdpBuilder::new_v4()
};
let builder = match builder {
Ok(builder) => builder,
Err(err) => {
gst_warning!(
CAT,
obj: element,
"Failed to create {} socket builder: {}",
if ipv6 { "IPv6" } else { "IPv4" },
err
);
return Ok(());
} }
.map_err(|err| { };
gst_error_msg!(
gst::ResourceError::OpenWrite,
["Failed to create socket: {}", err]
)
})?;
let socket = builder.bind(&saddr).map_err(|err| { let socket = builder.bind(&saddr).map_err(|err| {
gst_error_msg!( gst_error_msg!(