diff --git a/THANKS b/THANKS index b683121..2e84a2a 100644 --- a/THANKS +++ b/THANKS @@ -1,14 +1,16 @@ Many thanks to Jerry G Geiger for resurrecting this project from the dead. He added: +- audio_get_status - audio_get_volume - audio_set_volume -- get_disk_cdtext, get_track_cdtext -- audio_get_status -- is_tray_open +- cdio_guess_cd_type +- cdio_read_pvd - cdio_version (version string of linked library) - get_cddb_discid -- audio_get_status +- get_disk_cdtext - get_joliet_level +- get_track_cdtext +- is_tray_open He also fixed Build.PL so it works again and added many corrections to my faulty C interface code.; diff --git a/lib/Device/Cdio.pm b/lib/Device/Cdio.pm index f6e506e..19da307 100644 --- a/lib/Device/Cdio.pm +++ b/lib/Device/Cdio.pm @@ -251,11 +251,7 @@ sub get_devices { my($driver_id, @args) = _rearrange(['DRIVER_ID'], @p); return undef if _extra_args(@args); $driver_id = $perlcdio::DRIVER_DEVICE if !defined($driver_id); - # There's a bug in the swig code in that the input parameter - # is left on the stack - my @ret = perlcdio::get_devices($driver_id); - shift @ret; - return @ret; + return perlcdio::get_devices($driver_id); } =pod @@ -277,11 +273,7 @@ sub get_devices_ret { my($driver_id, @args) = _rearrange(['DRIVER_ID'], @p); return undef if _extra_args(@args); $driver_id = $perlcdio::DRIVER_DEVICE if !defined($driver_id); - # There's a bug in the swig code in that the input parameter - # is left on the stack - my @ret = perlcdio::get_devices_ret($driver_id); - shift @ret; - return @ret; + return perlcdio::get_devices_ret($driver_id); } =pod @@ -311,11 +303,7 @@ sub get_devices_with_cap { my($cap, $any, @args) = _rearrange(['CAPABILITIES', 'ANY'], @p); return undef if _extra_args(@args); $any = 1 if !defined($any); - # There's a bug in the swig code in that the input parameters - # are left on the stack - my @ret = perlcdio::get_devices_with_cap($cap, $any); - shift @ret; shift @ret; - return @ret; + return perlcdio::get_devices_with_cap($cap, $any); } =pod diff --git a/lib/Device/Cdio/Device.pm b/lib/Device/Cdio/Device.pm index f732833..1126368 100644 --- a/lib/Device/Cdio/Device.pm +++ b/lib/Device/Cdio/Device.pm @@ -607,6 +607,33 @@ sub get_media_changed { =pod +=head2 guess_cd_type + +$hash = $dev->guess_cd_type($lsn,$track); + +Try to determine what kind of CD-image and/or filesystem we have at +track $track. First argument is the start lsn of track $track. Returns a +hash reference with following keys: + + cdio_fs_t (enum cdio_fs_t from libcdio) FIXME: add text + cdio_fs_cap_t (enum cdio_fs_cap_t from libcdio) FIXME: add text + joliet_level If has Joliet extensions, this is the associated level + number (i.e. 1, 2, or 3). + iso_label 32 byte ISO fs label. + isofs_size size of ISO fs. + UDFVerMajor UDF fs version. + UDFVerMinor UDF fs version. + +=cut + +sub guess_cd_type { + my($self, $session, $track, @p) = @_; + return $perlcdio::BAD_PARAMETER if !_check_arg_count($#_, 2); + return perlcdio::guess_cd_type($self->{cd}, $session, $track); +} + +=pod + =head2 get_num_tracks get_num_tracks()->int @@ -885,6 +912,24 @@ sub set_speed { return perlcdio::set_speed($self->{cd}, $speed); } +=pod + +=head2 read_pvd + +$pvd = $dev->read_pvd; + +Reads and returns the ISO-9660 Primary Volume Descriptor (PVD) from the disk. +You can use perliso9660::get_pvd_type($pvd) ... methods to get the values. + +=cut + + +sub read_pvd { + my($self,@p) = @_; + return perlcdio::cdio_read_pvd($self->{cd}); +} + + 1; # Magic true value required at the end of a module __END__ diff --git a/swig/device.swg b/swig/device.swg index f73be0d..dcc882d 100644 --- a/swig/device.swg +++ b/swig/device.swg @@ -39,13 +39,27 @@ typedef char ** DeviceList_t; num++; } + if (num+argvi >= items) { + /* Extend the stack by (num - items) objects */ + EXTEND(sp, num-items); + } /* For each element in the array of strings, create a new * mortalscalar, and stuff it into the above array. */ - for (p = $1; *p; p++) { + for (num=0,p = $1; *p; p++) { /* Have perl compute the length of the string using strlen() */ + //PUSHs(sv_2mortal(newSVpv(*p, 0))); // uses SP, modified by dSP (XS) + ST(num++)=(sv_2mortal(newSVpv(*p, 0))); + } + /* FIXME: the + 1 is because p_cdio is still on the stack. */ + argvi += num; // fixed ?? + /* For each element in the array of strings, create a new + * mortalscalar, and stuff it into the above array. + for (p = $1; *p; p++) { + Have perl compute the length of the string using strlen() XPUSHs(sv_2mortal(newSVpv(*p, 0))); } - argvi += num; + argvi = num; + */ cdio_free_device_list($1); out: ; } @@ -189,7 +203,7 @@ get_default_device_driver(driver_id_t driver_id, driver_id_t *p_out_driver_id) } %} -%rename cdio_get_devices get_devices; +//%rename cdio_get_devices get_devices; /*! Return an array of device names. If you want a specific devices for a driver, give that device. If you want hardware devices, give DRIVER_DEVICE and if you want all possible devices, @@ -203,6 +217,14 @@ get_default_device_driver(driver_id_t driver_id, driver_id_t *p_out_driver_id) */ DeviceList_t cdio_get_devices (driver_id_t driver_id); +DeviceList_t get_devices(driver_id_t driver_id); + + +%inline %{ +DeviceList_t get_devices(driver_id_t driver_id) { + return cdio_get_devices(driver_id); +} +%} /* Like cdio_get_devices, but we may change the p_driver_id if we were given DRIVER_DEVICE or DRIVER_UNKNOWN. This is because often one wants to get a drive name and then *open* it diff --git a/swig/disc.swg b/swig/disc.swg index 5afd280..e7a2083 100644 --- a/swig/disc.swg +++ b/swig/disc.swg @@ -90,7 +90,6 @@ get_disc_mode (CdIo_t *p_cdio) return (const char *)newSV(0); return discmode2str[discmode]; } - %} @@ -157,3 +156,24 @@ uint32_t get_cddb_discid(CdIo_t *p_cdio) } %} +SV * guess_cd_type(const CdIo_t *cdio, int start_session, track_t track_num); +%inline %{ +SV * guess_cd_type(const CdIo_t *cdio, int start_session, track_t track_num) { + cdio_iso_analysis_t t; + int r; + HV * iso_analysis; + r = cdio_guess_cd_type (cdio, start_session, track_num, &t); + iso_analysis = newHV(); + hv_store(iso_analysis, "cdio_fs_t",9, newSViv(r&CDIO_FS_MASK),0); + hv_store(iso_analysis, "cdio_fs_cap_t",13, newSViv(r&~CDIO_FS_MASK),0); + hv_store(iso_analysis, "joliet_level",12, newSVuv(t.joliet_level),0); + hv_store(iso_analysis, "iso_label",9,newSVpv(t.iso_label,0),0); + hv_store(iso_analysis, "isofs_size",10, newSVuv(t.isofs_size),0); + hv_store(iso_analysis, "UDFVerMinor",11, + newSVuv((unsigned int)t.UDFVerMinor),0); + hv_store(iso_analysis, "UDFVerMajor",11, + newSVuv((unsigned int)t.UDFVerMajor),0); + + return newRV_noinc(sv_2mortal((SV*)iso_analysis)); +} +%} diff --git a/swig/perlcdio.swg b/swig/perlcdio.swg index f6e503d..42a3e77 100644 --- a/swig/perlcdio.swg +++ b/swig/perlcdio.swg @@ -14,6 +14,7 @@ use this library." #include #include #include +#include %} #include diff --git a/swig/read.swg b/swig/read.swg index bea4549..1c7ae51 100644 --- a/swig/read.swg +++ b/swig/read.swg @@ -162,3 +162,15 @@ read_data_bytes(const CdIo_t *p_cdio, lsn_t i_lsn, return p_buf; } %} + +iso9660_pvd_t *cdio_read_pvd ( const CdIo_t *p_cdio ); +%inline %{ +iso9660_pvd_t *cdio_read_pvd ( const CdIo_t *p_cdio ) { + static iso9660_pvd_t pvd; + int rc = cdio_read_data_sectors( p_cdio, &pvd, ISO_PVD_SECTOR, + ISO_BLOCKSIZE, 1); + if (rc < 0) return NULL; + return &pvd; + } +%} +