diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2015-04-05 16:44:30 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2015-04-05 16:44:30 +0200 |
commit | 27c190e5c0c158ca4fbd42af0ab0e4664aeeb446 (patch) | |
tree | 35c0a0d2e9df0d0c6fb746fd1c4ad08b6b9b2bbf | |
parent | 4fb89086357c6cd56e14a483a310c36ddf801490 (diff) | |
download | toolame-dab-27c190e5c0c158ca4fbd42af0ab0e4664aeeb446.tar.gz toolame-dab-27c190e5c0c158ca4fbd42af0ab0e4664aeeb446.tar.bz2 toolame-dab-27c190e5c0c158ca4fbd42af0ab0e4664aeeb446.zip |
Add startup timeout for libVLC state
-rw-r--r-- | toolame.c | 3 | ||||
-rw-r--r-- | vlc_input.c | 21 |
2 files changed, 23 insertions, 1 deletions
@@ -26,6 +26,7 @@ #include "xpad.h" #include "utils.h" #include "vlc_input.h" +#include "zmqoutput.h" #include <assert.h> @@ -541,6 +542,8 @@ int main (int argc, char **argv) peak_right = 0; } + fprintf(stdout, "Main loop has quit with samps_read = %zu\n", samps_read); + close_bit_stream_w (&bs); if ((glopts.verbosity > 1) && (glopts.vbr == TRUE)) { diff --git a/vlc_input.c b/vlc_input.c index 6786bab..1a73cb9 100644 --- a/vlc_input.c +++ b/vlc_input.c @@ -141,7 +141,26 @@ int vlc_in_prepare(unsigned verbosity, unsigned int rate, const char* uri) head_buffer = vlc_buffer_new(); // 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; + + int timeout; + for (timeout = 0; timeout < 100; timeout++) { + st = libvlc_media_get_state(media); + usleep(10*1000); + if (st != libvlc_NothingSpecial) { + ret = 0; + break; + } + } + } + + return ret; } ssize_t vlc_in_read(void *buf, size_t len) |