[vlc-commits] opensles: avoid infinite loop in linked list

Rafaël Carré git at videolan.org
Sat Dec 15 16:56:50 CET 2012


vlc | branch: master | Rafaël Carré <funman at videolan.org> | Sat Dec 15 16:56:15 2012 +0100| [901267b6b3270d54c0deef0855d72809c7bf9398] | committer: Rafaël Carré

opensles: avoid infinite loop in linked list

this can happen when moving buffers between our 2 linked lists

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

 modules/audio_output/opensles_android.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/modules/audio_output/opensles_android.c b/modules/audio_output/opensles_android.c
index 40b4fdb..a844901 100644
--- a/modules/audio_output/opensles_android.c
+++ b/modules/audio_output/opensles_android.c
@@ -195,6 +195,8 @@ static int WriteBuffer(audio_output_t *p_aout)
     /* If something bad happens, we must remove this buffer from the FIFO */
     block_t **pp_last_saved = p_sys->pp_last;
     block_t *p_last_saved = *pp_last_saved;
+    block_t *next_saved = b->p_next;
+    b->p_next = NULL;
 
     /* Put this block in the list of audio already written to opensles */
     block_ChainLastAppend( &p_sys->pp_last, b );
@@ -214,12 +216,15 @@ static int WriteBuffer(audio_output_t *p_aout)
             p_sys->pp_buffer_last = &p_sys->p_buffer_chain;
     } else {
         /* Remove that block from the list of audio already written */
-        msg_Err( p_aout, "error %lu%s", r, (r == SL_RESULT_BUFFER_INSUFFICIENT)
+        msg_Err( p_aout, "error %lu%s (%d bytes)", r, (r == SL_RESULT_BUFFER_INSUFFICIENT)
                 ? " buffer insufficient"
-                : "");
+                : "", b->i_buffer);
 
         p_sys->pp_last = pp_last_saved;
         *pp_last_saved = p_last_saved;
+
+        b->p_next = next_saved;
+
         p_sys->length -= len;
         next = NULL; /* We'll try again next time */
     }



More information about the vlc-commits mailing list