Commit bf90b313 authored by Felix Abecassis's avatar Felix Abecassis Committed by Jean-Baptiste Kempf

thumbnailer: do not wait until video position becomes *strictly* superior to THUMBNAIL_POSITION.

Avoid waiting unnecessarily when the media player reaches exactly THUMBNAIL_POSITION. However we must now wait until libvlc updates the position before polling with libvlc_media_player_get_position().
Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
(cherry picked from commit 0c2844f9)
Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent c14c54f0
......@@ -263,12 +263,12 @@ jbyteArray Java_org_videolan_libvlc_LibVLC_getThumbnail(JNIEnv *env, jobject thi
libvlc_media_player_play(mp);
libvlc_media_player_set_position(mp, THUMBNAIL_POSITION);
int loops = 100;
for (;;) {
float pos = libvlc_media_player_get_position(mp);
if (pos > THUMBNAIL_POSITION || !loops--)
const int wait_time = 50000;
const int max_attempts = 100;
for (int i = 0; i < max_attempts; ++i) {
if (libvlc_media_player_is_playing(mp) && libvlc_media_player_get_position(mp) >= THUMBNAIL_POSITION)
break;
usleep(50000);
usleep(wait_time);
}
/* Wait for the thumbnail to be generated. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment