Impliment MCN for bincue.

This commit is contained in:
rocky
2003-09-28 01:04:57 +00:00
parent 3c5888e31d
commit 5b79bb49ef
4 changed files with 41 additions and 8 deletions

View File

@@ -1,5 +1,5 @@
/* -*- c -*- /* -*- c -*-
$Id: cdio.h,v 1.22 2003/09/27 23:29:29 rocky Exp $ $Id: cdio.h,v 1.23 2003/09/28 01:04:57 rocky Exp $
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org> Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2003 Rocky Bernstein <rocky@panix.com> Copyright (C) 2003 Rocky Bernstein <rocky@panix.com>
@@ -131,8 +131,8 @@ extern "C" {
char * cdio_get_default_device (const CdIo *obj); char * cdio_get_default_device (const CdIo *obj);
/*! /*!
Return the media catalog number MCN from the CD or NULL if there is none or Return the media catalog number (MCN) from the CD or NULL if there
we don't have the ability to get it. is none or we don't have the ability to get it.
Note: string is malloc'd so caller has to free() the returned Note: string is malloc'd so caller has to free() the returned
string when done with it. string when done with it.

View File

@@ -1,5 +1,5 @@
/* /*
$Id: _cdio_bincue.c,v 1.31 2003/09/27 23:29:29 rocky Exp $ $Id: _cdio_bincue.c,v 1.32 2003/09/28 01:04:58 rocky Exp $
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org> Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2002,2003 Rocky Bernstein <rocky@panix.com> Copyright (C) 2002,2003 Rocky Bernstein <rocky@panix.com>
@@ -24,7 +24,7 @@
(*.cue). (*.cue).
*/ */
static const char _rcsid[] = "$Id: _cdio_bincue.c,v 1.31 2003/09/27 23:29:29 rocky Exp $"; static const char _rcsid[] = "$Id: _cdio_bincue.c,v 1.32 2003/09/28 01:04:58 rocky Exp $";
#include "cdio_assert.h" #include "cdio_assert.h"
#include "cdio_private.h" #include "cdio_private.h"
@@ -88,6 +88,7 @@ typedef struct {
bool sector_2336; /* Playstation (PSX) uses 2336-byte sectors */ bool sector_2336; /* Playstation (PSX) uses 2336-byte sectors */
char *cue_name; char *cue_name;
char *mcn; /* Media catalog number. */
track_info_t tocent[100]; /* entry info for each track */ track_info_t tocent[100]; /* entry info for each track */
track_t total_tracks; /* number of tracks in image */ track_t total_tracks; /* number of tracks in image */
track_t first_track_num; /* track number of first track */ track_t first_track_num; /* track number of first track */
@@ -314,6 +315,8 @@ _cdio_image_read_cue (_img_private_t *_obj)
_obj->total_tracks=0; _obj->total_tracks=0;
_obj->first_track_num=1; _obj->first_track_num=1;
_obj->mcn=NULL;
while ((fgets(line, MAXLINE, fp)) != NULL) { while ((fgets(line, MAXLINE, fp)) != NULL) {
char *s=NULL; char *s=NULL;
char *p; char *p;
@@ -326,6 +329,8 @@ _cdio_image_read_cue (_img_private_t *_obj)
_obj->bin_file = s; _obj->bin_file = s;
*/ */
/* printf("Found file name %s\n", s); */ /* printf("Found file name %s\n", s); */
} else if (1==sscanf(p, "CATALOG %as", &s)) {
_obj->mcn = s;
} else if (2==sscanf(p, "TRACK %d MODE2/%d", &track_num, &blocksize)) { } else if (2==sscanf(p, "TRACK %d MODE2/%d", &track_num, &blocksize)) {
track_info_t *this_track=&(_obj->tocent[_obj->total_tracks]); track_info_t *this_track=&(_obj->tocent[_obj->total_tracks]);
this_track->track_num = track_num; this_track->track_num = track_num;
@@ -563,6 +568,15 @@ _cdio_read_mode2_sectors (void *env, void *data, uint32_t lsn,
#define free_if_notnull(obj) \ #define free_if_notnull(obj) \
if (NULL != obj) free(obj); if (NULL != obj) free(obj);
static void
_cdio_bincue_free (void *env) {
_img_private_t *_obj = env;
if (NULL == _obj) return;
free_if_notnull(_obj->mcn);
cdio_generic_stream_free(_obj);
}
/*! /*!
Set the arg "key" with "value" in the source device. Set the arg "key" with "value" in the source device.
Currently "source" to set the source device in I/O operations Currently "source" to set the source device in I/O operations
@@ -650,6 +664,24 @@ _cdio_get_first_track_num(void *env)
return _obj->first_track_num; return _obj->first_track_num;
} }
/*!
Return the media catalog number (MCN) from the CD or NULL if there
is none or we don't have the ability to get it.
Note: string is malloc'd so caller has to free() the returned
string when done with it.
*/
static char *
_cdio_get_mcn(void *env)
{
_img_private_t *_obj = env;
_cdio_init (_obj);
if (NULL == _obj->mcn) return NULL;
return strdup(_obj->mcn);
}
/*! /*!
Return the number of tracks in the current medium. Return the number of tracks in the current medium.
If no cuesheet is available, We fake it an just say there's If no cuesheet is available, We fake it an just say there's
@@ -819,11 +851,11 @@ cdio_open_common (_img_private_t **_data)
{ {
cdio_funcs _funcs = { cdio_funcs _funcs = {
.eject_media = cdio_generic_bogus_eject_media, .eject_media = cdio_generic_bogus_eject_media,
.free = cdio_generic_stream_free, .free = _cdio_bincue_free,
.get_arg = _cdio_get_arg, .get_arg = _cdio_get_arg,
.get_default_device = cdio_get_default_device_bincue, .get_default_device = cdio_get_default_device_bincue,
.get_first_track_num= _cdio_get_first_track_num, .get_first_track_num= _cdio_get_first_track_num,
.get_mcn = NULL, .get_mcn = _cdio_get_mcn,
.get_num_tracks = _cdio_get_num_tracks, .get_num_tracks = _cdio_get_num_tracks,
.get_track_format = _cdio_get_track_format, .get_track_format = _cdio_get_track_format,
.get_track_green = _cdio_get_track_green, .get_track_green = _cdio_get_track_green,

View File

@@ -1,3 +1,4 @@
CATALOG 0000010271955
FILE "BOING.BIN" BINARY FILE "BOING.BIN" BINARY
TRACK 01 AUDIO TRACK 01 AUDIO
INDEX 01 00:00:00 INDEX 01 00:00:00

View File

@@ -6,7 +6,7 @@ CD-ROM Track List (1 - 1)
#: MSF LSN Type #: MSF LSN Type
1: 00:02:00 000000 audio 1: 00:02:00 000000 audio
170: 00:06:02 000302 leadout 170: 00:06:02 000302 leadout
Media Catalog Number (MCN): not available Media Catalog Number (MCN): 0000010271955
__________________________________ __________________________________
CD Analysis Report CD Analysis Report
Audio CD, CDDB disc ID is 02000401 Audio CD, CDDB disc ID is 02000401