Commit e43b973a authored by Richard Hosking's avatar Richard Hosking

v4l2: ALSA error handling.

parent 191479d7
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
/* /*
* TODO: Tuner partial implementation. * TODO: Tuner partial implementation.
* TODO: Alsa input support - experimental
*/ */
/***************************************************************************** /*****************************************************************************
...@@ -1129,10 +1128,32 @@ static block_t* GrabAudio( demux_t *p_demux ) ...@@ -1129,10 +1128,32 @@ static block_t* GrabAudio( demux_t *p_demux )
{ {
/* ALSA */ /* ALSA */
i_read = snd_pcm_readi( p_sys->p_alsa_pcm, p_block->p_buffer, p_sys->i_alsa_chunk_size ); i_read = snd_pcm_readi( p_sys->p_alsa_pcm, p_block->p_buffer, p_sys->i_alsa_chunk_size );
/* TODO: ALSA ERROR HANDLING?? xrun?? */ if( i_read <= 0 )
{
/* convert from frames to bytes */ int i_resume;
if( i_read > 0 ) i_read *= p_sys->i_alsa_frame_size; switch( i_read )
{
case -EAGAIN:
break;
case -EPIPE:
/* xrun */
snd_pcm_prepare( p_sys->p_alsa_pcm );
break;
case -ESTRPIPE:
/* suspend */
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:
msg_Err( p_demux, "Failed to read alsa frame (%s)", snd_strerror( i_read ) );
return 0;
}
}
else
{
/* convert from frames to bytes */
i_read *= p_sys->i_alsa_frame_size;
}
} }
else else
#endif #endif
...@@ -1153,6 +1174,7 @@ static block_t* GrabAudio( demux_t *p_demux ) ...@@ -1153,6 +1174,7 @@ static block_t* GrabAudio( demux_t *p_demux )
if( !p_sys->b_use_alsa ) if( !p_sys->b_use_alsa )
#endif #endif
{ {
/* OSS */
if( ioctl( p_sys->i_fd_audio, SNDCTL_DSP_GETISPACE, &buf_info ) == 0 ) if( ioctl( p_sys->i_fd_audio, SNDCTL_DSP_GETISPACE, &buf_info ) == 0 )
{ {
i_correct += buf_info.bytes; i_correct += buf_info.bytes;
...@@ -1161,8 +1183,7 @@ static block_t* GrabAudio( demux_t *p_demux ) ...@@ -1161,8 +1183,7 @@ static block_t* GrabAudio( demux_t *p_demux )
#ifdef HAVE_ALSA #ifdef HAVE_ALSA
else else
{ {
/* TODO: ALSA timing */ /* ALSA */
/* Very experimental code... */
int i_err; int i_err;
snd_pcm_sframes_t delay = 0; snd_pcm_sframes_t delay = 0;
if( ( i_err = snd_pcm_delay( p_sys->p_alsa_pcm, &delay ) ) >= 0 ) if( ( i_err = snd_pcm_delay( p_sys->p_alsa_pcm, &delay ) ) >= 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