0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00

demux: restructure chapter seeking code

Arrange the code such that commenting the first if will allow doing
stream chapter seeks instead of time chapter seeks again, if both are
possible.
This commit is contained in:
wm4 2013-05-09 01:09:08 +02:00
parent 729430387c
commit c2657d5c98

View File

@ -1327,22 +1327,22 @@ static void add_stream_chapters(struct demuxer *demuxer)
int demuxer_seek_chapter(demuxer_t *demuxer, int chapter, double *seek_pts)
{
int ris;
if (!demuxer->num_chapters || !demuxer->chapters) {
demux_flush(demuxer);
int ris = STREAM_UNSUPPORTED;
if (demuxer->num_chapters == 0)
ris = stream_control(demuxer->stream, STREAM_CTRL_SEEK_TO_CHAPTER,
&chapter);
if (ris != STREAM_UNSUPPORTED)
demux_control(demuxer, DEMUXER_CTRL_RESYNC, NULL);
if (ris != STREAM_UNSUPPORTED) {
demux_flush(demuxer);
demux_control(demuxer, DEMUXER_CTRL_RESYNC, NULL);
// exit status may be ok, but main() doesn't have to seek itself
// (because e.g. dvds depend on sectors, not on pts)
*seek_pts = -1.0;
return ris != STREAM_UNSUPPORTED ? chapter : -1;
} else { // chapters structure is set in the demuxer
return chapter;
} else {
if (chapter >= demuxer->num_chapters)
return -1;
if (chapter < 0)