forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem with cdRead()

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 Development
View previous topic :: View next topic  
Author Message
misfire



Joined: 06 Sep 2004
Posts: 120
Location: Germany

PostPosted: Sat Nov 26, 2005 12:47 am    Post subject: Problem with cdRead() Reply with quote

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:
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?
Back to top
View user's profile Send private message
evilo



Joined: 22 Apr 2004
Posts: 230

PostPosted: Sat Nov 26, 2005 1:21 am    Post subject: Reply with quote

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.).
Back to top
View user's profile Send private message Visit poster's website
misfire



Joined: 06 Sep 2004
Posts: 120
Location: Germany

PostPosted: Tue Dec 06, 2005 7:35 pm    Post subject: Reply with quote

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:
// 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.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PS2 Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group