[vlc-commits] mediacodec: wait to have the first frame successfully decoded to set the started flag

Adrien Maglo git at videolan.org
Mon Jun 9 11:18:41 CEST 2014


vlc | branch: master | Adrien Maglo <magsoft at videolan.org> | Fri Jun  6 13:43:52 2014 +0200| [703cfc648ee8e3fe70ee276508f44321a0b7b993] | committer: Adrien Maglo

mediacodec: wait to have the first frame successfully decoded to set the started flag

This is an attempt to fix a common crash in closeDecoder() we did not manage to reproduce with our devices.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=703cfc648ee8e3fe70ee276508f44321a0b7b993
---

 modules/codec/omxil/android_mediacodec.c |   10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/modules/codec/omxil/android_mediacodec.c b/modules/codec/omxil/android_mediacodec.c
index 94359c3..87b135d 100644
--- a/modules/codec/omxil/android_mediacodec.c
+++ b/modules/codec/omxil/android_mediacodec.c
@@ -523,7 +523,14 @@ static int OpenDecoder(vlc_object_t *p_this)
         (*env)->ExceptionClear(env);
         goto error;
     }
-    p_sys->started = true;
+
+    /* WARNING: we should normally set the started flag here, just after the start() call.
+       However, as libstagefright is asynchronous and is not entirely initialized after
+       the start() call, we wait to have successfully decoded the first frame before
+       setting this flag in order to try to avoid a crash happening during the module
+       CloseDecoder() function.
+       Note: calling release() without having called stop() does not seem to be an issue. */
+    //p_sys->started = true;
 
     p_sys->input_buffers = (*env)->CallObjectMethod(env, p_sys->codec, p_sys->get_input_buffers);
     p_sys->output_buffers = (*env)->CallObjectMethod(env, p_sys->codec, p_sys->get_output_buffers);
@@ -941,6 +948,7 @@ static picture_t *DecodeVideo(decoder_t *p_dec, block_t **pp_block)
         (*env)->CallVoidMethod(env, p_sys->codec, p_sys->queue_input_buffer, index, 0, size, ts, 0);
         (*env)->DeleteLocalRef(env, buf);
         p_sys->decoded = true;
+        p_sys->started = true;
         break;
     }
     if (!p_pic)



More information about the vlc-commits mailing list