Commit 171bdb14 authored by Jean-Paul Saman's avatar Jean-Paul Saman

access/alsa.c: simplify error recovery when capturing

Use highlevel function snd_pcm_recover() the recover from error states.
parent 7cfacd21
...@@ -377,33 +377,26 @@ static block_t* GrabAudio( demux_t *p_demux ) ...@@ -377,33 +377,26 @@ static block_t* GrabAudio( demux_t *p_demux )
return NULL; return NULL;
} }
if( i_read < 0 )
i_read = snd_pcm_recover( p_sys->p_alsa_pcm, i_read, 0 );
if( i_read <= 0 ) if( i_read <= 0 )
{ {
switch( i_read ) switch( i_read )
{ {
case -EPIPE: case 0: /* state recovered or no data */
/* xrun */ return NULL;
snd_pcm_prepare( p_sys->p_alsa_pcm ); case -EAGAIN:
break; snd_pcm_wait( p_sys->p_alsa_pcm, 10 ); /* See poll() comment in oss.c */
case -ESTRPIPE: return NULL;
{
/* suspend */
int i_resume = snd_pcm_resume( p_sys->p_alsa_pcm );
if( i_resume < 0 && i_resume != -EAGAIN ) snd_pcm_prepare( p_sys->p_alsa_pcm );
break;
}
default: default:
msg_Err( p_demux, "Failed to read alsa frame (%s)", snd_strerror( i_read ) ); msg_Err( p_demux, "Failed to read alsa frame (%s)", snd_strerror( i_read ) );
return 0; return 0;
} }
} }
else
{
/* convert from frames to bytes */ /* convert from frames to bytes */
i_read *= p_sys->i_alsa_frame_size; i_read *= p_sys->i_alsa_frame_size;
}
if( i_read <= 0 ) return 0;
p_block->i_buffer = i_read; p_block->i_buffer = i_read;
p_sys->p_block = 0; p_sys->p_block = 0;
......
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