Skip to content

Instantly share code, notes, and snippets.

@engleek
Created August 3, 2010 10:12
Show Gist options
  • Save engleek/506145 to your computer and use it in GitHub Desktop.
Save engleek/506145 to your computer and use it in GitHub Desktop.
ssize_t
DVDDiskNode::ReadAt(off_t pos, void *buffer, size_t size)
{
printf("DVD::ReadAt(%i, %lu)\n", (int)pos, (unsigned long)size);
int blockCount = ceil(size / DVD_VIDEO_LB_LEN);
uint8_t *buf = (uint8_t *) buffer;
buf = new uint8_t[blockCount * DVD_VIDEO_LB_LEN];
for (int i = 0; i < blockCount; i++) {
fResult = dvdnav_get_next_block(fDVDNav, buf + i * DVD_VIDEO_LB_LEN, &fEvent, &fLen);
if (fResult == DVDNAV_STATUS_ERR) {
printf("DVD: Error getting next block: %s\n", dvdnav_err_to_string(fDVDNav));
return B_ERROR;
}
while (fEvent != DVDNAV_BLOCK_OK) {
fResult = dvdnav_get_next_block(fDVDNav, buf + i * DVD_VIDEO_LB_LEN, &fEvent, &fLen);
if (fResult == DVDNAV_STATUS_ERR) {
printf("DVD: Error getting next block: %s\n", dvdnav_err_to_string(fDVDNav));
return B_ERROR;
}
}
}
return blockCount * DVD_VIDEO_LB_LEN;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment