+ /* Underrun, try to recover as quickly as possible */
+ next_date = mdate();
+ }
+ else
+ {
+ /* Here the device should be in RUNNING state, p_status is valid. */
+ snd_pcm_sframes_t delay = snd_pcm_status_get_delay( p_status );
+ if( delay == 0 ) /* workaround buggy alsa drivers */
+ if( snd_pcm_delay( p_sys->p_snd_pcm, &delay ) < 0 )
+ delay = 0; /* FIXME: use a positive minimal delay */
+ int i_bytes = snd_pcm_frames_to_bytes( p_sys->p_snd_pcm, delay );
+ next_date = mdate() + ( (mtime_t)i_bytes * 1000000
+ / p_aout->output.output.i_bytes_per_frame
+ / p_aout->output.output.i_rate
+ * p_aout->output.output.i_frame_length );