mirror of https://github.com/PCSX2/pcsx2.git
cdvdgigaherz:windows: Refactor to use early returns
This commit is contained in:
parent
5c158b4df9
commit
75c803df11
|
@ -206,43 +206,42 @@ bool IOCtlSrc::ReadDVDInfo()
|
||||||
std::array<u8, 22> buffer;
|
std::array<u8, 22> buffer;
|
||||||
DVD_READ_STRUCTURE dvdrs{{0}, DvdPhysicalDescriptor, 0, 0};
|
DVD_READ_STRUCTURE dvdrs{{0}, DvdPhysicalDescriptor, 0, 0};
|
||||||
|
|
||||||
BOOL ret = DeviceIoControl(m_device, IOCTL_DVD_READ_STRUCTURE, &dvdrs, sizeof(dvdrs),
|
if (!DeviceIoControl(m_device, IOCTL_DVD_READ_STRUCTURE, &dvdrs, sizeof(dvdrs),
|
||||||
buffer.data(), buffer.size(), &unused, nullptr);
|
buffer.data(), buffer.size(), &unused, nullptr))
|
||||||
if (ret) {
|
return false;
|
||||||
auto &layer = *reinterpret_cast<DVD_LAYER_DESCRIPTOR *>(
|
|
||||||
reinterpret_cast<DVD_DESCRIPTOR_HEADER *>(buffer.data())->Data);
|
|
||||||
|
|
||||||
u32 start_sector = _byteswap_ulong(layer.StartingDataSector);
|
auto &layer = *reinterpret_cast<DVD_LAYER_DESCRIPTOR *>(
|
||||||
u32 end_sector = _byteswap_ulong(layer.EndDataSector);
|
reinterpret_cast<DVD_DESCRIPTOR_HEADER *>(buffer.data())->Data);
|
||||||
|
|
||||||
if (layer.NumberOfLayers == 0) {
|
u32 start_sector = _byteswap_ulong(layer.StartingDataSector);
|
||||||
// Single layer
|
u32 end_sector = _byteswap_ulong(layer.EndDataSector);
|
||||||
m_media_type = 0;
|
|
||||||
m_layer_break = 0;
|
|
||||||
m_sectors = end_sector - start_sector + 1;
|
|
||||||
} else if (layer.TrackPath == 0) {
|
|
||||||
// Dual layer, Parallel Track Path
|
|
||||||
dvdrs.LayerNumber = 1;
|
|
||||||
ret = DeviceIoControl(m_device, IOCTL_DVD_READ_STRUCTURE, &dvdrs,
|
|
||||||
sizeof(dvdrs), buffer.data(), buffer.size(), &unused, nullptr);
|
|
||||||
if (ret) {
|
|
||||||
u32 layer1_start_sector = _byteswap_ulong(layer.StartingDataSector);
|
|
||||||
u32 layer1_end_sector = _byteswap_ulong(layer.EndDataSector);
|
|
||||||
|
|
||||||
m_media_type = 1;
|
if (layer.NumberOfLayers == 0) {
|
||||||
m_layer_break = end_sector - start_sector;
|
// Single layer
|
||||||
m_sectors = end_sector - start_sector + 1 + layer1_end_sector - layer1_start_sector + 1;
|
m_media_type = 0;
|
||||||
}
|
m_layer_break = 0;
|
||||||
} else {
|
m_sectors = end_sector - start_sector + 1;
|
||||||
// Dual layer, Opposite Track Path
|
} else if (layer.TrackPath == 0) {
|
||||||
u32 end_sector_layer0 = _byteswap_ulong(layer.EndLayerZeroSector);
|
// Dual layer, Parallel Track Path
|
||||||
m_media_type = 2;
|
dvdrs.LayerNumber = 1;
|
||||||
m_layer_break = end_sector_layer0 - start_sector;
|
if (!DeviceIoControl(m_device, IOCTL_DVD_READ_STRUCTURE, &dvdrs, sizeof(dvdrs),
|
||||||
m_sectors = end_sector_layer0 - start_sector + 1 + end_sector - (~end_sector_layer0 & 0xFFFFFFU) + 1;
|
buffer.data(), buffer.size(), &unused, nullptr))
|
||||||
}
|
return false;
|
||||||
|
u32 layer1_start_sector = _byteswap_ulong(layer.StartingDataSector);
|
||||||
|
u32 layer1_end_sector = _byteswap_ulong(layer.EndDataSector);
|
||||||
|
|
||||||
|
m_media_type = 1;
|
||||||
|
m_layer_break = end_sector - start_sector;
|
||||||
|
m_sectors = end_sector - start_sector + 1 + layer1_end_sector - layer1_start_sector + 1;
|
||||||
|
} else {
|
||||||
|
// Dual layer, Opposite Track Path
|
||||||
|
u32 end_sector_layer0 = _byteswap_ulong(layer.EndLayerZeroSector);
|
||||||
|
m_media_type = 2;
|
||||||
|
m_layer_break = end_sector_layer0 - start_sector;
|
||||||
|
m_sectors = end_sector_layer0 - start_sector + 1 + end_sector - (~end_sector_layer0 & 0xFFFFFFU) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return !!ret;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IOCtlSrc::ReadCDInfo()
|
bool IOCtlSrc::ReadCDInfo()
|
||||||
|
|
Loading…
Reference in New Issue