From 9c55974c637c7147af68720f9dd3a9d7ea946414 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 5 Feb 2005 19:18:49 +0000 Subject: [PATCH] remove MemoryCardDriverThreaded --- .../MemoryCard/MemoryCardDriverThreaded.cpp | 163 ------------------ .../MemoryCard/MemoryCardDriverThreaded.h | 70 -------- 2 files changed, 233 deletions(-) delete mode 100644 stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded.cpp delete mode 100644 stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded.h diff --git a/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded.cpp b/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded.cpp deleted file mode 100644 index adf5fbd439..0000000000 --- a/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded.cpp +++ /dev/null @@ -1,163 +0,0 @@ -#include "global.h" -#include "MemoryCardDriverThreaded.h" -#include "RageLog.h" -#include "RageUtil.h" -#include "RageFileManager.h" - - -template -bool VectorsAreEqual( const T &a, const T &b ) -{ - if( a.size() != b.size() ) - return false; - - for( unsigned i=0; iTrace( "Shutting down Mount thread..." ); - m_threadMemoryCardMount.Wait(); - LOG->Trace( "Mount thread shut down." ); -} - -MemoryCardDriverThreaded::~MemoryCardDriverThreaded() -{ - /* Must call StopThread from the derived destructor. Otherwise, we can - * call MountThreadDoOneUpdate from the thread after the derived dtor, - * which means that function is now virtual, and we'll crash with "pure - * virtual method called". */ - ASSERT( !m_threadMemoryCardMount.IsCreated() ); -} - -void MemoryCardDriverThreaded::SetMountThreadState( MountThreadState mts ) -{ - CHECKPOINT; - - MountThreadState old = m_MountThreadState; - - if( old != paused && mts == paused ) - m_mutexPause.Lock(); - - if( old == paused && mts != paused ) - m_mutexPause.Unlock(); - - m_MountThreadState = mts; -} - -int MemoryCardDriverThreaded::MountThread_Start( void *p ) -{ - ((MemoryCardDriverThreaded*)p)->MountThreadMain(); - return 0; -} - -void MemoryCardDriverThreaded::MountThreadMain() -{ - CHECKPOINT; - - while( !m_bShutdownNextUpdate ) - { - if( !this->MountThreadWaitForUpdate() ) - continue; - - LockMut( m_mutexPause ); // wait until we're unpaused - this->MountThreadDoOneUpdate(); - } -} - -bool MemoryCardDriverThreaded::MountThreadWaitForUpdate() -{ - usleep( 100000 ); - return true; -} - -bool MemoryCardDriverThreaded::StorageDevicesChanged() -{ - CHECKPOINT; - - LockMut( m_mutexStorageDevices ); - if( m_bStorageDevicesChanged ) - { - m_bStorageDevicesChanged = false; - return true; - } - else - { - return false; - } -} - -void MemoryCardDriverThreaded::GetStorageDevices( vector& vDevicesOut ) -{ - CHECKPOINT; - - LockMut( m_mutexStorageDevices ); - vDevicesOut.clear(); - for( unsigned i=0; i::const_iterator iter = find( m_vStorageDevices.begin(), m_vStorageDevices.end(), *pDevice ); - if( iter == m_vStorageDevices.end() ) - { - LOG->Warn( "Trying to mount a memory card that is no longer connected. bus %d port %d device %d path %s", pDevice->iBus, pDevice->iPort, pDevice->iLevel, pDevice->sOsMountDir.c_str() ); - return false; - } - - if( !iter->bWriteTestSucceeded ) - return false; - - this->Mount( pDevice ); - - return pDevice->bWriteTestSucceeded; -} - -/* - * (c) 2003-2004 Chris Danford - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons to - * whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF - * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS - * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT - * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ diff --git a/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded.h b/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded.h deleted file mode 100644 index b058740030..0000000000 --- a/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef MemoryCardDriverThreaded_H -#define MemoryCardDriverThreaded_H 1 - -#include "MemoryCardDriver.h" -#include "RageThreads.h" - -class MemoryCardDriverThreaded : public MemoryCardDriver -{ -public: - MemoryCardDriverThreaded(); - ~MemoryCardDriverThreaded(); - - virtual bool StorageDevicesChanged(); - virtual void GetStorageDevices( vector& vStorageDevicesOut ); - virtual bool MountAndTestWrite( UsbStorageDevice* pDevice ); - virtual void SetMountThreadState( MountThreadState mts ); - -private: - static int MountThread_Start( void *p ); - void MountThreadMain(); - - RageThread m_threadMemoryCardMount; - bool m_bShutdownNextUpdate; - - // Aquire this before detecting devices or reading/writing devices. - // Calling Pause() and Unpause will lock/unlock this so that the mounting thread - // will temporarily halt. - RageMutex m_mutexPause; - - MountThreadState m_MountThreadState; - -protected: - void StartThread(); // call this in the derived constructor to start the mounting thread - void StopThread(); // call this in the derived desstructor to stop the mounting thread - virtual void MountThreadDoOneUpdate() = 0; // this will get called as fast as possible - virtual bool MountThreadWaitForUpdate(); - virtual void Mount( UsbStorageDevice* pDevice ) = 0; - bool ShouldDoOsMount() { return m_MountThreadState==detect_and_mount; } - - vector m_vStorageDevices; - bool m_bStorageDevicesChanged; - RageMutex m_mutexStorageDevices; // protects the above two -}; - -#endif - -/* - * (c) 2003-2004 Chris Danford - * All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, and/or sell copies of the Software, and to permit persons to - * whom the Software is furnished to do so, provided that the above - * copyright notice(s) and this permission notice appear in all copies of - * the Software and that both the above copyright notice(s) and this - * permission notice appear in supporting documentation. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF - * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS - * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT - * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS - * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */