2017年3月16日 星期四

libVLC deadlock

VLC的問題困擾很久了,希望這個方法可以解決這個問題。

Sometimes the call libvlc_media_player_stop() function in GUI-thread leads to deadlocks. And it happens on an almost empty application. There is only the main form with control (like a panel), which carried the image output (assign through libvlc_media_player_set_hwnd()). Timer periodically (every 5 seconds) is called stop() and play(). No more functionality in that simple program. If the mouse to click on the associated control, then hang appears faster.

My solution is to call the stop() from the new thread and wait for its completion (via join ()). If the wait timeout set, before calling play(), you must ensure that the playing is done (check the return value of libvlc_media_player_get_state()). If you do call play() again, you will see a new window with video (as happens if you do not bind the output through libvlc_media_player_set_hwnd()).

Perhaps this message will be helpful.

沒有留言: