Commit e1e7a73c authored by Hans-Kristian Arntzen's avatar Hans-Kristian Arntzen Committed by Rémi Denis-Courmont

OSS audio output: Prefer GETODELAY over GETOSPACE.

Fix the possibly wrong assumption that we're able to accurately
calculate latency using GETOSPACE
(buffer size - available bytes to write).

New code uses GETODELAY to get latency directly but falls back to
GETOSPACE calculation should GETODELAY fail.
Signed-off-by: default avatarRémi Denis-Courmont <remi@remlab.net>
parent cc82de22
......@@ -553,6 +553,12 @@ static mtime_t BufferDuration( audio_output_t * p_aout )
audio_buf_info audio_buf;
int i_bytes;
#ifdef SNDCTL_DSP_GETODELAY
if ( ioctl( p_sys->i_fd, SNDCTL_DSP_GETODELAY, &i_bytes ) < 0 )
#endif
{
/* Fall back to GETOSPACE and approximate latency. */
/* Fill the audio_buf_info structure:
* - fragstotal: total number of fragments allocated
* - fragsize: size of a fragment in bytes
......@@ -562,6 +568,7 @@ static mtime_t BufferDuration( audio_output_t * p_aout )
/* calculate number of available fragments (not partially used ones) */
i_bytes = (audio_buf.fragstotal * audio_buf.fragsize) - audio_buf.bytes;
}
/* Return the fragment duration */
return (mtime_t)i_bytes * 1000000
......
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