summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-03-26 16:51:17 +0100
committerwm4 <wm4@nowhere>2014-03-30 17:54:10 +0200
commit96d7e80ddfe88425d73b8581c1409364b005ade9 (patch)
tree0bf64a7f0871fa3dd754fff2e3842b0df9ea83f0
parentdde72c5c54a296ab8592bf6046796444b5402e82 (diff)
downloadmpv-96d7e80ddfe88425d73b8581c1409364b005ade9.tar.bz2
mpv-96d7e80ddfe88425d73b8581c1409364b005ade9.tar.xz
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.
-rw-r--r--stream/stream_cdda.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/stream/stream_cdda.c b/stream/stream_cdda.c
index 529e3aa71c..347d6f993d 100644
--- a/stream/stream_cdda.c
+++ b/stream/stream_cdda.c
@@ -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;
}
}