[Android] Fix the msleep nanosleep wrapping

Martin Storsjö git at videolan.org
Sun Apr 8 14:47:42 CEST 2012


android | branch: master | Martin Storsjö <martin at martin.st> | Sun Apr  8 15:37:39 2012 +0300| [661f638650893b9b00ec673453cd3cf983db475f] | committer: Martin Storsjö

Fix the msleep nanosleep wrapping

The condition was inverted - the loop is supposed to sleep in 10 ms
increments. A one second msleep in practice slept for about 50 seconds.

Previously, if t.tv_nsec (the amount we actually sleep) was less than
ts.tv_nsec (the amount we should sleep in total), we actually slept the
full duration, but only subtracted 10 ms from the total time to sleep.

This fixes cases where the application hung with "can't get output
picture" at the end, if using hw decoding, and fixes audio output
with hw decoders on Samsung Galaxy S II when using the OpenSLES
aout, where the msleep(CLOCK_FREQ) hung for a very long time.

Signed-off-by: Martin Storsjö <martin at martin.st>

> http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=661f638650893b9b00ec673453cd3cf983db475f
---

 patches/0001-android-threads-support.patch |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/patches/0001-android-threads-support.patch b/patches/0001-android-threads-support.patch
index 8fded92..1c5421b 100644
--- a/patches/0001-android-threads-support.patch
+++ b/patches/0001-android-threads-support.patch
@@ -522,7 +522,7 @@ index a7a4873..598c692 100644
 +    vlc_testcancel();
 +    for (;;) {
 +        struct timespec t = { 0, 10 * 1000 * 1000 };
-+        if (t.tv_nsec < ts.tv_nsec)
++        if (ts.tv_sec <= 0 && t.tv_nsec > ts.tv_nsec)
 +            t.tv_nsec = ts.tv_nsec;
 +        while (nanosleep (&t, &t) == -1) {
 +            vlc_testcancel();



More information about the Android mailing list