Skip to content

Commit

Permalink
don't use CThread::SetName() from outside of CThread - it's not threa…
Browse files Browse the repository at this point in the history
…dsafe
  • Loading branch information
Jonathan Marshall committed Jul 23, 2011
1 parent 40499ec commit b3cbc44
Show file tree
Hide file tree
Showing 15 changed files with 13 additions and 40 deletions.
3 changes: 1 addition & 2 deletions xbmc/BackgroundInfoLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,11 @@ void CBackgroundInfoLoader::Load(CFileItemList& items)
m_nActiveThreads = nThreads;
for (int i=0; i < nThreads; i++)
{
CThread *pThread = new CThread(this);
CThread *pThread = new CThread(this, "Background Loader");
pThread->Create();
#ifndef _LINUX
pThread->SetPriority(THREAD_PRIORITY_BELOW_NORMAL);
#endif
pThread->SetName("Background Loader");
m_workers.push_back(pThread);
}

Expand Down
5 changes: 1 addition & 4 deletions xbmc/addons/AddonStatusHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ namespace ADDON
CCriticalSection CAddonStatusHandler::m_critSection;

CAddonStatusHandler::CAddonStatusHandler(const CStdString &addonID, ADDON_STATUS status, CStdString message, bool sameThread)
: CThread("CAddonStatusHandler:" + addonID)
{
if (!CAddonMgr::Get().GetAddon(addonID, m_addon))
return;
Expand All @@ -57,11 +58,7 @@ CAddonStatusHandler::CAddonStatusHandler(const CStdString &addonID, ADDON_STATUS
}
else
{
CStdString ThreadName;
ThreadName.Format("Addon Status: %s", m_addon->Name().c_str());

Create(true, THREAD_MINSTACKSIZE);
SetName(ThreadName.c_str());
SetPriority(-15);
}
}
Expand Down
4 changes: 1 addition & 3 deletions xbmc/cores/ExternalPlayer/ExternalPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ extern HWND g_hWnd;

