diff --git a/stepmania/src/MemoryCardManager.cpp b/stepmania/src/MemoryCardManager.cpp index bd7c05c38a..8debb138d9 100644 --- a/stepmania/src/MemoryCardManager.cpp +++ b/stepmania/src/MemoryCardManager.cpp @@ -148,6 +148,11 @@ void MemoryCardManager::LockCards( bool bLock ) FOREACH_PlayerNumber( p ) m_bTooLate[p] = false; } + + if( m_bCardsLocked ) + m_pDriver->DontDoOsMount(); + else + m_pDriver->DoOsMount(); } void MemoryCardManager::AssignUnassignedCards() diff --git a/stepmania/src/arch/MemoryCard/MemoryCardDriver.cpp b/stepmania/src/arch/MemoryCard/MemoryCardDriver.cpp index 582ad1b5e9..7eb23e4ab2 100644 --- a/stepmania/src/arch/MemoryCard/MemoryCardDriver.cpp +++ b/stepmania/src/arch/MemoryCard/MemoryCardDriver.cpp @@ -4,6 +4,21 @@ #include "arch/arch_platform.h" +bool UsbStorageDevice::operator==(const UsbStorageDevice& other) const +{ + // LOG->Trace( "Comparing %d %d %d %s %s to %d %d %d %s %s", + // iBus, iPort, iLevel, sName.c_str(), sOsMountDir.c_str(), + // other.iBus, other.iPort, other.iLevel, other.sName.c_str(), other.sOsMountDir.c_str() ); +#define COMPARE(x) if( x != other.x ) return false; + COMPARE( iBus ); + COMPARE( iPort ); + COMPARE( iLevel ); + COMPARE( sOsMountDir ); + return true; +#undef COMPARE +} + + MemoryCardDriver *MakeMemoryCardDriver() { if( !PREFSMAN->m_bMemoryCards ) diff --git a/stepmania/src/arch/MemoryCard/MemoryCardDriver.h b/stepmania/src/arch/MemoryCard/MemoryCardDriver.h index 4f57d8a524..077e562331 100644 --- a/stepmania/src/arch/MemoryCard/MemoryCardDriver.h +++ b/stepmania/src/arch/MemoryCard/MemoryCardDriver.h @@ -29,17 +29,7 @@ struct UsbStorageDevice bool IsBlank() { return sOsMountDir.empty(); } - bool operator==(const UsbStorageDevice& other) const - { -#define COMPARE(x) if( x != other.x ) return false; - COMPARE( iBus ); - COMPARE( iPort ); - COMPARE( iLevel ); - COMPARE( sName ); - COMPARE( sOsMountDir ); - return true; -#undef COMPARE - } + bool operator==(const UsbStorageDevice& other) const; bool operator!=(const UsbStorageDevice& other) const { return !operator==(other); @@ -59,6 +49,8 @@ public: virtual void ResetUsbStorage() = 0; virtual void PauseMountingThread() = 0; virtual void UnPauseMountingThread() = 0; + virtual void DoOsMount() = 0; + virtual void DontDoOsMount() = 0; }; MemoryCardDriver *MakeMemoryCardDriver(); diff --git a/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded.cpp b/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded.cpp index 9faf5d161b..8b2d342c69 100644 --- a/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded.cpp +++ b/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded.cpp @@ -26,6 +26,7 @@ MemoryCardDriverThreaded::MemoryCardDriverThreaded() : { m_bShutdownNextUpdate = false; m_bStorageDevicesChanged = false; + m_bDoOsMount = true; } void MemoryCardDriverThreaded::StartThread() @@ -61,6 +62,16 @@ void MemoryCardDriverThreaded::UnPauseMountingThread() m_mutexPause.Unlock(); } +void MemoryCardDriverThreaded::DoOsMount() +{ + m_bDoOsMount = true; +} + +void MemoryCardDriverThreaded::DontDoOsMount() +{ + m_bDoOsMount = false; +} + int MemoryCardDriverThreaded::MountThread_Start( void *p ) { ((MemoryCardDriverThreaded*)p)->MountThreadMain(); diff --git a/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded.h b/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded.h index fb85abe75d..3ec28200b8 100644 --- a/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded.h +++ b/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded.h @@ -27,6 +27,8 @@ public: virtual bool MountAndTestWrite( UsbStorageDevice* pDevice, CString sMountPoint ); virtual void PauseMountingThread(); virtual void UnPauseMountingThread(); + virtual void DoOsMount(); + virtual void DontDoOsMount(); private: static int MountThread_Start( void *p ); @@ -40,11 +42,16 @@ private: // will temporarily halt. RageMutex m_mutexPause; + // If true, detect and report changes in connected devices, but don't don't + // do the OS mount or unmount. + bool m_bDoOsMount; + 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 void Mount( UsbStorageDevice* pDevice, CString sMountPoint ) = 0; + bool ShouldDoOsMount() { return m_bDoOsMount; } vector m_vStorageDevices; bool m_bStorageDevicesChanged; diff --git a/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded_Linux.cpp b/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded_Linux.cpp index 86144cdf13..bda5909d72 100644 --- a/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded_Linux.cpp +++ b/stepmania/src/arch/MemoryCard/MemoryCardDriverThreaded_Linux.cpp @@ -221,7 +221,7 @@ void MemoryCardDriverThreaded_Linux::MountThreadDoOneUpdate() UsbStorageDeviceEx &old = vOld[i]; if( find(vNew.begin(),vNew.end(),old) == vNew.end() )// didn't find { - LOG->Trace( ssprintf("Disconnected bus %d port %d level %d path %s", old.iBus, old.iPort, old.iLevel, old.sOsMountDir.c_str()) ); + LOG->Trace( "Disconnected bus %d port %d level %d path %s", old.iBus, old.iPort, old.iLevel, old.sOsMountDir.c_str() ); vDisconnects.push_back( &old ); } } @@ -233,24 +233,26 @@ void MemoryCardDriverThreaded_Linux::MountThreadDoOneUpdate() UsbStorageDeviceEx &newd = vNew[i]; if( find(vOld.begin(),vOld.end(),newd) == vOld.end() )// didn't find { - LOG->Trace( ssprintf("Connected bus %d port %d level %d path %s", newd.iBus, newd.iPort, newd.iLevel, newd.sOsMountDir.c_str()) ); + LOG->Trace( "Connected bus %d port %d level %d path %s", newd.iBus, newd.iPort, newd.iLevel, newd.sOsMountDir.c_str() ); vConnects.push_back( &newd ); } } // unmount all disconnects - for( unsigned i=0; iTrace( "unmount disconnects %i/%i (%s)", i, vDisconnects.size(), sCommand.c_str() ); ExecuteCommand( sCommand ); LOG->Trace( "unmount disconnects %i/%i done", i, vDisconnects.size() ); - } - - // mount all connects - for( unsigned i=0; iTrace( "unmount old connect %i/%i done", i, vConnects.size() ); sCommand = "mount " + d.sOsMountDir; - LOG->Trace( "unmount new connect %i/%i (%s)", i, vConnects.size(), sCommand.c_str() ); + LOG->Trace( "mount new connect %i/%i (%s)", i, vConnects.size(), sCommand.c_str() ); bool bMountedSuccessfully = ExecuteCommand( sCommand ); - LOG->Trace( "unmount new connect %i/%i done", i, vConnects.size() ); + LOG->Trace( "mount new connect %i/%i done", i, vConnects.size() ); d.bWriteTestSucceeded = bMountedSuccessfully && TestWrite( d.sOsMountDir ); @@ -278,8 +280,9 @@ void MemoryCardDriverThreaded_Linux::MountThreadDoOneUpdate() d.sName = profile.GetDisplayName(); LOG->Trace( "write test %s", d.bWriteTestSucceeded ? "succeeded" : "failed" ); - } - + } + } + if( !vDisconnects.empty() || !vConnects.empty() ) { LockMut( m_mutexStorageDevices ); diff --git a/stepmania/src/arch/MemoryCard/MemoryCardDriver_Null.h b/stepmania/src/arch/MemoryCard/MemoryCardDriver_Null.h index 6159ed1c13..cd81b23624 100644 --- a/stepmania/src/arch/MemoryCard/MemoryCardDriver_Null.h +++ b/stepmania/src/arch/MemoryCard/MemoryCardDriver_Null.h @@ -15,6 +15,8 @@ public: virtual void ResetUsbStorage() {} virtual void PauseMountingThread() {} virtual void UnPauseMountingThread() {} + virtual void DoOsMount() {} + virtual void DontDoOsMount() {} }; #endif