[vlc-commits] opensles::Play() : be sure to avoid infinite loop
Rafaël Carré
git at videolan.org
Wed Jan 18 04:31:33 CET 2012
vlc | branch: master | Rafaël Carré <funman at videolan.org> | Tue Jan 17 22:28:23 2012 -0500| [6189c75855cf343875c334cd9a9b824b3585c5c0] | committer: Rafaël Carré
opensles::Play() : be sure to avoid infinite loop
drop audio packet after 5 seconds
it'll be much too late anyway; and 1 second later is arguably too late too
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6189c75855cf343875c334cd9a9b824b3585c5c0
---
modules/audio_output/opensles_android.c | 45 ++++++++++++++++++-------------
1 files changed, 26 insertions(+), 19 deletions(-)
diff --git a/modules/audio_output/opensles_android.c b/modules/audio_output/opensles_android.c
index 00d8f42..906b6bb 100644
--- a/modules/audio_output/opensles_android.c
+++ b/modules/audio_output/opensles_android.c
@@ -284,39 +284,46 @@ static void Close( vlc_object_t *p_this )
/*****************************************************************************
* Play: play a sound
*****************************************************************************/
-static void Play( audio_output_t * p_aout, block_t *p_buffer )
+static void Play( audio_output_t *p_aout, block_t *p_buffer )
{
- aout_sys_t * p_sys = p_aout->sys;
- SLresult result;
+ aout_sys_t *p_sys = p_aout->sys;
+ int tries = 5;
for (;;)
{
- result = (*p_sys->playerBufferQueue)->Enqueue(
+ SLresult result = (*p_sys->playerBufferQueue)->Enqueue(
p_sys->playerBufferQueue, p_buffer->p_buffer,
p_buffer->i_buffer );
- if( result == SL_RESULT_SUCCESS )
- break;
- if ( result != SL_RESULT_BUFFER_INSUFFICIENT )
+
+ switch (result)
{
- msg_Warn( p_aout, "Dropping invalid buffer" );
+ case SL_RESULT_SUCCESS:
+ p_sys->p_buffer_array[p_sys->i_toappend_buffer] = p_buffer;
+ if( ++p_sys->i_toappend_buffer == BUFF_QUEUE )
+ p_sys->i_toappend_buffer = 0;
+ return;
+
+ case SL_RESULT_BUFFER_INSUFFICIENT:
+ msg_Err( p_aout, "buffer insufficient");
+
+ if (tries--)
+ {
+ // Wait a bit to retry.
+ msleep(CLOCK_FREQ);
+ continue;
+ }
+
+ default:
+ msg_Warn( p_aout, "Error %lu, dropping buffer", result );
aout_BufferFree( p_buffer );
- return ;
+ return;
}
-
- msg_Err( p_aout, "write error (%lu)", result );
-
- // Wait a bit to retry. might miss calls to *cancel
- // but this is supposed to be rare anyway
- msleep(CLOCK_FREQ);
}
- p_sys->p_buffer_array[p_sys->i_toappend_buffer] = p_buffer;
- if( ++p_sys->i_toappend_buffer == BUFF_QUEUE )
- p_sys->i_toappend_buffer = 0;
}
static void PlayedCallback (SLAndroidSimpleBufferQueueItf caller, void *pContext )
{
- aout_sys_t *p_sys = (aout_sys_t*)pContext;
+ aout_sys_t *p_sys = pContext;
assert (caller == p_sys->playerBufferQueue);
More information about the vlc-commits
mailing list