2014-04-06 13:11:19 +00:00
|
|
|
/* PCSX2 - PS2 Emulator for PCs
|
|
|
|
* Copyright (C) 2002-2014 David Quintana [gigaherz]
|
|
|
|
*
|
|
|
|
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
|
|
|
* of the GNU Lesser General Public License as published by the Free Software Found-
|
|
|
|
* ation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
|
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with PCSX2.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2010-04-24 21:37:39 +00:00
|
|
|
#include "CDVD.h"
|
2016-10-25 00:32:51 +00:00
|
|
|
#include <atomic>
|
|
|
|
#include <condition_variable>
|
2016-11-11 17:51:19 +00:00
|
|
|
#include <limits>
|
2016-11-17 20:07:31 +00:00
|
|
|
#include <queue>
|
2016-10-25 00:51:36 +00:00
|
|
|
#include <thread>
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2016-12-17 14:17:27 +00:00
|
|
|
const u32 sectors_per_read = 16;
|
|
|
|
|
|
|
|
static_assert(sectors_per_read > 1 && !(sectors_per_read & (sectors_per_read - 1)),
|
|
|
|
"sectors_per_read must by a power of 2");
|
|
|
|
|
2016-11-11 17:51:19 +00:00
|
|
|
struct SectorInfo
|
|
|
|
{
|
|
|
|
u32 lsn;
|
|
|
|
s32 mode;
|
2016-12-17 14:17:27 +00:00
|
|
|
// Sectors are read in blocks, not individually
|
|
|
|
u8 data[2352 * sectors_per_read];
|
2016-11-11 17:51:19 +00:00
|
|
|
};
|
|
|
|
|
2016-12-17 22:03:50 +00:00
|
|
|
CacheRequest g_last_sector_block;
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2016-10-25 00:51:36 +00:00
|
|
|
static std::thread s_thread;
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2016-10-25 00:32:51 +00:00
|
|
|
static std::mutex s_notify_lock;
|
|
|
|
static std::condition_variable s_notify_cv;
|
|
|
|
static std::mutex s_request_lock;
|
2016-11-17 20:07:31 +00:00
|
|
|
static std::queue<CacheRequest> s_request_queue;
|
2016-10-24 23:08:09 +00:00
|
|
|
static std::mutex s_cache_lock;
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2016-10-25 00:32:51 +00:00
|
|
|
static std::atomic<bool> cdvd_is_open;
|
|
|
|
|
2014-05-26 12:28:56 +00:00
|
|
|
//bits: 12 would use 1<<12 entries, or 4096*16 sectors ~ 128MB
|
|
|
|
#define CACHE_SIZE 12
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2016-11-11 17:51:19 +00:00
|
|
|
const u32 CacheSize = 1U << CACHE_SIZE;
|
2010-04-24 21:37:39 +00:00
|
|
|
SectorInfo Cache[CacheSize];
|
|
|
|
|
2016-11-11 17:51:19 +00:00
|
|
|
u32 cdvdSectorHash(u32 lsn, s32 mode)
|
2010-04-24 21:37:39 +00:00
|
|
|
{
|
2016-09-19 17:24:54 +00:00
|
|
|
u32 t = 0;
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2016-09-19 17:24:54 +00:00
|
|
|
int i = 32;
|
2016-11-11 17:51:19 +00:00
|
|
|
u32 m = CacheSize - 1;
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2016-09-19 17:24:54 +00:00
|
|
|
while (i >= 0) {
|
|
|
|
t ^= lsn & m;
|
|
|
|
lsn >>= CACHE_SIZE;
|
|
|
|
i -= CACHE_SIZE;
|
|
|
|
}
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2016-09-19 17:24:54 +00:00
|
|
|
return (t ^ mode) & m;
|
2010-04-24 21:37:39 +00:00
|
|
|
}
|
|
|
|
|
2016-11-11 17:51:19 +00:00
|
|
|
void cdvdCacheUpdate(u32 lsn, s32 mode, u8 *data)
|
2010-04-24 21:37:39 +00:00
|
|
|
{
|
2016-10-24 23:08:09 +00:00
|
|
|
std::lock_guard<std::mutex> guard(s_cache_lock);
|
2016-09-19 17:24:54 +00:00
|
|
|
u32 entry = cdvdSectorHash(lsn, mode);
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2016-12-17 14:17:27 +00:00
|
|
|
memcpy(Cache[entry].data, data, 2352 * sectors_per_read);
|
2016-09-19 17:24:54 +00:00
|
|
|
Cache[entry].lsn = lsn;
|
|
|
|
Cache[entry].mode = mode;
|
2010-04-24 21:37:39 +00:00
|
|
|
}
|
|
|
|
|
2016-11-16 20:50:36 +00:00
|
|
|
bool cdvdCacheCheck(u32 lsn, s32 mode)
|
|
|
|
{
|
|
|
|
std::lock_guard<std::mutex> guard(s_cache_lock);
|
|
|
|
u32 entry = cdvdSectorHash(lsn, mode);
|
|
|
|
|
|
|
|
return Cache[entry].lsn == lsn && Cache[entry].mode == mode;
|
|
|
|
}
|
|
|
|
|
2016-11-11 17:51:19 +00:00
|
|
|
bool cdvdCacheFetch(u32 lsn, s32 mode, u8 *data)
|
2010-04-24 21:37:39 +00:00
|
|
|
{
|
2016-10-24 23:08:09 +00:00
|
|
|
std::lock_guard<std::mutex> guard(s_cache_lock);
|
2016-09-19 17:24:54 +00:00
|
|
|
u32 entry = cdvdSectorHash(lsn, mode);
|
|
|
|
|
|
|
|
if ((Cache[entry].lsn == lsn) &&
|
|
|
|
(Cache[entry].mode == mode)) {
|
2016-12-17 14:17:27 +00:00
|
|
|
memcpy(data, Cache[entry].data, 2352 * sectors_per_read);
|
2016-09-19 17:24:54 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
//printf("NOT IN CACHE\n");
|
|
|
|
return false;
|
2010-04-24 21:37:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void cdvdCacheReset()
|
|
|
|
{
|
2016-10-24 23:08:09 +00:00
|
|
|
std::lock_guard<std::mutex> guard(s_cache_lock);
|
2016-11-11 17:51:19 +00:00
|
|
|
for (u32 i = 0; i < CacheSize; i++) {
|
|
|
|
Cache[i].lsn = std::numeric_limits<u32>::max();
|
2016-09-19 17:24:54 +00:00
|
|
|
Cache[i].mode = -1;
|
|
|
|
}
|
2010-04-24 21:37:39 +00:00
|
|
|
}
|
|
|
|
|
2016-11-16 20:42:31 +00:00
|
|
|
bool cdvdReadBlockOfSectors(u32 sector, s32 mode, u8 *data)
|
|
|
|
{
|
2016-12-17 14:17:27 +00:00
|
|
|
u32 count = std::min(sectors_per_read, src->GetSectorCount() - sector);
|
2017-10-10 20:19:22 +00:00
|
|
|
const s32 media = src->GetMediaType();
|
2016-11-16 20:42:31 +00:00
|
|
|
|
2016-12-17 22:03:50 +00:00
|
|
|
// TODO: Is it really necessary to retry if it fails? I'm not sure the
|
|
|
|
// second time is really going to be any better.
|
|
|
|
for (int tries = 0; tries < 2; ++tries) {
|
2017-10-10 20:19:22 +00:00
|
|
|
if (media >= 0) {
|
2016-11-16 20:42:31 +00:00
|
|
|
if (src->ReadSectors2048(sector, count, data))
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
if (src->ReadSectors2352(sector, count, data))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-04-24 21:37:39 +00:00
|
|
|
void cdvdCallNewDiscCB()
|
|
|
|
{
|
2016-09-19 17:24:54 +00:00
|
|
|
weAreInNewDiskCB = true;
|
|
|
|
newDiscCB();
|
|
|
|
weAreInNewDiskCB = false;
|
2010-04-24 21:37:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool cdvdUpdateDiscStatus()
|
|
|
|
{
|
2016-10-22 23:53:41 +00:00
|
|
|
bool ready = src->DiscReady();
|
2016-09-19 17:24:54 +00:00
|
|
|
|
2016-10-22 23:53:41 +00:00
|
|
|
if (!ready) {
|
2016-09-19 17:24:54 +00:00
|
|
|
if (!disc_has_changed) {
|
|
|
|
disc_has_changed = true;
|
|
|
|
curDiskType = CDVD_TYPE_NODISC;
|
|
|
|
curTrayStatus = CDVD_TRAY_OPEN;
|
|
|
|
cdvdCallNewDiscCB();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (disc_has_changed) {
|
|
|
|
curDiskType = CDVD_TYPE_NODISC;
|
|
|
|
curTrayStatus = CDVD_TRAY_CLOSE;
|
|
|
|
|
|
|
|
disc_has_changed = false;
|
|
|
|
cdvdRefreshData();
|
2016-11-17 20:07:31 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
std::lock_guard<std::mutex> request_guard(s_request_lock);
|
|
|
|
s_request_queue = std::queue<CacheRequest>();
|
|
|
|
}
|
|
|
|
|
2016-09-19 17:24:54 +00:00
|
|
|
cdvdCallNewDiscCB();
|
|
|
|
}
|
|
|
|
}
|
2016-10-22 23:53:41 +00:00
|
|
|
return !ready;
|
2010-04-24 21:37:39 +00:00
|
|
|
}
|
|
|
|
|
2016-10-25 00:51:36 +00:00
|
|
|
void cdvdThread()
|
2010-04-24 21:37:39 +00:00
|
|
|
{
|
2016-12-17 14:17:27 +00:00
|
|
|
u8 buffer[2352 * sectors_per_read];
|
2016-12-17 22:03:50 +00:00
|
|
|
u32 prefetches_left = 0;
|
2016-11-17 20:07:31 +00:00
|
|
|
|
2016-09-19 17:24:54 +00:00
|
|
|
printf(" * CDVD: IO thread started...\n");
|
2016-10-25 00:32:51 +00:00
|
|
|
std::unique_lock<std::mutex> guard(s_notify_lock);
|
2016-09-19 17:24:54 +00:00
|
|
|
|
|
|
|
while (cdvd_is_open) {
|
|
|
|
if (cdvdUpdateDiscStatus()) {
|
|
|
|
// Need to sleep some to avoid an aggressive spin that sucks the cpu dry.
|
2016-11-17 20:07:01 +00:00
|
|
|
s_notify_cv.wait_for(guard, std::chrono::milliseconds(10));
|
2016-12-17 22:03:50 +00:00
|
|
|
prefetches_left = 0;
|
2016-09-19 17:24:54 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-12-17 22:03:50 +00:00
|
|
|
if (prefetches_left == 0)
|
|
|
|
s_notify_cv.wait_for(guard, std::chrono::milliseconds(250));
|
2016-09-19 17:24:54 +00:00
|
|
|
|
|
|
|
// check again to make sure we're not done here...
|
|
|
|
if (!cdvd_is_open)
|
|
|
|
break;
|
|
|
|
|
2016-12-17 22:03:50 +00:00
|
|
|
// Read request
|
2016-11-17 20:07:31 +00:00
|
|
|
bool handling_request = false;
|
|
|
|
CacheRequest request;
|
2016-09-19 17:24:54 +00:00
|
|
|
|
2016-11-17 20:07:31 +00:00
|
|
|
{
|
|
|
|
std::lock_guard<std::mutex> request_guard(s_request_lock);
|
|
|
|
if (!s_request_queue.empty()) {
|
|
|
|
request = s_request_queue.front();
|
|
|
|
s_request_queue.pop();
|
|
|
|
handling_request = true;
|
|
|
|
}
|
2016-09-19 17:24:54 +00:00
|
|
|
}
|
|
|
|
|
2016-12-17 22:03:50 +00:00
|
|
|
if (!handling_request) {
|
|
|
|
if (prefetches_left == 0)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
--prefetches_left;
|
2016-09-19 17:24:54 +00:00
|
|
|
|
2016-12-17 22:03:50 +00:00
|
|
|
u32 next_prefetch_lsn = g_last_sector_block.lsn + sectors_per_read;
|
|
|
|
request = {next_prefetch_lsn, g_last_sector_block.mode};
|
|
|
|
}
|
2016-09-19 17:24:54 +00:00
|
|
|
|
2016-12-17 22:03:50 +00:00
|
|
|
// Handle request
|
|
|
|
if (!cdvdCacheCheck(request.lsn, request.mode)) {
|
|
|
|
if (cdvdReadBlockOfSectors(request.lsn, request.mode, buffer)) {
|
|
|
|
cdvdCacheUpdate(request.lsn, request.mode, buffer);
|
2016-09-19 17:24:54 +00:00
|
|
|
} else {
|
2016-12-17 22:03:50 +00:00
|
|
|
// If the read fails, further reads are likely to fail too.
|
|
|
|
prefetches_left = 0;
|
|
|
|
continue;
|
2016-09-19 17:24:54 +00:00
|
|
|
}
|
|
|
|
}
|
2016-12-17 22:03:50 +00:00
|
|
|
|
|
|
|
g_last_sector_block = request;
|
|
|
|
|
|
|
|
if (!handling_request)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// Prefetch
|
|
|
|
u32 next_prefetch_lsn = g_last_sector_block.lsn + sectors_per_read;
|
|
|
|
if (next_prefetch_lsn >= src->GetSectorCount()) {
|
|
|
|
prefetches_left = 0;
|
|
|
|
} else {
|
|
|
|
const u32 max_prefetches = 16;
|
|
|
|
u32 remaining = src->GetSectorCount() - next_prefetch_lsn;
|
|
|
|
prefetches_left = std::min((remaining + sectors_per_read - 1) / sectors_per_read, max_prefetches);
|
|
|
|
}
|
2016-09-19 17:24:54 +00:00
|
|
|
}
|
|
|
|
printf(" * CDVD: IO thread finished.\n");
|
2010-04-24 21:37:39 +00:00
|
|
|
}
|
|
|
|
|
2016-10-25 00:51:36 +00:00
|
|
|
bool cdvdStartThread()
|
2010-04-24 21:37:39 +00:00
|
|
|
{
|
2016-09-19 17:24:54 +00:00
|
|
|
cdvd_is_open = true;
|
2016-10-25 00:51:36 +00:00
|
|
|
try {
|
|
|
|
s_thread = std::thread(cdvdThread);
|
|
|
|
} catch (std::system_error &) {
|
|
|
|
cdvd_is_open = false;
|
|
|
|
return false;
|
|
|
|
}
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2016-09-19 17:24:54 +00:00
|
|
|
cdvdCacheReset();
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2016-10-25 00:51:36 +00:00
|
|
|
return true;
|
2010-04-24 21:37:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void cdvdStopThread()
|
|
|
|
{
|
2016-09-19 17:24:54 +00:00
|
|
|
cdvd_is_open = false;
|
2016-10-25 00:32:51 +00:00
|
|
|
s_notify_cv.notify_one();
|
2016-10-25 00:51:36 +00:00
|
|
|
s_thread.join();
|
2010-04-24 21:37:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
s32 cdvdRequestSector(u32 sector, s32 mode)
|
|
|
|
{
|
2016-10-17 19:15:57 +00:00
|
|
|
if (sector >= src->GetSectorCount())
|
2016-09-19 17:24:54 +00:00
|
|
|
return -1;
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2016-12-17 14:17:27 +00:00
|
|
|
// Align to cache block
|
|
|
|
sector &= ~(sectors_per_read - 1);
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2016-11-17 20:07:31 +00:00
|
|
|
if (cdvdCacheCheck(sector, mode))
|
2016-09-19 17:24:54 +00:00
|
|
|
return 0;
|
2016-11-17 20:07:31 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
std::lock_guard<std::mutex> guard(s_request_lock);
|
|
|
|
s_request_queue.push({sector, mode});
|
2016-09-19 17:24:54 +00:00
|
|
|
}
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2016-10-25 00:32:51 +00:00
|
|
|
s_notify_cv.notify_one();
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2016-09-19 17:24:54 +00:00
|
|
|
return 0;
|
2010-04-24 21:37:39 +00:00
|
|
|
}
|
|
|
|
|
2016-11-11 17:51:19 +00:00
|
|
|
u8 *cdvdGetSector(u32 sector, s32 mode)
|
2010-04-24 21:37:39 +00:00
|
|
|
{
|
2016-12-17 14:17:27 +00:00
|
|
|
static u8 buffer[2352 * sectors_per_read];
|
|
|
|
|
|
|
|
// Align to cache block
|
|
|
|
u32 sector_block = sector & ~(sectors_per_read - 1);
|
2016-11-16 22:02:00 +00:00
|
|
|
|
|
|
|
if (!cdvdCacheFetch(sector_block, mode, buffer))
|
|
|
|
if (cdvdReadBlockOfSectors(sector_block, mode, buffer))
|
|
|
|
cdvdCacheUpdate(sector_block, mode, buffer);
|
2016-09-19 17:24:54 +00:00
|
|
|
|
2017-10-10 20:19:22 +00:00
|
|
|
if (src->GetMediaType() >= 0) {
|
2016-11-16 22:02:00 +00:00
|
|
|
u32 offset = 2048 * (sector - sector_block);
|
|
|
|
return buffer + offset;
|
2016-09-19 17:24:54 +00:00
|
|
|
}
|
|
|
|
|
2016-11-16 22:02:00 +00:00
|
|
|
u32 offset = 2352 * (sector - sector_block);
|
|
|
|
u8 *data = buffer + offset;
|
2016-09-19 17:24:54 +00:00
|
|
|
|
|
|
|
switch (mode) {
|
2017-10-10 20:19:22 +00:00
|
|
|
case CDVD_MODE_2048:
|
|
|
|
// Data location depends on CD mode
|
|
|
|
return (data[15] & 3) == 2 ? data + 24 : data + 16;
|
2016-09-19 17:24:54 +00:00
|
|
|
case CDVD_MODE_2328:
|
|
|
|
return data + 24;
|
|
|
|
case CDVD_MODE_2340:
|
|
|
|
return data + 12;
|
|
|
|
}
|
|
|
|
return data;
|
2010-04-24 21:37:39 +00:00
|
|
|
}
|
|
|
|
|
2016-12-17 14:18:10 +00:00
|
|
|
s32 cdvdDirectReadSector(u32 sector, s32 mode, u8 *buffer)
|
2010-04-24 21:37:39 +00:00
|
|
|
{
|
2016-12-17 14:17:27 +00:00
|
|
|
static u8 data[2352 * sectors_per_read];
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2016-12-17 14:18:10 +00:00
|
|
|
if (sector >= src->GetSectorCount())
|
2016-09-19 17:24:54 +00:00
|
|
|
return -1;
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2016-12-17 14:17:27 +00:00
|
|
|
// Align to cache block
|
2016-12-17 14:18:10 +00:00
|
|
|
u32 sector_block = sector & ~(sectors_per_read - 1);
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2016-12-17 14:18:10 +00:00
|
|
|
if (!cdvdCacheFetch(sector_block, mode, data)) {
|
|
|
|
if (cdvdReadBlockOfSectors(sector_block, mode, data))
|
|
|
|
cdvdCacheUpdate(sector_block, mode, data);
|
2016-09-19 17:24:54 +00:00
|
|
|
}
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2017-10-10 20:19:22 +00:00
|
|
|
if (src->GetMediaType() >= 0) {
|
2016-12-17 14:18:10 +00:00
|
|
|
u32 offset = 2048 * (sector - sector_block);
|
2016-09-19 17:24:54 +00:00
|
|
|
memcpy(buffer, data + offset, 2048);
|
|
|
|
return 0;
|
|
|
|
}
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2016-12-17 14:18:10 +00:00
|
|
|
u32 offset = 2352 * (sector - sector_block);
|
2016-11-11 17:51:19 +00:00
|
|
|
u8 *bfr = data + offset;
|
2010-04-24 21:37:39 +00:00
|
|
|
|
2016-09-19 17:24:54 +00:00
|
|
|
switch (mode) {
|
2017-10-10 20:19:22 +00:00
|
|
|
case CDVD_MODE_2048:
|
|
|
|
// Data location depends on CD mode
|
|
|
|
std::memcpy(buffer, (bfr[15] & 3) == 2 ? bfr + 24 : bfr + 16, 2048);
|
|
|
|
return 0;
|
2016-09-19 17:24:54 +00:00
|
|
|
case CDVD_MODE_2328:
|
|
|
|
memcpy(buffer, bfr + 24, 2328);
|
|
|
|
return 0;
|
|
|
|
case CDVD_MODE_2340:
|
|
|
|
memcpy(buffer, bfr + 12, 2340);
|
|
|
|
return 0;
|
|
|
|
default:
|
2016-12-17 22:38:04 +00:00
|
|
|
memcpy(buffer, bfr, 2352);
|
2016-09-19 17:24:54 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2010-04-24 21:37:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
s32 cdvdGetMediaType()
|
|
|
|
{
|
2016-09-19 17:24:54 +00:00
|
|
|
return src->GetMediaType();
|
2010-04-24 21:37:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
s32 cdvdRefreshData()
|
|
|
|
{
|
2016-10-26 16:31:26 +00:00
|
|
|
const char *diskTypeName = "Unknown";
|
2016-09-19 17:24:54 +00:00
|
|
|
|
|
|
|
//read TOC from device
|
|
|
|
cdvdParseTOC();
|
|
|
|
|
|
|
|
if ((etrack == 0) || (strack > etrack)) {
|
|
|
|
curDiskType = CDVD_TYPE_NODISC;
|
|
|
|
} else {
|
|
|
|
s32 mt = cdvdGetMediaType();
|
|
|
|
|
|
|
|
if (mt < 0)
|
|
|
|
curDiskType = CDVD_TYPE_DETCTCD;
|
|
|
|
else if (mt == 0)
|
|
|
|
curDiskType = CDVD_TYPE_DETCTDVDS;
|
|
|
|
else
|
|
|
|
curDiskType = CDVD_TYPE_DETCTDVDD;
|
|
|
|
}
|
|
|
|
|
|
|
|
curTrayStatus = CDVD_TRAY_CLOSE;
|
|
|
|
|
|
|
|
switch (curDiskType) {
|
|
|
|
case CDVD_TYPE_DETCTDVDD:
|
|
|
|
diskTypeName = "Double-Layer DVD";
|
|
|
|
break;
|
|
|
|
case CDVD_TYPE_DETCTDVDS:
|
|
|
|
diskTypeName = "Single-Layer DVD";
|
|
|
|
break;
|
|
|
|
case CDVD_TYPE_DETCTCD:
|
|
|
|
diskTypeName = "CD-ROM";
|
|
|
|
break;
|
|
|
|
case CDVD_TYPE_NODISC:
|
|
|
|
diskTypeName = "No Disc";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
printf(" * CDVD: Disk Type: %s\n", diskTypeName);
|
|
|
|
|
|
|
|
cdvdCacheReset();
|
|
|
|
|
|
|
|
return 0;
|
2010-04-24 21:37:39 +00:00
|
|
|
}
|