Skip to content

Commit

Permalink
fixed: Move storing of streamdetails from CApp::PlayFile() to the Sav…
Browse files Browse the repository at this point in the history
…eFileState-job, where it already partially was (for DVD stuff).

This fixes a few issues:
- Races causing possible invalid streamdetails to be stored in the db;
- Stream details for current file were not stored when item was not in the db yet;
- Check whether the streamdetails in the db need updating by comparing. This fixes also fixes previously invalid/incomplete stored details;
- Also clarify the special case for DVD stuff.
  • Loading branch information
arnova committed Mar 4, 2013
1 parent 39fc7de commit 48ad150
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 27 deletions.
28 changes: 7 additions & 21 deletions xbmc/Application.cpp
Expand Up @@ -4125,24 +4125,6 @@ bool CApplication::PlayFile(const CFileItem& item, bool bRestart)
if( options.fullscreen && g_renderManager.IsStarted()
&& g_windowManager.GetActiveWindow() != WINDOW_FULLSCREEN_VIDEO )
SwitchToFullScreen();

if (!item.IsDVDImage() && !item.IsDVDFile())
{
CVideoInfoTag *details = m_itemCurrentFile->GetVideoInfoTag();
// Save information about the stream if we currently have no data
if (!details->HasStreamDetails() ||
details->m_streamDetails.GetVideoDuration() <= 0)
{
if (m_pPlayer->GetStreamDetails(details->m_streamDetails) && details->HasStreamDetails())
{
CVideoDatabase dbs;
dbs.Open();
dbs.SetStreamDetailsForFileId(details->m_streamDetails, details->m_iFileId);
dbs.Close();
CUtil::DeleteVideoDatabaseDirectoryCache();
}
}
}
}
#endif
else
Expand Down Expand Up @@ -4441,11 +4423,15 @@ void CApplication::UpdateFileState()

if (m_progressTrackingItem->IsVideo())
{
if ((m_progressTrackingItem->IsDVDImage() || m_progressTrackingItem->IsDVDFile()) && m_pPlayer->GetTotalTime() > 15*60*1000)
// Special case for DVDs: Only extract streamdetails if title length > 15m. Should yield more correct info
if (!(m_progressTrackingItem->IsDVDImage() || m_progressTrackingItem->IsDVDFile()) || m_pPlayer->GetTotalTime() > 15*60*1000)
{
m_progressTrackingItem->GetVideoInfoTag()->m_streamDetails.Reset();
m_pPlayer->GetStreamDetails(m_progressTrackingItem->GetVideoInfoTag()->m_streamDetails);
CStreamDetails details;
// Update with stream details from player, if any
if (m_pPlayer->GetStreamDetails(details))
m_progressTrackingItem->GetVideoInfoTag()->m_streamDetails = details;
}

// Update bookmark for save
m_progressTrackingVideoResumeBookmark.player = CPlayerCoreFactory::GetPlayerName(m_eCurrentPlayer);
m_progressTrackingVideoResumeBookmark.playerState = m_pPlayer->GetPlayerState();
Expand Down
17 changes: 11 additions & 6 deletions xbmc/utils/SaveFileStateJob.h
Expand Up @@ -96,14 +96,19 @@ bool CSaveFileStateJob::DoWork()
videodatabase.SetVideoSettings(progressTrackingFile, g_settings.m_currentVideoSettings);
}

if ((m_item.IsDVDImage() ||
m_item.IsDVDFile() ) &&
m_item.HasVideoInfoTag() &&
m_item.GetVideoInfoTag()->HasStreamDetails())
if (m_item.HasVideoInfoTag() && m_item.GetVideoInfoTag()->HasStreamDetails())
{
videodatabase.SetStreamDetailsForFile(m_item.GetVideoInfoTag()->m_streamDetails,progressTrackingFile);
updateListing = true;
CFileItem dbItem(m_item);
videodatabase.GetStreamDetails(dbItem); // Fetch stream details from the db (if any)

// Check whether the item's db streamdetails need updating
if (!dbItem.GetVideoInfoTag()->HasStreamDetails() || dbItem.GetVideoInfoTag()->m_streamDetails != m_item.GetVideoInfoTag()->m_streamDetails)
{
videodatabase.SetStreamDetailsForFile(m_item.GetVideoInfoTag()->m_streamDetails, progressTrackingFile);
updateListing = true;
}
}

// in order to properly update the the list, we need to update the stack item which is held in g_application.m_stackFileItemToUpdate
if (m_item.HasProperty("stackFileItemToUpdate"))
{
Expand Down

0 comments on commit 48ad150

Please sign in to comment.