CExternalPlayer::CExternalPlayer(IPlayerCallback& callback)
: IPlayer(callback),
CThread()
CThread("CExternalPlayer")
{
m_bAbortRequest = false;
m_bIsPlaying = false;
Expand Down Expand Up @@ -135,8 +135,6 @@ bool CExternalPlayer::IsPlaying() const

void CExternalPlayer::Process()
{
SetName("CExternalPlayer");

CStdString mainFile = m_launchFilename;
CStdString archiveContent = "";

Expand Down
3 changes: 1 addition & 2 deletions xbmc/cores/dvdplayer/DVDPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ void CSelectionStreams::Update(CDVDInputStream* input, CDVDDemux* demuxer)

CDVDPlayer::CDVDPlayer(IPlayerCallback& callback)
: IPlayer(callback),
CThread(),
CThread("CDVDPlayer"),
m_CurrentAudio(STREAM_AUDIO),
m_CurrentVideo(STREAM_VIDEO),
m_CurrentSubtitle(STREAM_SUBTITLE),
Expand Down Expand Up @@ -419,7 +419,6 @@ bool CDVDPlayer::IsPlaying() const

void CDVDPlayer::OnStartup()
{
CThread::SetName("CDVDPlayer");
m_CurrentVideo.Clear();
m_CurrentAudio.Clear();
m_CurrentSubtitle.Clear();
Expand Down
4 changes: 1 addition & 3 deletions xbmc/cores/dvdplayer/DVDPlayerAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class CDVDMsgAudioCodecChange : public CDVDMsg


CDVDPlayerAudio::CDVDPlayerAudio(CDVDClock* pClock, CDVDMessageQueue& parent)
: CThread()
: CThread("CDVDPlayerAudio")
, m_messageQueue("audio")
, m_messageParent(parent)
, m_dvdAudio((bool&)m_bStop)
Expand Down Expand Up @@ -515,8 +515,6 @@ int CDVDPlayerAudio::DecodeFrame(DVDAudioFrame &audioframe, bool bDropPacket)

void CDVDPlayerAudio::OnStartup()
{
CThread::SetName("CDVDPlayerAudio");

m_decode.msg = NULL;
m_decode.Release();

Expand Down
7 changes: 1 addition & 6 deletions xbmc/cores/dvdplayer/DVDPlayerTeletext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ signed int CDVDTeletextTools::deh24(unsigned char *p)


CDVDTeletextData::CDVDTeletextData()
: CThread()
: CThread("CDVDTeletextData")
, m_messageQueue("teletext")
{
m_speed = DVD_PLAYSPEED_NORMAL;
Expand Down Expand Up @@ -233,11 +233,6 @@ void CDVDTeletextData::ResetTeletextCache()
m_TXTCache.SubPage = 0;
}

void CDVDTeletextData::OnStartup()
{
CThread::SetName("CDVDTeletextData");
}

void CDVDTeletextData::Process()
{
int b1, b2, b3, b4;
Expand Down
1 change: 0 additions & 1 deletion xbmc/cores/dvdplayer/DVDPlayerTeletext.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ class CDVDTeletextData : public CThread
CDVDMessageQueue m_messageQueue;

protected:
virtual void OnStartup();
virtual void OnExit();
virtual void Process();

Expand Down
3 changes: 1 addition & 2 deletions xbmc/cores/dvdplayer/DVDPlayerVideo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class CDVDMsgVideoCodecChange : public CDVDMsg
CDVDPlayerVideo::CDVDPlayerVideo( CDVDClock* pClock
, CDVDOverlayContainer* pOverlayContainer
, CDVDMessageQueue& parent)
: CThread()
: CThread("CDVDPlayerVideo")
, m_messageQueue("video")
, m_messageParent(parent)
{
Expand Down Expand Up @@ -271,7 +271,6 @@ void CDVDPlayerVideo::CloseStream(bool bWaitForBuffers)

void CDVDPlayerVideo::OnStartup()
{
CThread::SetName("CDVDPlayerVideo");
m_iDroppedFrames = 0;

m_crop.x1 = m_crop.x2 = 0.0f;
Expand Down
3 changes: 1 addition & 2 deletions xbmc/input/windows/IRServerSuite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

CRemoteControl g_RemoteControl;

CRemoteControl::CRemoteControl()
CRemoteControl::CRemoteControl() : CThread("CRemoteControl")
{
m_socket = INVALID_SOCKET;
m_bInitialized = false;
Expand Down Expand Up @@ -79,7 +79,6 @@ void CRemoteControl::Initialize()
if (m_isConnecting || m_bInitialized) return;
//trying to connect when there is nothing to connect to is kinda slow so kick it off in a thread.
Create();
SetName("CRemoteControl");
}

void CRemoteControl::Process()
Expand Down
3 changes: 1 addition & 2 deletions xbmc/interfaces/DbusServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,8 @@ void CDbusServer::StartServer(CApplication *parent)
}

m_bStop = false;
m_pThread = new CThread(this);
m_pThread = new CThread(this, "DbusServer");
m_pThread->Create();
m_pThread->SetName("DbusServer");
}

void CDbusServer::StopServer(bool bWait)
Expand Down
7 changes: 1 addition & 6 deletions xbmc/interfaces/python/XBPyThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ extern "C"
char* dll_getenv(const char* szKey);
}

XBPyThread::XBPyThread(XBPython *pExecuter, int id)
XBPyThread::XBPyThread(XBPython *pExecuter, int id) : CThread("XBPyThread")
{
CLog::Log(LOGDEBUG,"new python thread created. id=%d", id);
m_pExecuter = pExecuter;
Expand Down Expand Up @@ -129,11 +129,6 @@ int XBPyThread::setArgv(const std::vector<CStdString> &argv)
return 0;
}

void XBPyThread::OnStartup()
{
CThread::SetName("Python Thread");
}

void XBPyThread::Process()
{
CLog::Log(LOGDEBUG,"Python thread: start processing");
Expand Down
1 change: 0 additions & 1 deletion xbmc/interfaces/python/XBPyThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class XBPyThread : public CThread

void setSource(const CStdString &src);

virtual void OnStartup();
virtual void Process();
virtual void OnExit();
virtual void OnException();
Expand Down
3 changes: 1 addition & 2 deletions xbmc/network/EventServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ using namespace std;
/* CEventServer */
/************************************************************************/
CEventServer* CEventServer::m_pInstance = NULL;
CEventServer::CEventServer()
CEventServer::CEventServer() : CThread("CEventServer")
{
m_pSocket = NULL;
m_pPacketBuffer = NULL;
Expand Down Expand Up @@ -98,7 +98,6 @@ void CEventServer::StartServer()
}

CThread::Create();
CThread::SetName("EventServer");
}

void CEventServer::StopServer(bool bWait)
Expand Down
3 changes: 1 addition & 2 deletions xbmc/storage/DetectDVDType.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ CDetectDVDMedia* CDetectDVDMedia::m_pInstance = NULL;
CStdString CDetectDVDMedia::m_diskLabel = "";
CStdString CDetectDVDMedia::m_diskPath = "";

CDetectDVDMedia::CDetectDVDMedia()
CDetectDVDMedia::CDetectDVDMedia() : CThread("CDetectDVDMedia")
{
m_bAutorun = false;
m_bStop = false;
Expand All @@ -87,7 +87,6 @@ void CDetectDVDMedia::OnStartup()

void CDetectDVDMedia::Process()
{
SetName("CDetectDVDMedia");
// for apple - currently disable this check since cdio will return null if no media is loaded
#ifndef __APPLE__
//Before entering loop make sure we actually have a CDrom drive
Expand Down
3 changes: 1 addition & 2 deletions xbmc/utils/JobManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ bool CJob::ShouldCancel(unsigned int progress, unsigned int total) const
return false;
}

CJobWorker::CJobWorker(CJobManager *manager)
CJobWorker::CJobWorker(CJobManager *manager) : CThread("Jobworker")
{
m_jobManager = manager;
Create(true); // start work immediately, and kill ourselves when we're done
Expand All @@ -51,7 +51,6 @@ CJobWorker::~CJobWorker()
void CJobWorker::Process()
{
SetPriority( GetMinPriority() );
SetName("Jobworker");
while (true)
{
// request an item from our manager (this call is blocking)
Expand Down

0 comments on commit b3cbc44

Please sign in to comment.