aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Rusak <lorusak@gmail.com>2022-02-01 19:29:32 -0800
committerGitHub <noreply@github.com>2022-02-01 19:29:32 -0800
commit23bd1db7c4801ec312026bcaedc7a8c8e74231d3 (patch)
tree5be9ae26ec426461c5b11ab5a298ec6e2ee50f21
parentec33cbda1b98c2946deae7ed300cdab8a74618f7 (diff)
parent5be3467b4b62c64c34578a2656a43a84711ec50d (diff)
Merge pull request #20888 from lrusak/endtime-chrono-PR-1
Propagate Endtime std::chrono changes out
-rw-r--r--xbmc/Application.cpp3
-rw-r--r--xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp8
-rw-r--r--xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEStream.cpp15
-rw-r--r--xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEStream.h4
-rw-r--r--xbmc/cores/VideoPlayer/DVDMessage.cpp29
-rw-r--r--xbmc/cores/VideoPlayer/DVDMessage.h6
-rw-r--r--xbmc/cores/VideoPlayer/DVDMessageQueue.cpp4
-rw-r--r--xbmc/cores/VideoPlayer/VideoPlayer.cpp7
-rw-r--r--xbmc/cores/VideoPlayer/VideoPlayerAudio.cpp2
-rw-r--r--xbmc/cores/VideoPlayer/VideoPlayerVideo.cpp8
-rw-r--r--xbmc/cores/VideoPlayer/VideoRenderers/RenderManager.cpp13
-rw-r--r--xbmc/cores/VideoPlayer/VideoRenderers/RenderManager.h5
-rw-r--r--xbmc/dialogs/GUIDialogCache.cpp13
-rw-r--r--xbmc/dialogs/GUIDialogCache.h4
-rw-r--r--xbmc/filesystem/CacheStrategy.cpp14
-rw-r--r--xbmc/filesystem/CacheStrategy.h6
-rw-r--r--xbmc/filesystem/CircularCache.cpp8
-rw-r--r--xbmc/filesystem/CircularCache.h2
-rw-r--r--xbmc/filesystem/FileCache.cpp10
-rw-r--r--xbmc/pvr/guilib/PVRGUIChannelNavigator.cpp41
-rw-r--r--xbmc/windowing/X11/WinEventsX11.cpp4
-rw-r--r--xbmc/windowing/X11/WinEventsX11.h2
-rw-r--r--xbmc/windowing/X11/WinSystemX11.cpp2
23 files changed, 118 insertions, 92 deletions
diff --git a/xbmc/Application.cpp b/xbmc/Application.cpp
index 083a3c2d41..4386f6ff7c 100644
--- a/xbmc/Application.cpp
+++ b/xbmc/Application.cpp
@@ -2618,7 +2618,8 @@ bool CApplication::PlayMedia(CFileItem& item, const std::string &player, int iPl
}
else if (item.IsPlayList() || item.IsInternetStream())
{
- CGUIDialogCache* dlgCache = new CGUIDialogCache(5000, g_localizeStrings.Get(10214), item.GetLabel());
+ CGUIDialogCache* dlgCache =
+ new CGUIDialogCache(5s, g_localizeStrings.Get(10214), item.GetLabel());
//is or could be a playlist
std::unique_ptr<CPlayList> pPlayList (CPlayListFactory::Create(item));
diff --git a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp
index 20c6987f53..b96cd9e5c7 100644
--- a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp
+++ b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAE.cpp
@@ -2391,8 +2391,10 @@ CSampleBuffer* CActiveAE::SyncStream(CActiveAEStream *stream)
}
}
- int timeout = (stream->m_syncState != CAESyncInfo::AESyncState::SYNC_INSYNC) ? 100 : stream->GetErrorInterval();
- bool newerror = stream->m_syncError.Get(error, std::chrono::milliseconds(timeout));
+ std::chrono::milliseconds timeout = (stream->m_syncState != CAESyncInfo::AESyncState::SYNC_INSYNC)
+ ? 100ms
+ : stream->GetErrorInterval();
+ bool newerror = stream->m_syncError.Get(error, timeout);
if (newerror && fabs(error) > threshold && stream->m_syncState == CAESyncInfo::AESyncState::SYNC_INSYNC)
{
@@ -2548,7 +2550,7 @@ CSampleBuffer* CActiveAE::SyncStream(CActiveAEStream *stream)
stream->m_processingBuffers->SetRR(1.0, m_settings.atempoThreshold);
}
- stream->m_syncError.SetErrorInterval(std::chrono::milliseconds(stream->GetErrorInterval()));
+ stream->m_syncError.SetErrorInterval(stream->GetErrorInterval());
return ret;
}
diff --git a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEStream.cpp b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEStream.cpp
index dbc5bd614e..86a4f98f49 100644
--- a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEStream.cpp
+++ b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEStream.cpp
@@ -51,7 +51,6 @@ CActiveAEStream::CActiveAEStream(AEAudioFormat *format, unsigned int streamid, C
m_pClock = NULL;
m_lastPts = 0;
m_lastPtsJump = 0;
- m_errorInterval = 1000;
m_clockSpeed = 1.0;
}
@@ -197,7 +196,7 @@ double CActiveAEStream::CalcResampleRatio(double error)
double proportional = 0.0;
double proportionaldiv = 2.0;
- proportional = error / GetErrorInterval() / proportionaldiv;
+ proportional = error / GetErrorInterval().count() / proportionaldiv;
double clockspeed = 1.0;
if (m_pClock)
@@ -214,9 +213,9 @@ double CActiveAEStream::CalcResampleRatio(double error)
return ret;
}
-int CActiveAEStream::GetErrorInterval()
+std::chrono::milliseconds CActiveAEStream::GetErrorInterval()
{
- int ret = m_errorInterval;
+ std::chrono::milliseconds ret = m_errorInterval;
double rr = m_processingBuffers->GetRR();
if (rr > 1.02 || rr < 0.98)
ret *= 3;
@@ -269,15 +268,15 @@ unsigned int CActiveAEStream::AddData(const uint8_t* const *data, unsigned int o
{
if (m_lastPtsJump != 0)
{
- int diff = pts - m_lastPtsJump;
+ auto diff = std::chrono::milliseconds(static_cast<int>(pts - m_lastPtsJump));
if (diff > m_errorInterval)
{
- diff += 1000;
- diff = std::min(diff, 6000);
+ diff += 1s;
+ diff = std::min(diff, 6000ms);
CLog::Log(LOGINFO,
"CActiveAEStream::AddData - messy timestamps, increasing interval for "
"measuring average error to {} ms",
- diff);
+ diff.count());
m_errorInterval = diff;
}
}
diff --git a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEStream.h b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEStream.h
index 926abc6aa0..b7502d5662 100644
--- a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEStream.h
+++ b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEStream.h
@@ -141,7 +141,7 @@ protected:
void InitRemapper();
void RemapBuffer();
double CalcResampleRatio(double error);
- int GetErrorInterval();
+ std::chrono::milliseconds GetErrorInterval();
public:
unsigned int GetSpace() override;
@@ -210,7 +210,7 @@ protected:
IAEResample *m_remapper;
double m_lastPts;
double m_lastPtsJump;
- std::atomic_int m_errorInterval;
+ std::chrono::milliseconds m_errorInterval{1000};
// only accessed by engine
CActiveAEBufferPool *m_inputBuffers;
diff --git a/xbmc/cores/VideoPlayer/DVDMessage.cpp b/xbmc/cores/VideoPlayer/DVDMessage.cpp
index 4d81599de0..50a319c327 100644
--- a/xbmc/cores/VideoPlayer/DVDMessage.cpp
+++ b/xbmc/cores/VideoPlayer/DVDMessage.cpp
@@ -17,25 +17,27 @@
#include <algorithm>
+using namespace std::chrono_literals;
+
class CDVDMsgGeneralSynchronizePriv
{
public:
- CDVDMsgGeneralSynchronizePriv(unsigned int timeout, unsigned int sources)
- : sources(sources), reached(0), timeout(std::chrono::milliseconds(timeout))
+ CDVDMsgGeneralSynchronizePriv(std::chrono::milliseconds timeout, unsigned int sources)
+ : sources(sources), reached(0), m_timer(timeout)
{}
unsigned int sources;
unsigned int reached;
CCriticalSection section;
XbmcThreads::ConditionVariable condition;
- XbmcThreads::EndTime<> timeout;
+ XbmcThreads::EndTime<> m_timer;
};
/**
* CDVDMsgGeneralSynchronize --- GENERAL_SYNCRONIZR
*/
-CDVDMsgGeneralSynchronize::CDVDMsgGeneralSynchronize(unsigned int timeout, unsigned int sources) :
- CDVDMsg(GENERAL_SYNCHRONIZE),
- m_p(new CDVDMsgGeneralSynchronizePriv(timeout, sources))
+CDVDMsgGeneralSynchronize::CDVDMsgGeneralSynchronize(std::chrono::milliseconds timeout,
+ unsigned int sources)
+ : CDVDMsg(GENERAL_SYNCHRONIZE), m_p(new CDVDMsgGeneralSynchronizePriv(timeout, sources))
{
}
@@ -46,11 +48,11 @@ CDVDMsgGeneralSynchronize::~CDVDMsgGeneralSynchronize()
delete m_p;
}
-bool CDVDMsgGeneralSynchronize::Wait(unsigned int milliseconds, unsigned int source)
+bool CDVDMsgGeneralSynchronize::Wait(std::chrono::milliseconds timeout, unsigned int source)
{
CSingleLock lock(m_p->section);
- XbmcThreads::EndTime<> timeout{std::chrono::milliseconds(milliseconds)};
+ XbmcThreads::EndTime<> timer{timeout};
m_p->reached |= (source & m_p->sources);
if ((m_p->sources & SYNCSOURCE_ANY) && source)
@@ -60,16 +62,16 @@ bool CDVDMsgGeneralSynchronize::Wait(unsigned int milliseconds, unsigned int sou
while (m_p->reached != m_p->sources)
{
- milliseconds = std::min(m_p->timeout.GetTimeLeft().count(), timeout.GetTimeLeft().count());
- if (m_p->condition.wait(lock, std::chrono::milliseconds(milliseconds)))
+ timeout = std::min(m_p->m_timer.GetTimeLeft(), timer.GetTimeLeft());
+ if (m_p->condition.wait(lock, timeout))
continue;
- if (m_p->timeout.IsTimePast())
+ if (m_p->m_timer.IsTimePast())
{
CLog::Log(LOGDEBUG, "CDVDMsgGeneralSynchronize - global timeout");
return true; // global timeout, we are done
}
- if (timeout.IsTimePast())
+ if (timer.IsTimePast())
{
return false; /* request timeout, should be retried */
}
@@ -79,7 +81,8 @@ bool CDVDMsgGeneralSynchronize::Wait(unsigned int milliseconds, unsigned int sou
void CDVDMsgGeneralSynchronize::Wait(std::atomic<bool>& abort, unsigned int source)
{
- while(!Wait(100, source) && !abort);
+ while (!Wait(100ms, source) && !abort)
+ ;
}
/**
diff --git a/xbmc/cores/VideoPlayer/DVDMessage.h b/xbmc/cores/VideoPlayer/DVDMessage.h
index 60b248f5cb..5b1dcf7602 100644
--- a/xbmc/cores/VideoPlayer/DVDMessage.h
+++ b/xbmc/cores/VideoPlayer/DVDMessage.h
@@ -108,12 +108,12 @@ class CDVDMsgGeneralSynchronizePriv;
class CDVDMsgGeneralSynchronize : public CDVDMsg
{
public:
- CDVDMsgGeneralSynchronize(unsigned int timeout, unsigned int sources);
- ~CDVDMsgGeneralSynchronize() override;
+ CDVDMsgGeneralSynchronize(std::chrono::milliseconds timeout, unsigned int sources);
+ ~CDVDMsgGeneralSynchronize() override;
// waits until all threads waiting, released the object
// if abort is set somehow
- bool Wait(unsigned int ms, unsigned int source);
+ bool Wait(std::chrono::milliseconds ms, unsigned int source);
void Wait(std::atomic<bool>& abort, unsigned int source);
private:
diff --git a/xbmc/cores/VideoPlayer/DVDMessageQueue.cpp b/xbmc/cores/VideoPlayer/DVDMessageQueue.cpp
index a6e1bfef26..c9069c19b7 100644
--- a/xbmc/cores/VideoPlayer/DVDMessageQueue.cpp
+++ b/xbmc/cores/VideoPlayer/DVDMessageQueue.cpp
@@ -15,6 +15,8 @@
#include <math.h>
+using namespace std::chrono_literals;
+
CDVDMessageQueue::CDVDMessageQueue(const std::string &owner) : m_hEvent(true), m_owner(owner)
{
m_iDataSize = 0;
@@ -296,7 +298,7 @@ void CDVDMessageQueue::WaitUntilEmpty()
}
CLog::Log(LOGINFO, "CDVDMessageQueue({})::WaitUntilEmpty", m_owner);
- auto msg = std::make_shared<CDVDMsgGeneralSynchronize>(40000, SYNCSOURCE_ANY);
+ auto msg = std::make_shared<CDVDMsgGeneralSynchronize>(40s, SYNCSOURCE_ANY);
Put(msg);
msg->Wait(m_bAbortRequest, 0);
diff --git a/xbmc/cores/VideoPlayer/VideoPlayer.cpp b/xbmc/cores/VideoPlayer/VideoPlayer.cpp
index 13ad63952b..62e52089ad 100644
--- a/xbmc/cores/VideoPlayer/VideoPlayer.cpp
+++ b/xbmc/cores/VideoPlayer/VideoPlayer.cpp
@@ -2425,7 +2425,7 @@ void CVideoPlayer::SynchronizeDemuxer()
if(!m_messenger.IsInited())
return;
- auto message = std::make_shared<CDVDMsgGeneralSynchronize>(500, SYNCSOURCE_PLAYER);
+ auto message = std::make_shared<CDVDMsgGeneralSynchronize>(500ms, SYNCSOURCE_PLAYER);
m_messenger.Put(message);
message->Wait(m_bStop, 0);
}
@@ -2981,7 +2981,7 @@ void CVideoPlayer::HandleMessages()
}
else if (pMsg->IsType(CDVDMsg::GENERAL_SYNCHRONIZE))
{
- if (std::static_pointer_cast<CDVDMsgGeneralSynchronize>(pMsg)->Wait(100, SYNCSOURCE_PLAYER))
+ if (std::static_pointer_cast<CDVDMsgGeneralSynchronize>(pMsg)->Wait(100ms, SYNCSOURCE_PLAYER))
CLog::Log(LOGDEBUG, "CVideoPlayer - CDVDMsg::GENERAL_SYNCHRONIZE");
}
else if (pMsg->IsType(CDVDMsg::PLAYER_AVCHANGE))
@@ -3883,8 +3883,7 @@ void CVideoPlayer::FlushBuffers(double pts, bool accurate, bool sync)
m_playSpeed == DVD_PLAYSPEED_PAUSE)
{
// make sure players are properly flushed, should put them in stalled state
- auto msg =
- std::make_shared<CDVDMsgGeneralSynchronize>(1000, SYNCSOURCE_AUDIO | SYNCSOURCE_VIDEO);
+ auto msg = std::make_shared<CDVDMsgGeneralSynchronize>(1s, SYNCSOURCE_AUDIO | SYNCSOURCE_VIDEO);
m_VideoPlayerAudio->SendMessage(msg, 1);
m_VideoPlayerVideo->SendMessage(msg, 1);
msg->Wait(m_bStop, 0);
diff --git a/xbmc/cores/VideoPlayer/VideoPlayerAudio.cpp b/xbmc/cores/VideoPlayer/VideoPlayerAudio.cpp
index f04ec55ad6..afb4abade5 100644
--- a/xbmc/cores/VideoPlayer/VideoPlayerAudio.cpp
+++ b/xbmc/cores/VideoPlayer/VideoPlayerAudio.cpp
@@ -286,7 +286,7 @@ void CVideoPlayerAudio::Process()
// handle messages
if (pMsg->IsType(CDVDMsg::GENERAL_SYNCHRONIZE))
{
- if (std::static_pointer_cast<CDVDMsgGeneralSynchronize>(pMsg)->Wait(100, SYNCSOURCE_AUDIO))
+ if (std::static_pointer_cast<CDVDMsgGeneralSynchronize>(pMsg)->Wait(100ms, SYNCSOURCE_AUDIO))
CLog::Log(LOGDEBUG, "CVideoPlayerAudio - CDVDMsg::GENERAL_SYNCHRONIZE");
else
m_messageQueue.Put(pMsg, 1); // push back as prio message, to process other prio messages
diff --git a/xbmc/cores/VideoPlayer/VideoPlayerVideo.cpp b/xbmc/cores/VideoPlayer/VideoPlayerVideo.cpp
index f3a833a2aa..28cb58c9d5 100644
--- a/xbmc/cores/VideoPlayer/VideoPlayerVideo.cpp
+++ b/xbmc/cores/VideoPlayer/VideoPlayerVideo.cpp
@@ -402,7 +402,7 @@ void CVideoPlayerVideo::Process()
if (pMsg->IsType(CDVDMsg::GENERAL_SYNCHRONIZE))
{
- if (std::static_pointer_cast<CDVDMsgGeneralSynchronize>(pMsg)->Wait(100, SYNCSOURCE_VIDEO))
+ if (std::static_pointer_cast<CDVDMsgGeneralSynchronize>(pMsg)->Wait(100ms, SYNCSOURCE_VIDEO))
{
CLog::Log(LOGDEBUG, "CVideoPlayerVideo - CDVDMsg::GENERAL_SYNCHRONIZE");
}
@@ -907,13 +907,13 @@ CVideoPlayerVideo::EOutputState CVideoPlayerVideo::OutputPicture(const VideoPict
return OUTPUT_DROPPED;
}
- int timeToDisplay = DVD_TIME_TO_MSEC(pPicture->pts - iPlayingClock);
+ auto timeToDisplay = std::chrono::milliseconds(DVD_TIME_TO_MSEC(pPicture->pts - iPlayingClock));
// make sure waiting time is not negative
- int maxWaitTime = std::min(std::max(timeToDisplay + 500, 50), 500);
+ std::chrono::milliseconds maxWaitTime = std::min(std::max(timeToDisplay + 500ms, 50ms), 500ms);
// don't wait when going ff
if (m_speed > DVD_PLAYSPEED_NORMAL)
- maxWaitTime = std::max(timeToDisplay, 0);
+ maxWaitTime = std::max(timeToDisplay, 0ms);
int buffer = m_renderManager.WaitForBuffer(m_bAbortOutput, maxWaitTime);
if (buffer < 0)
{
diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/RenderManager.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/RenderManager.cpp
index 7355b6a51f..0ed615657b 100644
--- a/xbmc/cores/VideoPlayer/VideoRenderers/RenderManager.cpp
+++ b/xbmc/cores/VideoPlayer/VideoRenderers/RenderManager.cpp
@@ -260,9 +260,9 @@ void CRenderManager::ShowVideo(bool enable)
DiscardBuffer();
}
-void CRenderManager::FrameWait(int ms)
+void CRenderManager::FrameWait(std::chrono::milliseconds duration)
{
- XbmcThreads::EndTime<> timeout{std::chrono::milliseconds(ms)};
+ XbmcThreads::EndTime<> timeout{duration};
CSingleLock lock(m_presentlock);
while(m_presentstep == PRESENT_IDLE && !timeout.IsTimePast())
m_presentevent.wait(lock, timeout.GetTimeLeft());
@@ -297,7 +297,7 @@ void CRenderManager::FrameMove()
return;
firstFrame = true;
- FrameWait(50);
+ FrameWait(50ms);
}
CheckEnableClockSync();
@@ -1069,7 +1069,8 @@ bool CRenderManager::Supports(ESCALINGMETHOD method)
return false;
}
-int CRenderManager::WaitForBuffer(volatile std::atomic_bool&bStop, int timeout)
+int CRenderManager::WaitForBuffer(volatile std::atomic_bool& bStop,
+ std::chrono::milliseconds timeout)
{
CSingleLock lock(m_presentlock);
@@ -1097,10 +1098,10 @@ int CRenderManager::WaitForBuffer(volatile std::atomic_bool&bStop, int timeout)
return 0;
}
- XbmcThreads::EndTime<> endtime{std::chrono::milliseconds(timeout)};
+ XbmcThreads::EndTime<> endtime{timeout};
while(m_free.empty())
{
- m_presentevent.wait(lock, std::min(50ms, std::chrono::milliseconds(timeout)));
+ m_presentevent.wait(lock, std::min(50ms, timeout));
if (endtime.IsTimePast() || bStop)
{
return -1;
diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/RenderManager.h b/xbmc/cores/VideoPlayer/VideoRenderers/RenderManager.h
index d50a55eed3..7900db734c 100644
--- a/xbmc/cores/VideoPlayer/VideoRenderers/RenderManager.h
+++ b/xbmc/cores/VideoPlayer/VideoRenderers/RenderManager.h
@@ -61,7 +61,7 @@ public:
void GetVideoRect(CRect &source, CRect &dest, CRect &view);
float GetAspectRatio();
void FrameMove();
- void FrameWait(int ms);
+ void FrameWait(std::chrono::milliseconds duration);
void Render(bool clear, DWORD flags = 0, DWORD alpha = 255, bool gui = true);
bool IsVideoLayer();
RESOLUTION GetResolution();
@@ -97,7 +97,8 @@ public:
* in case no buffer is available. Player may call this in a loop and decides
* by itself when it wants to drop a frame.
*/
- int WaitForBuffer(volatile std::atomic_bool& bStop, int timeout = 100);
+ int WaitForBuffer(volatile std::atomic_bool& bStop,
+ std::chrono::milliseconds timeout = std::chrono::milliseconds(100));
/**
* Can be called by player for lateness detection. This is done best by
diff --git a/xbmc/dialogs/GUIDialogCache.cpp b/xbmc/dialogs/GUIDialogCache.cpp
index 73cf6554a7..a80e6e45e7 100644
--- a/xbmc/dialogs/GUIDialogCache.cpp
+++ b/xbmc/dialogs/GUIDialogCache.cpp
@@ -23,9 +23,10 @@
using namespace KODI::MESSAGING;
using namespace std::chrono_literals;
-CGUIDialogCache::CGUIDialogCache(DWORD dwDelay, const std::string& strHeader, const std::string& strMsg) : CThread("GUIDialogCache"),
- m_strHeader(strHeader),
- m_strLinePrev(strMsg)
+CGUIDialogCache::CGUIDialogCache(std::chrono::milliseconds delay,
+ const std::string& strHeader,
+ const std::string& strMsg)
+ : CThread("GUIDialogCache"), m_strHeader(strHeader), m_strLinePrev(strMsg)
{
bSentCancel = false;
@@ -36,12 +37,12 @@ CGUIDialogCache::CGUIDialogCache(DWORD dwDelay, const std::string& strHeader, co
/* if progress dialog is already running, take it over */
if( m_pDlg->IsDialogRunning() )
- dwDelay = 0;
+ delay = 0ms;
- if(dwDelay == 0)
+ if (delay == 0ms)
OpenDialog();
else
- m_endtime.Set(std::chrono::milliseconds(static_cast<unsigned int>(dwDelay)));
+ m_endtime.Set(delay);
Create(true);
}
diff --git a/xbmc/dialogs/GUIDialogCache.h b/xbmc/dialogs/GUIDialogCache.h
index a705cd05e5..9d8e58e572 100644
--- a/xbmc/dialogs/GUIDialogCache.h
+++ b/xbmc/dialogs/GUIDialogCache.h
@@ -19,7 +19,9 @@ class CGUIDialogProgress;
class CGUIDialogCache : public CThread, public XFILE::IFileCallback
{
public:
- CGUIDialogCache(DWORD dwDelay = 0, const std::string& strHeader="", const std::string& strMsg="");
+ CGUIDialogCache(std::chrono::milliseconds delay = std::chrono::milliseconds(100),
+ const std::string& strHeader = "",
+ const std::string& strMsg = "");
~CGUIDialogCache() override;
void SetHeader(const std::string& strHeader);
void SetHeader(int nHeader);
diff --git a/xbmc/filesystem/CacheStrategy.cpp b/xbmc/filesystem/CacheStrategy.cpp
index dcb8e23f36..7aaeec9fde 100644
--- a/xbmc/filesystem/CacheStrategy.cpp
+++ b/xbmc/filesystem/CacheStrategy.cpp
@@ -30,6 +30,8 @@
using namespace XFILE;
+using namespace std::chrono_literals;
+
CCacheStrategy::~CCacheStrategy() = default;
void CCacheStrategy::EndOfInput() {
@@ -180,12 +182,12 @@ int CSimpleFileCache::ReadFromCache(char *pBuffer, size_t iMaxSize)
return readBytes;
}
-int64_t CSimpleFileCache::WaitForData(uint32_t iMinAvail, uint32_t iMillis)
+int64_t CSimpleFileCache::WaitForData(uint32_t iMinAvail, std::chrono::milliseconds timeout)
{
- if( iMillis == 0 || IsEndOfInput() )
+ if (timeout == 0ms || IsEndOfInput())
return GetAvailableRead();
- XbmcThreads::EndTime<> endTime{std::chrono::milliseconds(iMillis)};
+ XbmcThreads::EndTime<> endTime{timeout};
while (!IsEndOfInput())
{
int64_t iAvail = GetAvailableRead();
@@ -219,7 +221,7 @@ int64_t CSimpleFileCache::Seek(int64_t iFilePosition)
}
if (nDiff > 0 &&
- WaitForData(static_cast<uint32_t>(iTarget - m_nReadPosition), 5000) == CACHE_RC_TIMEOUT)
+ WaitForData(static_cast<uint32_t>(iTarget - m_nReadPosition), 5s) == CACHE_RC_TIMEOUT)
{
CLog::Log(LOGDEBUG, "CSimpleFileCache::{} - <{}> Wait for position {} failed. Ended up at {}",
__FUNCTION__, m_filename, iFilePosition, m_nWritePosition);
@@ -330,9 +332,9 @@ int CDoubleCache::ReadFromCache(char *pBuffer, size_t iMaxSize)
return m_pCache->ReadFromCache(pBuffer, iMaxSize);
}
-int64_t CDoubleCache::WaitForData(uint32_t iMinAvail, uint32_t iMillis)
+int64_t CDoubleCache::WaitForData(uint32_t iMinAvail, std::chrono::milliseconds timeout)
{
- return m_pCache->WaitForData(iMinAvail, iMillis);
+ return m_pCache->WaitForData(iMinAvail, timeout);
}
int64_t CDoubleCache::Seek(int64_t iFilePosition)
diff --git a/xbmc/filesystem/CacheStrategy.h b/xbmc/filesystem/CacheStrategy.h
index 72d8224f62..76c66bb454 100644
--- a/xbmc/filesystem/CacheStrategy.h
+++ b/xbmc/filesystem/CacheStrategy.h
@@ -32,7 +32,7 @@ public:
virtual size_t GetMaxWriteSize(const size_t& iRequestSize) = 0;
virtual int WriteToCache(const char *pBuffer, size_t iSize) = 0;
virtual int ReadFromCache(char *pBuffer, size_t iMaxSize) = 0;
- virtual int64_t WaitForData(uint32_t iMinAvail, uint32_t iMillis) = 0;
+ virtual int64_t WaitForData(uint32_t iMinAvail, std::chrono::milliseconds timeout) = 0;
virtual int64_t Seek(int64_t iFilePosition) = 0;
@@ -73,7 +73,7 @@ public:
size_t GetMaxWriteSize(const size_t& iRequestSize) override;
int WriteToCache(const char *pBuffer, size_t iSize) override;
int ReadFromCache(char *pBuffer, size_t iMaxSize) override;
- int64_t WaitForData(uint32_t iMinAvail, uint32_t iMillis) override;
+ int64_t WaitForData(uint32_t iMinAvail, std::chrono::milliseconds timeout) override;
int64_t Seek(int64_t iFilePosition) override;
bool Reset(int64_t iSourcePosition) override;
@@ -109,7 +109,7 @@ public:
size_t GetMaxWriteSize(const size_t& iRequestSize) override;
int WriteToCache(const char *pBuffer, size_t iSize) override;
int ReadFromCache(char *pBuffer, size_t iMaxSize) override;
- int64_t WaitForData(uint32_t iMinAvail, uint32_t iMillis) override;
+ int64_t WaitForData(uint32_t iMinAvail, std::chrono::milliseconds timeout) override;
int64_t Seek(int64_t iFilePosition) override;
bool Reset(int64_t iSourcePosition) override;
diff --git a/xbmc/filesystem/CircularCache.cpp b/xbmc/filesystem/CircularCache.cpp
index ecedbb2c50..154caa5243 100644
--- a/xbmc/filesystem/CircularCache.cpp
+++ b/xbmc/filesystem/CircularCache.cpp
@@ -181,18 +181,18 @@ int CCircularCache::ReadFromCache(char *buf, size_t len)
* Note that caller needs to make sure there's sufficient space in the forward
* buffer for "minimum" bytes else we may block the full timeout time
*/
-int64_t CCircularCache::WaitForData(uint32_t minimum, uint32_t millis)
+int64_t CCircularCache::WaitForData(uint32_t minimum, std::chrono::milliseconds timeout)
{
CSingleLock lock(m_sync);
int64_t avail = m_end - m_cur;
- if(millis == 0 || IsEndOfInput())
+ if (timeout == 0ms || IsEndOfInput())
return avail;
if(minimum > m_size - m_size_back)
minimum = m_size - m_size_back;
- XbmcThreads::EndTime<> endtime{std::chrono::milliseconds(millis)};
+ XbmcThreads::EndTime<> endtime{timeout};
while (!IsEndOfInput() && avail < minimum && !endtime.IsTimePast() )
{
lock.Leave();
@@ -219,7 +219,7 @@ int64_t CCircularCache::Seek(int64_t pos)
m_cur = m_end;
lock.Leave();
- WaitForData((size_t)(pos - m_cur), 5000);
+ WaitForData((size_t)(pos - m_cur), 5s);
lock.Enter();
if (pos < m_beg || pos > m_end)
diff --git a/xbmc/filesystem/CircularCache.h b/xbmc/filesystem/CircularCache.h
index 1dd9ccaeb1..21d3e6b10b 100644
--- a/xbmc/filesystem/CircularCache.h
+++ b/xbmc/filesystem/CircularCache.h
@@ -26,7 +26,7 @@ public:
size_t GetMaxWriteSize(const size_t& iRequestSize) override;
int WriteToCache(const char *buf, size_t len) override;
int ReadFromCache(char *buf, size_t len) override;
- int64_t WaitForData(uint32_t minimum, uint32_t iMillis) override;
+ int64_t WaitForData(uint32_t minimum, std::chrono::milliseconds timeout) override;
int64_t Seek(int64_t pos) override;
bool Reset(int64_t pos) override;
diff --git a/xbmc/filesystem/FileCache.cpp b/xbmc/filesystem/FileCache.cpp
index 1b612fe9d9..a8c059a8f7 100644
--- a/xbmc/filesystem/FileCache.cpp
+++ b/xbmc/filesystem/FileCache.cpp
@@ -334,7 +334,7 @@ void CFileCache::Process()
if (iRead <= 0)
{
// Check for actual EOF and retry as long as we still have data in our cache
- if (m_writePos < m_fileSize && m_pCache->WaitForData(0, 0) > 0)
+ if (m_writePos < m_fileSize && m_pCache->WaitForData(0, 0ms) > 0)
{
CLog::Log(LOGWARNING, "CFileCache::{} - <{}> source read returned {}! Will retry",
__FUNCTION__, m_sourcePath, iRead);
@@ -424,7 +424,7 @@ void CFileCache::Process()
*/
if (m_bFilling && m_forwardCacheSize != 0)
{
- const int64_t forward = m_pCache->WaitForData(0, 0);
+ const int64_t forward = m_pCache->WaitForData(0, 0ms);
if (forward + m_chunkSize >= m_forwardCacheSize)
{
if (m_writeRateActual < m_writeRate)
@@ -484,7 +484,7 @@ retry:
if (iRc == CACHE_RC_WOULD_BLOCK)
{
// just wait for some data to show up
- iRc = m_pCache->WaitForData(1, 10000);
+ iRc = m_pCache->WaitForData(1, 10s);
if (iRc > 0)
goto retry;
}
@@ -549,7 +549,7 @@ int64_t CFileCache::Seek(int64_t iFilePosition, int iWhence)
{
CLog::Log(LOGDEBUG, "CFileCache::{} - <{}> waiting for position {}", __FUNCTION__,
m_sourcePath, iTarget);
- if (m_pCache->WaitForData(static_cast<uint32_t>(iTarget - m_seekPos), 10000) <
+ if (m_pCache->WaitForData(static_cast<uint32_t>(iTarget - m_seekPos), 10s) <
iTarget - m_seekPos)
{
CLog::Log(LOGWARNING, "CFileCache::{} - <{}> failed to get remaining data", __FUNCTION__,
@@ -609,7 +609,7 @@ int CFileCache::IoControl(EIoControl request, void* param)
if (request == IOCTRL_CACHE_STATUS)
{
SCacheStatus* status = (SCacheStatus*)param;
- status->forward = m_pCache->WaitForData(0, 0);
+ status->forward = m_pCache->WaitForData(0, 0ms);
status->maxrate = m_writeRate;
status->currate = m_writeRateActual;
status->lowrate = m_writeRateLowSpeed;
diff --git a/xbmc/pvr/guilib/PVRGUIChannelNavigator.cpp b/xbmc/pvr/guilib/PVRGUIChannelNavigator.cpp
index 21023d8e00..ba55de4c1b 100644
--- a/xbmc/pvr/guilib/PVRGUIChannelNavigator.cpp
+++ b/xbmc/pvr/guilib/PVRGUIChannelNavigator.cpp
@@ -24,16 +24,19 @@
#include "utils/JobManager.h"
#include "utils/XTimeUtils.h"
+using namespace std::chrono_literals;
+
namespace
{
class CPVRChannelTimeoutJobBase : public CJob, public IJobCallback
{
public:
CPVRChannelTimeoutJobBase() = delete;
- CPVRChannelTimeoutJobBase(PVR::CPVRGUIChannelNavigator& channelNavigator, int iTimeout)
- : m_channelNavigator(channelNavigator)
+ CPVRChannelTimeoutJobBase(PVR::CPVRGUIChannelNavigator& channelNavigator,
+ std::chrono::milliseconds timeout)
+ : m_channelNavigator(channelNavigator)
{
- m_delayTimer.Set(std::chrono::milliseconds(iTimeout));
+ m_delayTimer.Set(timeout);
}
~CPVRChannelTimeoutJobBase() override = default;
@@ -66,8 +69,11 @@ private:
class CPVRChannelEntryTimeoutJob : public CPVRChannelTimeoutJobBase
{
public:
- CPVRChannelEntryTimeoutJob(PVR::CPVRGUIChannelNavigator& channelNavigator, int iTimeout)
- : CPVRChannelTimeoutJobBase(channelNavigator, iTimeout) {}
+ CPVRChannelEntryTimeoutJob(PVR::CPVRGUIChannelNavigator& channelNavigator,
+ std::chrono::milliseconds timeout)
+ : CPVRChannelTimeoutJobBase(channelNavigator, timeout)
+ {
+ }
~CPVRChannelEntryTimeoutJob() override = default;
const char* GetType() const override { return "pvr-channel-entry-timeout-job"; }
void OnTimeout() override { m_channelNavigator.SwitchToCurrentChannel(); }
@@ -76,8 +82,11 @@ public:
class CPVRChannelInfoTimeoutJob : public CPVRChannelTimeoutJobBase
{
public:
- CPVRChannelInfoTimeoutJob(PVR::CPVRGUIChannelNavigator& channelNavigator, int iTimeout)
- : CPVRChannelTimeoutJobBase(channelNavigator, iTimeout) {}
+ CPVRChannelInfoTimeoutJob(PVR::CPVRGUIChannelNavigator& channelNavigator,
+ std::chrono::milliseconds timeout)
+ : CPVRChannelTimeoutJobBase(channelNavigator, timeout)
+ {
+ }
~CPVRChannelInfoTimeoutJob() override = default;
const char* GetType() const override { return "pvr-channel-info-timeout-job"; }
void OnTimeout() override { m_channelNavigator.HideInfo(); }
@@ -144,14 +153,16 @@ namespace PVR
if (IsPreview() && eSwitchMode == ChannelSwitchMode::INSTANT_OR_DELAYED_SWITCH)
{
- int iTimeout = CServiceBroker::GetSettingsComponent()->GetSettings()->GetInt(CSettings::SETTING_PVRPLAYBACK_CHANNELENTRYTIMEOUT);
- if (iTimeout > 0)
+ auto timeout =
+ std::chrono::milliseconds(CServiceBroker::GetSettingsComponent()->GetSettings()->GetInt(
+ CSettings::SETTING_PVRPLAYBACK_CHANNELENTRYTIMEOUT));
+ if (timeout > 0ms)
{
// delayed switch
if (m_iChannelEntryJobId >= 0)
CJobManager::GetInstance().CancelJob(m_iChannelEntryJobId);
- CPVRChannelEntryTimeoutJob* job = new CPVRChannelEntryTimeoutJob(*this, iTimeout);
+ CPVRChannelEntryTimeoutJob* job = new CPVRChannelEntryTimeoutJob(*this, timeout);
m_iChannelEntryJobId = CJobManager::GetInstance().AddJob(job, dynamic_cast<IJobCallback*>(job));
}
else
@@ -200,9 +211,11 @@ namespace PVR
void CPVRGUIChannelNavigator::ShowInfo(bool bForce)
{
- int iTimeout = CServiceBroker::GetSettingsComponent()->GetSettings()->GetInt(CSettings::SETTING_PVRMENU_DISPLAYCHANNELINFO);
+ auto timeout =
+ std::chrono::seconds(CServiceBroker::GetSettingsComponent()->GetSettings()->GetInt(
+ CSettings::SETTING_PVRMENU_DISPLAYCHANNELINFO));
- if (bForce || iTimeout > 0)
+ if (bForce || timeout > 0s)
{
CServiceBroker::GetGUI()->GetInfoManager().GetInfoProviders().GetPlayerInfoProvider().SetShowInfo(true);
@@ -214,9 +227,9 @@ namespace PVR
m_iChannelInfoJobId = -1;
}
- if (!bForce && iTimeout > 0)
+ if (!bForce && timeout > 0s)
{
- CPVRChannelInfoTimeoutJob* job = new CPVRChannelInfoTimeoutJob(*this, iTimeout * 1000);
+ CPVRChannelInfoTimeoutJob* job = new CPVRChannelInfoTimeoutJob(*this, timeout);
m_iChannelInfoJobId = CJobManager::GetInstance().AddJob(job, dynamic_cast<IJobCallback*>(job));
}
}
diff --git a/xbmc/windowing/X11/WinEventsX11.cpp b/xbmc/windowing/X11/WinEventsX11.cpp
index 426f70e894..bbd01b5c97 100644
--- a/xbmc/windowing/X11/WinEventsX11.cpp
+++ b/xbmc/windowing/X11/WinEventsX11.cpp
@@ -269,12 +269,12 @@ bool CWinEventsX11::HasStructureChanged()
return ret;
}
-void CWinEventsX11::SetXRRFailSafeTimer(int millis)
+void CWinEventsX11::SetXRRFailSafeTimer(std::chrono::milliseconds duration)
{
if (!m_display)
return;
- m_xrrFailSafeTimer.Set(std::chrono::milliseconds(millis));
+ m_xrrFailSafeTimer.Set(duration);
m_xrrEventPending = true;
}
diff --git a/xbmc/windowing/X11/WinEventsX11.h b/xbmc/windowing/X11/WinEventsX11.h
index b14440897f..b2111dabbf 100644
--- a/xbmc/windowing/X11/WinEventsX11.h
+++ b/xbmc/windowing/X11/WinEventsX11.h
@@ -34,7 +34,7 @@ public:
void Quit();
bool HasStructureChanged();
void PendingResize(int width, int height);
- void SetXRRFailSafeTimer(int millis);
+ void SetXRRFailSafeTimer(std::chrono::milliseconds duration);
protected:
XBMCKey LookupXbmcKeySym(KeySym keysym);
diff --git a/xbmc/windowing/X11/WinSystemX11.cpp b/xbmc/windowing/X11/WinSystemX11.cpp
index 89c32e7fc6..ec87bf267b 100644
--- a/xbmc/windowing/X11/WinSystemX11.cpp
+++ b/xbmc/windowing/X11/WinSystemX11.cpp
@@ -631,7 +631,7 @@ void CWinSystemX11::OnLostDevice()
(*i)->OnLostDisplay();
}
- m_winEventsX11->SetXRRFailSafeTimer(3000);
+ m_winEventsX11->SetXRRFailSafeTimer(3s);
}
void CWinSystemX11::Register(IDispResource *resource)