Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CDDA streams assume that the first track number is zero. #6467

Closed
vext01 opened this issue Jan 26, 2019 · 2 comments
Closed

CDDA streams assume that the first track number is zero. #6467

vext01 opened this issue Jan 26, 2019 · 2 comments

Comments

@vext01
Copy link

vext01 commented Jan 26, 2019

mpv version and platform

At least 0.22.0 and master.

Reproduction steps

Play a CD whose start track is not one.

Expected behavior

Reports playing the correct track number.

Actual behavior

This CD starts with track 7:

$ cd-info
...
CD-ROM Track List (7 - 11)
  #: MSF       LSN    Type   Green? Copy? Channels Premphasis?
  7: 00:02:00  000000 audio  false  no    0        no
  8: 03:07:72  013947 audio  false  no    0        no
  9: 05:46:12  025812 audio  false  no    0        no
 10: 07:24:74  033224 audio  false  no    0        no
 11: 09:41:34  043459 audio  false  no    0        no
170: 12:48:10  057460 leadout (128 MB raw, 128 MB formatted)
fremen:edd> mpv cdda://
Playing: cdda://
[cdda] Switched to track 1 <------------------------------------ !
 (+) Audio --aid=1 (pcm_s16le)
AO: [sdl] 44100Hz stereo 2ch s16
A: 00:00:02 / 00:12:46 (0%) Cache: 10s+3MB
...

Track 7 is heard playing.

Sample files

Here's how to make a CD with a start track number of 7:

cdrskin -v dev=/dev/rcd0d cd_start_tno=7 trackA.wav trackB.wav trackC.wav

Obviously switch out the device node for your CD drive.

@vext01
Copy link
Author

vext01 commented Jan 26, 2019

Here's the problem code:

static int fill_buffer(stream_t *s, char *buffer, int max_len)
{
    cdda_priv *p = (cdda_priv *)s->priv;
    int16_t *buf;
    int i;

    if (max_len < CDIO_CD_FRAMESIZE_RAW)
        return -1;

    if ((p->sector < p->start_sector) || (p->sector > p->end_sector)) {
        return 0;
    }

    buf = paranoia_read(p->cdp, cdparanoia_callback);
    if (!buf)
        return 0;

    p->sector++;
    memcpy(buffer, buf, CDIO_CD_FRAMESIZE_RAW);

    for (i = 0; i < p->cd->tracks; i++) {
        if (p->cd->disc_toc[i].dwStartSector == p->sector - 1) {
            print_track_info(s, i + 1); <-------------------------- !
            break;
        }
    }

    return CDIO_CD_FRAMESIZE_RAW;
}

i+1 is the wrong track number to report if the first track is not one.

@ghost
Copy link

ghost commented Oct 25, 2019

Feel free to provide patches; they probably have a good chance of getting in. I don't think anyone else is going to look at this. Closing.

@ghost ghost closed this as completed Oct 25, 2019
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants