summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
authorUoti Urpala <uau@glyph.nonexistent.invalid>2010-04-24 20:09:31 +0300
committerUoti Urpala <uau@glyph.nonexistent.invalid>2010-04-25 22:48:10 +0300
commita2133d76847dd4c7a19d6826cd9a6562bedfdbc4 (patch)
tree84d45683615f51b73c624f51ad62f46247ccedfc /stream
parent9c63c084ff589de88ddf26c64a074cdac0eca046 (diff)
downloadmpv-a2133d76847dd4c7a19d6826cd9a6562bedfdbc4.tar.bz2
mpv-a2133d76847dd4c7a19d6826cd9a6562bedfdbc4.tar.xz
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.
Diffstat (limited to 'stream')
-rw-r--r--stream/open.c2
-rw-r--r--stream/stream.h2
-rw-r--r--stream/stream_dvd.c38
-rw-r--r--stream/stream_dvd.h1
-rw-r--r--stream/stream_dvdnav.c5
5 files changed, 3 insertions, 45 deletions
diff --git a/stream/open.c b/stream/open.c
index 3eb895349f..f5cf71fae8 100644
--- a/stream/open.c
+++ b/stream/open.c
@@ -39,8 +39,6 @@
/// We keep these 2 for the gui atm, but they will be removed.
int vcd_track=0;
char* cdrom_device=NULL;
-int dvd_chapter=1;
-int dvd_last_chapter=0;
char* dvd_device=NULL;
int dvd_title=0;
diff --git a/stream/stream.h b/stream/stream.h
index 62a2ee8d4e..d46730bd80 100644
--- a/stream/stream.h
+++ b/stream/stream.h
@@ -342,8 +342,6 @@ void stream_set_interrupt_callback(int (*cb)(struct input_ctx*, int),
int stream_check_interrupt(int time);
extern int dvd_title;
-extern int dvd_chapter;
-extern int dvd_last_chapter;
extern int dvd_angle;
extern char * audio_stream;
diff --git a/stream/stream_dvd.c b/stream/stream_dvd.c
index d1a91f88c1..a006047871 100644
--- a/stream/stream_dvd.c
+++ b/stream/stream_dvd.c
@@ -83,42 +83,6 @@ static const struct m_struct_st stream_opts = {
stream_opts_fields
};
-int dvd_parse_chapter_range(const m_option_t *conf, const char *range) {
- const char *s;
- char *t;
- if (!range)
- return M_OPT_MISSING_PARAM;
- s = range;
- dvd_chapter = 1;
- dvd_last_chapter = 0;
- if(*range && isdigit(*range)) {
- dvd_chapter = strtol(range, &s, 10);
- if(range == s) {
- mp_tmsg(MSGT_OPEN, MSGL_ERR, "Invalid chapter range specification %s\n", range);
- return M_OPT_INVALID;
- }
- }
- if(*s == 0)
- return 0;
- else if(*s != '-') {
- mp_tmsg(MSGT_OPEN, MSGL_ERR, "Invalid chapter range specification %s\n", range);
- return M_OPT_INVALID;
- }
- ++s;
- if(*s == 0)
- return 0;
- if(! isdigit(*s)) {
- mp_tmsg(MSGT_OPEN, MSGL_ERR, "Invalid chapter range specification %s\n", range);
- return M_OPT_INVALID;
- }
- dvd_last_chapter = strtol(s, &t, 10);
- if (s == t || *t) {
- mp_tmsg(MSGT_OPEN, MSGL_ERR, "Invalid chapter range specification %s\n", range);
- return M_OPT_INVALID;
- }
- return 0;
-}
-
int dvd_chapter_from_cell(dvd_priv_t* dvd,int title,int cell)
{
pgc_t * cur_pgc;
@@ -411,8 +375,6 @@ static void dvd_close(dvd_priv_t *d) {
ifoClose(d->vmg_file);
DVDCloseFile(d->title);
DVDClose(d->dvd);
- dvd_chapter = 1;
- dvd_last_chapter = 0;
dvd_set_speed(dvd_device_current, -1); /* -1 => restore default */
}
diff --git a/stream/stream_dvd.h b/stream/stream_dvd.h
index 1e6c80163a..5872cb1d59 100644
--- a/stream/stream_dvd.h
+++ b/stream/stream_dvd.h
@@ -62,6 +62,5 @@ int dvd_lang_from_sid(stream_t *stream, int id);
int dvd_aid_from_lang(stream_t *stream, unsigned char* lang);
int dvd_sid_from_lang(stream_t *stream, unsigned char* lang);
int dvd_chapter_from_cell(dvd_priv_t *dvd,int title,int cell);
-int dvd_parse_chapter_range(const m_option_t *conf, const char *range);
#endif /* MPLAYER_STREAM_DVD_H */
diff --git a/stream/stream_dvdnav.c b/stream/stream_dvdnav.c
index b87fdaa4c5..5932fd049c 100644
--- a/stream/stream_dvdnav.c
+++ b/stream/stream_dvdnav.c
@@ -23,6 +23,7 @@
#include <unistd.h>
#include <string.h>
#include <errno.h>
+#include "options.h"
#include "mp_msg.h"
#include "osdep/timer.h"
#include "input/input.h"
@@ -379,9 +380,9 @@ static int fill_buffer(stream_t *s, char *but, int len)
priv->state &= ~NAV_FLAG_WAIT;
if (priv->state & NAV_FLAG_WAIT_READ_AUTO)
priv->state |= NAV_FLAG_WAIT_READ;
- if(priv->title > 0 && dvd_last_chapter > 0) {
+ if(priv->title > 0 && s->opts->chapterrange[1] > 0) {
int tit=0, part=0;
- if(dvdnav_current_title_info(priv->dvdnav, &tit, &part) == DVDNAV_STATUS_OK && part > dvd_last_chapter) {
+ if(dvdnav_current_title_info(priv->dvdnav, &tit, &part) == DVDNAV_STATUS_OK && part > s->opts->chapterrange[1]) {
priv->state |= NAV_FLAG_EOF;
return 0;
}