Fix unnecessary remounts of cards that weren't changed since last update.\nDon't do OS mounts or unmounts while after cards are locked. It can cause skips.
This commit is contained in:
@@ -148,6 +148,11 @@ void MemoryCardManager::LockCards( bool bLock )
|
|||||||
FOREACH_PlayerNumber( p )
|
FOREACH_PlayerNumber( p )
|
||||||
m_bTooLate[p] = false;
|
m_bTooLate[p] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( m_bCardsLocked )
|
||||||
|
m_pDriver->DontDoOsMount();
|
||||||
|
else
|
||||||
|
m_pDriver->DoOsMount();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemoryCardManager::AssignUnassignedCards()
|
void MemoryCardManager::AssignUnassignedCards()
|
||||||
|
|||||||
@@ -4,6 +4,21 @@
|
|||||||
|
|
||||||
#include "arch/arch_platform.h"
|
#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()
|
MemoryCardDriver *MakeMemoryCardDriver()
|
||||||
{
|
{
|
||||||
if( !PREFSMAN->m_bMemoryCards )
|
if( !PREFSMAN->m_bMemoryCards )
|
||||||
|
|||||||
@@ -29,17 +29,7 @@ struct UsbStorageDevice
|
|||||||
|
|
||||||
bool IsBlank() { return sOsMountDir.empty(); }
|
bool IsBlank() { return sOsMountDir.empty(); }
|
||||||
|
|
||||||
bool operator==(const UsbStorageDevice& other) const
|
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);
|
return !operator==(other);
|
||||||
@@ -59,6 +49,8 @@ public:
|
|||||||
virtual void ResetUsbStorage() = 0;
|
virtual void ResetUsbStorage() = 0;
|
||||||
virtual void PauseMountingThread() = 0;
|
virtual void PauseMountingThread() = 0;
|
||||||
virtual void UnPauseMountingThread() = 0;
|
virtual void UnPauseMountingThread() = 0;
|
||||||
|
virtual void DoOsMount() = 0;
|
||||||
|
virtual void DontDoOsMount() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
MemoryCardDriver *MakeMemoryCardDriver();
|
MemoryCardDriver *MakeMemoryCardDriver();
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ MemoryCardDriverThreaded::MemoryCardDriverThreaded() :
|
|||||||
{
|
{
|
||||||
m_bShutdownNextUpdate = false;
|
m_bShutdownNextUpdate = false;
|
||||||
m_bStorageDevicesChanged = false;
|
m_bStorageDevicesChanged = false;
|
||||||
|
m_bDoOsMount = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemoryCardDriverThreaded::StartThread()
|
void MemoryCardDriverThreaded::StartThread()
|
||||||
@@ -61,6 +62,16 @@ void MemoryCardDriverThreaded::UnPauseMountingThread()
|
|||||||
m_mutexPause.Unlock();
|
m_mutexPause.Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MemoryCardDriverThreaded::DoOsMount()
|
||||||
|
{
|
||||||
|
m_bDoOsMount = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MemoryCardDriverThreaded::DontDoOsMount()
|
||||||
|
{
|
||||||
|
m_bDoOsMount = false;
|
||||||
|
}
|
||||||
|
|
||||||
int MemoryCardDriverThreaded::MountThread_Start( void *p )
|
int MemoryCardDriverThreaded::MountThread_Start( void *p )
|
||||||
{
|
{
|
||||||
((MemoryCardDriverThreaded*)p)->MountThreadMain();
|
((MemoryCardDriverThreaded*)p)->MountThreadMain();
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ public:
|
|||||||
virtual bool MountAndTestWrite( UsbStorageDevice* pDevice, CString sMountPoint );
|
virtual bool MountAndTestWrite( UsbStorageDevice* pDevice, CString sMountPoint );
|
||||||
virtual void PauseMountingThread();
|
virtual void PauseMountingThread();
|
||||||
virtual void UnPauseMountingThread();
|
virtual void UnPauseMountingThread();
|
||||||
|
virtual void DoOsMount();
|
||||||
|
virtual void DontDoOsMount();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static int MountThread_Start( void *p );
|
static int MountThread_Start( void *p );
|
||||||
@@ -40,11 +42,16 @@ private:
|
|||||||
// will temporarily halt.
|
// will temporarily halt.
|
||||||
RageMutex m_mutexPause;
|
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:
|
protected:
|
||||||
void StartThread(); // call this in the derived constructor to start the mounting thread
|
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
|
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 MountThreadDoOneUpdate() = 0; // this will get called as fast as possible
|
||||||
virtual void Mount( UsbStorageDevice* pDevice, CString sMountPoint ) = 0;
|
virtual void Mount( UsbStorageDevice* pDevice, CString sMountPoint ) = 0;
|
||||||
|
bool ShouldDoOsMount() { return m_bDoOsMount; }
|
||||||
|
|
||||||
vector<UsbStorageDeviceEx> m_vStorageDevices;
|
vector<UsbStorageDeviceEx> m_vStorageDevices;
|
||||||
bool m_bStorageDevicesChanged;
|
bool m_bStorageDevicesChanged;
|
||||||
|
|||||||
@@ -221,7 +221,7 @@ void MemoryCardDriverThreaded_Linux::MountThreadDoOneUpdate()
|
|||||||
UsbStorageDeviceEx &old = vOld[i];
|
UsbStorageDeviceEx &old = vOld[i];
|
||||||
if( find(vNew.begin(),vNew.end(),old) == vNew.end() )// didn't find
|
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 );
|
vDisconnects.push_back( &old );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -233,12 +233,14 @@ void MemoryCardDriverThreaded_Linux::MountThreadDoOneUpdate()
|
|||||||
UsbStorageDeviceEx &newd = vNew[i];
|
UsbStorageDeviceEx &newd = vNew[i];
|
||||||
if( find(vOld.begin(),vOld.end(),newd) == vOld.end() )// didn't find
|
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 );
|
vConnects.push_back( &newd );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// unmount all disconnects
|
// unmount all disconnects
|
||||||
|
if( ShouldDoOsMount() )
|
||||||
|
{
|
||||||
for( unsigned i=0; i<vDisconnects.size(); i++ )
|
for( unsigned i=0; i<vDisconnects.size(); i++ )
|
||||||
{
|
{
|
||||||
UsbStorageDeviceEx &d = *vDisconnects[i];
|
UsbStorageDeviceEx &d = *vDisconnects[i];
|
||||||
@@ -263,9 +265,9 @@ void MemoryCardDriverThreaded_Linux::MountThreadDoOneUpdate()
|
|||||||
LOG->Trace( "unmount old connect %i/%i done", i, vConnects.size() );
|
LOG->Trace( "unmount old connect %i/%i done", i, vConnects.size() );
|
||||||
|
|
||||||
sCommand = "mount " + d.sOsMountDir;
|
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 );
|
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 );
|
d.bWriteTestSucceeded = bMountedSuccessfully && TestWrite( d.sOsMountDir );
|
||||||
|
|
||||||
@@ -279,6 +281,7 @@ void MemoryCardDriverThreaded_Linux::MountThreadDoOneUpdate()
|
|||||||
|
|
||||||
LOG->Trace( "write test %s", d.bWriteTestSucceeded ? "succeeded" : "failed" );
|
LOG->Trace( "write test %s", d.bWriteTestSucceeded ? "succeeded" : "failed" );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( !vDisconnects.empty() || !vConnects.empty() )
|
if( !vDisconnects.empty() || !vConnects.empty() )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ public:
|
|||||||
virtual void ResetUsbStorage() {}
|
virtual void ResetUsbStorage() {}
|
||||||
virtual void PauseMountingThread() {}
|
virtual void PauseMountingThread() {}
|
||||||
virtual void UnPauseMountingThread() {}
|
virtual void UnPauseMountingThread() {}
|
||||||
|
virtual void DoOsMount() {}
|
||||||
|
virtual void DontDoOsMount() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user