From 268b3c310d543f9129331a9b592099b42d814188 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Mon, 30 Mar 2015 18:37:56 +0200 Subject: VLC: Add additional state check at startup --- src/VLCInput.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/VLCInput.cpp b/src/VLCInput.cpp index 7c782b0..687e144 100644 --- a/src/VLCInput.cpp +++ b/src/VLCInput.cpp @@ -114,7 +114,25 @@ int VLCInput::prepare() libvlc_media_release(m); // Start playing - return libvlc_media_player_play(m_mp); + int ret = libvlc_media_player_play(m_mp); + + if (ret == 0) { + libvlc_media_t *media = libvlc_media_player_get_media(m_mp); + libvlc_state_t st; + + ret = -1; + + for (int timeout = 0; timeout < 100; timeout++) { + st = libvlc_media_get_state(media); + boost::this_thread::sleep(boost::posix_time::milliseconds(10)); + if (st != libvlc_NothingSpecial) { + ret = 0; + break; + } + } + } + + return ret; } void VLCInput::preRender_cb(uint8_t** pp_pcm_buffer, size_t size) -- cgit v1.2.3