summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-09-22 03:04:57 +0200
committerwm4 <wm4@nowhere>2013-09-22 03:31:25 +0200
commitcc7f8ee6204ffbeac195623a6be59ab9bcc32622 (patch)
tree5a7026d8d36ffe1168c1d1ed70d27f98ad912732
parentb0f7a26f1a6dc061db0a60908842371e7a010db2 (diff)
downloadmpv-cc7f8ee6204ffbeac195623a6be59ab9bcc32622.tar.bz2
mpv-cc7f8ee6204ffbeac195623a6be59ab9bcc32622.tar.xz
mplayer: attempt to make playback resume work with DVD/BD
The problem with DVD/BD and playback resume is that most often, the filename is just "dvd://", while the actual path to the DVD disk image is given with --dvd-device. But playback resume works on the filename only. Add a pretty bad hack that includes the path to the disk image if the filename starts with dvd://, and the same for BD respectively. (It's a bad hack, but I want to go to bed, so here we go. I might revert or improve it later, depending on user feedback.) We have to cleanup the global variable mess around the dvd_device. Ideally, this should go into MPOpts, but it isn't yet. Make the code paths in mplayer.c take MPOpts anyway.
-rw-r--r--mpvcore/command.c3
-rw-r--r--mpvcore/mp_core.h3
-rw-r--r--mpvcore/mplayer.c27
-rw-r--r--mpvcore/options.c4
-rw-r--r--stream/stream.h3
-rw-r--r--stream/stream_cdda.c2
-rw-r--r--stream/stream_dvd_common.h2
-rw-r--r--stream/stream_vcd.c2
8 files changed, 27 insertions, 19 deletions
diff --git a/mpvcore/command.c b/mpvcore/command.c
index 9e1e5f1c56..413ca9d1e5 100644
--- a/mpvcore/command.c
+++ b/mpvcore/command.c
@@ -2411,7 +2411,8 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
talloc_free(pl);
if (!append && mpctx->playlist->first) {
- struct playlist_entry *e = mp_resume_playlist(mpctx->playlist);
+ struct playlist_entry *e =
+ mp_resume_playlist(mpctx->playlist, opts);
mp_set_playlist_entry(mpctx, e ? e : mpctx->playlist->first);
}
} else {
diff --git a/mpvcore/mp_core.h b/mpvcore/mp_core.h
index 98096aa5fe..4b8a5fcef9 100644
--- a/mpvcore/mp_core.h
+++ b/mpvcore/mp_core.h
@@ -336,7 +336,8 @@ struct playlist_entry *mp_next_file(struct MPContext *mpctx, int direction,
int mp_get_cache_percent(struct MPContext *mpctx);
void mp_write_watch_later_conf(struct MPContext *mpctx);
void mp_set_playlist_entry(struct MPContext *mpctx, struct playlist_entry *e);
-struct playlist_entry *mp_resume_playlist(struct playlist *pl);
+struct playlist_entry *mp_resume_playlist(struct playlist *playlist,
+ struct MPOpts *opts);
void mp_force_video_refresh(struct MPContext *mpctx);
void mp_print_version(int always);
diff --git a/mpvcore/mplayer.c b/mpvcore/mplayer.c
index f4bf6c9316..fbba387681 100644
--- a/mpvcore/mplayer.c
+++ b/mpvcore/mplayer.c
@@ -777,17 +777,28 @@ static void load_per_file_config(m_config_t *conf, const char * const file,
#define MP_WATCH_LATER_CONF "watch_later"
-static char *get_playback_resume_config_filename(const char *fname)
+static char *get_playback_resume_config_filename(const char *fname,
+ struct MPOpts *opts)
{
char *res = NULL;
void *tmp = talloc_new(NULL);
const char *realpath = fname;
- if (!mp_is_url(bstr0(fname))) {
+ bstr bfname = bstr0(fname);
+ if (!mp_is_url(bfname)) {
char *cwd = mp_getcwd(tmp);
if (!cwd)
goto exit;
realpath = mp_path_join(tmp, bstr0(cwd), bstr0(fname));
}
+#ifdef CONFIG_DVDREAD
+ if (bstr_startswith0(bfname, "dvd://"))
+ realpath = talloc_asprintf(tmp, "%s - %s", realpath, dvd_device);
+#endif
+#ifdef CONFIG_LIBBLURAY
+ if (bstr_startswith0(bfname, "br://") || bstr_startswith0(bfname, "bd://") ||
+ bstr_startswith0(bfname, "bluray://"))
+ realpath = talloc_asprintf(tmp, "%s - %s", realpath, bluray_device);
+#endif
uint8_t md5[16];
av_md5_sum(md5, realpath, strlen(realpath));
char *conf = talloc_strdup(tmp, "");
@@ -853,7 +864,8 @@ void mp_write_watch_later_conf(struct MPContext *mpctx)
mk_config_dir(MP_WATCH_LATER_CONF);
- char *conffile = get_playback_resume_config_filename(mpctx->filename);
+ char *conffile = get_playback_resume_config_filename(mpctx->filename,
+ mpctx->opts);
talloc_steal(tmp, conffile);
if (!conffile)
goto exit;
@@ -880,7 +892,7 @@ exit:
static void load_playback_resume(m_config_t *conf, const char *file)
{
- char *fname = get_playback_resume_config_filename(file);
+ char *fname = get_playback_resume_config_filename(file, conf->optstruct);
if (fname && mp_path_exists(fname)) {
// Never apply the saved start position to following files
m_config_backup_opt(conf, "start");
@@ -897,10 +909,11 @@ static void load_playback_resume(m_config_t *conf, const char *file)
// resume file for them, this is simpler, and also has the nice property
// that appending to a playlist doesn't interfere with resuming (especially
// if the playlist comes from the command line).
-struct playlist_entry *mp_resume_playlist(struct playlist *playlist)
+struct playlist_entry *mp_resume_playlist(struct playlist *playlist,
+ struct MPOpts *opts)
{
for (struct playlist_entry *e = playlist->first; e; e = e->next) {
- char *conf = get_playback_resume_config_filename(e->filename);
+ char *conf = get_playback_resume_config_filename(e->filename, opts);
bool exists = conf && mp_path_exists(conf);
talloc_free(conf);
if (exists)
@@ -4892,7 +4905,7 @@ static int mpv_main(int argc, char *argv[])
if (opts->shuffle)
playlist_shuffle(mpctx->playlist);
- mpctx->playlist->current = mp_resume_playlist(mpctx->playlist);
+ mpctx->playlist->current = mp_resume_playlist(mpctx->playlist, opts);
if (!mpctx->playlist->current)
mpctx->playlist->current = mpctx->playlist->first;
diff --git a/mpvcore/options.c b/mpvcore/options.c
index afeb7e80fa..658003492e 100644
--- a/mpvcore/options.c
+++ b/mpvcore/options.c
@@ -53,8 +53,6 @@ extern char *lirc_configfile;
extern int mp_msg_color;
extern int mp_msg_module;
-extern int dvd_speed; /* stream/stream_dvd.c */
-
/* defined in demux: */
extern const m_option_t demux_rawaudio_opts[];
extern const m_option_t demux_rawvideo_opts[];
@@ -178,8 +176,6 @@ static const m_option_t scaler_filter_conf[]={
{NULL, NULL, 0, 0, 0, 0, NULL}
};
-extern char *dvd_device, *cdrom_device;
-
extern double mf_fps;
extern char * mf_type;
extern const struct m_obj_list vf_obj_list;
diff --git a/stream/stream.h b/stream/stream.h
index 525265b52c..49d9abcf67 100644
--- a/stream/stream.h
+++ b/stream/stream.h
@@ -257,8 +257,11 @@ int stream_check_interrupt(int time);
bool stream_manages_timeline(stream_t *s);
+/* stream/stream_dvd.c */
extern int dvd_title;
extern int dvd_angle;
+extern int dvd_speed;
+extern char *dvd_device, *cdrom_device;
extern int bluray_angle;
extern char *bluray_device;
diff --git a/stream/stream_cdda.c b/stream/stream_cdda.c
index 4c114ca1ac..9c7504a83d 100644
--- a/stream/stream_cdda.c
+++ b/stream/stream_cdda.c
@@ -50,8 +50,6 @@
#include "mpvcore/mp_msg.h"
-extern char *cdrom_device;
-
typedef struct {
cdrom_drive_t *cd;
cdrom_paranoia_t *cdp;
diff --git a/stream/stream_dvd_common.h b/stream/stream_dvd_common.h
index 8044c6251b..0a6c6789e1 100644
--- a/stream/stream_dvd_common.h
+++ b/stream/stream_dvd_common.h
@@ -23,11 +23,9 @@
#include <inttypes.h>
#include <dvdread/ifo_types.h>
-extern char *dvd_device;
extern const char * const dvd_audio_stream_channels[6];
extern const char * const dvd_audio_stream_types[8];
-extern int dvd_speed;
void dvd_set_speed(char *device, unsigned speed);
int mp_dvdtimetomsec(dvd_time_t *dt);
diff --git a/stream/stream_vcd.c b/stream/stream_vcd.c
index dacf2763f8..4c6dbcc074 100644
--- a/stream/stream_vcd.c
+++ b/stream/stream_vcd.c
@@ -56,8 +56,6 @@
#define vcd_close(priv) (close(((mp_vcd_priv_t*)priv)->fd))
#endif
-extern char *cdrom_device;
-
static int fill_buffer(stream_t *s, char* buffer, int max_len){
if(s->pos > s->end_pos) /// don't past end of current track
return 0;