[vlc-commits] [Git][videolan/vlc][master] 5 commits: cdrom: remove always true parameter
Steve Lhomme (@robUx4)
gitlab at videolan.org
Wed Sep 8 06:20:22 UTC 2021
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
2d7ac259 by Steve Lhomme at 2021-09-08T06:03:08+00:00
cdrom: remove always true parameter
- - - - -
211a0f1f by Steve Lhomme at 2021-09-08T06:03:08+00:00
cdrom: reindent after previous patch
No functional changes.
- - - - -
2bc92c82 by Steve Lhomme at 2021-09-08T06:03:08+00:00
cdrom: warn when the lead out of an audio CD is not found
If it's missing we can't compute the length of the last track.
- - - - -
e308e93d by Steve Lhomme at 2021-09-08T06:03:08+00:00
cdrom: use CDROM_READ_TOC_EX_FORMAT_TOC instead of deprecated IOCTL_CDROM_READ_TOC
See https://docs.microsoft.com/en-us/windows-hardware/drivers/storage/cd-rom-io-control-codes
This is available since XP so could be backported.
We can read LBA values directly instead of MSF values shifted by 2s.
- - - - -
f0f7bf3e by Steve Lhomme at 2021-09-08T06:03:08+00:00
access: only compile and use DiscProbeMacOSPermission() on Apple platforms
- - - - -
8 changed files:
- modules/access/cdda.c
- modules/access/disc_helper.h
- modules/access/dvdnav.c
- modules/access/dvdread.c
- modules/access/vcd/cdrom.c
- modules/access/vcd/cdrom.h
- modules/access/vcd/cdrom_internals.h
- modules/access/vcd/vcd.c
Changes:
=====================================
modules/access/cdda.c
=====================================
@@ -112,10 +112,12 @@ static vcddev_t *DiscOpen(vlc_object_t *obj, const char *location,
devpath[2] = '\0';
#endif
+#ifdef __APPLE__
if (DiscProbeMacOSPermission(obj, devpath) != VLC_SUCCESS) {
free(devpath);
return NULL;
}
+#endif
/* Open CDDA */
vcddev_t *dev = ioctl_Open(obj, devpath);
@@ -306,7 +308,7 @@ static int DemuxOpen(vlc_object_t *obj, vcddev_t *dev, unsigned track)
/* Track number in input item */
if (sys->start == (unsigned)-1 || sys->length == (unsigned)-1)
{
- vcddev_toc_t *p_toc = ioctl_GetTOC(obj, dev, true);
+ vcddev_toc_t *p_toc = ioctl_GetTOC(obj, dev);
if(p_toc == NULL)
goto error;
@@ -870,7 +872,7 @@ static int AccessOpen(vlc_object_t *obj, vcddev_t *dev)
}
sys->vcddev = dev;
- sys->p_toc = ioctl_GetTOC(obj, dev, true);
+ sys->p_toc = ioctl_GetTOC(obj, dev);
if (sys->p_toc == NULL)
{
msg_Err(obj, "cannot count tracks");
=====================================
modules/access/disc_helper.h
=====================================
@@ -18,6 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
+#ifdef __APPLE__
#include <errno.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -25,10 +26,8 @@
#include <vlc_dialog.h>
#include <vlc_fs.h>
-
inline static int DiscProbeMacOSPermission( vlc_object_t *p_this, const char *psz_file )
{
-#ifdef __APPLE__
/* Check is only relevant starting macOS Catalina */
if( __builtin_available( macOS 10.15, * ) )
{
@@ -62,9 +61,5 @@ inline static int DiscProbeMacOSPermission( vlc_object_t *p_this, const char *ps
}
return VLC_SUCCESS;
-#else
- VLC_UNUSED( p_this );
- VLC_UNUSED( psz_file );
- return VLC_SUCCESS;
-#endif
}
+#endif
=====================================
modules/access/dvdnav.c
=====================================
@@ -412,8 +412,10 @@ static int AccessDemuxOpen ( vlc_object_t *p_this )
if( !forced && ProbeDVD( psz_file ) != VLC_SUCCESS )
goto bailout;
+#ifdef __APPLE__
if( forced && DiscProbeMacOSPermission( p_this, psz_file ) != VLC_SUCCESS )
goto bailout;
+#endif
/* Open dvdnav */
#if DVDREAD_VERSION < DVDREAD_VERSION_CODE(6, 1, 2)
=====================================
modules/access/dvdread.c
=====================================
@@ -195,11 +195,13 @@ static int Open( vlc_object_t *p_this )
if( unlikely(psz_file == NULL) )
return VLC_EGENERIC;
+#ifdef __APPLE__
if( DiscProbeMacOSPermission( p_this, psz_file ) != VLC_SUCCESS )
{
free( psz_file );
return VLC_EGENERIC;
}
+#endif
/* Open dvdread */
#if DVDREAD_VERSION < DVDREAD_VERSION_CODE(6, 1, 2)
=====================================
modules/access/vcd/cdrom.c
=====================================
@@ -260,8 +260,7 @@ void ioctl_Close( vlc_object_t * p_this, vcddev_t *p_vcddev )
* ioctl_GetTOC: Read the Table of Content, fill in the p_sectors map
* if b_fill_sector_info is true.
*****************************************************************************/
-vcddev_toc_t * ioctl_GetTOC( vlc_object_t *p_this, const vcddev_t *p_vcddev,
- bool b_fill_sectorinfo )
+vcddev_toc_t * ioctl_GetTOC( vlc_object_t *p_this, const vcddev_t *p_vcddev )
{
vcddev_toc_t *p_toc = calloc(1, sizeof(*p_toc));
if(!p_toc)
@@ -276,17 +275,14 @@ vcddev_toc_t * ioctl_GetTOC( vlc_object_t *p_this, const vcddev_t *p_vcddev,
*p_toc = p_vcddev->toc;
p_toc->p_sectors = NULL;
- if( b_fill_sectorinfo )
+ p_toc->p_sectors = calloc( p_toc->i_tracks + 1, sizeof(*p_toc->p_sectors) );
+ if( p_toc->p_sectors == NULL )
{
- p_toc->p_sectors = calloc( p_toc->i_tracks + 1, sizeof(*p_toc->p_sectors) );
- if( p_toc->p_sectors == NULL )
- {
- free( p_toc );
- return NULL;
- }
- memcpy( p_toc->p_sectors, p_vcddev->toc.p_sectors,
- (p_toc->i_tracks + 1) * sizeof(*p_toc->p_sectors) );
+ free( p_toc );
+ return NULL;
}
+ memcpy( p_toc->p_sectors, p_vcddev->toc.p_sectors,
+ (p_toc->i_tracks + 1) * sizeof(*p_toc->p_sectors) );
return p_toc;
}
@@ -314,60 +310,58 @@ vcddev_toc_t * ioctl_GetTOC( vlc_object_t *p_this, const vcddev_t *p_vcddev,
&p_toc->i_first_track,
&p_toc->i_last_track );
- if( b_fill_sectorinfo )
- {
- int i, i_leadout = -1;
- CDTOCDescriptor *pTrackDescriptors;
- u_char track;
-
- p_toc->p_sectors = calloc( p_toc->i_tracks + 1,
- sizeof(*p_toc->p_sectors) );
- if( p_toc->p_sectors == NULL )
- {
- vcddev_toc_Free( p_toc );
- darwin_freeTOC( pTOC );
- return NULL;
- }
+ int i, i_leadout = -1;
+ CDTOCDescriptor *pTrackDescriptors;
+ u_char track;
- pTrackDescriptors = pTOC->descriptors;
+ p_toc->p_sectors = calloc( p_toc->i_tracks + 1,
+ sizeof(*p_toc->p_sectors) );
+ if( p_toc->p_sectors == NULL )
+ {
+ vcddev_toc_Free( p_toc );
+ darwin_freeTOC( pTOC );
+ return NULL;
+ }
- for( p_toc->i_tracks = 0, i = 0; i < i_descriptors; i++ )
- {
- track = pTrackDescriptors[i].point;
+ pTrackDescriptors = pTOC->descriptors;
- if( track == 0xA2 )
- i_leadout = i;
+ for( p_toc->i_tracks = 0, i = 0; i < i_descriptors; i++ )
+ {
+ track = pTrackDescriptors[i].point;
- if( track > CD_MAX_TRACK_NO || track < CD_MIN_TRACK_NO )
- continue;
+ if( track == 0xA2 )
+ i_leadout = i;
- p_toc->p_sectors[p_toc->i_tracks].i_control = pTrackDescriptors[i].control;
- p_toc->p_sectors[p_toc->i_tracks++].i_lba =
- CDConvertMSFToLBA( pTrackDescriptors[i].p );
- }
+ if( track > CD_MAX_TRACK_NO || track < CD_MIN_TRACK_NO )
+ continue;
- if( i_leadout == -1 )
- {
- msg_Err( p_this, "leadout not found" );
- vcddev_toc_Free( p_toc );
- darwin_freeTOC( pTOC );
- return NULL;
- }
+ p_toc->p_sectors[p_toc->i_tracks].i_control = pTrackDescriptors[i].control;
+ p_toc->p_sectors[p_toc->i_tracks++].i_lba =
+ CDConvertMSFToLBA( pTrackDescriptors[i].p );
+ }
- /* set leadout sector */
- p_toc->p_sectors[p_toc->i_tracks].i_lba =
- CDConvertMSFToLBA( pTrackDescriptors[i_leadout].p );
+ if( i_leadout == -1 )
+ {
+ msg_Err( p_this, "leadout not found" );
+ vcddev_toc_Free( p_toc );
+ darwin_freeTOC( pTOC );
+ return NULL;
}
+ /* set leadout sector */
+ p_toc->p_sectors[p_toc->i_tracks].i_lba =
+ CDConvertMSFToLBA( pTrackDescriptors[i_leadout].p );
+
darwin_freeTOC( pTOC );
#elif defined( _WIN32 )
DWORD dwBytesReturned;
CDROM_TOC cdrom_toc;
- if( DeviceIoControl( p_vcddev->h_device_handle, IOCTL_CDROM_READ_TOC,
- NULL, 0, &cdrom_toc, sizeof(CDROM_TOC),
- &dwBytesReturned, NULL ) == 0 )
+ CDROM_READ_TOC_EX TOCEx = { .Format = CDROM_READ_TOC_EX_FORMAT_TOC, .Msf = 0 };
+ if( DeviceIoControl( p_vcddev->h_device_handle, IOCTL_CDROM_READ_TOC_EX,
+ &TOCEx, sizeof(TOCEx),
+ &cdrom_toc, sizeof(cdrom_toc), &dwBytesReturned, 0 ) == 0 )
{
msg_Err( p_this, "could not read TOCHDR" );
vcddev_toc_Free( p_toc );
@@ -378,24 +372,24 @@ vcddev_toc_t * ioctl_GetTOC( vlc_object_t *p_this, const vcddev_t *p_vcddev,
p_toc->i_first_track = cdrom_toc.FirstTrack;
p_toc->i_last_track = cdrom_toc.LastTrack;
- if( b_fill_sectorinfo )
+ if ( cdrom_toc.TrackData[p_toc->i_tracks].TrackNumber != 0xAA )
+ msg_Warn(p_this, "leadout not read properly");
+
+ p_toc->p_sectors = calloc( p_toc->i_tracks + 1, sizeof(p_toc->p_sectors) );
+ if( p_toc->p_sectors == NULL )
{
- p_toc->p_sectors = calloc( p_toc->i_tracks + 1, sizeof(p_toc->p_sectors) );
- if( p_toc->p_sectors == NULL )
- {
- vcddev_toc_Free( p_toc );
- return NULL;
- }
+ vcddev_toc_Free( p_toc );
+ return NULL;
+ }
- for( int i = 0 ; i <= p_toc->i_tracks ; i++ )
- {
- p_toc->p_sectors[ i ].i_control = cdrom_toc.TrackData[i].Control;
- p_toc->p_sectors[ i ].i_lba = MSF_TO_LBA2(
- cdrom_toc.TrackData[i].Address[1],
- cdrom_toc.TrackData[i].Address[2],
- cdrom_toc.TrackData[i].Address[3] );
- msg_Dbg( p_this, "p_sectors: %i, %i", i, p_toc->p_sectors[i].i_lba);
- }
+ for( int i = 0 ; i <= p_toc->i_tracks ; i++ )
+ {
+ p_toc->p_sectors[ i ].i_control = cdrom_toc.TrackData[i].Control;
+ p_toc->p_sectors[ i ].i_lba = (unsigned)cdrom_toc.TrackData[i].Address[0] << 24 |
+ (unsigned)cdrom_toc.TrackData[i].Address[1] << 16 |
+ (unsigned)cdrom_toc.TrackData[i].Address[2] << 8 |
+ (unsigned)cdrom_toc.TrackData[i].Address[3];
+ msg_Dbg( p_this, "p_sectors: %i, %i", i, p_toc->p_sectors[i].i_lba);
}
#elif defined( __OS2__ )
@@ -420,49 +414,46 @@ vcddev_toc_t * ioctl_GetTOC( vlc_object_t *p_this, const vcddev_t *p_vcddev,
p_toc->i_first_track = tochdr.first_track;
p_toc->i_last_track = tochdr.last_track;
- if( b_fill_sectorinfo )
+ cdrom_get_track_t get_track = {{'C', 'D', '0', '1'}, };
+ cdrom_track_t track;
+ int i;
+
+ p_toc->p_sectors = calloc( p_toc->i_tracks + 1, sizeof(*p_toc->p_sectors) );
+ if( p_toc->p_sectors == NULL )
{
- cdrom_get_track_t get_track = {{'C', 'D', '0', '1'}, };
- cdrom_track_t track;
- int i;
+ vcddev_toc_Free( p_toc );
+ return NULL;
+ }
- p_toc->p_sectors = calloc( p_toc->i_tracks + 1, sizeof(*p_toc->p_sectors) );
- if( p_toc->p_sectors == NULL )
+ for( i = 0 ; i < p_toc->i_tracks ; i++ )
+ {
+ get_track.track = tochdr.first_track + i;
+ rc = DosDevIOCtl( p_vcddev->hcd, IOCTL_CDROMAUDIO,
+ CDROMAUDIO_GETAUDIOTRACK,
+ &get_track, sizeof(get_track), ¶m_len,
+ &track, sizeof(track), &data_len );
+ if (rc)
{
+ msg_Err( p_this, "could not read %d track",
+ get_track.track );
vcddev_toc_Free( p_toc );
return NULL;
}
- for( i = 0 ; i < p_toc->i_tracks ; i++ )
- {
- get_track.track = tochdr.first_track + i;
- rc = DosDevIOCtl( p_vcddev->hcd, IOCTL_CDROMAUDIO,
- CDROMAUDIO_GETAUDIOTRACK,
- &get_track, sizeof(get_track), ¶m_len,
- &track, sizeof(track), &data_len );
- if (rc)
- {
- msg_Err( p_this, "could not read %d track",
- get_track.track );
- vcddev_toc_Free( p_toc );
- return NULL;
- }
-
- p_toc->p_sectors[ i ].i_lba = MSF_TO_LBA2(
- track.start.minute,
- track.start.second,
- track.start.frame );
- msg_Dbg( p_this, "p_sectors: %i, %i", i, p_toc->p_sectors[i].i_lba);
- }
-
- /* for lead-out track */
p_toc->p_sectors[ i ].i_lba = MSF_TO_LBA2(
- tochdr.lead_out.minute,
- tochdr.lead_out.second,
- tochdr.lead_out.frame );
+ track.start.minute,
+ track.start.second,
+ track.start.frame );
msg_Dbg( p_this, "p_sectors: %i, %i", i, p_toc->p_sectors[i].i_lba);
}
+ /* for lead-out track */
+ p_toc->p_sectors[ i ].i_lba = MSF_TO_LBA2(
+ tochdr.lead_out.minute,
+ tochdr.lead_out.second,
+ tochdr.lead_out.frame );
+ msg_Dbg( p_this, "p_sectors: %i, %i", i, p_toc->p_sectors[i].i_lba);
+
#elif defined( HAVE_IOC_TOC_HEADER_IN_SYS_CDIO_H ) \
|| defined( HAVE_SCSIREQ_IN_SYS_SCSIIO_H )
struct ioc_toc_header tochdr;
@@ -480,47 +471,44 @@ vcddev_toc_t * ioctl_GetTOC( vlc_object_t *p_this, const vcddev_t *p_vcddev,
p_toc->i_first_track = tochdr.starting_track;
p_toc->i_last_track = tochdr.ending_track;
- if( b_fill_sectorinfo )
+ p_toc->p_sectors = calloc( p_toc->i_tracks + 1, sizeof(*p_toc->p_sectors) );
+ if( p_toc->p_sectors == NULL )
+ {
+ vcddev_toc_Free( p_toc );
+ return NULL;
+ }
+
+ toc_entries.address_format = CD_LBA_FORMAT;
+ toc_entries.starting_track = 0;
+ toc_entries.data_len = ( p_toc->i_tracks + 1 ) *
+ sizeof( struct cd_toc_entry );
+ toc_entries.data = (struct cd_toc_entry *)
+ malloc( toc_entries.data_len );
+ if( toc_entries.data == NULL )
+ {
+ vcddev_toc_Free( p_toc );
+ return NULL;
+ }
+
+ /* Read the TOC */
+ if( ioctl( p_vcddev->i_device_handle, CDIOREADTOCENTRYS,
+ &toc_entries ) == -1 )
+ {
+ msg_Err( p_this, "could not read the TOC" );
+ free( toc_entries.data );
+ vcddev_toc_Free( p_toc );
+ return NULL;
+ }
+
+ /* Fill the p_sectors structure with the track/sector matches */
+ for( int i = 0 ; i <= p_toc->i_tracks ; i++ )
{
- p_toc->p_sectors = calloc( p_toc->i_tracks + 1, sizeof(*p_toc->p_sectors) );
- if( p_toc->p_sectors == NULL )
- {
- vcddev_toc_Free( p_toc );
- return NULL;
- }
-
- toc_entries.address_format = CD_LBA_FORMAT;
- toc_entries.starting_track = 0;
- toc_entries.data_len = ( p_toc->i_tracks + 1 ) *
- sizeof( struct cd_toc_entry );
- toc_entries.data = (struct cd_toc_entry *)
- malloc( toc_entries.data_len );
- if( toc_entries.data == NULL )
- {
- vcddev_toc_Free( p_toc );
- return NULL;
- }
-
- /* Read the TOC */
- if( ioctl( p_vcddev->i_device_handle, CDIOREADTOCENTRYS,
- &toc_entries ) == -1 )
- {
- msg_Err( p_this, "could not read the TOC" );
- free( toc_entries.data );
- vcddev_toc_Free( p_toc );
- return NULL;
- }
-
- /* Fill the p_sectors structure with the track/sector matches */
- for( int i = 0 ; i <= p_toc->i_tracks ; i++ )
- {
#if defined( HAVE_SCSIREQ_IN_SYS_SCSIIO_H )
- /* FIXME: is this ok? */
- p_toc->p_sectors[ i ].i_lba = toc_entries.data[i].addr.lba;
+ /* FIXME: is this ok? */
+ p_toc->p_sectors[ i ].i_lba = toc_entries.data[i].addr.lba;
#else
- p_toc->p_sectors[ i ].i_lba = ntohl( toc_entries.data[i].addr.lba );
+ p_toc->p_sectors[ i ].i_lba = ntohl( toc_entries.data[i].addr.lba );
#endif
- }
}
#else
struct cdrom_tochdr tochdr;
@@ -539,34 +527,31 @@ vcddev_toc_t * ioctl_GetTOC( vlc_object_t *p_this, const vcddev_t *p_vcddev,
p_toc->i_first_track = tochdr.cdth_trk0;
p_toc->i_last_track = tochdr.cdth_trk1;
- if( b_fill_sectorinfo )
+ p_toc->p_sectors = calloc( p_toc->i_tracks + 1, sizeof(*p_toc->p_sectors) );
+ if( p_toc->p_sectors == NULL )
+ {
+ free( p_toc );
+ return NULL;
+ }
+
+ /* Fill the p_sectors structure with the track/sector matches */
+ for( int i = 0 ; i <= p_toc->i_tracks ; i++ )
{
- p_toc->p_sectors = calloc( p_toc->i_tracks + 1, sizeof(*p_toc->p_sectors) );
- if( p_toc->p_sectors == NULL )
+ tocent.cdte_format = CDROM_LBA;
+ tocent.cdte_track =
+ ( i == p_toc->i_tracks ) ? CDROM_LEADOUT : tochdr.cdth_trk0 + i;
+
+ if( ioctl( p_vcddev->i_device_handle, CDROMREADTOCENTRY,
+ &tocent ) == -1 )
{
+ msg_Err( p_this, "could not read TOCENTRY" );
+ free( p_toc->p_sectors );
free( p_toc );
return NULL;
}
- /* Fill the p_sectors structure with the track/sector matches */
- for( int i = 0 ; i <= p_toc->i_tracks ; i++ )
- {
- tocent.cdte_format = CDROM_LBA;
- tocent.cdte_track =
- ( i == p_toc->i_tracks ) ? CDROM_LEADOUT : tochdr.cdth_trk0 + i;
-
- if( ioctl( p_vcddev->i_device_handle, CDROMREADTOCENTRY,
- &tocent ) == -1 )
- {
- msg_Err( p_this, "could not read TOCENTRY" );
- free( p_toc->p_sectors );
- free( p_toc );
- return NULL;
- }
-
- p_toc->p_sectors[ i ].i_lba = tocent.cdte_addr.lba;
- p_toc->p_sectors[ i ].i_control = tocent.cdte_ctrl;
- }
+ p_toc->p_sectors[ i ].i_lba = tocent.cdte_addr.lba;
+ p_toc->p_sectors[ i ].i_control = tocent.cdte_ctrl;
}
#endif
=====================================
modules/access/vcd/cdrom.h
=====================================
@@ -146,7 +146,7 @@ typedef struct entries_sect_s
*****************************************************************************/
vcddev_t *ioctl_Open ( vlc_object_t *, const char * );
void ioctl_Close ( vlc_object_t *, vcddev_t * );
-vcddev_toc_t * ioctl_GetTOC ( vlc_object_t *, const vcddev_t *, bool );
+vcddev_toc_t * ioctl_GetTOC ( vlc_object_t *, const vcddev_t * );
int ioctl_ReadSectors ( vlc_object_t *, const vcddev_t *,
int, uint8_t *, int, int );
=====================================
modules/access/vcd/cdrom_internals.h
=====================================
@@ -114,6 +114,11 @@ typedef struct _CDROM_READ_TOC_EX {
#define MINIMUM_CDROM_READ_TOC_EX_SIZE 2
+#define CDROM_READ_TOC_EX_FORMAT_TOC 0x00
+#define CDROM_READ_TOC_EX_FORMAT_SESSION 0x01
+#define CDROM_READ_TOC_EX_FORMAT_FULL_TOC 0x02
+#define CDROM_READ_TOC_EX_FORMAT_PMA 0x03
+#define CDROM_READ_TOC_EX_FORMAT_ATIP 0x04
#define CDROM_READ_TOC_EX_FORMAT_CDTEXT 0x05
#endif /* _WIN32 */
=====================================
modules/access/vcd/vcd.c
=====================================
@@ -152,7 +152,7 @@ static int Open( vlc_object_t *p_this )
p_sys->titles[i].seekpoints = NULL;
/* We read the Table Of Content information */
- p_sys->p_toc = ioctl_GetTOC( VLC_OBJECT(p_access), p_sys->vcddev, true );
+ p_sys->p_toc = ioctl_GetTOC( VLC_OBJECT(p_access), p_sys->vcddev );
if( p_sys->p_toc == NULL )
{
msg_Err( p_access, "unable to count tracks" );
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/484909d5d5bf71976d59b5e7d0bdfde9fb2ca743...f0f7bf3ee2d2b3a8788d98af52cb89f4787ba83c
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/484909d5d5bf71976d59b5e7d0bdfde9fb2ca743...f0f7bf3ee2d2b3a8788d98af52cb89f4787ba83c
You're receiving this email because of your account on code.videolan.org.
More information about the vlc-commits
mailing list