Skip to content

Commit

Permalink
pvr: move the pvrplayback.scantime check to DVDPlayer instead of tryi…
Browse files Browse the repository at this point in the history
…ng to handle it in CPVRClients. always restart the timer if the stream buffers run dry. closes #118
  • Loading branch information
opdenkamp committed May 26, 2011
1 parent ec2a867 commit 23f1065
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 26 deletions.
16 changes: 15 additions & 1 deletion xbmc/cores/dvdplayer/DVDPlayer.cpp
Expand Up @@ -349,6 +349,7 @@ bool CDVDPlayer::OpenFile(const CFileItem& file, const CPlayerOptions &options)
m_item = file;
m_mimetype = file.GetMimeType();
m_filename = file.m_strPath;
m_scanStart = 0;

m_ready.Reset();
Create();
Expand Down Expand Up @@ -950,7 +951,10 @@ void CDVDPlayer::Process()
// make sure all selected stream have data on startup
if (m_pInputStream->IsStreamType(DVDSTREAM_TYPE_PVRMANAGER)
&& !g_PVRManager.IsPlayingRecording())
{
SetCaching(CACHESTATE_PVR);
m_scanStart = CTimeUtils::GetTimeMS();
}
else
SetCaching(CACHESTATE_INIT);

Expand Down Expand Up @@ -1107,10 +1111,16 @@ void CDVDPlayer::Process()
else if (m_pInputStream->IsStreamType(DVDSTREAM_TYPE_PVRMANAGER))
{
CDVDInputStreamPVRManager* pStream = static_cast<CDVDInputStreamPVRManager*>(m_pInputStream);

if (pStream->IsEOF())
break;

if (m_scanStart && CTimeUtils::GetTimeMS() - m_scanStart >= (unsigned int) g_guiSettings.GetInt("pvrplayback.scantime")*1000)
{
CLog::Log(LOGERROR,"CDVDPlayer - %s - no video or audio data available after %i seconds, playback stopped",
__FUNCTION__, g_guiSettings.GetInt("pvrplayback.scantime"));
break;
}

Sleep(100);
continue;
}
Expand Down Expand Up @@ -2157,6 +2167,9 @@ void CDVDPlayer::SetCaching(ECacheState state)
m_dvdPlayerAudio.SendMessage(new CDVDMsg(CDVDMsg::PLAYER_STARTED), 1);
m_dvdPlayerVideo.SetSpeed(DVD_PLAYSPEED_PAUSE);
m_dvdPlayerVideo.SendMessage(new CDVDMsg(CDVDMsg::PLAYER_STARTED), 1);

if (state == CACHESTATE_PVR)
m_scanStart = CTimeUtils::GetTimeMS();
}

if(state == CACHESTATE_PLAY
Expand All @@ -2165,6 +2178,7 @@ void CDVDPlayer::SetCaching(ECacheState state)
m_clock.SetSpeed(m_playSpeed);
m_dvdPlayerAudio.SetSpeed(m_playSpeed);
m_dvdPlayerVideo.SetSpeed(m_playSpeed);
m_scanStart = 0;
}
m_caching = state;
}
Expand Down
11 changes: 6 additions & 5 deletions xbmc/cores/dvdplayer/DVDPlayer.h
Expand Up @@ -296,11 +296,12 @@ class CDVDPlayer : public IPlayer, public CThread, public IDVDPlayer

bool m_bAbortRequest;

std::string m_filename; // holds the actual filename
std::string m_mimetype; // hold a hint to what content file contains (mime type)
ECacheState m_caching;
CFileItem m_item;
long m_ChannelEntryTimeOut;
std::string m_filename; // holds the actual filename
std::string m_mimetype; // hold a hint to what content file contains (mime type)
ECacheState m_caching;
CFileItem m_item;
unsigned int m_scanStart;
long m_ChannelEntryTimeOut;

CCurrentStream m_CurrentAudio;
CCurrentStream m_CurrentVideo;
Expand Down
20 changes: 0 additions & 20 deletions xbmc/pvr/addons/PVRClients.cpp
Expand Up @@ -152,7 +152,6 @@ void CPVRClients::Unload(void)
m_bAllClientsLoaded = false;
m_currentChannel = NULL;
m_currentRecording = NULL;
m_scanStart = 0;
m_strPlayingClientName = "";

m_clientsProps.clear();
Expand Down Expand Up @@ -355,22 +354,6 @@ int CPVRClients::ReadStream(void* lpBuf, int64_t uiBufSize)
{
CSingleLock lock(m_critSection);

/* Check stream for available video or audio data, if after the scantime no stream
is present playback is canceled and returns to the window */
if (m_scanStart)
{
if (CTimeUtils::GetTimeMS() - m_scanStart > (unsigned int) g_guiSettings.GetInt("pvrplayback.scantime")*1000)
{
CLog::Log(LOGERROR,"PVRManager - %s - no video or audio data available after %i seconds, playback stopped",
__FUNCTION__, g_guiSettings.GetInt("pvrplayback.scantime"));
{
return 0;
}
}
else if (g_application.IsPlayingVideo() || g_application.IsPlayingAudio())
m_scanStart = 0;
}

if (m_currentChannel)
return m_clientMap[m_currentChannel->ClientID()]->ReadLiveStream(lpBuf, uiBufSize);
else if (m_currentRecording)
Expand Down Expand Up @@ -507,7 +490,6 @@ bool CPVRClients::OpenLiveStream(const CPVRChannel &tag)
else
m_strPlayingClientName = g_localizeStrings.Get(13205);

m_scanStart = CTimeUtils::GetTimeMS(); /* Reset the stream scan timer */
bReturn = true;
}

Expand Down Expand Up @@ -564,7 +546,6 @@ bool CPVRClients::SwitchChannel(const CPVRChannel &channel)
if (client->SwitchChannel(channel))
{
m_currentChannel = &channel;
m_scanStart = CTimeUtils::GetTimeMS(); /* Reset the stream scan timer */
ResetQualityData();

bReturn = true;
Expand Down Expand Up @@ -621,7 +602,6 @@ bool CPVRClients::OpenRecordedStream(const CPVRRecording &tag)
{
m_currentRecording = &tag;
m_strPlayingClientName = GetClientName(tag.m_iClientId);
m_scanStart = CTimeUtils::GetTimeMS(); /* Reset the stream scan timer */
bReturn = true;
}

Expand Down

0 comments on commit 23f1065

Please sign in to comment.