From b4e08f9f8fc0fcb37f099b206c5d38c4b070b5c4 Mon Sep 17 00:00:00 2001 From: Rainer Hochecker Date: Mon, 23 Feb 2015 19:53:19 +0100 Subject: [PATCH 1/3] dvdplayer: sync audio after having issued GENERAL_RESYNC --- xbmc/cores/dvdplayer/DVDPlayerAudio.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp b/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp index 605e116b9ff0c..1027543ac66fa 100644 --- a/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp +++ b/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp @@ -371,6 +371,7 @@ int CDVDPlayerAudio::DecodeFrame(DVDAudioFrame &audioframe) m_dvdAudio.SetPlayingPts(m_audioClock); if (pMsgGeneralResync->m_clock) m_pClock->Discontinuity(m_dvdAudio.GetPlayingPts()); + m_syncclock = true; } else if (pMsg->IsType(CDVDMsg::GENERAL_RESET)) { From 550f3b04f56bac2465f18dd1648c191bd9c16db8 Mon Sep 17 00:00:00 2001 From: Rainer Hochecker Date: Tue, 24 Feb 2015 19:42:05 +0100 Subject: [PATCH 2/3] [AE] - force re-create of ffmpeg resampler after error --- .../cores/AudioEngine/Engines/ActiveAE/ActiveAEBuffer.cpp | 7 +++++++ .../Engines/ActiveAE/ActiveAEResampleFFMPEG.cpp | 8 ++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEBuffer.cpp b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEBuffer.cpp index 3b0a015b75d43..44d47a1c9c4aa 100644 --- a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEBuffer.cpp +++ b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEBuffer.cpp @@ -292,6 +292,13 @@ bool CActiveAEBufferPoolResample::ResampleBuffers(int64_t timestamp) in ? in->pkt->data : NULL, in ? in->pkt->nb_samples : 0, m_resampleRatio); + // in case of error, trigger re-create of resampler + if (out_samples < 0) + { + out_samples = 0; + m_changeResampler = true; + } + m_procSample->pkt->nb_samples += out_samples; busy = true; m_empty = (out_samples == 0); diff --git a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResampleFFMPEG.cpp b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResampleFFMPEG.cpp index de188e70beec4..c3305cb888fce 100644 --- a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResampleFFMPEG.cpp +++ b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResampleFFMPEG.cpp @@ -184,11 +184,11 @@ int CActiveAEResampleFFMPEG::Resample(uint8_t **dst_buffer, int dst_samples, uin if (ratio != 1.0) { if (swr_set_compensation(m_pContext, - (dst_samples*ratio-dst_samples)*m_dst_rate/m_src_rate, - dst_samples*m_dst_rate/m_src_rate) < 0) + (dst_samples*ratio-dst_samples)*m_dst_rate/m_src_rate, + dst_samples*m_dst_rate/m_src_rate) < 0) { CLog::Log(LOGERROR, "CActiveAEResampleFFMPEG::Resample - set compensation failed"); - return 0; + return -1; } } @@ -196,7 +196,7 @@ int CActiveAEResampleFFMPEG::Resample(uint8_t **dst_buffer, int dst_samples, uin if (ret < 0) { CLog::Log(LOGERROR, "CActiveAEResampleFFMPEG::Resample - resample failed"); - return 0; + return -1; } // special handling for S24 formats which are carried in S32 From cec0fb43fa4bd40a46dda46be5491aac74637e3d Mon Sep 17 00:00:00 2001 From: Rainer Hochecker Date: Wed, 25 Feb 2015 17:40:59 +0100 Subject: [PATCH 3/3] dvdplayer: flush audio errors on large sync error --- xbmc/cores/dvdplayer/DVDPlayerAudio.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp b/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp index 1027543ac66fa..7f115892f5e41 100644 --- a/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp +++ b/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp @@ -653,6 +653,8 @@ void CDVDPlayerAudio::HandleSyncError(double duration) if (fabs(error) > DVD_MSEC_TO_TIME(100)) { m_syncclock = true; + m_errors.Flush(); + m_integral = 0.0; return; } else if (m_syncclock && fabs(error) < DVD_MSEC_TO_TIME(50))