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 @@
/*
$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>
@@ -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.

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>
@@ -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.

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) 2002, 2003, 2004, 2005 Rocky Bernstein <rocky@panix.com>
@@ -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 <string.h>
@@ -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,

View File

@@ -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