[vlc-devel] [PATCH] non-blocking filewriter
Rémi Denis-Courmont
remi at remlab.net
Tue Apr 28 22:24:56 CEST 2009
Le mardi 28 avril 2009 11:46:30 Jarmo Torvinen, vous avez écrit :
> If the non-blocking mode is enabled, the writer is replaced with new
> writer that adds data to a fifo buffer. The buffer is read by a
> writer thread writing data to the final destination and freeing the
> blocks.
This is not quite ready for merging as is.
* You should really use vlc_clone/vlc_cancel/vlc_join as it is more
lightweight than creating an object _and_ an object thread. You don't really
seem to need an object.
* Your use of FD_SET is prone to a buffer overflow here. poll() would avoid
the problem.
* Please don't use an arbitrary timeout in select(). It is useless here.
vlc_object_kill() or vlc_cancel() will anyway interrupt your thread
asynchronously at block_FifoGet(), select() or write(), whichever happens
first.
* In fact, you could really put the file descriptor back into blocking mode,
skip event handling altogether, and kill two context switches per iteration.
You just need a pair of block_cleanup_push()/vlc_cleanup_pop() around the
write() call to avoid leaking memory.
--
Rémi Denis-Courmont
http://www.remlab.net/
More information about the vlc-devel
mailing list