DKIOCCDREAD not returning expected number of bytes
DKIOCCDREAD not returning expected number of bytes
- Subject: DKIOCCDREAD not returning expected number of bytes
- From: "Stephen F. Booth" <email@hidden>
- Date: Sat, 1 Nov 2008 09:45:03 -0700
I've recently purchased some external CD/DVD drives, and I am seeing
strange behavior (with multiple devices) which I haven't ever seen
using the Apple supplied drives.
Specifically, I am requesting 775 sectors of CD-DA data and C2 error
flags. Since a CD-DA sector is 2352 bytes and the C2 error flags for
a sector are 294 bytes, I expect to get 2646 bytes per sector of data
from the drive. So in total I expect 2050650 bytes of data per read.
What I'm getting, though, is less data than that. The weird thing is
that the data doesn't even seem to come in multiples of 2646:
Requested 2050650 bytes at sector 33557 (offset 88791822), got 195796
Requested 2050650 bytes at sector 16230 (offset 42944580), got 388960
Requested 2050650 bytes at sector 68572 (offset 181441512), got 388960
Obviously 195796 / 2646 is 73.99, and 388960 / 2646 is 146.99. I
thought perhaps I was only getting CD-DA sectors back (which would
violate MMC), but again 195796 / 2352 is 83.2 and 388960 / 2352 is
165.37. The final check I did was for C2 error flags only but again
the data comes out to partial sectors.
The drive is not a cheap no-name; the results above came from a
Pioneer DVD-RW DVR-116C.
The code I'm using to read looks like this:
dk_cd_read_t cd_read;
NSUInteger blockSize = 0;
if(kCDSectorAreaUser & sectorAreas) blockSize += kCDSectorSizeCDDA;
if(kCDSectorAreaErrorFlags & sectorAreas) blockSize += kCDSectorSizeErrorFlags;
if(kCDSectorAreaSubChannelQ & sectorAreas) blockSize +=
kCDSectorSizeQSubchannel;
bzero(&cd_read, sizeof(cd_read));
bzero(buffer, blockSize * sectorCount);
cd_read.offset = (uint64_t)blockSize * startSector;
cd_read.sectorArea = sectorAreas;
cd_read.sectorType = kCDSectorTypeCDDA;
cd_read.buffer = buffer;
cd_read.bufferLength = blockSize * sectorCount;
if(-1 == ioctl(self.fd, DKIOCCDREAD, &cd_read)) {
self.error = [NSError errorWithDomain:NSPOSIXErrorDomain code:errno
userInfo:nil];
return 0;
}
#if DEBUG
if(cd_read.bufferLength != (blockSize * sectorCount))
NSLog(@"Requested %ld bytes at sector %ld (offset %ld), got %ld",
blockSize * sectorCount, startSector, blockSize * startSector,
cd_read.bufferLength);
#endif
I have never had my Apple-supplied drive (a Matshita DVD-R UJ-867)
return fewer bytes than requested. If I was at least getting complete
sectors back I could handle that.
Has anyone seen this before? Is this a bug somewhere or just a case
that needs to be handled?
Stephen
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden