simplify; pausing and threading is handled above (Linux update in a few
minutes)
This commit is contained in:
@@ -51,19 +51,14 @@ class MemoryCardDriver
|
||||
public:
|
||||
MemoryCardDriver() {};
|
||||
virtual ~MemoryCardDriver() {};
|
||||
virtual bool StorageDevicesChanged() = 0;
|
||||
virtual void GetStorageDevices( vector<UsbStorageDevice>& vStorageDevicesOut ) = 0;
|
||||
virtual bool MountAndTestWrite( UsbStorageDevice* pDevice ) = 0; // return false if mount or write fails
|
||||
virtual bool Mount( UsbStorageDevice* pDevice ) = 0; // return false if mount or write fails
|
||||
virtual void Unmount( UsbStorageDevice* pDevice ) = 0;
|
||||
virtual void Flush( UsbStorageDevice* pDevice ) = 0;
|
||||
virtual void ResetUsbStorage() = 0;
|
||||
enum MountThreadState
|
||||
{
|
||||
detect_and_mount,
|
||||
detect_and_dont_mount,
|
||||
paused
|
||||
};
|
||||
virtual void SetMountThreadState( MountThreadState mts ) = 0;
|
||||
virtual void Reset() { }
|
||||
|
||||
/* Poll for memory card changes. If anything has changed, fill in vStorageDevicesOut
|
||||
* and return true. */
|
||||
virtual bool DoOneUpdate( bool bMount, vector<UsbStorageDevice>& vStorageDevicesOut ) = 0;
|
||||
};
|
||||
|
||||
MemoryCardDriver *MakeMemoryCardDriver();
|
||||
|
||||
@@ -13,13 +13,10 @@ const CString TEMP_MOUNT_POINT = "@mctemptimeout/";
|
||||
MemoryCardDriverThreaded_Windows::MemoryCardDriverThreaded_Windows()
|
||||
{
|
||||
m_dwLastLogicalDrives = 0;
|
||||
|
||||
StartThread();
|
||||
}
|
||||
|
||||
MemoryCardDriverThreaded_Windows::~MemoryCardDriverThreaded_Windows()
|
||||
{
|
||||
StopThread();
|
||||
}
|
||||
|
||||
typedef const CString& CCStringRef;
|
||||
@@ -58,28 +55,21 @@ static bool TestWrite( CCStringRef sDrive )
|
||||
return true;
|
||||
}
|
||||
|
||||
void MemoryCardDriverThreaded_Windows::ResetUsbStorage()
|
||||
void MemoryCardDriverThreaded_Windows::Reset()
|
||||
{
|
||||
m_dwLastLogicalDrives = 0;
|
||||
}
|
||||
|
||||
bool MemoryCardDriverThreaded_Windows::MountThreadWaitForUpdate()
|
||||
bool MemoryCardDriverThreaded_Windows::DoOneUpdate( bool bMount, vector<UsbStorageDevice>& vStorageDevicesOut )
|
||||
{
|
||||
DWORD dwNewLogicalDrives = ::GetLogicalDrives();
|
||||
if( dwNewLogicalDrives == m_dwLastLogicalDrives )
|
||||
{
|
||||
// no change from last update
|
||||
usleep( 50000 );
|
||||
return false;
|
||||
}
|
||||
|
||||
m_dwLastLogicalDrives = dwNewLogicalDrives;
|
||||
return true;
|
||||
}
|
||||
|
||||
void MemoryCardDriverThreaded_Windows::MountThreadDoOneUpdate()
|
||||
{
|
||||
DWORD dwNewLogicalDrives = ::GetLogicalDrives();
|
||||
|
||||
{
|
||||
vector<UsbStorageDevice> vNewStorageDevices;
|
||||
@@ -124,19 +114,17 @@ void MemoryCardDriverThreaded_Windows::MountThreadDoOneUpdate()
|
||||
|
||||
CHECKPOINT;
|
||||
|
||||
{
|
||||
LockMut( m_mutexStorageDevices );
|
||||
m_bStorageDevicesChanged = true;
|
||||
m_vStorageDevices = vNewStorageDevices;
|
||||
}
|
||||
vStorageDevicesOut = vNewStorageDevices;
|
||||
|
||||
CHECKPOINT;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void MemoryCardDriverThreaded_Windows::Mount( UsbStorageDevice* pDevice )
|
||||
bool MemoryCardDriverThreaded_Windows::Mount( UsbStorageDevice* pDevice )
|
||||
{
|
||||
// nothing to do here...
|
||||
return true;
|
||||
}
|
||||
|
||||
void MemoryCardDriverThreaded_Windows::Unmount( UsbStorageDevice* pDevice )
|
||||
|
||||
@@ -1,22 +1,20 @@
|
||||
#ifndef MemoryCardDriverThreaded_Windows_H
|
||||
#define MemoryCardDriverThreaded_Windows_H 1
|
||||
#define MemoryCardDriverThreaded_Windows_H
|
||||
|
||||
#include "MemoryCardDriverThreaded.h"
|
||||
#include "MemoryCardDriver.h"
|
||||
#include <windows.h>
|
||||
|
||||
class MemoryCardDriverThreaded_Windows : public MemoryCardDriverThreaded
|
||||
class MemoryCardDriverThreaded_Windows : public MemoryCardDriver
|
||||
{
|
||||
public:
|
||||
MemoryCardDriverThreaded_Windows();
|
||||
virtual ~MemoryCardDriverThreaded_Windows();
|
||||
|
||||
virtual bool DoOneUpdate( bool bMount, vector<UsbStorageDevice>& vStorageDevicesOut );
|
||||
virtual bool Mount( UsbStorageDevice* pDevice );
|
||||
virtual void Unmount( UsbStorageDevice* pDevice );
|
||||
virtual void Flush( UsbStorageDevice* pDevice );
|
||||
protected:
|
||||
virtual void Mount( UsbStorageDevice* pDevice );
|
||||
virtual void ResetUsbStorage();
|
||||
virtual void MountThreadDoOneUpdate();
|
||||
virtual bool MountThreadWaitForUpdate();
|
||||
virtual void Reset();
|
||||
|
||||
DWORD m_dwLastLogicalDrives;
|
||||
};
|
||||
|
||||
@@ -7,17 +7,10 @@ class MemoryCardDriver_Null : public MemoryCardDriver
|
||||
{
|
||||
public:
|
||||
MemoryCardDriver_Null() {}
|
||||
virtual bool StorageDevicesChanged() { return false; }
|
||||
virtual void GetStorageDevices( vector<UsbStorageDevice>& vStorageDevicesOut ) {}
|
||||
virtual bool MountAndTestWrite( UsbStorageDevice* pDevice ) { return false; }
|
||||
virtual bool DoOneUpdate( bool bMount, vector<UsbStorageDevice>& vStorageDevicesOut ) { return false; }
|
||||
virtual bool Mount( UsbStorageDevice* pDevice ) { return false; }
|
||||
virtual void Unmount( UsbStorageDevice* pDevice ) {}
|
||||
virtual void Flush( UsbStorageDevice* pDevice ) {}
|
||||
virtual void ResetUsbStorage() {}
|
||||
virtual void PauseMountingThread() {}
|
||||
virtual void UnPauseMountingThread() {}
|
||||
virtual void DoOsMount() {}
|
||||
virtual void DontDoOsMount() {}
|
||||
virtual void SetMountThreadState( MountThreadState mts ) {}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user