sacd-ripper / sacd-ripper

SACD ripping software using a PS3
GNU General Public License v2.0
342 stars 109 forks source link

To read 2064 bytes sector. #89

Open Sergy2001 opened 8 years ago

Sergy2001 commented 8 years ago

Please add those code to read 2064 bytes sectors. (stolen from foo_input_sacd-0.9.6)

___ scarletbook.h ____ /**

___ scarletbook.c ____

include "scarletbook.h"

uint32_t sacd_sector_size = SACD_LSN_SIZE;

_ scarletbook_read.c __ master_toc = handle->master_toc = (master_toc_t *) handle->master_data;

if (strncmp("SACDMTOC", master_toc->id, 8) != 0) { fprintf(stderr, "libsacdread: Try use 2064 SACD sector size!\n"); sacd_sector_size = SACD_PSN_SIZE; if (!sacd_read_block_raw(handle->sacd, START_OF_MASTER_TOC, MASTER_TOC_LEN, handle->master_data)) return 0; }

if (strncmp("SACDMTOC", master_toc->id, 8) != 0)
{
    fprintf(stderr, "libsacdread: Not a ScarletBook disc!\n");
    return 0;
}

_ sacd_input.c __ /**

ssize_t ret = 0;

switch (sacd_sector_size) {
case SACD_LSN_SIZE:
{
    ret = lseek(dev->fd, (off_t)pos * (off_t)SACD_LSN_SIZE, SEEK_SET);
    if (ret < 0) return 0;

    ret = read(dev->fd, buffer, (unsigned int)blocks * SACD_LSN_SIZE); //if (ret < 0) return ret; //One of the reads failed, too bad.  We won't even bother returning the reads that went OK, and as in the POSIX spec the file position is left unspecified after a failure.
    if (ret != blocks * SACD_LSN_SIZE) return 0;
    break;
}
case SACD_PSN_SIZE:
{
    for (uint32_t i = 0; i < blocks; i++) 
    {
        ret = lseek(dev->fd, (off_t)(pos + i) * (off_t)SACD_PSN_SIZE + 12, SEEK_SET);
        if (ret < 0) return 0;

        ret = read(dev->fd, (uint8_t*)buffer + i * SACD_LSN_SIZE, SACD_LSN_SIZE);
        if (ret != SACD_LSN_SIZE) return 0;
    }
    break;
}
}
return blocks;

endif

}