From a2133d76847dd4c7a19d6826cd9a6562bedfdbc4 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Sat, 24 Apr 2010 20:09:31 +0300 Subject: options: move -chapter values to option struct -chapter can optionally take a range with a start and an end. Add a new option type which supports such values and use that instead of a custom per-option function. This commit also fixes a build configuration bug: before the availability of the -chapter option depended on DVD functionality being enabled in the binary, even though the option works with other sources too. --- mplayer.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'mplayer.c') diff --git a/mplayer.c b/mplayer.c index b8505aafb4..0432670a99 100644 --- a/mplayer.c +++ b/mplayer.c @@ -3571,8 +3571,8 @@ if(stream_dump_type==5){ mp_tmsg(MSGT_CPLAYER,MSGL_FATAL,"Cannot open dump file.\n"); exit_player(mpctx, EXIT_ERROR); } - if (dvd_chapter > 1) { - int chapter = dvd_chapter - 1; + if (opts->chapterrange[0] > 1) { + int chapter = opts->chapterrange[0] - 1; stream_control(mpctx->stream, STREAM_CTRL_SEEK_TO_CHAPTER, &chapter); } while(!mpctx->stream->eof && !async_quit_request){ @@ -3583,10 +3583,11 @@ if(stream_dump_type==5){ exit_player(mpctx, EXIT_ERROR); } } - if(dvd_last_chapter > 0) { + if (opts->chapterrange[1] > 0) { int chapter = -1; if (stream_control(mpctx->stream, STREAM_CTRL_GET_CURRENT_CHAPTER, - &chapter) == STREAM_OK && chapter + 1 > dvd_last_chapter) + &chapter) == STREAM_OK + && chapter + 1 > opts->chapterrange[1]) break; } } @@ -3715,9 +3716,9 @@ if(!mpctx->demuxer) mpctx->num_sources = 1; } -if(dvd_chapter>1) { +if(opts->chapterrange[0]>1) { double pts; - if (seek_chapter(mpctx, dvd_chapter-1, &pts, NULL) >= 0 && pts > -1.0) + if (seek_chapter(mpctx, opts->chapterrange[0]-1, &pts, NULL) >= 0 && pts > -1.0) seek(mpctx, pts, SEEK_ABSOLUTE); } @@ -3799,9 +3800,9 @@ if((stream_dump_type)&&(stream_dump_type<4)){ if( (mpctx->demuxer->file_format==DEMUXER_TYPE_AVI || mpctx->demuxer->file_format==DEMUXER_TYPE_ASF || mpctx->demuxer->file_format==DEMUXER_TYPE_MOV) && stream_dump_type==2) fwrite(&in_size,1,4,f); if(in_size>0) fwrite(start,in_size,1,f); - if(dvd_last_chapter>0) { + if (opts->chapterrange[1] > 0) { int cur_chapter = demuxer_get_current_chapter(mpctx->demuxer); - if(cur_chapter!=-1 && cur_chapter+1>dvd_last_chapter) + if(cur_chapter!=-1 && cur_chapter+1 > opts->chapterrange[1]) break; } } @@ -4090,9 +4091,9 @@ if (mpctx->stream->type == STREAMTYPE_DVDNAV) { while(!mpctx->stop_play){ float aq_sleep_time=0; -if(dvd_last_chapter>0) { +if (opts->chapterrange[1] > 0) { int cur_chapter = get_current_chapter(mpctx); - if(cur_chapter!=-1 && cur_chapter+1>dvd_last_chapter) + if(cur_chapter!=-1 && cur_chapter+1 > opts->chapterrange[1]) goto goto_next_file; } -- cgit v1.2.3