Add API routine to get last session number.

This commit is contained in:
rocky
2005-03-05 10:10:16 +00:00
parent d76eddad1b
commit 822a203ba8
23 changed files with 103 additions and 30 deletions

View File

@@ -1,5 +1,5 @@
/* -*- c -*- /* -*- c -*-
$Id: device.h,v 1.16 2005/03/01 09:33:52 rocky Exp $ $Id: device.h,v 1.17 2005/03/05 10:10:16 rocky Exp $
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com> Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
@@ -360,6 +360,15 @@ extern "C" {
/* out*/ cdio_hwinfo_t *p_hw_info ); /* out*/ cdio_hwinfo_t *p_hw_info );
/*!
Return the session number of the last on the CD.
@param p_cdio the CD object to be acted upon.
@param i_last_session pointer to the session number to be returned.
*/
driver_return_code_t cdio_get_last_session (CdIo_t *p_cdio, /*out*/ unsigned
int *i_last_session);
/*! /*!
Find out if media has changed since the last call. Find out if media has changed since the last call.
@param p_cdio the CD object to be acted upon. @param p_cdio the CD object to be acted upon.

View File

@@ -1,5 +1,5 @@
/* /*
$Id: cdio_private.h,v 1.19 2005/03/05 09:26:52 rocky Exp $ $Id: cdio_private.h,v 1.20 2005/03/05 10:10:16 rocky Exp $
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com> Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -202,6 +202,15 @@ extern "C" {
bool (*get_hwinfo) bool (*get_hwinfo)
( const CdIo_t *p_cdio, /* out*/ cdio_hwinfo_t *p_hw_info ); ( const CdIo_t *p_cdio, /* out*/ cdio_hwinfo_t *p_hw_info );
/*!
Return the session number of the last on the CD.
@param p_cdio the CD object to be acted upon.
@param i_last_session pointer to the session number to be returned.
*/
driver_return_code_t (*get_last_session)
(void *p_env, /*out*/ unsigned int *i_last_session);
/*! /*!
Find out if media has changed since the last call. Find out if media has changed since the last call.
@param p_env the CD object to be acted upon. @param p_env the CD object to be acted upon.

View File

@@ -1,5 +1,5 @@
/* /*
$Id: device.c,v 1.10 2005/02/10 01:59:06 rocky Exp $ $Id: device.c,v 1.11 2005/03/05 10:10:16 rocky Exp $
Copyright (C) 2005 Rocky Bernstein <rocky@panix.com> Copyright (C) 2005 Rocky Bernstein <rocky@panix.com>
@@ -576,6 +576,21 @@ cdio_get_hwinfo (const CdIo_t *p_cdio, cdio_hwinfo_t *hw_info)
} }
} }
/*!
Return the session number of the last on the CD.
@param p_cdio the CD object to be acted upon.
@param i_last_session pointer to the session number to be returned.
*/
driver_return_code_t cdio_get_last_session (CdIo_t *p_cdio, /*out*/ unsigned
int *i_last_session)
{
if (!p_cdio) return DRIVER_OP_UNINIT;
if (p_cdio->op.get_last_session)
return p_cdio->op.get_last_session(p_cdio->env, i_last_session);
return DRIVER_OP_UNSUPPORTED;
}
/*! /*!
Find out if media has changed since the last call. Find out if media has changed since the last call.
@param p_cdio the CD object to be acted upon. @param p_cdio the CD object to be acted upon.

View File

@@ -1,5 +1,5 @@
/* /*
$Id: gnu_linux.c,v 1.1 2005/03/05 09:26:52 rocky Exp $ $Id: gnu_linux.c,v 1.2 2005/03/05 10:10:16 rocky Exp $
Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org> Copyright (C) 2001 Herbert Valerio Riedel <hvr@gnu.org>
Copyright (C) 2002, 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com> Copyright (C) 2002, 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -27,7 +27,7 @@
# include "config.h" # include "config.h"
#endif #endif
static const char _rcsid[] = "$Id: gnu_linux.c,v 1.1 2005/03/05 09:26:52 rocky Exp $"; static const char _rcsid[] = "$Id: gnu_linux.c,v 1.2 2005/03/05 10:10:16 rocky Exp $";
#include <string.h> #include <string.h>
@@ -396,6 +396,33 @@ get_drive_cap_linux (const void *p_user_data,
} }
#endif #endif
/*!
Return the session number of the last on the CD.
@param p_cdio the CD object to be acted upon.
@param i_last_session pointer to the session number to be returned.
*/
static driver_return_code_t
get_last_session_linux (void *p_user_data,
/*out*/ unsigned int *i_last_session)
{
const _img_private_t *p_env = p_user_data;
struct cdrom_multisession ms;
int i_rc;
ms.addr_format = CDROM_LBA;
i_rc = ioctl(p_env->gen.fd, CDROMMULTISESSION, &ms);
if (0 == i_rc) {
*i_last_session = ms.addr.lba;
return DRIVER_OP_SUCCESS;
} else {
cdio_warn ("ioctl CDROMMULTISESSION failed: %s\n", strerror(errno));
return DRIVER_OP_ERROR;
}
}
/*! /*!
Find out if media has changed since the last call. Find out if media has changed since the last call.
@param p_user_data the environment object to be acted upon. @param p_user_data the environment object to be acted upon.
@@ -1318,6 +1345,7 @@ cdio_open_am_linux (const char *psz_orig_source, const char *access_mode)
#endif #endif
.get_first_track_num = get_first_track_num_generic, .get_first_track_num = get_first_track_num_generic,
.get_hwinfo = NULL, .get_hwinfo = NULL,
.get_last_session = get_last_session_linux,
.get_media_changed = get_media_changed_linux, .get_media_changed = get_media_changed_linux,
.get_mcn = get_mcn_linux, .get_mcn = get_mcn_linux,
.get_num_tracks = get_num_tracks_generic, .get_num_tracks = get_num_tracks_generic,

View File

@@ -62,6 +62,7 @@ cdio_get_first_track_num
cdio_get_hwinfo cdio_get_hwinfo
cdio_get_joliet_level cdio_get_joliet_level
cdio_get_last_track_num cdio_get_last_track_num
cdio_get_last_session
cdio_get_media_changed cdio_get_media_changed
cdio_get_mcn cdio_get_mcn
cdio_get_num_tracks cdio_get_num_tracks

View File

@@ -1,5 +1,5 @@
/* /*
$Id: cd-info.c,v 1.126 2005/03/02 04:24:00 rocky Exp $ $Id: cd-info.c,v 1.127 2005/03/05 10:10:16 rocky Exp $
Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com> Copyright (C) 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
Copyright (C) 1996, 1997, 1998 Gerd Knorr <kraxel@bytesex.org> Copyright (C) 1996, 1997, 1998 Gerd Knorr <kraxel@bytesex.org>
@@ -1140,14 +1140,27 @@ main(int argc, const char *argv[])
if (i_read_cap & CDIO_DRIVE_CAP_READ_MCN) if (i_read_cap & CDIO_DRIVE_CAP_READ_MCN)
report(stdout, "not available\n"); report(stdout, "not available\n");
else else
report(stdout, "not supported by drive\n"); report(stdout, "not supported by drive/driver\n");
} } else {
else {
report(stdout, "%s\n", media_catalog_number); report(stdout, "%s\n", media_catalog_number);
free(media_catalog_number); free(media_catalog_number);
} }
/* List number of sessions */
{
unsigned int i_last_session;
report(stdout, "Last CD Session #: "); fflush(stdout);
if (DRIVER_OP_SUCCESS == cdio_get_last_session(p_cdio, &i_last_session))
{
report(stdout, "%d\n", i_last_session);
} else {
if (i_read_cap & CDIO_DRIVE_CAP_MISC_MULTI_SESSION)
report(stdout, "failed\n");
else
report(stdout, "not supported by drive/driver\n");
}
}
/* get audio status from subchannel */ /* get audio status from subchannel */
if ( CDIO_DISC_MODE_CD_DA == discmode || if ( CDIO_DISC_MODE_CD_DA == discmode ||
CDIO_DISC_MODE_CD_MIXED == discmode ) { CDIO_DISC_MODE_CD_MIXED == discmode ) {
@@ -1219,25 +1232,6 @@ main(int argc, const char *argv[])
} }
} }
#if CDIO_IOCTL_FINISHED
if (!opts.no_ioctl) {
report(stdout, "What ioctl's report...\n");
#ifdef CDROMMULTISESSION
/* get multisession */
report( stdout, "multisession: "); fflush(stdout);
ms.addr_format = CDROM_LBA;
if (ioctl(filehandle,CDROMMULTISESSION,&ms))
report( stdout, "FAILED\n");
else
report( stdout, "%d%s\n",ms.addr.lba,ms.xa_flag?" XA":"");
#endif
}
#endif /*CDIO_IOCTL_FINISHED*/
if (!opts.no_analysis) { if (!opts.no_analysis) {
if (b_playing_audio) { if (b_playing_audio) {
/* Running a CD Analysis would mess up audio playback.*/ /* Running a CD Analysis would mess up audio playback.*/

View File

@@ -9,6 +9,7 @@ CD-ROM Track List (1 - 1)
1: 00:02:00 000000 audio false yes 0 no 1: 00:02:00 000000 audio false yes 0 no
170: 00:09:64 000589 leadout (1 MB raw, 1 MB formatted) 170: 00:09:64 000589 leadout (1 MB raw, 1 MB formatted)
Media Catalog Number (MCN): 123456789ABCD Media Catalog Number (MCN): 123456789ABCD
Last CD Session #: not supported by drive/driver
audio status: not implemented audio status: not implemented
__________________________________ __________________________________
CD Analysis Report CD Analysis Report

View File

@@ -9,6 +9,7 @@ CD-ROM Track List (1 - 1)
1: 00:02:00 000000 audio false yes 2 no 1: 00:02:00 000000 audio false yes 2 no
170: 00:06:02 000302 leadout (693 KB raw, 693 KB formatted) 170: 00:06:02 000302 leadout (693 KB raw, 693 KB formatted)
Media Catalog Number (MCN): 0000010271955 Media Catalog Number (MCN): 0000010271955
Last CD Session #: not supported by drive/driver
audio status: not implemented audio status: not implemented
__________________________________ __________________________________
CD Analysis Report CD Analysis Report

View File

@@ -5,6 +5,7 @@ __________________________________
Disc mode is listed as: CD-DATA (Mode 1) Disc mode is listed as: CD-DATA (Mode 1)
Media Catalog Number (MCN): not available Media Catalog Number (MCN): not available
Last CD Session #: not supported by drive/driver
__________________________________ __________________________________
CD Analysis Report CD Analysis Report
CD-ROM with ISO 9660 filesystem CD-ROM with ISO 9660 filesystem

View File

@@ -5,6 +5,7 @@ __________________________________
Disc mode is listed as: CD-DATA (Mode 1) Disc mode is listed as: CD-DATA (Mode 1)
Media Catalog Number (MCN): not available Media Catalog Number (MCN): not available
Last CD Session #: not supported by drive/driver
__________________________________ __________________________________
CD Analysis Report CD Analysis Report
CD-ROM with ISO 9660 filesystem CD-ROM with ISO 9660 filesystem

View File

@@ -9,3 +9,4 @@ CD-ROM Track List (1 - 1)
1: 00:02:00 000000 data false no 1: 00:02:00 000000 data false no
170: 00:06:02 000302 leadout (693 KB raw, 604 KB formatted) 170: 00:06:02 000302 leadout (693 KB raw, 604 KB formatted)
Media Catalog Number (MCN): not available Media Catalog Number (MCN): not available
Last CD Session #: not supported by drive/driver

View File

@@ -9,3 +9,4 @@ CD-ROM Track List (1 - 1)
1: 00:02:00 000000 data false no 1: 00:02:00 000000 data false no
170: 00:06:02 000302 leadout (693 KB raw, 604 KB formatted) 170: 00:06:02 000302 leadout (693 KB raw, 604 KB formatted)
Media Catalog Number (MCN): not available Media Catalog Number (MCN): not available
Last CD Session #: not supported by drive/driver

View File

@@ -9,6 +9,7 @@ CD-ROM Track List (1 - 1)
1: 00:02:00 000000 data false no 1: 00:02:00 000000 data false no
170: 00:06:02 000302 leadout (693 KB raw, 604 KB formatted) 170: 00:06:02 000302 leadout (693 KB raw, 604 KB formatted)
Media Catalog Number (MCN): not available Media Catalog Number (MCN): not available
Last CD Session #: not supported by drive/driver
__________________________________ __________________________________
CD Analysis Report CD Analysis Report
CD-ROM with ISO 9660 filesystem CD-ROM with ISO 9660 filesystem

View File

@@ -9,6 +9,7 @@ CD-ROM Track List (1 - 1)
1: 00:02:00 000000 data false no 1: 00:02:00 000000 data false no
170: 00:06:02 000302 leadout (693 KB raw, 604 KB formatted) 170: 00:06:02 000302 leadout (693 KB raw, 604 KB formatted)
Media Catalog Number (MCN): not available Media Catalog Number (MCN): not available
Last CD Session #: not supported by drive/driver
__________________________________ __________________________________
CD Analysis Report CD Analysis Report
CD-ROM with ISO 9660 filesystem CD-ROM with ISO 9660 filesystem

View File

@@ -9,6 +9,7 @@ CD-ROM Track List (1 - 1)
1: 00:02:00 000000 data false no 1: 00:02:00 000000 data false no
170: 00:06:02 000302 leadout (693 KB raw, 604 KB formatted) 170: 00:06:02 000302 leadout (693 KB raw, 604 KB formatted)
Media Catalog Number (MCN): not available Media Catalog Number (MCN): not available
Last CD Session #: not supported by drive/driver
__________________________________ __________________________________
CD Analysis Report CD Analysis Report
CD-ROM with ISO 9660 filesystem CD-ROM with ISO 9660 filesystem

View File

@@ -9,6 +9,7 @@ CD-ROM Track List (1 - 1)
1: 00:02:00 000000 data false no 1: 00:02:00 000000 data false no
170: 00:06:02 000302 leadout (693 KB raw, 604 KB formatted) 170: 00:06:02 000302 leadout (693 KB raw, 604 KB formatted)
Media Catalog Number (MCN): not available Media Catalog Number (MCN): not available
Last CD Session #: not supported by drive/driver
__________________________________ __________________________________
CD Analysis Report CD Analysis Report
CD-ROM with ISO 9660 filesystem CD-ROM with ISO 9660 filesystem

View File

@@ -8,6 +8,7 @@ CD-ROM Track List (1 - 1)
1: 00:02:00 000000 data false no 1: 00:02:00 000000 data false no
170: 00:06:02 000302 leadout (693 KB raw, 604 KB formatted) 170: 00:06:02 000302 leadout (693 KB raw, 604 KB formatted)
Media Catalog Number (MCN): not available Media Catalog Number (MCN): not available
Last CD Session #: not supported by drive/driver
__________________________________ __________________________________
CD Analysis Report CD Analysis Report
CD-ROM with ISO 9660 filesystem CD-ROM with ISO 9660 filesystem

View File

@@ -8,6 +8,7 @@ CD-ROM Track List (1 - 1)
1: 00:02:00 000000 data false no 1: 00:02:00 000000 data false no
170: 00:06:02 000302 leadout (693 KB raw, 604 KB formatted) 170: 00:06:02 000302 leadout (693 KB raw, 604 KB formatted)
Media Catalog Number (MCN): not available Media Catalog Number (MCN): not available
Last CD Session #: not supported by drive/driver
__________________________________ __________________________________
CD Analysis Report CD Analysis Report
CD-ROM with ISO 9660 filesystem CD-ROM with ISO 9660 filesystem

View File

@@ -10,6 +10,7 @@ CD-ROM Track List (1 - 2)
2: 00:18:51 001251 XA true no 2: 00:18:51 001251 XA true no
170: 00:39:71 002846 leadout (6 MB raw, 6 MB formatted) 170: 00:39:71 002846 leadout (6 MB raw, 6 MB formatted)
Media Catalog Number (MCN): not available Media Catalog Number (MCN): not available
Last CD Session #: not supported by drive/driver
__________________________________ __________________________________
CD Analysis Report CD Analysis Report
CD-ROM with CD-RTOS and ISO 9660 filesystem CD-ROM with CD-RTOS and ISO 9660 filesystem

View File

@@ -9,6 +9,7 @@ CD-ROM Track List (1 - 2)
2: 00:09:01 000526 XA true yes 2: 00:09:01 000526 XA true yes
170: 00:56:56 004106 leadout (9 MB raw, 9 MB formatted) 170: 00:56:56 004106 leadout (9 MB raw, 9 MB formatted)
Media Catalog Number (MCN): not available Media Catalog Number (MCN): not available
Last CD Session #: not supported by drive/driver
__________________________________ __________________________________
CD Analysis Report CD Analysis Report
CD-ROM with CD-RTOS and ISO 9660 filesystem CD-ROM with CD-RTOS and ISO 9660 filesystem

View File

@@ -10,6 +10,7 @@ CD-ROM Track List (1 - 2)
2: 00:22:53 001553 XA true no 2: 00:22:53 001553 XA true no
170: 01:17:62 005687 leadout (12 MB raw, 12 MB formatted) 170: 01:17:62 005687 leadout (12 MB raw, 12 MB formatted)
Media Catalog Number (MCN): Media Catalog Number (MCN):
Last CD Session #: not supported by drive/driver
__________________________________ __________________________________
CD Analysis Report CD Analysis Report
CD-ROM with ISO 9660 filesystem CD-ROM with ISO 9660 filesystem

View File

@@ -10,6 +10,7 @@ CD-ROM Track List (1 - 3)
3: 00:24:71 001721 XA true yes 3: 00:24:71 001721 XA true yes
170: 00:30:10 002110 leadout (4 MB raw, 4 MB formatted) 170: 00:30:10 002110 leadout (4 MB raw, 4 MB formatted)
Media Catalog Number (MCN): not available Media Catalog Number (MCN): not available
Last CD Session #: not supported by drive/driver
__________________________________ __________________________________
CD Analysis Report CD Analysis Report
CD-ROM with CD-RTOS and ISO 9660 filesystem CD-ROM with CD-RTOS and ISO 9660 filesystem

View File

@@ -13,6 +13,7 @@ CD-ROM Track List (1 - 5)
5: 00:22:01 001501 XA true no 5: 00:22:01 001501 XA true no
170: 00:25:01 001726 leadout (3 MB raw, 3 MB formatted) 170: 00:25:01 001726 leadout (3 MB raw, 3 MB formatted)
Media Catalog Number (MCN): not available Media Catalog Number (MCN): not available
Last CD Session #: not supported by drive/driver
__________________________________ __________________________________
CD Analysis Report CD Analysis Report
CD-ROM with CD-RTOS and ISO 9660 filesystem CD-ROM with CD-RTOS and ISO 9660 filesystem