<html><head></head><body>If (is_playing && get_position) does exactly this :)<br><br><div class="gmail_quote"><br>
Felix Abecassis <felix.abecassis@gmail.com> a écrit :<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">Because I don't want to call get_position before is_playing becomes true.<br />But you are right, it can be done.<br /><br />2013/11/26 Rafaël Carré <rafael.carre@gmail.com>:<br /><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;">Why not merge is_playing and get_position in one single loop?<br /><br /><br />Felix Abecassis <felix.abecassis@gmail.com> a écrit :<br /><br /><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #ad7fa8; padding-left: 1ex;">Avoid waiting unnecessarily when the media player reaches exactly<br />THUMBNAIL_POSITION. However we must now wait until libvlc updates the<br />position before polling with libvlc_media_player_get_position().<br />---<br />vlc-android/jni/thumbnailer.c | 15 +++++++++++----<br />1 file changed, 11 insertions(+), 4 deletions(-)<br /><br />diff --git a/vlc-android/jni/thumbnailer.c
b/vlc-android/jni/thumbnailer.c<br />index 2d41a59..4086612 100644<br />--- a/vlc-android/jni/thumbnailer.c<br />+++ b/vlc-android/jni/thumbnailer.c<br />@@ -263,12 +263,19 @@ jbyteArray<br />Java_org_videolan_libvlc_LibVLC_getThumbnail(JNIEnv *env, jobject thi<br />libvlc_media_player_play(mp);<br />libvlc_media_player_set_position(mp, THUMBNAIL_POSITION);<br /><br />- int loops = 100;<br />- for (;;) {<br />+ int wait_time = 50000;<br />+ int max_attempts = 100;<br />+ for (int i = 0; i < max_attempts; ++i) {<br />+ int playing = libvlc_media_player_is_playing(mp);<br />+<br />if (playing)<br />+ break;<br />+ usleep(wait_time);<br />+ }<br />+ for (int i = 0; i < max_attempts; ++i) {<br />float pos = libvlc_media_player_get_position(mp);<br />- if (pos > THUMBNAIL_POSITION || !loops--)<br />+ if (pos >= THUMBNAIL_POSITION)<br />break;<br />- usleep(50000);<br />+ usleep(wait_time);<br />}<br
/><br />/* Wait for the thumbnail to be generated. */</blockquote><br /><br />--<br />Envoyé de mon téléphone Android avec K-9 Mail. Excusez la brièveté.<br /><br /><hr /><br />Android mailing list<br />Android@videolan.org<br /><a href="https://mailman.videolan.org/listinfo/android">https://mailman.videolan.org/listinfo/android</a></blockquote><br /><br /><br /></pre></blockquote></div><br>
-- <br>
Envoyé de mon téléphone Android avec K-9 Mail. Excusez la brièveté.</body></html>