Commit 62e338ce authored by Rafaël Carré's avatar Rafaël Carré Committed by Jean-Baptiste Kempf

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
(cherry picked from commit 6189c75855cf343875c334cd9a9b824b3585c5c0)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent b9fb627b
...@@ -284,39 +284,46 @@ static void Close( vlc_object_t *p_this ) ...@@ -284,39 +284,46 @@ static void Close( vlc_object_t *p_this )
/***************************************************************************** /*****************************************************************************
* Play: play a sound * 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; aout_sys_t *p_sys = p_aout->sys;
SLresult result; int tries = 5;
for (;;) for (;;)
{ {
result = (*p_sys->playerBufferQueue)->Enqueue( SLresult result = (*p_sys->playerBufferQueue)->Enqueue(
p_sys->playerBufferQueue, p_buffer->p_buffer, p_sys->playerBufferQueue, p_buffer->p_buffer,
p_buffer->i_buffer ); p_buffer->i_buffer );
if( result == SL_RESULT_SUCCESS )
break; switch (result)
if ( result != SL_RESULT_BUFFER_INSUFFICIENT )
{ {
msg_Warn( p_aout, "Dropping invalid buffer" ); case SL_RESULT_SUCCESS:
aout_BufferFree( p_buffer ); p_sys->p_buffer_array[p_sys->i_toappend_buffer] = p_buffer;
return ; if( ++p_sys->i_toappend_buffer == BUFF_QUEUE )
} p_sys->i_toappend_buffer = 0;
return;
msg_Err( p_aout, "write error (%lu)", result ); case SL_RESULT_BUFFER_INSUFFICIENT:
msg_Err( p_aout, "buffer insufficient");
// Wait a bit to retry. might miss calls to *cancel if (tries--)
// but this is supposed to be rare anyway {
// Wait a bit to retry.
msleep(CLOCK_FREQ); msleep(CLOCK_FREQ);
continue;
}
default:
msg_Warn( p_aout, "Error %lu, dropping buffer", result );
aout_BufferFree( p_buffer );
return;
}
} }
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 ) 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); assert (caller == p_sys->playerBufferQueue);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment