diff --git a/xbmc/AutoSwitch.cpp b/xbmc/AutoSwitch.cpp index cd12746a311e9..e2bb56c5904be 100644 --- a/xbmc/AutoSwitch.cpp +++ b/xbmc/AutoSwitch.cpp @@ -238,5 +238,5 @@ float CAutoSwitch::MetadataPercentage(const CFileItemList &vecItems) if(item->IsParentFolder()) total--; } - return (float)count / total; + return (total != 0) ? ((float)count / total) : 0.0f; } diff --git a/xbmc/cores/VideoPlayer/DVDMessage.cpp b/xbmc/cores/VideoPlayer/DVDMessage.cpp index 5aed6918d217d..0dcc664fd8627 100644 --- a/xbmc/cores/VideoPlayer/DVDMessage.cpp +++ b/xbmc/cores/VideoPlayer/DVDMessage.cpp @@ -88,13 +88,9 @@ bool CDVDMsgGeneralSynchronize::Wait(unsigned int milliseconds, unsigned int sou return true; } -void CDVDMsgGeneralSynchronize::Wait(volatile bool *abort, unsigned int source) +void CDVDMsgGeneralSynchronize::Wait(std::atomic& abort, unsigned int source) { - while(!Wait(100, source)) - { - if(abort && *abort) - return; - } + while(!Wait(100, source) && !abort); } long CDVDMsgGeneralSynchronize::Release() diff --git a/xbmc/cores/VideoPlayer/DVDMessage.h b/xbmc/cores/VideoPlayer/DVDMessage.h index dadc64052b568..55187210949c0 100644 --- a/xbmc/cores/VideoPlayer/DVDMessage.h +++ b/xbmc/cores/VideoPlayer/DVDMessage.h @@ -30,6 +30,7 @@ // include as less is possible to prevent dependencies #include "DVDResource.h" +#include #include #include @@ -148,8 +149,8 @@ class CDVDMsgGeneralSynchronize : public CDVDMsg // waits until all threads waiting, released the object // if abort is set somehow - bool Wait(unsigned int ms , unsigned int source); - void Wait(volatile bool *abort, unsigned int source); + bool Wait(unsigned int ms , unsigned int source); + void Wait(std::atomic& abort, unsigned int source); private: class CDVDMsgGeneralSynchronizePriv* m_p; }; diff --git a/xbmc/cores/VideoPlayer/DVDMessageQueue.cpp b/xbmc/cores/VideoPlayer/DVDMessageQueue.cpp index aeefd77cf8504..8d82d91922e29 100644 --- a/xbmc/cores/VideoPlayer/DVDMessageQueue.cpp +++ b/xbmc/cores/VideoPlayer/DVDMessageQueue.cpp @@ -246,7 +246,7 @@ void CDVDMessageQueue::WaitUntilEmpty() CLog::Log(LOGNOTICE, "CDVDMessageQueue(%s)::WaitUntilEmpty", m_owner.c_str()); CDVDMsgGeneralSynchronize* msg = new CDVDMsgGeneralSynchronize(40000, 0); Put(msg->Acquire()); - msg->Wait(&m_bAbortRequest, 0); + msg->Wait(m_bAbortRequest, 0); msg->Release(); } diff --git a/xbmc/cores/VideoPlayer/DVDMessageQueue.h b/xbmc/cores/VideoPlayer/DVDMessageQueue.h index 41b535a46c572..814883e594cff 100644 --- a/xbmc/cores/VideoPlayer/DVDMessageQueue.h +++ b/xbmc/cores/VideoPlayer/DVDMessageQueue.h @@ -21,6 +21,7 @@ */ #include "DVDMessage.h" +#include #include #include #include @@ -111,7 +112,7 @@ class CDVDMessageQueue CEvent m_hEvent; mutable CCriticalSection m_section; - bool m_bAbortRequest; + std::atomic m_bAbortRequest; bool m_bInitialized; int m_iDataSize; diff --git a/xbmc/cores/VideoPlayer/VideoPlayer.cpp b/xbmc/cores/VideoPlayer/VideoPlayer.cpp index cb62c52ce0261..f8e307922fc64 100644 --- a/xbmc/cores/VideoPlayer/VideoPlayer.cpp +++ b/xbmc/cores/VideoPlayer/VideoPlayer.cpp @@ -2368,7 +2368,7 @@ void CVideoPlayer::SynchronizeDemuxer(unsigned int timeout) CDVDMsgGeneralSynchronize* message = new CDVDMsgGeneralSynchronize(timeout, 0); m_messenger.Put(message->Acquire()); - message->Wait(&m_bStop, 0); + message->Wait(m_bStop, 0); message->Release(); } @@ -3922,7 +3922,7 @@ void CVideoPlayer::FlushBuffers(bool queued, double pts, bool accurate, bool syn CDVDMsgGeneralSynchronize* msg = new CDVDMsgGeneralSynchronize(1000, 0); m_VideoPlayerAudio->SendMessage(msg->Acquire(), 1); m_VideoPlayerVideo->SendMessage(msg->Acquire(), 1); - msg->Wait(&m_bStop, 0); + msg->Wait(m_bStop, 0); msg->Release(); // purge any pending PLAYER_STARTED messages diff --git a/xbmc/dialogs/GUIDialogKeyboardGeneric.h b/xbmc/dialogs/GUIDialogKeyboardGeneric.h index 1694733dbe727..5fd5b93e7fdd6 100644 --- a/xbmc/dialogs/GUIDialogKeyboardGeneric.h +++ b/xbmc/dialogs/GUIDialogKeyboardGeneric.h @@ -87,7 +87,7 @@ class CGUIDialogKeyboardGeneric : public CGUIDialog, public CGUIKeyboard std::string m_strHeading; std::string m_text; ///< current text - IInputCodingTable *m_codingtable; + IInputCodingTablePtr m_codingtable; std::vector m_words; std::string m_hzcode; int m_pos; diff --git a/xbmc/guilib/GUIFontCache.cpp b/xbmc/guilib/GUIFontCache.cpp index 72717be5a2e68..20e2f94cf21df 100644 --- a/xbmc/guilib/GUIFontCache.cpp +++ b/xbmc/guilib/GUIFontCache.cpp @@ -32,6 +32,10 @@ class CGUIFontCacheImpl using HashIter = typename HashMap::iterator; using AgeMap = std::multimap; + ~EntryList() + { + Flush(); + } HashIter Insert(size_t hash, CGUIFontCacheEntry *v) { auto r (hashMap.insert(typename HashMap::value_type(hash, v))); diff --git a/xbmc/input/InputCodingTable.h b/xbmc/input/InputCodingTable.h index 0bdd96a8df53d..e380887fdd4e7 100644 --- a/xbmc/input/InputCodingTable.h +++ b/xbmc/input/InputCodingTable.h @@ -21,6 +21,7 @@ */ #include +#include #include class IInputCodingTable @@ -58,3 +59,5 @@ class IInputCodingTable protected: std::string m_codechars; }; + +typedef std::shared_ptr IInputCodingTablePtr; diff --git a/xbmc/input/KeyboardLayout.cpp b/xbmc/input/KeyboardLayout.cpp index e4b5b1cf147f3..30717de8f8712 100644 --- a/xbmc/input/KeyboardLayout.cpp +++ b/xbmc/input/KeyboardLayout.cpp @@ -69,7 +69,7 @@ bool CKeyboardLayout::Load(const TiXmlElement* element) const TiXmlElement *keyboard = element->FirstChildElement("keyboard"); if (element->Attribute("codingtable")) - m_codingtable = CInputCodingTableFactory::CreateCodingTable(element->Attribute("codingtable"), element); + m_codingtable = IInputCodingTablePtr(CInputCodingTableFactory::CreateCodingTable(element->Attribute("codingtable"), element)); else m_codingtable = NULL; while (keyboard != NULL) diff --git a/xbmc/input/KeyboardLayout.h b/xbmc/input/KeyboardLayout.h index def9fe18d0099..fd3cd836b75aa 100644 --- a/xbmc/input/KeyboardLayout.h +++ b/xbmc/input/KeyboardLayout.h @@ -23,15 +23,16 @@ #include #include +#include "InputCodingTable.h" + class TiXmlElement; -class IInputCodingTable; class CKeyboardLayout { public: CKeyboardLayout(); virtual ~CKeyboardLayout(); - IInputCodingTable* GetCodingTable() { return m_codingtable; } + IInputCodingTablePtr GetCodingTable() { return m_codingtable; } bool Load(const TiXmlElement* element); @@ -58,5 +59,5 @@ class CKeyboardLayout std::string m_language; std::string m_layout; Keyboards m_keyboards; - IInputCodingTable* m_codingtable; + IInputCodingTablePtr m_codingtable; }; diff --git a/xbmc/network/EventServer.h b/xbmc/network/EventServer.h index 97869ec51b4c2..72129bfbb9bd2 100644 --- a/xbmc/network/EventServer.h +++ b/xbmc/network/EventServer.h @@ -26,6 +26,7 @@ #include "threads/CriticalSection.h" #include "threads/SingleLock.h" +#include #include #include #include @@ -82,7 +83,7 @@ namespace EVENTSERVER int m_iListenTimeout; int m_iMaxClients; unsigned char* m_pPacketBuffer; - bool m_bRunning; + std::atomic m_bRunning; CCriticalSection m_critSection; bool m_bRefreshSettings; }; diff --git a/xbmc/network/upnp/UPnP.cpp b/xbmc/network/upnp/UPnP.cpp index a8d5f00c8779c..2370ee6edaa2a 100644 --- a/xbmc/network/upnp/UPnP.cpp +++ b/xbmc/network/upnp/UPnP.cpp @@ -421,7 +421,7 @@ CUPnP::CUPnP() : m_CtrlPointHolder(new CCtrlPointReferenceHolder()) { NPT_LogManager::GetDefault().Configure("plist:.level=FINE;.handlers=CustomHandler;"); - NPT_LogHandler::Create("CustomHandler", "xbmc", m_LogHandler); + NPT_LogHandler::Create("xbmc", "CustomHandler", m_LogHandler); m_LogHandler->SetCustomHandlerFunction(&UPnPLogger); // initialize upnp context diff --git a/xbmc/threads/Event.cpp b/xbmc/threads/Event.cpp index ce581110306c5..b7e5282de7b34 100644 --- a/xbmc/threads/Event.cpp +++ b/xbmc/threads/Event.cpp @@ -120,6 +120,7 @@ namespace XbmcThreads signaled == NULL && iter != events.end(); ++iter) { CEvent* cur = *iter; + CSingleLock lock2(cur->mutex); if (cur->signaled) signaled = cur; } diff --git a/xbmc/threads/Thread.h b/xbmc/threads/Thread.h index bb1c9be4e97f8..ce377bdb32cc4 100644 --- a/xbmc/threads/Thread.h +++ b/xbmc/threads/Thread.h @@ -24,6 +24,7 @@ #pragma once +#include #include #include #include "Event.h" @@ -91,7 +92,7 @@ class CThread virtual void OnExit(){}; virtual void Process(); - volatile bool m_bStop; + std::atomic m_bStop; enum WaitResponse { WAIT_INTERRUPTED = -1, WAIT_SIGNALED = 0, WAIT_TIMEDOUT = 1 }; diff --git a/xbmc/video/videosync/VideoSync.h b/xbmc/video/videosync/VideoSync.h index a4dc688a2d761..a430cb029f604 100644 --- a/xbmc/video/videosync/VideoSync.h +++ b/xbmc/video/videosync/VideoSync.h @@ -18,6 +18,7 @@ * . * */ +#include class CVideoReferenceClock; typedef void (*PUPDATECLOCK)(int NrVBlanks, uint64_t time, CVideoReferenceClock *clock); @@ -28,7 +29,7 @@ class CVideoSync CVideoSync(CVideoReferenceClock *clock) { m_refClock = clock; }; virtual ~CVideoSync() {}; virtual bool Setup(PUPDATECLOCK func) = 0; - virtual void Run(volatile bool& stop) = 0; + virtual void Run(std::atomic& stop) = 0; virtual void Cleanup() = 0; virtual float GetFps() = 0; virtual void RefreshChanged() {}; diff --git a/xbmc/video/videosync/VideoSyncAndroid.cpp b/xbmc/video/videosync/VideoSyncAndroid.cpp index 601891066c44b..f875cdb523d11 100644 --- a/xbmc/video/videosync/VideoSyncAndroid.cpp +++ b/xbmc/video/videosync/VideoSyncAndroid.cpp @@ -47,7 +47,7 @@ bool CVideoSyncAndroid::Setup(PUPDATECLOCK func) return true; } -void CVideoSyncAndroid::Run(volatile bool& stop) +void CVideoSyncAndroid::Run(std::atomic& stop) { while(!stop && !m_abort) { diff --git a/xbmc/video/videosync/VideoSyncAndroid.h b/xbmc/video/videosync/VideoSyncAndroid.h index 52d337a21099e..0dc60b0dc0846 100644 --- a/xbmc/video/videosync/VideoSyncAndroid.h +++ b/xbmc/video/videosync/VideoSyncAndroid.h @@ -30,7 +30,7 @@ class CVideoSyncAndroid : public CVideoSync, IDispResource // CVideoSync interface virtual bool Setup(PUPDATECLOCK func); - virtual void Run(volatile bool& stop); + virtual void Run(std::atomic& stop); virtual void Cleanup(); virtual float GetFps(); diff --git a/xbmc/video/videosync/VideoSyncD3D.cpp b/xbmc/video/videosync/VideoSyncD3D.cpp index 35154760c592a..19c9bfaa6ae9a 100644 --- a/xbmc/video/videosync/VideoSyncD3D.cpp +++ b/xbmc/video/videosync/VideoSyncD3D.cpp @@ -67,7 +67,7 @@ bool CVideoSyncD3D::Setup(PUPDATECLOCK func) return true; } -void CVideoSyncD3D::Run(volatile bool& stop) +void CVideoSyncD3D::Run(std::atomic& stop) { int64_t Now; int64_t LastVBlankTime; diff --git a/xbmc/video/videosync/VideoSyncD3D.h b/xbmc/video/videosync/VideoSyncD3D.h index c6e6ba9fbdd6a..486b6206f668f 100644 --- a/xbmc/video/videosync/VideoSyncD3D.h +++ b/xbmc/video/videosync/VideoSyncD3D.h @@ -30,7 +30,7 @@ class CVideoSyncD3D : public CVideoSync, IDispResource public: CVideoSyncD3D(CVideoReferenceClock *clock) : CVideoSync(clock) {}; bool Setup(PUPDATECLOCK func) override; - void Run(volatile bool& stop) override; + void Run(std::atomic& stop) override; void Cleanup() override; float GetFps() override; void RefreshChanged() override; diff --git a/xbmc/video/videosync/VideoSyncDRM.cpp b/xbmc/video/videosync/VideoSyncDRM.cpp index c9955e67d5b46..c86a7b771d7ce 100644 --- a/xbmc/video/videosync/VideoSyncDRM.cpp +++ b/xbmc/video/videosync/VideoSyncDRM.cpp @@ -78,7 +78,7 @@ bool CVideoSyncDRM::Setup(PUPDATECLOCK func) return true; } -void CVideoSyncDRM::Run(volatile bool& stop) +void CVideoSyncDRM::Run(std::atomic& stop) { drmVBlank vbl; VblInfo info; diff --git a/xbmc/video/videosync/VideoSyncDRM.h b/xbmc/video/videosync/VideoSyncDRM.h index 040c4f33a1805..b6807171f31f1 100644 --- a/xbmc/video/videosync/VideoSyncDRM.h +++ b/xbmc/video/videosync/VideoSyncDRM.h @@ -29,7 +29,7 @@ class CVideoSyncDRM : public CVideoSync, IDispResource public: CVideoSyncDRM(CVideoReferenceClock *clock) : CVideoSync(clock) {}; virtual bool Setup(PUPDATECLOCK func); - virtual void Run(volatile bool& stop); + virtual void Run(std::atomic& stop); virtual void Cleanup(); virtual float GetFps(); virtual void OnResetDisplay(); diff --git a/xbmc/video/videosync/VideoSyncGLX.cpp b/xbmc/video/videosync/VideoSyncGLX.cpp index d35108a911ceb..fd28e007e3750 100644 --- a/xbmc/video/videosync/VideoSyncGLX.cpp +++ b/xbmc/video/videosync/VideoSyncGLX.cpp @@ -183,7 +183,7 @@ bool CVideoSyncGLX::Setup(PUPDATECLOCK func) return true; } -void CVideoSyncGLX::Run(volatile bool& stop) +void CVideoSyncGLX::Run(std::atomic& stop) { unsigned int PrevVblankCount; unsigned int VblankCount; diff --git a/xbmc/video/videosync/VideoSyncGLX.h b/xbmc/video/videosync/VideoSyncGLX.h index c3c3809568e79..7d23c47f03671 100644 --- a/xbmc/video/videosync/VideoSyncGLX.h +++ b/xbmc/video/videosync/VideoSyncGLX.h @@ -34,7 +34,7 @@ class CVideoSyncGLX : public CVideoSync, IDispResource public: CVideoSyncGLX(CVideoReferenceClock *clock) : CVideoSync(clock) {}; virtual bool Setup(PUPDATECLOCK func); - virtual void Run(volatile bool& stop); + virtual void Run(std::atomic& stop); virtual void Cleanup(); virtual float GetFps(); virtual void OnLostDisplay(); diff --git a/xbmc/video/videosync/VideoSyncIMX.cpp b/xbmc/video/videosync/VideoSyncIMX.cpp index 51f4f5fa0f628..fa7c27c4e5838 100644 --- a/xbmc/video/videosync/VideoSyncIMX.cpp +++ b/xbmc/video/videosync/VideoSyncIMX.cpp @@ -50,7 +50,7 @@ bool CVideoSyncIMX::Setup(PUPDATECLOCK func) return true; } -void CVideoSyncIMX::Run(volatile bool& stop) +void CVideoSyncIMX::Run(std::atomic& stop) { int counter; diff --git a/xbmc/video/videosync/VideoSyncIMX.h b/xbmc/video/videosync/VideoSyncIMX.h index d435292dd665a..7220ac60bab88 100644 --- a/xbmc/video/videosync/VideoSyncIMX.h +++ b/xbmc/video/videosync/VideoSyncIMX.h @@ -30,7 +30,7 @@ class CVideoSyncIMX : public CVideoSync, IDispResource CVideoSyncIMX(CVideoReferenceClock *clock); virtual ~CVideoSyncIMX(); virtual bool Setup(PUPDATECLOCK func); - virtual void Run(volatile bool& stop); + virtual void Run(std::atomic& stop); virtual void Cleanup(); virtual float GetFps(); virtual void OnResetDisplay(); diff --git a/xbmc/video/videosync/VideoSyncIos.cpp b/xbmc/video/videosync/VideoSyncIos.cpp index 86fa4a525ef47..8dcefdb82d3c9 100644 --- a/xbmc/video/videosync/VideoSyncIos.cpp +++ b/xbmc/video/videosync/VideoSyncIos.cpp @@ -47,7 +47,7 @@ bool CVideoSyncIos::Setup(PUPDATECLOCK func) return setupOk; } -void CVideoSyncIos::Run(volatile bool& stop) +void CVideoSyncIos::Run(std::atomic& stop) { //because cocoa has a vblank callback, we just keep sleeping until we're asked to stop the thread while(!stop && !m_abort) diff --git a/xbmc/video/videosync/VideoSyncIos.h b/xbmc/video/videosync/VideoSyncIos.h index 12e7d8fceab1b..a31590f6d80dc 100644 --- a/xbmc/video/videosync/VideoSyncIos.h +++ b/xbmc/video/videosync/VideoSyncIos.h @@ -30,7 +30,7 @@ class CVideoSyncIos : public CVideoSync, IDispResource // CVideoSync interface virtual bool Setup(PUPDATECLOCK func); - virtual void Run(volatile bool& stop); + virtual void Run(std::atomic& stop); virtual void Cleanup(); virtual float GetFps(); diff --git a/xbmc/video/videosync/VideoSyncOsx.cpp b/xbmc/video/videosync/VideoSyncOsx.cpp index 3ba382340b0bd..f7173dc6b69bb 100644 --- a/xbmc/video/videosync/VideoSyncOsx.cpp +++ b/xbmc/video/videosync/VideoSyncOsx.cpp @@ -49,7 +49,7 @@ bool CVideoSyncOsx::Setup(PUPDATECLOCK func) return true; } -void CVideoSyncOsx::Run(volatile bool& stop) +void CVideoSyncOsx::Run(std::atomic& stop) { InitDisplayLink(); diff --git a/xbmc/video/videosync/VideoSyncOsx.h b/xbmc/video/videosync/VideoSyncOsx.h index b946a4bb8bc46..b8b5b303ccbde 100644 --- a/xbmc/video/videosync/VideoSyncOsx.h +++ b/xbmc/video/videosync/VideoSyncOsx.h @@ -36,7 +36,7 @@ class CVideoSyncOsx : public CVideoSync, IDispResource // CVideoSync interface virtual bool Setup(PUPDATECLOCK func); - virtual void Run(volatile bool& stop); + virtual void Run(std::atomic& stop); virtual void Cleanup(); virtual float GetFps(); virtual void RefreshChanged(); diff --git a/xbmc/video/videosync/VideoSyncPi.cpp b/xbmc/video/videosync/VideoSyncPi.cpp index f87fdad414536..0b512d3b0be4d 100644 --- a/xbmc/video/videosync/VideoSyncPi.cpp +++ b/xbmc/video/videosync/VideoSyncPi.cpp @@ -39,7 +39,7 @@ bool CVideoSyncPi::Setup(PUPDATECLOCK func) return true; } -void CVideoSyncPi::Run(volatile bool& stop) +void CVideoSyncPi::Run(std::atomic& stop) { /* This shouldn't be very busy and timing is important so increase priority */ CThread::GetCurrentThread()->SetPriority(CThread::GetCurrentThread()->GetPriority()+1); diff --git a/xbmc/video/videosync/VideoSyncPi.h b/xbmc/video/videosync/VideoSyncPi.h index 10a9fa81bd796..c7c3d12c71ea3 100644 --- a/xbmc/video/videosync/VideoSyncPi.h +++ b/xbmc/video/videosync/VideoSyncPi.h @@ -29,7 +29,7 @@ class CVideoSyncPi : public CVideoSync, IDispResource public: CVideoSyncPi(CVideoReferenceClock *clock) : CVideoSync(clock) {}; virtual bool Setup(PUPDATECLOCK func); - virtual void Run(volatile bool& stop); + virtual void Run(std::atomic& stop); virtual void Cleanup(); virtual float GetFps(); virtual void OnResetDisplay(); diff --git a/xbmc/windows/GUIWindowSplash.cpp b/xbmc/windows/GUIWindowSplash.cpp index 93ffc41ce1fb6..1834013bde231 100644 --- a/xbmc/windows/GUIWindowSplash.cpp +++ b/xbmc/windows/GUIWindowSplash.cpp @@ -33,7 +33,7 @@ CGUIWindowSplash::CGUIWindowSplash(void) : CGUIWindow(WINDOW_SPLASH, "") CGUIWindowSplash::~CGUIWindowSplash(void) { - delete m_image; + } void CGUIWindowSplash::OnInitWindow() @@ -44,7 +44,7 @@ void CGUIWindowSplash::OnInitWindow() CLog::Log(LOGINFO, "load splash image: %s", CSpecialProtocol::TranslatePath(splashImage).c_str()); - m_image = new CGUIImage(0, 0, 0, 0, g_graphicsContext.GetWidth(), g_graphicsContext.GetHeight(), CTextureInfo(splashImage)); + m_image = std::unique_ptr(new CGUIImage(0, 0, 0, 0, g_graphicsContext.GetWidth(), g_graphicsContext.GetHeight(), CTextureInfo(splashImage))); m_image->SetAspectRatio(CAspectRatio::AR_SCALE); } @@ -56,4 +56,4 @@ void CGUIWindowSplash::Render() m_image->AllocResources(); m_image->Render(); m_image->FreeResources(); -} \ No newline at end of file +} diff --git a/xbmc/windows/GUIWindowSplash.h b/xbmc/windows/GUIWindowSplash.h index 510db066c9491..4c29abd6f9907 100644 --- a/xbmc/windows/GUIWindowSplash.h +++ b/xbmc/windows/GUIWindowSplash.h @@ -20,6 +20,8 @@ * */ +#include + #include "guilib/GUIWindow.h" class CGUITextLayout; @@ -35,5 +37,5 @@ class CGUIWindowSplash : public CGUIWindow protected: virtual void OnInitWindow(); private: - CGUIImage* m_image; + std::unique_ptr m_image; };