Commit 6189c758 authored by Rafaël Carré's avatar 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
parent d5b953c4
......@@ -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);
......
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