[vlc-commits] [Git][videolan/vlc][3.0.x] cdrom: read the track type (audio or data) from the cuesheet

Steve Lhomme (@robUx4) gitlab at videolan.org
Mon Sep 7 13:20:28 UTC 2026



Steve Lhomme pushed to branch 3.0.x at VideoLAN / VLC


Commits:
6d15f15b by Steve Lhomme at 2026-09-07T13:12:16+00:00
cdrom: read the track type (audio or data) from the cuesheet

We look for:
[ ]+TRACK dd AUDIO
[ ]+TRACK dd
[ ]+TRACK dd (anything)

Set the LeadOut type to the same type as the last track.

Fixes #26036

(cherry picked from commit 8df1e10a4ad423d163d2424fe9503f43c4084393)
Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>

- - - - -


1 changed file:

- modules/access/vcd/cdrom.c


Changes:

=====================================
modules/access/vcd/cdrom.c
=====================================
@@ -912,12 +912,31 @@ static int OpenVCDImage( vlc_object_t * p_this, const char *psz_dev,
      * about the cuefile */
     p_toc->i_tracks = 0;
 
+    int track_subcodes = 0x00;
+
     while( fgets( line, 1024, cuefile ) && p_toc->i_tracks < INT_MAX-1 )
     {
         /* look for a TRACK line */
-        char psz_dummy[10];
-        if( !sscanf( line, "%9s", psz_dummy ) || strcmp(psz_dummy, "TRACK") )
+        unsigned track_num;
+        char psz_track_type[32];
+        const char *track_start = strstr(line, "TRACK ");
+        if( track_start == NULL )
+            continue;
+        track_start += 6; // skip the "TRACK " part
+        int i = sscanf( track_start, "%u %31s", &track_num, psz_track_type );
+        if( i != 2 ) // no type set: assume audio track
+            psz_track_type[0] = '\0';
+        if( i<=0 )
+            i = sscanf( track_start, "%u", &track_num);
+        if( i<=0 )
             continue;
+        if ( psz_track_type[0] && strcmp(psz_track_type,"AUDIO")!=0)
+        {
+            msg_Dbg( p_this, "detected %s track %02u", psz_track_type, track_num);
+            track_subcodes = CD_ROM_DATA_FLAG;
+        }
+        else
+            track_subcodes = 0x00;
 
         /* look for an INDEX line */
         while( fgets( line, 1024, cuefile ) )
@@ -934,7 +953,7 @@ static int OpenVCDImage( vlc_object_t * p_this, const char *psz_dev,
                 goto error;
             p_toc->p_sectors = buf;
             p_toc->p_sectors[p_toc->i_tracks].i_lba = MSF_TO_LBA(i_min, i_sec, i_frame);
-            p_toc->p_sectors[p_toc->i_tracks].i_control = 0x00;
+            p_toc->p_sectors[p_toc->i_tracks].i_control = track_subcodes;
             msg_Dbg( p_this, "vcd track %i begins at sector:%i",
                      p_toc->i_tracks, p_toc->p_sectors[p_toc->i_tracks].i_lba );
             p_toc->i_tracks++;
@@ -950,10 +969,9 @@ static int OpenVCDImage( vlc_object_t * p_this, const char *psz_dev,
     p_toc->p_sectors = buf;
     p_toc->p_sectors[p_toc->i_tracks].i_lba =
             lseek(p_vcddev->i_vcdimage_handle, 0, SEEK_END) / VCD_SECTOR_SIZE;
-    p_toc->p_sectors[p_toc->i_tracks].i_control = 0x00;
-    msg_Dbg( p_this, "vcd track %i, begins at sector:%i",
-             p_toc->i_tracks, p_toc->p_sectors[p_toc->i_tracks].i_lba );
-    p_toc->i_tracks++;
+    p_toc->p_sectors[p_toc->i_tracks].i_control = track_subcodes;
+    msg_Dbg( p_this, "vcd tracks end at sector:%i",
+             p_toc->p_sectors[p_toc->i_tracks].i_lba );
     p_toc->i_first_track = 1;
     p_toc->i_last_track = p_toc->i_tracks;
     i_ret = 0;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/6d15f15bcc1eb8b23c6d4c8b5866e708ed83e61d

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/6d15f15bcc1eb8b23c6d4c8b5866e708ed83e61d
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help




More information about the vlc-commits mailing list