Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

dvdplayer: don't call into audio device from non audio thread

CoreAE has a bug where AddPackets is a blocking operation. This causes
DVDAudio to blocked during this time. Since this is called from rendering
thread, we end up blocking GUI/video rendering.
  • Loading branch information...
commit a83ee9952e4164ce65e7f9f8a56b0bfef664b9da 1 parent 629b5c4
Joakim Plate elupus authored
34 xbmc/cores/dvdplayer/DVDPlayerAudio.cpp
View
@@ -503,6 +503,24 @@ void CDVDPlayerAudio::OnStartup()
#endif
}
+void CDVDPlayerAudio::UpdatePlayerInfo()
+{
+ std::ostringstream s;
+ s << "aq:" << setw(2) << min(99,m_messageQueue.GetLevel() + MathUtils::round_int(100.0/8.0*m_dvdAudio.GetCacheTime())) << "%";
+ s << ", Kb/s:" << fixed << setprecision(2) << (double)GetAudioBitrate() / 1024.0;
+
+ //print the inverse of the resample ratio, since that makes more sense
+ //if the resample ratio is 0.5, then we're playing twice as fast
+ if (m_synctype == SYNC_RESAMPLE)
+ s << ", rr:" << fixed << setprecision(5) << 1.0 / m_resampleratio;
+
+ s << ", att:" << fixed << setprecision(1) << log(GetCurrentAttenuation()) * 20.0f << " dB";
+
+ { CSingleLock lock(m_info_section);
+ m_info = s.str();
+ }
+}
+
void CDVDPlayerAudio::Process()
{
CLog::Log(LOGNOTICE, "running thread: CDVDPlayerAudio::Process()");
@@ -519,6 +537,8 @@ void CDVDPlayerAudio::Process()
result = DecodeFrame(audioframe, m_speed > DVD_PLAYSPEED_NORMAL || m_speed < 0 ||
CAEFactory::IsSuspended()); // blocks if no audio is available, but leaves critical section before doing so
+ UpdatePlayerInfo();
+
if( result & DECODE_FLAG_ERROR )
{
CLog::Log(LOGDEBUG, "CDVDPlayerAudio::Process - Decode Error");
@@ -858,18 +878,8 @@ bool CDVDPlayerAudio::SwitchCodecIfNeeded()
string CDVDPlayerAudio::GetPlayerInfo()
{
- std::ostringstream s;
- s << "aq:" << setw(2) << min(99,m_messageQueue.GetLevel() + MathUtils::round_int(100.0/8.0*m_dvdAudio.GetCacheTime())) << "%";
- s << ", Kb/s:" << fixed << setprecision(2) << (double)GetAudioBitrate() / 1024.0;
-
- //print the inverse of the resample ratio, since that makes more sense
- //if the resample ratio is 0.5, then we're playing twice as fast
- if (m_synctype == SYNC_RESAMPLE)
- s << ", rr:" << fixed << setprecision(5) << 1.0 / m_resampleratio;
-
- s << ", att:" << fixed << setprecision(1) << log(GetCurrentAttenuation()) * 20.0f << " dB";
-
- return s.str();
+ CSingleLock lock(m_info_section);
+ return m_info;
}
int CDVDPlayerAudio::GetAudioBitrate()
6 xbmc/cores/dvdplayer/DVDPlayerAudio.h
View
@@ -126,6 +126,8 @@ class CDVDPlayerAudio : public CThread
int DecodeFrame(DVDAudioFrame &audioframe, bool bDropPacket);
+ void UpdatePlayerInfo();
+
CDVDMessageQueue m_messageQueue;
CDVDMessageQueue& m_messageParent;
@@ -206,5 +208,9 @@ class CDVDPlayerAudio : public CThread
bool m_prevskipped;
double m_maxspeedadjust;
double m_resampleratio; //resample ratio when using SYNC_RESAMPLE, used for the codec info
+
+
+ CCriticalSection m_info_section;
+ std::string m_info;
};
Please sign in to comment.
Something went wrong with that request. Please try again.