mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-04-29 08:45:42 -04:00
System: Use existing CD media when loading state where possible
This commit is contained in:
parent
0398c6cb4a
commit
93528db388
@ -450,15 +450,15 @@ void CDROM::InsertMedia(std::unique_ptr<CDImage> media)
|
|||||||
m_reader.SetMedia(std::move(media));
|
m_reader.SetMedia(std::move(media));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDROM::RemoveMedia(bool force /* = false */)
|
std::unique_ptr<CDImage> CDROM::RemoveMedia(bool force /* = false */)
|
||||||
{
|
{
|
||||||
if (!HasMedia() && !force)
|
if (!HasMedia() && !force)
|
||||||
return;
|
return nullptr;
|
||||||
|
|
||||||
const TickCount stop_ticks = GetTicksForStop(true);
|
const TickCount stop_ticks = GetTicksForStop(true);
|
||||||
|
|
||||||
Log_InfoPrintf("Removing CD...");
|
Log_InfoPrintf("Removing CD...");
|
||||||
m_reader.RemoveMedia();
|
std::unique_ptr<CDImage> image = m_reader.RemoveMedia();
|
||||||
|
|
||||||
m_last_sector_header_valid = false;
|
m_last_sector_header_valid = false;
|
||||||
|
|
||||||
@ -484,6 +484,8 @@ void CDROM::RemoveMedia(bool force /* = false */)
|
|||||||
m_drive_state = DriveState::ShellOpening;
|
m_drive_state = DriveState::ShellOpening;
|
||||||
m_drive_event->SetIntervalAndSchedule(stop_ticks);
|
m_drive_event->SetIntervalAndSchedule(stop_ticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDROM::SetUseReadThread(bool enabled)
|
void CDROM::SetUseReadThread(bool enabled)
|
||||||
|
@ -32,7 +32,7 @@ public:
|
|||||||
std::string GetMediaFileName() const { return m_reader.GetMediaFileName(); }
|
std::string GetMediaFileName() const { return m_reader.GetMediaFileName(); }
|
||||||
|
|
||||||
void InsertMedia(std::unique_ptr<CDImage> media);
|
void InsertMedia(std::unique_ptr<CDImage> media);
|
||||||
void RemoveMedia(bool force = false);
|
std::unique_ptr<CDImage> RemoveMedia(bool force = false);
|
||||||
|
|
||||||
// I/O
|
// I/O
|
||||||
u8 ReadRegister(u32 offset);
|
u8 ReadRegister(u32 offset);
|
||||||
|
@ -43,10 +43,10 @@ void CDROMAsyncReader::SetMedia(std::unique_ptr<CDImage> media)
|
|||||||
m_media = std::move(media);
|
m_media = std::move(media);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDROMAsyncReader::RemoveMedia()
|
std::unique_ptr<CDImage> CDROMAsyncReader::RemoveMedia()
|
||||||
{
|
{
|
||||||
WaitForReadToComplete();
|
WaitForReadToComplete();
|
||||||
m_media.reset();
|
return std::move(m_media);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDROMAsyncReader::QueueReadSector(CDImage::LBA lba)
|
void CDROMAsyncReader::QueueReadSector(CDImage::LBA lba)
|
||||||
|
@ -26,7 +26,7 @@ public:
|
|||||||
void StopThread();
|
void StopThread();
|
||||||
|
|
||||||
void SetMedia(std::unique_ptr<CDImage> media);
|
void SetMedia(std::unique_ptr<CDImage> media);
|
||||||
void RemoveMedia();
|
std::unique_ptr<CDImage> RemoveMedia();
|
||||||
|
|
||||||
void QueueReadSector(CDImage::LBA lba);
|
void QueueReadSector(CDImage::LBA lba);
|
||||||
void QueueReadNextSector();
|
void QueueReadNextSector();
|
||||||
|
@ -432,11 +432,17 @@ bool System::DoLoadState(ByteStream* state, bool init_components, bool force_sof
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
media = CDImage::Open(media_filename.c_str());
|
media = m_cdrom->RemoveMedia();
|
||||||
if (!media)
|
if (!media || media->GetFileName() != media_filename)
|
||||||
{
|
{
|
||||||
m_host_interface->ReportFormattedError("Failed to open CD image from save state: '%s'.", media_filename.c_str());
|
media.reset();
|
||||||
return false;
|
media = CDImage::Open(media_filename.c_str());
|
||||||
|
if (!media)
|
||||||
|
{
|
||||||
|
m_host_interface->ReportFormattedError("Failed to open CD image from save state: '%s'.",
|
||||||
|
media_filename.c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user