dvdplayer: keep copy of internal state of dvdplayeraudio
authorJoakim Plate <elupus@ecce.se>
Sun, 1 Jun 2014 13:24:14 +0000 (15:24 +0200)
committerfritsch <Peter.Fruehberger@gmail.com>
Mon, 2 Jun 2014 06:30:44 +0000 (08:30 +0200)
This avoids external threads messing with internal objects like
audio renderers.

xbmc/cores/dvdplayer/DVDPlayerAudio.cpp
xbmc/cores/dvdplayer/DVDPlayerAudio.h

index f6df01f..fba9b3c 100644 (file)
@@ -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;
   }
 }
 
@@ -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()
@@ -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;
 }
index 4b48514..81e28c1 100644 (file)
@@ -142,7 +142,7 @@ public:
   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;
@@ -230,8 +230,19 @@ protected:
   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;
 };