mirror of
https://github.com/holub/mame
synced 2025-05-28 16:43:04 +03:00
cdrom: Bunch of fixes
This commit is contained in:
parent
9287a147fd
commit
232c846392
@ -129,12 +129,33 @@ std::pair<std::error_condition, std::string> cdrom_image_device::call_load()
|
||||
|
||||
// open the CHD file
|
||||
if (chd)
|
||||
{
|
||||
if (chd->is_cd())
|
||||
m_cdrom_handle.reset(new cdrom_file(chd));
|
||||
else if(m_dvd_compat && chd->is_dvd())
|
||||
m_dvdrom_handle.reset(new dvdrom_file(chd));
|
||||
else
|
||||
{
|
||||
err = image_error::UNSUPPORTED;
|
||||
goto error;
|
||||
}
|
||||
m_cdrom_handle.reset(new cdrom_file(chd));
|
||||
}
|
||||
else
|
||||
m_cdrom_handle.reset(new cdrom_file(filename()));
|
||||
|
||||
if (!m_cdrom_handle)
|
||||
goto error;
|
||||
{
|
||||
try {
|
||||
auto *cdrom = new cdrom_file(filename());
|
||||
m_cdrom_handle.reset(cdrom);
|
||||
} catch(void *) {
|
||||
try {
|
||||
auto *dvdrom = new dvdrom_file(filename());
|
||||
m_dvdrom_handle.reset(dvdrom);
|
||||
} catch(void *) {
|
||||
err = image_error::UNSUPPORTED;
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return std::make_pair(std::error_condition(), std::string());
|
||||
|
||||
@ -178,6 +199,8 @@ bool cdrom_image_device::read_data(uint32_t lbasector, void *buffer, uint32_t da
|
||||
{
|
||||
if (m_cdrom_handle)
|
||||
return m_cdrom_handle->read_data(lbasector, buffer, datatype, phys);
|
||||
if (m_dvdrom_handle)
|
||||
return !m_dvdrom_handle->read_data(lbasector, buffer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -217,7 +240,7 @@ bool cdrom_image_device::is_cd() const
|
||||
|
||||
bool cdrom_image_device::is_gd() const
|
||||
{
|
||||
return false;
|
||||
return m_cdrom_handle && m_cdrom_handle->is_gdrom();
|
||||
}
|
||||
|
||||
bool cdrom_image_device::is_dvd() const
|
||||
|
@ -151,6 +151,7 @@ public:
|
||||
static const char *get_subtype_string(uint32_t subtype);
|
||||
static std::error_condition parse_metadata(chd_file *chd, toc &toc);
|
||||
static std::error_condition write_metadata(chd_file *chd, const toc &toc);
|
||||
bool is_gdrom() const { return cdtoc.flags & (CD_FLAG_GDROM|CD_FLAG_GDROMLE); }
|
||||
|
||||
// ECC utilities
|
||||
static bool ecc_verify(const uint8_t *sector);
|
||||
|
Loading…
Reference in New Issue
Block a user