[Bug 281020] Cannot play sound tracks on mixed-mode CDs (read() fails with EINVAL)

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 24 Aug 2024 07:24:36 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=281020

            Bug ID: 281020
           Summary: Cannot play sound tracks on mixed-mode CDs (read()
                    fails with EINVAL)
           Product: Base System
           Version: 14.1-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: damjan.jov@gmail.com

On a mixed-mode CD (a CD with both data and sound tracks), it is not possible
to play the sound tracks.

The way that eg. multimedia/vlc reads sound from a CD involves:
int fd = open("/dev/cd0", ...)
int block_size = 2352;
ioctl(fd, CDRIOCSETBLOCKSIZE, &block_size);
lseek(fd, some multiple of 2352, SEEK_SET);
read(fd, buffer, some multiple of 2352);
and on a pure sound CD, this works perfectly, both in VLC and a test
application I made.

However when using that code on a mixed-mode CD (with both data and sound
tracks), read() always fails with EINVAL, whether the offset is within a data
track or a sound track. The only way to make read() succeed on such CDs, is to
use a block size of 2048, and an offset that places the read within a data
track. Attempting to read music tracks always fails with EINVAL, regardless of
the block size.

It will take me some time to confirm, but this may be a regression from commit
dd78f43259efd551f76a6cb7744bce49c215863e, which was meant to "make the media
check asynchronous", but also made many other changes, including setting a
block size of 2352 for pure sound CDs (which could be why they still work, but
mixed-mode CDs don't).

-- 
You are receiving this mail because:
You are the assignee for the bug.