Skip to content

Commit

Permalink
VideoPlayer: fix resync of audio
Browse files Browse the repository at this point in the history
  • Loading branch information
FernetMenta authored and popcornmix committed Jan 18, 2016
1 parent 1bc107e commit d4670e3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodec.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ typedef struct stDVDAudioFrame
{
uint8_t* data[16];
double pts;
bool hasTimestamp;
double duration;
unsigned int nb_frames;
unsigned int framesize;
Expand Down
14 changes: 9 additions & 5 deletions xbmc/cores/VideoPlayer/VideoPlayerAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,12 @@ int CVideoPlayerAudio::DecodeFrame(DVDAudioFrame &audioframe)
if (audioframe.nb_frames == 0)
continue;

if (audioframe.pts == DVD_NOPTS_VALUE)
audioframe.pts = m_audioClock;
audioframe.pts = m_audioClock;

if (dts == DVD_NOPTS_VALUE)
audioframe.hasTimestamp = false;
else
audioframe.hasTimestamp = true;

if (audioframe.format.m_sampleRate && m_streaminfo.samplerate != (int) audioframe.format.m_sampleRate)
{
Expand Down Expand Up @@ -380,8 +384,7 @@ int CVideoPlayerAudio::DecodeFrame(DVDAudioFrame &audioframe)
double pts = static_cast<CDVDMsgDouble*>(pMsg)->m_value;
CLog::Log(LOGDEBUG, "CVideoPlayerAudio - CDVDMsg::GENERAL_RESYNC(%f)", pts);

m_audioClock = pts;
m_ptsInput.Flush();
m_audioClock = pts + m_dvdAudio.GetDelay();
if (m_speed != DVD_PLAYSPEED_PAUSE)
m_dvdAudio.Resume();
m_syncState = IDVDStreamPlayer::SYNC_INSYNC;
Expand All @@ -399,6 +402,7 @@ int CVideoPlayerAudio::DecodeFrame(DVDAudioFrame &audioframe)
m_dvdAudio.Flush();
m_ptsInput.Flush();
m_stalled = true;
m_audioClock = 0;

if (sync)
{
Expand Down Expand Up @@ -571,7 +575,7 @@ void CVideoPlayerAudio::Process()
msg.player = VideoPlayer_AUDIO;
msg.cachetotal = cachetotal;
msg.cachetime = cachetime;
msg.timestamp = m_audioClock;
msg.timestamp = audioframe.hasTimestamp ? audioframe.pts : DVD_NOPTS_VALUE;
m_messageParent.Put(new CDVDMsgType<SStartMsg>(CDVDMsg::PLAYER_STARTED, msg));
}
}
Expand Down

0 comments on commit d4670e3

Please sign in to comment.