Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added: if the bitrate of audio and video combined is higher than half…

… the readrate, increase the readrate
  • Loading branch information...
commit 72f7cefa2c6c94cd8e35fd18c63b5a85287c2676 1 parent 323084f
bobo1on1 authored
View
21 xbmc/cores/dvdplayer/DVDPlayer.cpp
@@ -318,6 +318,7 @@ CDVDPlayer::CDVDPlayer(IPlayerCallback& callback)
m_errorCount = 0;
m_playSpeed = DVD_PLAYSPEED_NORMAL;
m_caching = CACHESTATE_DONE;
+ m_readrate = 0;
#ifdef DVDDEBUG_MESSAGE_TRACKER
g_dvdMessageTracker.Init();
@@ -565,7 +566,10 @@ bool CDVDPlayer::OpenDemuxStream()
int64_t len = m_pInputStream->GetLength();
int64_t tim = m_pDemuxer->GetStreamLength();
if(len > 0 && tim > 0)
- m_pInputStream->SetReadRate(len * 1000 / tim);
+ {
+ m_readrate = len * 1000 / tim;
+ m_pInputStream->SetReadRate(m_readrate);
+ }
return true;
}
@@ -1059,6 +1063,9 @@ void CDVDPlayer::Process()
// update application with our state
UpdateApplication(1000);
+ //update readrate based on peak bitrate
+ UpdateReadRate();
+
// if the queues are full, no need to read more
if ((!m_dvdPlayerAudio.AcceptsData() && m_CurrentAudio.id >= 0)
|| (!m_dvdPlayerVideo.AcceptsData() && m_CurrentVideo.id >= 0))
@@ -3773,6 +3780,18 @@ void CDVDPlayer::UpdateApplication(double timeout)
m_UpdateApplication = CDVDClock::GetAbsoluteClock();
}
+void CDVDPlayer::UpdateReadRate()
+{
+ //if the combined audio and video bitrate is more than half the readrate
+ //increase the readrate
+ unsigned int bytespersecond = (GetVideoBitrate() + GetAudioBitrate()) / 8;
+ if (bytespersecond * 2 > m_readrate)
+ {
+ m_readrate = bytespersecond * 3;
+ m_pInputStream->SetReadRate(m_readrate);
+ }
+}
+
bool CDVDPlayer::CanRecord()
{
CSingleLock lock(m_StateSection);
View
3  xbmc/cores/dvdplayer/DVDPlayer.h
@@ -304,6 +304,7 @@ class CDVDPlayer : public IPlayer, public CThread, public IDVDPlayer
void UpdateApplication(double timeout);
void UpdatePlayState(double timeout);
+ void UpdateReadRate();
double m_UpdateApplication;
bool m_bAbortRequest;
@@ -312,6 +313,8 @@ class CDVDPlayer : public IPlayer, public CThread, public IDVDPlayer
std::string m_mimetype; // hold a hint to what content file contains (mime type)
ECacheState m_caching;
CFileItem m_item;
+ unsigned m_readrate;
+
CCurrentStream m_CurrentAudio;
Please sign in to comment.
Something went wrong with that request. Please try again.