在omxplayer.cpp中
// keep latency under control by adjusting clock (and so resampling audio)
if (m_config_audio.is_live)
{
float latency = DVD_NOPTS_VALUE;
if (m_has_audio && audio_pts != DVD_NOPTS_VALUE)
latency = audio_fifo;
else if (!m_has_audio && m_has_video && video_pts != DVD_NOPTS_VALUE)
latency = video_fifo;
if (!m_Pause && latency != DVD_NOPTS_VALUE)
{
if (m_av_clock->OMXIsPaused())
{
if (latency > m_threshold)
{
CLog::Log(LOGDEBUG, "Resume %.2f,%.2f (%d,%d,%d,%d) EOF:%d PKT:%p\n", audio_fifo, video_fifo, audio_fifo_low, video_fifo_low, audio_fifo_high, video_fifo_high, m_omx_reader.IsEof(), m_omx_pkt);
m_av_clock->OMXResume();
m_latency = latency;
}
}
else
{
m_latency = m_latency*0.99f + latency*0.01f;
float speed = 1.0f;
if (m_latency < 0.5f*m_threshold)
speed = 0.990f;
else if (m_latency < 0.9f*m_threshold)
speed = 0.999f;
else if (m_latency > 2.0f*m_threshold)
speed = 1.010f;
else if (m_latency > 1.1f*m_threshold)
speed = 1.001f;
m_av_clock->OMXSetSpeed(S(speed));
m_av_clock->OMXSetSpeed(S(speed), true, true);
CLog::Log(LOGDEBUG, "Live: %.2f (%.2f) S:%.3f T:%.2f\n", m_latency, latency, speed, m_threshold);
if (m_threshold < 0.0f)
m_threshold = m_config_audio.is_live ? 0.7f : 0.2f;
在使用--live时可设置m_threshold,但是上面调节速度较慢,需调整!