summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-03-25 01:24:27 +0100
committerwm4 <wm4@nowhere>2014-03-25 01:24:27 +0100
commit7bd3f2648152d41db9a9d3f479358d0d8f38b210 (patch)
treeb17ba6b78eaacd86c01923d9e317db77464ecfc2 /stream
parent7f39b4655e76bf26a32a415b0c21bfd4102c6b31 (diff)
downloadmpv-7bd3f2648152d41db9a9d3f479358d0d8f38b210.tar.bz2
mpv-7bd3f2648152d41db9a9d3f479358d0d8f38b210.tar.xz
stream_cdda: report track times
Report the time for each chapter (tracks are treated as chapters). This allows us to get rid of the "old" chapter mechanism, and also behaves better with the frontend. This makes assumptions about the audio formats, but that format is hardcoded anyway in the rawaudio demuxer defaults (and always was).
Diffstat (limited to 'stream')
-rw-r--r--stream/stream_cdda.c35
1 files changed, 8 insertions, 27 deletions
diff --git a/stream/stream_cdda.c b/stream/stream_cdda.c
index 5d095f6d74..529e3aa71c 100644
--- a/stream/stream_cdda.c
+++ b/stream/stream_cdda.c
@@ -273,37 +273,18 @@ static int control(stream_t *stream, int cmd, void *arg)
*(unsigned int *)arg = end_track + 1 - start_track;
return STREAM_OK;
}
- case STREAM_CTRL_SEEK_TO_CHAPTER:
+ case STREAM_CTRL_GET_CHAPTER_TIME:
{
- int r;
- unsigned int track = *(unsigned int *)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);
- int seek_sector;
- if (start_track == -1 || end_track == -1)
- return STREAM_ERROR;
- track += start_track;
- if (track > end_track) {
- seek(stream, (p->end_sector + 1) * CDIO_CD_FRAMESIZE_RAW);
- // seeking beyond EOF should not be an error,
- // the cache cannot handle changing stream pos and
- // returning error.
- return STREAM_OK;
- }
- seek_sector = track == 0 ? p->start_sector
- : p->cd->disc_toc[track].dwStartSector;
- r = seek(stream, seek_sector * CDIO_CD_FRAMESIZE_RAW);
- if (r)
- return STREAM_OK;
- break;
- }
- case STREAM_CTRL_GET_CURRENT_CHAPTER:
- {
- int start_track = get_track_by_sector(p, p->start_sector);
- int cur_track = get_track_by_sector(p, p->sector);
- if (start_track == -1 || cur_track == -1)
+ track += start_track + 1;
+ if (track > end_track)
return STREAM_ERROR;
- *(unsigned int *)arg = cur_track - start_track;
+ int64_t sector = p->cd->disc_toc[track].dwStartSector;
+ int64_t pos = sector * CDIO_CD_FRAMESIZE_RAW;
+ // Assume standard audio CD: 44.1khz, 2 channels, s16 samples
+ *(double *)arg = pos / (44100 * 2 * 2);
return STREAM_OK;
}
}