mirror of
https://github.com/mpv-player/mpv.git
synced 2026-10-18 15:51:27 +08:00
stream_cdda: fix track time accuracy
Don't use an integer division to get the time, since that would round on second boundaries. Also round up the time by sector size. Seeking rounds down due to alignment constraints, but if we round up the time, we can make it land on the exact destination sector. This fixes that the track change code printed the previous track when seeking by chapter.
This commit is contained in:
@@ -282,9 +282,9 @@ static int control(stream_t *stream, int cmd, void *arg)
|
||||
if (track > end_track)
|
||||
return STREAM_ERROR;
|
||||
int64_t sector = p->cd->disc_toc[track].dwStartSector;
|
||||
int64_t pos = sector * CDIO_CD_FRAMESIZE_RAW;
|
||||
int64_t pos = sector * (CDIO_CD_FRAMESIZE_RAW + 1) - 1;
|
||||
// Assume standard audio CD: 44.1khz, 2 channels, s16 samples
|
||||
*(double *)arg = pos / (44100 * 2 * 2);
|
||||
*(double *)arg = pos / (44100.0 * 2 * 2);
|
||||
return STREAM_OK;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user