[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Libcdio-devel] [PATCH 2/3] Implement get_last_session_os2()
From: |
KO Myung-Hun |
Subject: |
[Libcdio-devel] [PATCH 2/3] Implement get_last_session_os2() |
Date: |
Mon, 12 Dec 2016 17:17:22 +0900 |
---
lib/driver/os2.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 54 insertions(+), 2 deletions(-)
diff --git a/lib/driver/os2.c b/lib/driver/os2.c
index c6907ad..77e233b 100644
--- a/lib/driver/os2.c
+++ b/lib/driver/os2.c
@@ -66,6 +66,11 @@ typedef struct {
access_mode_t access_mode;
+ /* Session information */
+ int i_first_session;
+ int i_last_session;
+ int i_first_track_in_last_session;
+
/* Track information */
toc_t toc[CDIO_CD_MAX_TRACKS + 1]; /* 1 more for leadout */
int i_first_track;
@@ -629,6 +634,23 @@ get_discmode_os2(void *p_user_data)
return discmode;
}
+/*! Get the LSN of the first track of the last session of
+ 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_os2 (void *p_user_data, /*out*/ lsn_t *i_last_session)
+{
+ _img_private_t *p_env = p_user_data;
+
+ *i_last_session =
+ p_env->toc[ p_env->i_first_track_in_last_session ].lsn_start;
+
+ return DRIVER_OP_SUCCESS;
+}
+
#define CDROMDISK_EXECMD 0x7A
/* 0, if transfer data to device, 1, if transfer data from device */
@@ -1009,6 +1031,22 @@ read_toc_os2 (void *p_user_data)
{
_img_private_t *p_env = p_user_data;
+ mmc_cdb_t cdb = {{ 0, }};
+
+ struct {
+ BYTE auc_len[ 2 ];
+ BYTE uc_first_session;
+ BYTE uc_last_session;
+
+ struct {
+ BYTE uc_reserved1;
+ BYTE uc_control_and_adr;
+ BYTE uc_first_track;
+ BYTE uc_reserved2;
+ BYTE auc_lba[ 4 ];
+ } s_last_session;
+ } s_toc;
+
struct {
UCHAR auch_sign[4];
} s_param_disk = {{'C', 'D', '0', '1'}};
@@ -1036,6 +1074,22 @@ read_toc_os2 (void *p_user_data)
ULONG rc;
int i_track;
+ CDIO_MMC_SET_COMMAND( cdb.field, CDIO_MMC_GPCMD_READ_TOC );
+ cdb.field[ 2 ] = CDIO_MMC_READTOC_FMT_SESSION;
+ CDIO_MMC_SET_READ_LENGTH16( cdb.field, sizeof( s_toc ));
+ if( run_mmc_cmd_os2( p_env, 0,
+ mmc_get_cmd_len( cdb.field[ 0 ]), &cdb,
SCSI_MMC_DATA_READ,
+ sizeof( s_toc ), &s_toc ) == DRIVER_OP_ERROR )
+ {
+ cdio_warn("read_toc_os2 : run_mmc_cmd_os2(CDIO_MMC_GPCMD_READ_TOC)
failed\n");
+
+ return false;
+ }
+
+ p_env->i_first_session = s_toc.uc_first_session;
+ p_env->i_last_session = s_toc.uc_last_session;
+ p_env->i_first_track_in_last_session = s_toc.s_last_session.uc_first_track;
+
rc = DosDevIOCtl(
p_env->h_cd, IOCTL_CDROMAUDIO, CDROMAUDIO_GETAUDIODISK,
&s_param_disk, sizeof( s_param_disk ), &ul_param_len,
@@ -1546,9 +1600,7 @@ cdio_open_os2 (const char *psz_orig_source)
_funcs.get_drive_cap = get_drive_cap_mmc;
_funcs.get_first_track_num = get_first_track_num_generic;
_funcs.get_hwinfo = NULL;
-#if 0
_funcs.get_last_session = get_last_session_os2;
-#endif
_funcs.get_media_changed = get_media_changed_mmc;
_funcs.get_mcn = _cdio_get_mcn;
_funcs.get_num_tracks = get_num_tracks_generic;
--
2.9.2