mirror of https://github.com/mpv-player/mpv
stream_cdda: fix bugs in chapter time retrieval
Looks like a bunch of off-by-one errors.
The track number was mistakenly offset by 1 - this shifted all chapters
by one, and make the first chapter start on the second track (so the
"chapter" property returned -1 in the first track since it was before
the first chapter).
Also, the calculation of the sector destination was messed up. This
comes from commit 32d818f0
, where I apparently attempted to calculate
the position to one byte before the section, but unfortunately math
doesn't work this way and it was nonsense. Just drop this idea; while it
may help with seeking (probably...), it also returns slightly different
times. The user shall use hr-seeks if accurate seeking is required.
Hopefully fixes #1560.
This commit is contained in:
parent
b715fb6df1
commit
5bce4664be
|
@ -257,11 +257,11 @@ static int control(stream_t *stream, int cmd, void *arg)
|
|||
int track = *(double *)arg;
|
||||
int start_track = get_track_by_sector(p, p->start_sector);
|
||||
int end_track = get_track_by_sector(p, p->end_sector);
|
||||
track += start_track + 1;
|
||||
track += start_track;
|
||||
if (track > end_track)
|
||||
return STREAM_ERROR;
|
||||
int64_t sector = p->cd->disc_toc[track].dwStartSector;
|
||||
int64_t pos = sector * (CDIO_CD_FRAMESIZE_RAW + 1) - 1;
|
||||
int64_t pos = sector * CDIO_CD_FRAMESIZE_RAW;
|
||||
// Assume standard audio CD: 44.1khz, 2 channels, s16 samples
|
||||
*(double *)arg = pos / (44100.0 * 2 * 2);
|
||||
return STREAM_OK;
|
||||
|
|
Loading…
Reference in New Issue