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