diff options
author | Joakim Plate <elupus@ecce.se> | 2013-05-25 14:05:17 +0200 |
---|---|---|
committer | Joakim Plate <elupus@ecce.se> | 2013-05-25 14:13:18 +0200 |
commit | a83ee9952e4164ce65e7f9f8a56b0bfef664b9da (patch) | |
tree | 8142a42b299f28e1cf4ef17a90e40c2f80ed6c69 | |
parent | 629b5c491c89e9e6757a2c88d00e50c2c0650ba1 (diff) |
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.
-rw-r--r-- | xbmc/cores/dvdplayer/DVDPlayerAudio.cpp | 34 | ||||
-rw-r--r-- | xbmc/cores/dvdplayer/DVDPlayerAudio.h | 6 |
2 files changed, 28 insertions, 12 deletions
diff --git a/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp b/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp index e2ea458495..80ac86b2c5 100644 --- a/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp +++ b/xbmc/cores/dvdplayer/DVDPlayerAudio.cpp @@ -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() diff --git a/xbmc/cores/dvdplayer/DVDPlayerAudio.h b/xbmc/cores/dvdplayer/DVDPlayerAudio.h index f6aba9fb5d..60fbab63e9 100644 --- a/xbmc/cores/dvdplayer/DVDPlayerAudio.h +++ b/xbmc/cores/dvdplayer/DVDPlayerAudio.h @@ -126,6 +126,8 @@ protected: int DecodeFrame(DVDAudioFrame &audioframe, bool bDropPacket); + void UpdatePlayerInfo(); + CDVDMessageQueue m_messageQueue; CDVDMessageQueue& m_messageParent; @@ -206,5 +208,9 @@ protected: 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; }; |