Skip to content

Commit

Permalink
dvdplayer: keep copy of internal state of dvdplayeraudio
Browse files Browse the repository at this point in the history
This avoids external threads messing with internal objects like
audio renderers.
  • Loading branch information
elupus authored and fritsch committed Jun 2, 2014
1 parent 8b2c236 commit 3021cfa
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
12 changes: 9 additions & 3 deletions xbmc/cores/dvdplayer/DVDPlayerAudio.cpp
Expand Up @@ -475,8 +475,13 @@ void CDVDPlayerAudio::UpdatePlayerInfo()

s << ", att:" << fixed << setprecision(1) << log(GetCurrentAttenuation()) * 20.0f << " dB";

SInfo info;
info.info = s.str();
info.pts = m_dvdAudio.GetPlayingPts();
info.passthrough = m_pAudioCodec && m_pAudioCodec->NeedPassthrough();

{ CSingleLock lock(m_info_section);
m_info = s.str();
m_info = info;
}
}

Expand Down Expand Up @@ -779,7 +784,7 @@ bool CDVDPlayerAudio::SwitchCodecIfNeeded()
string CDVDPlayerAudio::GetPlayerInfo()
{
CSingleLock lock(m_info_section);
return m_info;
return m_info.info;
}

int CDVDPlayerAudio::GetAudioBitrate()
Expand All @@ -789,5 +794,6 @@ int CDVDPlayerAudio::GetAudioBitrate()

bool CDVDPlayerAudio::IsPassthrough() const
{
return m_pAudioCodec && m_pAudioCodec->NeedPassthrough();
CSingleLock lock(m_info_section);
return m_info.passthrough;
}
15 changes: 13 additions & 2 deletions xbmc/cores/dvdplayer/DVDPlayerAudio.h
Expand Up @@ -142,7 +142,7 @@ class CDVDPlayerAudio : public CThread
CPTSOutputQueue m_ptsOutput;
CPTSInputQueue m_ptsInput;

double GetCurrentPts() { return m_dvdAudio.GetPlayingPts(); }
double GetCurrentPts() { CSingleLock lock(m_info_section); return m_info.pts; }

bool IsStalled() { return m_stalled; }
bool IsPassthrough() const;
Expand Down Expand Up @@ -230,8 +230,19 @@ class CDVDPlayerAudio : public CThread
double m_maxspeedadjust;
double m_resampleratio; //resample ratio when using SYNC_RESAMPLE, used for the codec info

struct SInfo
{
SInfo()
: pts(DVD_NOPTS_VALUE)
, passthrough(false)
{}

std::string info;
double pts;
bool passthrough;
};

CCriticalSection m_info_section;
std::string m_info;
SInfo m_info;
};

0 comments on commit 3021cfa

Please sign in to comment.