Page 1 of 1

Problem with cdRead()

Posted: Sat Nov 26, 2005 12:47 am
by misfire
I've encountered a problem with cdRead(). When I try to read a non-existing sector, cdRead() returns 1 (OK) instead of 0 (error).

Example:

Code: Select all

void readtest()
{
	int ret;
	u8 buf[2048];
	CdvdReadMode_t mode;

	memset(buf, 0, sizeof(buf));
	mode.retries = 10;
	mode.sectorType = CDVD_SECTOR_2048;
	mode.readSpeed = CDVD_SPIN_NORMAL;

	cdInit(0);
	printf("Reading data from disc... ");
	ret = cdRead(-1, 1, buf, &mode); // read the sector at LBA (-1)
	cdSync(0); // blocking
	if (!ret) printf("Failed.\n");
	else printf("OK.\n");
}
And the output is: "Reading data from disc... OK."
I don't know why it acts like that.

Also, does anybody know how to get the total number of sectors on a disc? I guess this information is stored in the TOC, but where?

Posted: Sat Nov 26, 2005 1:21 am
by evilo
the TOC is a special area that cannot be read with the CdRead() function.

However, you can use the CdGetToc() function (seeing the function name, I don't think you need further information on it).

if you want some examples of usage, just check the sdk sources (audsrv for i.e.).

Posted: Tue Dec 06, 2005 7:35 pm
by misfire
I know how to read the TOC, I just can't find any information on how it is organized?

Also, what is its exact size? In libcdvd.h it says:

Code: Select all

// get toc from inserted disc
// 
// args:	buffer to hold toc (1024 or 2064 bytes?)
// returns:	1 if successful
//			0 otherwise
s32  cdGetToc(u8 *toc); 
Any help would be appreciated.