serialize all memory card operations since mount operations hang if we're doing lsusb or reading USB mass storage descriptors in another thread
This commit is contained in:
@@ -232,7 +232,8 @@ void GameState::PlayersFinalized()
|
||||
|
||||
m_bPlayersFinalized = true;
|
||||
|
||||
MEMCARDMAN->LockCards( true );
|
||||
MEMCARDMAN->PauseMountingThread();
|
||||
MEMCARDMAN->LockCards( true ); // this does a mount
|
||||
|
||||
// apply saved default modifiers if any
|
||||
FOREACH_HumanPlayer( pn )
|
||||
@@ -272,6 +273,7 @@ void GameState::PlayersFinalized()
|
||||
|
||||
if( PREFSMAN->m_bMemoryCardsMountOnlyWhenNecessary )
|
||||
MEMCARDMAN->UnmountAllUsedCards();
|
||||
MEMCARDMAN->UnPauseMountingThread();
|
||||
}
|
||||
|
||||
/* This data is added to each player profile, and to the machine profile per-player. */
|
||||
@@ -343,10 +345,9 @@ void GameState::EndGame()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MEMCARDMAN->PauseMountingThread();
|
||||
if( PREFSMAN->m_bMemoryCardsMountOnlyWhenNecessary )
|
||||
MEMCARDMAN->UnmountAllUsedCards();
|
||||
|
||||
MEMCARDMAN->MountAllUsedCards();
|
||||
|
||||
BOOKKEEPER->WriteToDisk();
|
||||
PROFILEMAN->SaveAllProfiles();
|
||||
@@ -359,11 +360,15 @@ void GameState::EndGame()
|
||||
PROFILEMAN->UnloadProfile( pn );
|
||||
}
|
||||
|
||||
if( PREFSMAN->m_bMemoryCardsMountOnlyWhenNecessary )
|
||||
MEMCARDMAN->UnmountAllUsedCards();
|
||||
|
||||
// Reset the USB storage device numbers -after- saving
|
||||
CHECKPOINT;
|
||||
MEMCARDMAN->FlushAndReset();
|
||||
CHECKPOINT;
|
||||
|
||||
|
||||
SONGMAN->FreeAllLoadedFromProfiles();
|
||||
|
||||
// make sure we don't execute EndGame twice.
|
||||
|
||||
@@ -215,16 +215,16 @@ void MemoryCardManager::LockCards( bool bLock )
|
||||
m_pDriver->MountAndTestWrite(&m_Device[p], MEM_CARD_MOUNT_POINT[p]);
|
||||
}
|
||||
}
|
||||
|
||||
if( !bWasLocked && bLock )
|
||||
m_pDriver->SetMountThreadState( MemoryCardDriver::detect_and_dont_mount );
|
||||
else
|
||||
|
||||
if( !bLock )
|
||||
{
|
||||
m_pDriver->SetMountThreadState( MemoryCardDriver::detect_and_mount );
|
||||
}
|
||||
}
|
||||
|
||||
void MemoryCardManager::TryMountAllCards()
|
||||
{
|
||||
FOREACH_PlayerNumber( p )
|
||||
FOREACH_EnabledPlayer( p )
|
||||
{
|
||||
if( m_Device[p].IsBlank() ) // they don't have an assigned card
|
||||
continue;
|
||||
@@ -235,12 +235,12 @@ void MemoryCardManager::TryMountAllCards()
|
||||
|
||||
void MemoryCardManager::MountAllUsedCards()
|
||||
{
|
||||
FOREACH_PlayerNumber( p )
|
||||
FOREACH_EnabledPlayer( p )
|
||||
{
|
||||
if( m_Device[p].IsBlank() ) // they don't have an assigned card
|
||||
continue;
|
||||
|
||||
if( m_bTooLate[p] || !m_Device[p].bWriteTestSucceeded )
|
||||
if( m_bTooLate[p] || !m_Device[p].bWriteTestSucceeded || !PROFILEMAN->ProfileWasLoadedFromMemoryCard(p) )
|
||||
continue;
|
||||
|
||||
m_pDriver->MountAndTestWrite(&m_Device[p], MEM_CARD_MOUNT_POINT[p]);
|
||||
@@ -249,12 +249,12 @@ void MemoryCardManager::MountAllUsedCards()
|
||||
|
||||
void MemoryCardManager::UnmountAllUsedCards()
|
||||
{
|
||||
FOREACH_PlayerNumber( p )
|
||||
FOREACH_EnabledPlayer( p )
|
||||
{
|
||||
if( m_Device[p].IsBlank() ) // they don't have an assigned card
|
||||
continue;
|
||||
|
||||
if( m_bTooLate[p] || !m_Device[p].bWriteTestSucceeded )
|
||||
if( m_bTooLate[p] || !m_Device[p].bWriteTestSucceeded || !PROFILEMAN->ProfileWasLoadedFromMemoryCard(p) )
|
||||
continue;
|
||||
|
||||
m_pDriver->Unmount(&m_Device[p], MEM_CARD_MOUNT_POINT[p]);
|
||||
@@ -317,9 +317,11 @@ void MemoryCardManager::UnPauseMountingThread()
|
||||
bool IsAnyPlayerUsingMemoryCard()
|
||||
{
|
||||
FOREACH_HumanPlayer( pn )
|
||||
{
|
||||
if( MEMCARDMAN->GetCardState(pn) == MEMORY_CARD_STATE_READY )
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#include "LuaFunctions.h"
|
||||
|
||||
@@ -33,10 +33,10 @@ public:
|
||||
void MountCard( PlayerNumber pn );
|
||||
void UnmountCard( PlayerNumber pn );
|
||||
|
||||
void PauseMountingThread(); // call this before reading or writing to memory card
|
||||
void UnPauseMountingThread(); // call this when done reading or writing to memory card
|
||||
void PauseMountingThread(); // call this before mouting, reading, or writing to memory card
|
||||
void UnPauseMountingThread(); // call this when done mouting, reading, or writing to memory card
|
||||
|
||||
void FlushAndReset(); // force all files to be written to mounted memory cards
|
||||
void FlushAndReset(); // force all files to be flushed to mounted memory cards
|
||||
|
||||
bool PathIsMemCard( CString sDir ) const;
|
||||
|
||||
|
||||
@@ -139,12 +139,9 @@ bool ProfileManager::LoadProfileFromMemoryCard( PlayerNumber pn )
|
||||
sDir += PREFSMAN->m_sMemoryCardProfileSubdir;
|
||||
sDir += '/';
|
||||
|
||||
MEMCARDMAN->PauseMountingThread();
|
||||
bool bSuccess;
|
||||
bSuccess = LoadProfile( pn, sDir, true );
|
||||
|
||||
MEMCARDMAN->UnPauseMountingThread();
|
||||
|
||||
return true; // If a card is inserted, we want to use the memory card to save - even if the Profile load failed.
|
||||
}
|
||||
|
||||
@@ -180,14 +177,8 @@ bool ProfileManager::SaveProfile( PlayerNumber pn ) const
|
||||
if( m_sProfileDir[pn].empty() )
|
||||
return false;
|
||||
|
||||
if( ProfileWasLoadedFromMemoryCard(pn) )
|
||||
MEMCARDMAN->PauseMountingThread();
|
||||
|
||||
bool b = m_Profile[pn].SaveAllToDir( m_sProfileDir[pn], PREFSMAN->m_bSignProfileData );
|
||||
|
||||
if( ProfileWasLoadedFromMemoryCard(pn) )
|
||||
MEMCARDMAN->UnPauseMountingThread();
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
@@ -1353,6 +1353,7 @@ void ScreenEvaluation::Input( const DeviceInput& DeviceI, const InputEventType t
|
||||
if( !m_bSavedScreenshot[pn] && // only allow one screenshot
|
||||
PROFILEMAN->IsUsingProfile(pn) )
|
||||
{
|
||||
MEMCARDMAN->PauseMountingThread();
|
||||
if( PROFILEMAN->ProfileWasLoadedFromMemoryCard(pn) && PREFSMAN->m_bMemoryCardsMountOnlyWhenNecessary )
|
||||
MEMCARDMAN->MountCard( pn );
|
||||
|
||||
@@ -1364,6 +1365,7 @@ void ScreenEvaluation::Input( const DeviceInput& DeviceI, const InputEventType t
|
||||
|
||||
if( PROFILEMAN->ProfileWasLoadedFromMemoryCard(pn) && PREFSMAN->m_bMemoryCardsMountOnlyWhenNecessary )
|
||||
MEMCARDMAN->UnmountCard( pn );
|
||||
MEMCARDMAN->UnPauseMountingThread();
|
||||
|
||||
if( !sFileName.empty() )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user