Work on mode1 reading. Remove some of the bogusity in cdio.c and bincue.c
win2, now works!
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: _cdio_bincue.c,v 1.42 2004/02/26 03:57:42 rocky Exp $
|
||||
$Id: _cdio_bincue.c,v 1.43 2004/03/05 04:23:52 rocky Exp $
|
||||
|
||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||
Copyright (C) 2002, 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||
@@ -24,7 +24,7 @@
|
||||
(*.cue).
|
||||
*/
|
||||
|
||||
static const char _rcsid[] = "$Id: _cdio_bincue.c,v 1.42 2004/02/26 03:57:42 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: _cdio_bincue.c,v 1.43 2004/03/05 04:23:52 rocky Exp $";
|
||||
|
||||
#include "cdio_assert.h"
|
||||
#include "cdio_private.h"
|
||||
@@ -510,6 +510,70 @@ _cdio_read_audio_sectors (void *env, void *data, lsn_t lsn,
|
||||
from lsn. Returns 0 if no error.
|
||||
*/
|
||||
static int
|
||||
_cdio_read_mode1_sector (void *env, void *data, lsn_t lsn,
|
||||
bool mode1_form2)
|
||||
{
|
||||
_img_private_t *_obj = env;
|
||||
int ret;
|
||||
char buf[CDIO_CD_FRAMESIZE_RAW] = { 0, };
|
||||
int blocksize = _obj->sector_2336
|
||||
? M2RAW_SECTOR_SIZE : CDIO_CD_FRAMESIZE_RAW;
|
||||
|
||||
_cdio_init (_obj);
|
||||
|
||||
ret = cdio_stream_seek (_obj->gen.data_source, lsn * blocksize, SEEK_SET);
|
||||
if (ret!=0) return ret;
|
||||
|
||||
ret = cdio_stream_read (_obj->gen.data_source,
|
||||
_obj->sector_2336
|
||||
? (buf + CDIO_CD_SYNC_SIZE + CDIO_CD_HEADER_SIZE)
|
||||
: buf,
|
||||
blocksize, 1);
|
||||
if (ret==0) return ret;
|
||||
|
||||
memcpy (data, buf + CDIO_CD_SYNC_SIZE + CDIO_CD_HEADER_SIZE,
|
||||
mode1_form2 ? M2RAW_SECTOR_SIZE: CDIO_CD_FRAMESIZE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Reads nblocks of mode1 sectors from cd device into data starting
|
||||
from lsn.
|
||||
Returns 0 if no error.
|
||||
*/
|
||||
static int
|
||||
_cdio_read_mode1_sectors (void *env, void *data, uint32_t lsn,
|
||||
bool mode1_form2, unsigned int nblocks)
|
||||
{
|
||||
_img_private_t *_obj = env;
|
||||
int i;
|
||||
int retval;
|
||||
|
||||
for (i = 0; i < nblocks; i++) {
|
||||
if (mode1_form2) {
|
||||
if ( (retval = _cdio_read_mode1_sector (_obj,
|
||||
((char *)data)
|
||||
+ (M2RAW_SECTOR_SIZE * i),
|
||||
lsn + i, true)) )
|
||||
return retval;
|
||||
} else {
|
||||
char buf[M2RAW_SECTOR_SIZE] = { 0, };
|
||||
if ( (retval = _cdio_read_mode1_sector (_obj, buf, lsn + i, false)) )
|
||||
return retval;
|
||||
|
||||
memcpy (((char *)data) + (CDIO_CD_FRAMESIZE * i),
|
||||
buf, CDIO_CD_FRAMESIZE);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Reads a single mode1 sector from cd device into data starting
|
||||
from lsn. Returns 0 if no error.
|
||||
*/
|
||||
static int
|
||||
_cdio_read_mode2_sector (void *env, void *data, lsn_t lsn,
|
||||
bool mode2_form2)
|
||||
{
|
||||
@@ -531,11 +595,8 @@ _cdio_read_mode2_sector (void *env, void *data, lsn_t lsn,
|
||||
blocksize, 1);
|
||||
if (ret==0) return ret;
|
||||
|
||||
if (mode2_form2)
|
||||
memcpy (data, buf + CDIO_CD_SYNC_SIZE + CDIO_CD_HEADER_SIZE,
|
||||
M2RAW_SECTOR_SIZE);
|
||||
else
|
||||
memcpy (data, buf + CDIO_CD_XA_SYNC_HEADER, CDIO_CD_FRAMESIZE);
|
||||
memcpy (data, buf + CDIO_CD_XA_SYNC_HEADER,
|
||||
mode2_form2 ? M2RAW_SECTOR_SIZE : CDIO_CD_FRAMESIZE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -896,6 +957,8 @@ cdio_open_common (_img_private_t **_data)
|
||||
.lseek = _cdio_lseek,
|
||||
.read = _cdio_read,
|
||||
.read_audio_sectors = _cdio_read_audio_sectors,
|
||||
.read_mode1_sector = _cdio_read_mode1_sector,
|
||||
.read_mode1_sectors = _cdio_read_mode1_sectors,
|
||||
.read_mode2_sector = _cdio_read_mode2_sector,
|
||||
.read_mode2_sectors = _cdio_read_mode2_sectors,
|
||||
.set_arg = _cdio_set_arg,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: _cdio_win32.c,v 1.27 2004/03/03 02:41:18 rocky Exp $
|
||||
$Id: _cdio_win32.c,v 1.28 2004/03/05 04:23:52 rocky Exp $
|
||||
|
||||
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
static const char _rcsid[] = "$Id: _cdio_win32.c,v 1.27 2004/03/03 02:41:18 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: _cdio_win32.c,v 1.28 2004/03/05 04:23:52 rocky Exp $";
|
||||
|
||||
#include <cdio/cdio.h>
|
||||
#include <cdio/sector.h>
|
||||
@@ -145,6 +145,68 @@ _cdio_read_audio_sectors (void *user_data, void *data, lsn_t lsn,
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Reads a single mode1 sector from cd device into data starting
|
||||
from lsn. Returns 0 if no error.
|
||||
*/
|
||||
static int
|
||||
_cdio_read_mode1_sector (void *user_data, void *data, lsn_t lsn,
|
||||
bool mode1_form2)
|
||||
{
|
||||
_img_private_t *env = user_data;
|
||||
|
||||
if (env->gen.ioctls_debugged == 75)
|
||||
cdio_debug ("only displaying every 75th ioctl from now on");
|
||||
|
||||
if (env->gen.ioctls_debugged == 30 * 75)
|
||||
cdio_debug ("only displaying every 30*75th ioctl from now on");
|
||||
|
||||
if (env->gen.ioctls_debugged < 75
|
||||
|| (env->gen.ioctls_debugged < (30 * 75)
|
||||
&& env->gen.ioctls_debugged % 75 == 0)
|
||||
|| env->gen.ioctls_debugged % (30 * 75) == 0)
|
||||
cdio_debug ("reading %lu", (unsigned long int) lsn);
|
||||
|
||||
env->gen.ioctls_debugged++;
|
||||
|
||||
if ( env->hASPI ) {
|
||||
return 1;
|
||||
} else {
|
||||
return win32ioctl_read_mode1_sector( env, data, lsn, mode1_form2 );
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Reads nblocks of mode1 sectors from cd device into data starting
|
||||
from lsn.
|
||||
Returns 0 if no error.
|
||||
*/
|
||||
static int
|
||||
_cdio_read_mode1_sectors (void *user_data, void *data, lsn_t lsn,
|
||||
bool mode1_form2, unsigned int nblocks)
|
||||
{
|
||||
_img_private_t *env = user_data;
|
||||
int i;
|
||||
int retval;
|
||||
|
||||
for (i = 0; i < nblocks; i++) {
|
||||
if (mode1_form2) {
|
||||
if ( (retval = _cdio_read_mode1_sector (env,
|
||||
((char *)data) + (M2RAW_SECTOR_SIZE * i),
|
||||
lsn + i, true)) )
|
||||
return retval;
|
||||
} else {
|
||||
char buf[M2RAW_SECTOR_SIZE] = { 0, };
|
||||
if ( (retval = _cdio_read_mode1_sector (env, buf, lsn + i, false)) )
|
||||
return retval;
|
||||
|
||||
memcpy (((char *)data) + (CDIO_CD_FRAMESIZE * i),
|
||||
buf, CDIO_CD_FRAMESIZE);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Reads a single mode2 sector from cd device into data starting
|
||||
from lsn. Returns 0 if no error.
|
||||
@@ -191,7 +253,7 @@ _cdio_read_mode2_sector (void *user_data, void *data, lsn_t lsn,
|
||||
*/
|
||||
static int
|
||||
_cdio_read_mode2_sectors (void *user_data, void *data, lsn_t lsn,
|
||||
bool mode2_form2, unsigned int nblocks)
|
||||
bool mode2_form2, unsigned int nblocks)
|
||||
{
|
||||
_img_private_t *env = user_data;
|
||||
int i;
|
||||
@@ -200,7 +262,8 @@ _cdio_read_mode2_sectors (void *user_data, void *data, lsn_t lsn,
|
||||
for (i = 0; i < nblocks; i++) {
|
||||
if (mode2_form2) {
|
||||
if ( (retval = _cdio_read_mode2_sector (env,
|
||||
((char *)data) + (M2RAW_SECTOR_SIZE * i),
|
||||
((char *)data)
|
||||
+ (M2RAW_SECTOR_SIZE * i),
|
||||
lsn + i, true)) )
|
||||
return retval;
|
||||
} else {
|
||||
@@ -577,6 +640,8 @@ cdio_open_win32 (const char *source_name)
|
||||
.lseek = NULL,
|
||||
.read = NULL,
|
||||
.read_audio_sectors = _cdio_read_audio_sectors,
|
||||
.read_mode1_sector = _cdio_read_mode1_sector,
|
||||
.read_mode1_sectors = _cdio_read_mode1_sectors,
|
||||
.read_mode2_sector = _cdio_read_mode2_sector,
|
||||
.read_mode2_sectors = _cdio_read_mode2_sectors,
|
||||
.set_arg = _cdio_set_arg,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: _cdio_win32.h,v 1.3 2004/02/05 03:02:16 rocky Exp $
|
||||
$Id: _cdio_win32.h,v 1.4 2004/03/05 04:23:52 rocky Exp $
|
||||
|
||||
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -60,6 +60,14 @@ int
|
||||
win32ioctl_read_mode2_sector (_img_private_t *env, void *data, lsn_t lsn,
|
||||
bool mode2_form2);
|
||||
|
||||
/*!
|
||||
Reads a single mode1 sector using the DeviceIoControl method into
|
||||
data starting from lsn. Returns 0 if no error.
|
||||
*/
|
||||
int
|
||||
win32ioctl_read_mode1_sector (_img_private_t *env, void *data, lsn_t lsn,
|
||||
bool mode2_form2);
|
||||
|
||||
const char *win32ioctl_is_cdrom(const char drive_letter);
|
||||
|
||||
/*!
|
||||
|
||||
39
lib/cdio.c
39
lib/cdio.c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: cdio.c,v 1.38 2004/02/07 02:40:20 rocky Exp $
|
||||
$Id: cdio.c,v 1.39 2004/03/05 04:23:52 rocky Exp $
|
||||
|
||||
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
||||
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
|
||||
@@ -37,7 +37,7 @@
|
||||
#include <cdio/logging.h>
|
||||
#include "cdio_private.h"
|
||||
|
||||
static const char _rcsid[] = "$Id: cdio.c,v 1.38 2004/02/07 02:40:20 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: cdio.c,v 1.39 2004/03/05 04:23:52 rocky Exp $";
|
||||
|
||||
|
||||
const char *track_format2str[6] =
|
||||
@@ -678,44 +678,35 @@ cdio_read_mode1_sector (const CdIo *cdio, void *data, lsn_t lsn, bool is_form2)
|
||||
{
|
||||
uint32_t size = is_form2 ? M2RAW_SECTOR_SIZE : CDIO_CD_FRAMESIZE ;
|
||||
char buf[M2RAW_SECTOR_SIZE] = { 0, };
|
||||
int ret;
|
||||
|
||||
cdio_assert (cdio != NULL);
|
||||
cdio_assert (data != NULL);
|
||||
|
||||
if (cdio->op.lseek && cdio->op.read) {
|
||||
if (cdio->op.read_mode1_sector && cdio->op.read_mode1_sector) {
|
||||
return cdio->op.read_mode1_sector(cdio->env, data, lsn, is_form2);
|
||||
} else if (cdio->op.lseek && cdio->op.read) {
|
||||
if (0 > cdio_lseek(cdio, CDIO_CD_FRAMESIZE*lsn, SEEK_SET))
|
||||
return -1;
|
||||
if (0 > cdio_read(cdio, buf, CDIO_CD_FRAMESIZE))
|
||||
return -1;
|
||||
memcpy (data, buf, size);
|
||||
return 0;
|
||||
} else {
|
||||
ret = cdio_read_mode2_sector(cdio, data, lsn, is_form2);
|
||||
if (ret == 0)
|
||||
memcpy (data, buf+CDIO_CD_SUBHEADER_SIZE, size);
|
||||
}
|
||||
return ret;
|
||||
|
||||
return 1;
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
cdio_read_mode1_sectors (const CdIo *cdio, void *data, lsn_t lsn,
|
||||
cdio_read_mode1_sectors (const CdIo *cdio, void *buf, lsn_t lsn,
|
||||
bool is_form2, unsigned int num_sectors)
|
||||
{
|
||||
uint32_t size = is_form2 ? M2RAW_SECTOR_SIZE : CDIO_CD_FRAMESIZE ;
|
||||
int retval;
|
||||
int i;
|
||||
|
||||
cdio_assert (cdio != NULL);
|
||||
cdio_assert (buf != NULL);
|
||||
cdio_assert (cdio->op.read_mode1_sectors != NULL);
|
||||
|
||||
for (i = 0; i < num_sectors; i++) {
|
||||
if ( (retval = cdio_read_mode1_sector (cdio,
|
||||
((char *)data) + (size * i),
|
||||
lsn + i, is_form2)) )
|
||||
return retval;
|
||||
}
|
||||
return 0;
|
||||
return cdio->op.read_mode1_sectors (cdio->env, buf, lsn, is_form2,
|
||||
num_sectors);
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -741,15 +732,15 @@ cdio_read_mode2_sector (const CdIo *cdio, void *buf, lsn_t lsn,
|
||||
}
|
||||
|
||||
int
|
||||
cdio_read_mode2_sectors (const CdIo *cdio, void *buf, lsn_t lsn, bool mode2raw,
|
||||
unsigned num_sectors)
|
||||
cdio_read_mode2_sectors (const CdIo *cdio, void *buf, lsn_t lsn,
|
||||
bool is_form2, unsigned int num_sectors)
|
||||
{
|
||||
cdio_assert (cdio != NULL);
|
||||
cdio_assert (buf != NULL);
|
||||
cdio_assert (cdio->op.read_mode2_sectors != NULL);
|
||||
|
||||
return cdio->op.read_mode2_sectors (cdio->env, buf, lsn,
|
||||
mode2raw, num_sectors);
|
||||
is_form2, num_sectors);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
$Id: cdio_private.h,v 1.18 2004/02/07 18:53:02 rocky Exp $
|
||||
$Id: cdio_private.h,v 1.19 2004/03/05 04:23:52 rocky Exp $
|
||||
|
||||
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
|
||||
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -146,7 +146,7 @@ extern "C" {
|
||||
from lsn. Returns 0 if no error.
|
||||
*/
|
||||
int (*read_mode2_sector) (void *env, void *buf, lsn_t lsn,
|
||||
bool mode2raw);
|
||||
bool mode2_form2);
|
||||
|
||||
/*!
|
||||
Reads nblocks of mode2 sectors from cd device into data starting
|
||||
@@ -154,7 +154,22 @@ extern "C" {
|
||||
Returns 0 if no error.
|
||||
*/
|
||||
int (*read_mode2_sectors) (void *env, void *buf, lsn_t lsn,
|
||||
bool mode2raw, unsigned int nblocks);
|
||||
bool mode2_form2, unsigned int nblocks);
|
||||
|
||||
/*!
|
||||
Reads a single mode1 sector from cd device into buf starting
|
||||
from lsn. Returns 0 if no error.
|
||||
*/
|
||||
int (*read_mode1_sector) (void *env, void *buf, lsn_t lsn,
|
||||
bool mode1_form2);
|
||||
|
||||
/*!
|
||||
Reads nblocks of mode1 sectors from cd device into data starting
|
||||
from lsn.
|
||||
Returns 0 if no error.
|
||||
*/
|
||||
int (*read_mode1_sectors) (void *env, void *buf, lsn_t lsn,
|
||||
bool mode1_form2, unsigned int nblocks);
|
||||
|
||||
/*!
|
||||
Set the arg "key" with "value" in the source device.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: win32ioctl.c,v 1.5 2004/03/04 04:01:30 rocky Exp $
|
||||
$Id: win32ioctl.c,v 1.6 2004/03/05 04:23:52 rocky Exp $
|
||||
|
||||
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
static const char _rcsid[] = "$Id: win32ioctl.c,v 1.5 2004/03/04 04:01:30 rocky Exp $";
|
||||
static const char _rcsid[] = "$Id: win32ioctl.c,v 1.6 2004/03/05 04:23:52 rocky Exp $";
|
||||
|
||||
#include <cdio/cdio.h>
|
||||
#include <cdio/sector.h>
|
||||
@@ -224,14 +224,12 @@ win32ioctl_read_audio_sectors (_img_private_t *env, void *data, lsn_t lsn,
|
||||
}
|
||||
|
||||
/*!
|
||||
Reads a single mode2 sector using the DeviceIoControl method into
|
||||
Reads a single raw sector using the DeviceIoControl method into
|
||||
data starting from lsn. Returns 0 if no error.
|
||||
*/
|
||||
int
|
||||
win32ioctl_read_mode2_sector (_img_private_t *env, void *data, lsn_t lsn,
|
||||
bool mode2_form2)
|
||||
static int
|
||||
win32ioctl_read_raw_sector (_img_private_t *env, void *buf, lsn_t lsn)
|
||||
{
|
||||
char buf[CDIO_CD_FRAMESIZE_RAW] = { 0, };
|
||||
SCSI_PASS_THROUGH_DIRECT sptd;
|
||||
BOOL success;
|
||||
DWORD dwBytesReturned;
|
||||
@@ -279,12 +277,49 @@ win32ioctl_read_mode2_sector (_img_private_t *env, void *data, lsn_t lsn,
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (mode2_form2)
|
||||
memcpy (data, buf + 24, M2RAW_SECTOR_SIZE);
|
||||
else
|
||||
memcpy (((char *)data), buf + 24, CDIO_CD_FRAMESIZE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
Reads a single mode2 sector using the DeviceIoControl method into
|
||||
data starting from lsn. Returns 0 if no error.
|
||||
*/
|
||||
int
|
||||
win32ioctl_read_mode2_sector (_img_private_t *env, void *data, lsn_t lsn,
|
||||
bool mode2_form2)
|
||||
{
|
||||
char buf[CDIO_CD_FRAMESIZE_RAW] = { 0, };
|
||||
int ret = win32ioctl_read_raw_sector (env, buf, lsn);
|
||||
|
||||
if ( 0 != ret) return ret;
|
||||
|
||||
memcpy (data,
|
||||
buf + CDIO_CD_SYNC_SIZE + CDIO_CD_XA_HEADER,
|
||||
mode2_form2 ? M2RAW_SECTOR_SIZE: CDIO_CD_FRAMESIZE);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
Reads a single mode2 sector using the DeviceIoControl method into
|
||||
data starting from lsn. Returns 0 if no error.
|
||||
*/
|
||||
int
|
||||
win32ioctl_read_mode1_sector (_img_private_t *env, void *data, lsn_t lsn,
|
||||
bool mode2_form2)
|
||||
{
|
||||
char buf[CDIO_CD_FRAMESIZE_RAW] = { 0, };
|
||||
int ret = win32ioctl_read_raw_sector (env, buf, lsn);
|
||||
|
||||
if ( 0 != ret) return ret;
|
||||
|
||||
memcpy (data,
|
||||
buf + CDIO_CD_SYNC_SIZE+CDIO_CD_HEADER_SIZE,
|
||||
mode2_form2 ? M2RAW_SECTOR_SIZE: CDIO_CD_FRAMESIZE);
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
Reference in New Issue
Block a user