threadshare: ts-udpsink changes state from NULL to READY failure due to prepare_socket
When working with pipelines that has ts-udpsink in and its state is changed in sequence: NULL->PLAYING, then PLAYING->NULL, and then back to NULL->PLAYING, the third changing state got failure.
I found that when changing state from NULL to READY, the UdpSink call the method prepare_socket that will process in backtrace:
UdpSink::change_state
gst::StateChange::NullToReady =>
UdpSink::prepare
Udpsink::prepare_socket
let socket = context.enter(|| {
Async::<UdpSocket>::try_from(socket).map_err(|err| { ==> (1)
error_msg!(
gst::ResourceError::OpenWrite, ===> error was raised here.
["Failed to setup Async socket: {}", err]
)
})
})?;
(1)
Async::<UdpSocket>::try_from
Async::new
Reactor::insert_io
polling::Poller::add ===> errror here
This makes me suspect that the socket was added twice leading error, so I checked with a simple rust program that call Poller::add two times for a socket and I got the error:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 17, kind: AlreadyExists, message: "File exists" }', src/main.rs:11:42