diff --git a/include/cdio/device.h b/include/cdio/device.h index d4a0f66f..7b3fdbb0 100644 --- a/include/cdio/device.h +++ b/include/cdio/device.h @@ -1,5 +1,5 @@ /* -*- 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 @@ -360,6 +360,15 @@ extern "C" { /* 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. @param p_cdio the CD object to be acted upon. diff --git a/lib/driver/cdio_private.h b/lib/driver/cdio_private.h index 5aafd005..5904e8cb 100644 --- a/lib/driver/cdio_private.h +++ b/lib/driver/cdio_private.h @@ -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 @@ -202,6 +202,15 @@ extern "C" { bool (*get_hwinfo) ( 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. @param p_env the CD object to be acted upon. diff --git a/lib/driver/device.c b/lib/driver/device.c index 96d50fbc..3ff56ebb 100644 --- a/lib/driver/device.c +++ b/lib/driver/device.c @@ -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 @@ -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. @param p_cdio the CD object to be acted upon. diff --git a/lib/driver/gnu_linux.c b/lib/driver/gnu_linux.c index 4c085af2..187a5cc2 100644 --- a/lib/driver/gnu_linux.c +++ b/lib/driver/gnu_linux.c @@ -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 Copyright (C) 2002, 2003, 2004, 2005 Rocky Bernstein @@ -27,7 +27,7 @@ # include "config.h" #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 @@ -396,6 +396,33 @@ get_drive_cap_linux (const void *p_user_data, } #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. @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 .get_first_track_num = get_first_track_num_generic, .get_hwinfo = NULL, + .get_last_session = get_last_session_linux, .get_media_changed = get_media_changed_linux, .get_mcn = get_mcn_linux, .get_num_tracks = get_num_tracks_generic, diff --git a/lib/driver/libcdio.sym b/lib/driver/libcdio.sym index c7f99fca..e55bdbbd 100644 --- a/lib/driver/libcdio.sym +++ b/lib/driver/libcdio.sym @@ -62,6 +62,7 @@ cdio_get_first_track_num cdio_get_hwinfo cdio_get_joliet_level cdio_get_last_track_num +cdio_get_last_session cdio_get_media_changed cdio_get_mcn cdio_get_num_tracks diff --git a/src/cd-info.c b/src/cd-info.c index 81da3ba0..cd4594da 100644 --- a/src/cd-info.c +++ b/src/cd-info.c @@ -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 Copyright (C) 1996, 1997, 1998 Gerd Knorr @@ -1140,14 +1140,27 @@ main(int argc, const char *argv[]) if (i_read_cap & CDIO_DRIVE_CAP_READ_MCN) report(stdout, "not available\n"); else - report(stdout, "not supported by drive\n"); - } - - else { + report(stdout, "not supported by drive/driver\n"); + } else { report(stdout, "%s\n", 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 */ if ( CDIO_DISC_MODE_CD_DA == 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 (b_playing_audio) { /* Running a CD Analysis would mess up audio playback.*/ diff --git a/test/cdda-mcn.right b/test/cdda-mcn.right index 3a57c16f..e6e79658 100644 --- a/test/cdda-mcn.right +++ b/test/cdda-mcn.right @@ -9,6 +9,7 @@ CD-ROM Track List (1 - 1) 1: 00:02:00 000000 audio false yes 0 no 170: 00:09:64 000589 leadout (1 MB raw, 1 MB formatted) Media Catalog Number (MCN): 123456789ABCD +Last CD Session #: not supported by drive/driver audio status: not implemented __________________________________ CD Analysis Report diff --git a/test/cdda.right b/test/cdda.right index 048d18bb..5786eda1 100644 --- a/test/cdda.right +++ b/test/cdda.right @@ -9,6 +9,7 @@ CD-ROM Track List (1 - 1) 1: 00:02:00 000000 audio false yes 2 no 170: 00:06:02 000302 leadout (693 KB raw, 693 KB formatted) Media Catalog Number (MCN): 0000010271955 +Last CD Session #: not supported by drive/driver audio status: not implemented __________________________________ CD Analysis Report diff --git a/test/check_opts0.right b/test/check_opts0.right index 5c5c7585..02fc6fd4 100644 --- a/test/check_opts0.right +++ b/test/check_opts0.right @@ -5,6 +5,7 @@ __________________________________ Disc mode is listed as: CD-DATA (Mode 1) Media Catalog Number (MCN): not available +Last CD Session #: not supported by drive/driver __________________________________ CD Analysis Report CD-ROM with ISO 9660 filesystem diff --git a/test/check_opts1.right b/test/check_opts1.right index 5c5c7585..02fc6fd4 100644 --- a/test/check_opts1.right +++ b/test/check_opts1.right @@ -5,6 +5,7 @@ __________________________________ Disc mode is listed as: CD-DATA (Mode 1) Media Catalog Number (MCN): not available +Last CD Session #: not supported by drive/driver __________________________________ CD Analysis Report CD-ROM with ISO 9660 filesystem diff --git a/test/check_opts2.right b/test/check_opts2.right index 5a88d403..419faa06 100644 --- a/test/check_opts2.right +++ b/test/check_opts2.right @@ -9,3 +9,4 @@ CD-ROM Track List (1 - 1) 1: 00:02:00 000000 data false no 170: 00:06:02 000302 leadout (693 KB raw, 604 KB formatted) Media Catalog Number (MCN): not available +Last CD Session #: not supported by drive/driver diff --git a/test/check_opts3.right b/test/check_opts3.right index 5a88d403..419faa06 100644 --- a/test/check_opts3.right +++ b/test/check_opts3.right @@ -9,3 +9,4 @@ CD-ROM Track List (1 - 1) 1: 00:02:00 000000 data false no 170: 00:06:02 000302 leadout (693 KB raw, 604 KB formatted) Media Catalog Number (MCN): not available +Last CD Session #: not supported by drive/driver diff --git a/test/check_opts4.right b/test/check_opts4.right index 28992c53..893b9298 100644 --- a/test/check_opts4.right +++ b/test/check_opts4.right @@ -9,6 +9,7 @@ CD-ROM Track List (1 - 1) 1: 00:02:00 000000 data false no 170: 00:06:02 000302 leadout (693 KB raw, 604 KB formatted) Media Catalog Number (MCN): not available +Last CD Session #: not supported by drive/driver __________________________________ CD Analysis Report CD-ROM with ISO 9660 filesystem diff --git a/test/check_opts5.right b/test/check_opts5.right index 28992c53..893b9298 100644 --- a/test/check_opts5.right +++ b/test/check_opts5.right @@ -9,6 +9,7 @@ CD-ROM Track List (1 - 1) 1: 00:02:00 000000 data false no 170: 00:06:02 000302 leadout (693 KB raw, 604 KB formatted) Media Catalog Number (MCN): not available +Last CD Session #: not supported by drive/driver __________________________________ CD Analysis Report CD-ROM with ISO 9660 filesystem diff --git a/test/check_opts6.right b/test/check_opts6.right index 28992c53..893b9298 100644 --- a/test/check_opts6.right +++ b/test/check_opts6.right @@ -9,6 +9,7 @@ CD-ROM Track List (1 - 1) 1: 00:02:00 000000 data false no 170: 00:06:02 000302 leadout (693 KB raw, 604 KB formatted) Media Catalog Number (MCN): not available +Last CD Session #: not supported by drive/driver __________________________________ CD Analysis Report CD-ROM with ISO 9660 filesystem diff --git a/test/check_opts7.right b/test/check_opts7.right index 28992c53..893b9298 100644 --- a/test/check_opts7.right +++ b/test/check_opts7.right @@ -9,6 +9,7 @@ CD-ROM Track List (1 - 1) 1: 00:02:00 000000 data false no 170: 00:06:02 000302 leadout (693 KB raw, 604 KB formatted) Media Catalog Number (MCN): not available +Last CD Session #: not supported by drive/driver __________________________________ CD Analysis Report CD-ROM with ISO 9660 filesystem diff --git a/test/isofs-m1-no-rr.right b/test/isofs-m1-no-rr.right index 5617fe48..f397642c 100644 --- a/test/isofs-m1-no-rr.right +++ b/test/isofs-m1-no-rr.right @@ -8,6 +8,7 @@ CD-ROM Track List (1 - 1) 1: 00:02:00 000000 data false no 170: 00:06:02 000302 leadout (693 KB raw, 604 KB formatted) Media Catalog Number (MCN): not available +Last CD Session #: not supported by drive/driver __________________________________ CD Analysis Report CD-ROM with ISO 9660 filesystem diff --git a/test/isofs-m1.right b/test/isofs-m1.right index b6f52558..5503c123 100644 --- a/test/isofs-m1.right +++ b/test/isofs-m1.right @@ -8,6 +8,7 @@ CD-ROM Track List (1 - 1) 1: 00:02:00 000000 data false no 170: 00:06:02 000302 leadout (693 KB raw, 604 KB formatted) Media Catalog Number (MCN): not available +Last CD Session #: not supported by drive/driver __________________________________ CD Analysis Report CD-ROM with ISO 9660 filesystem diff --git a/test/monvoisin.right b/test/monvoisin.right index 233e5d8e..e2616a83 100644 --- a/test/monvoisin.right +++ b/test/monvoisin.right @@ -10,6 +10,7 @@ CD-ROM Track List (1 - 2) 2: 00:18:51 001251 XA true no 170: 00:39:71 002846 leadout (6 MB raw, 6 MB formatted) Media Catalog Number (MCN): not available +Last CD Session #: not supported by drive/driver __________________________________ CD Analysis Report CD-ROM with CD-RTOS and ISO 9660 filesystem diff --git a/test/svcd_ogt_test_ntsc.right b/test/svcd_ogt_test_ntsc.right index dedce687..00cf1e2c 100644 --- a/test/svcd_ogt_test_ntsc.right +++ b/test/svcd_ogt_test_ntsc.right @@ -9,6 +9,7 @@ CD-ROM Track List (1 - 2) 2: 00:09:01 000526 XA true yes 170: 00:56:56 004106 leadout (9 MB raw, 9 MB formatted) Media Catalog Number (MCN): not available +Last CD Session #: not supported by drive/driver __________________________________ CD Analysis Report CD-ROM with CD-RTOS and ISO 9660 filesystem diff --git a/test/svcdgs.right b/test/svcdgs.right index c37584b7..fa17e6ce 100644 --- a/test/svcdgs.right +++ b/test/svcdgs.right @@ -10,6 +10,7 @@ CD-ROM Track List (1 - 2) 2: 00:22:53 001553 XA true no 170: 01:17:62 005687 leadout (12 MB raw, 12 MB formatted) Media Catalog Number (MCN): +Last CD Session #: not supported by drive/driver __________________________________ CD Analysis Report CD-ROM with ISO 9660 filesystem diff --git a/test/vcd_demo.right b/test/vcd_demo.right index 9e814158..66799790 100644 --- a/test/vcd_demo.right +++ b/test/vcd_demo.right @@ -10,6 +10,7 @@ CD-ROM Track List (1 - 3) 3: 00:24:71 001721 XA true yes 170: 00:30:10 002110 leadout (4 MB raw, 4 MB formatted) Media Catalog Number (MCN): not available +Last CD Session #: not supported by drive/driver __________________________________ CD Analysis Report CD-ROM with CD-RTOS and ISO 9660 filesystem diff --git a/test/videocd.right b/test/videocd.right index 1ba2994d..98e60d43 100644 --- a/test/videocd.right +++ b/test/videocd.right @@ -13,6 +13,7 @@ CD-ROM Track List (1 - 5) 5: 00:22:01 001501 XA true no 170: 00:25:01 001726 leadout (3 MB raw, 3 MB formatted) Media Catalog Number (MCN): not available +Last CD Session #: not supported by drive/driver __________________________________ CD Analysis Report CD-ROM with CD-RTOS and ISO 9660 filesystem