From 5bce4664beaddbcc256d333816ad6cdddf16a83d Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 4 Feb 2015 15:17:49 +0100 Subject: 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. --- stream/stream_cdda.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'stream') diff --git a/stream/stream_cdda.c b/stream/stream_cdda.c index 52eeb3e3e5..a75ee3ae40 100644 --- a/stream/stream_cdda.c +++ b/stream/stream_cdda.c @@ -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; -- cgit v1.2.3