summaryrefslogtreecommitdiffstats
path: root/mpvcore
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-11-04 00:43:06 +0100
committerwm4 <wm4@nowhere>2013-11-04 00:43:06 +0100
commitf7b2d644eff7fae2d74259ae14ec2b05b00c9b9b (patch)
treeca5462391d6a8f7b8e254c51c88f30efea91b90f /mpvcore
parent37388ebb0ef9085c841d7f94e665a5a77cfe0e92 (diff)
parent25affdcc886ce010995804553396d81d90a321d3 (diff)
downloadmpv-f7b2d644eff7fae2d74259ae14ec2b05b00c9b9b.tar.bz2
mpv-f7b2d644eff7fae2d74259ae14ec2b05b00c9b9b.tar.xz
Merge branch 'master' into have_configure
Conflicts: configure
Diffstat (limited to 'mpvcore')
-rw-r--r--mpvcore/player/loadfile.c5
-rw-r--r--mpvcore/player/playloop.c32
2 files changed, 22 insertions, 15 deletions
diff --git a/mpvcore/player/loadfile.c b/mpvcore/player/loadfile.c
index 24b81934ad..baa49f0db5 100644
--- a/mpvcore/player/loadfile.c
+++ b/mpvcore/player/loadfile.c
@@ -894,8 +894,9 @@ static void print_resolve_contents(struct mp_log *log,
// from the given playlist pl, so the entries don't actually need to be copied.
static void transfer_playlist(struct MPContext *mpctx, struct playlist *pl)
{
- if (mpctx->demuxer->playlist->first) {
- playlist_transfer_entries(mpctx->playlist, mpctx->demuxer->playlist);
+ if (pl->first) {
+ playlist_transfer_entries(mpctx->playlist, pl);
+ // current entry is replaced
if (mpctx->playlist->current)
playlist_remove(mpctx->playlist, mpctx->playlist->current);
} else {
diff --git a/mpvcore/player/playloop.c b/mpvcore/player/playloop.c
index 1162572946..d4db03c446 100644
--- a/mpvcore/player/playloop.c
+++ b/mpvcore/player/playloop.c
@@ -206,8 +206,8 @@ static void seek_reset(struct MPContext *mpctx, bool reset_ao, bool reset_ac)
}
// return -1 if seek failed (non-seekable stream?), 0 otherwise
-static int seek(MPContext *mpctx, struct seek_params seek,
- bool timeline_fallthrough)
+static int mp_seek(MPContext *mpctx, struct seek_params seek,
+ bool timeline_fallthrough)
{
struct MPOpts *opts = mpctx->opts;
uint64_t prev_seek_ts = mpctx->vo_pts_history_seek_ts;
@@ -215,6 +215,11 @@ static int seek(MPContext *mpctx, struct seek_params seek,
if (!mpctx->demuxer)
return -1;
+ if (!mpctx->demuxer->seekable) {
+ MP_ERR(mpctx, "Can't seek in this file.\n");
+ return -1;
+ }
+
if (mpctx->stop_play == AT_END_OF_FILE)
mpctx->stop_play = KEEP_PLAYING;
bool hr_seek = mpctx->demuxer->accurate_seek && opts->correct_pts;
@@ -387,7 +392,7 @@ void queue_seek(struct MPContext *mpctx, enum seek_type type, double amount,
void execute_queued_seek(struct MPContext *mpctx)
{
if (mpctx->seek.type) {
- seek(mpctx, mpctx->seek, false);
+ mp_seek(mpctx, mpctx->seek, false);
mpctx->seek = (struct seek_params){0};
}
}
@@ -452,11 +457,12 @@ double get_current_pos_ratio(struct MPContext *mpctx, bool use_range)
if (len > 0 && !demuxer->ts_resets_possible) {
ans = MPCLAMP((pos - start) / len, 0, 1);
} else {
- int64_t size = (demuxer->movi_end - demuxer->movi_start);
+ struct stream *s = demuxer->stream;
+ int64_t size = s->end_pos - s->start_pos;
int64_t fpos = demuxer->filepos > 0 ?
demuxer->filepos : stream_tell(demuxer->stream);
if (size > 0)
- ans = MPCLAMP((double)(fpos - demuxer->movi_start) / size, 0, 1);
+ ans = MPCLAMP((double)(fpos - s->start_pos) / size, 0, 1);
}
if (use_range) {
if (mpctx->opts->play_frames > 0)
@@ -812,10 +818,10 @@ static void handle_backstep(struct MPContext *mpctx)
// The whole point is getting frames _before_ that PTS,
// so apply an arbitrary offset. (In theory the offset
// has to be large enough to reach the previous frame.)
- seek(mpctx, (struct seek_params){
- .type = MPSEEK_ABSOLUTE,
- .amount = current_pts - 1.0,
- }, false);
+ mp_seek(mpctx, (struct seek_params){
+ .type = MPSEEK_ABSOLUTE,
+ .amount = current_pts - 1.0,
+ }, false);
// Don't leave hr-seek mode. If all goes right, hr-seek
// mode is cancelled as soon as the frame before
// current_pts is found during hr-seeking.
@@ -1184,10 +1190,10 @@ void run_playloop(struct MPContext *mpctx)
&& (opts->gapless_audio || buffered_audio < 0.05)
&& (!mpctx->paused || was_restart)) {
if (end_is_chapter) {
- seek(mpctx, (struct seek_params){
- .type = MPSEEK_ABSOLUTE,
- .amount = mpctx->timeline[mpctx->timeline_part+1].start
- }, true);
+ mp_seek(mpctx, (struct seek_params){
+ .type = MPSEEK_ABSOLUTE,
+ .amount = mpctx->timeline[mpctx->timeline_part+1].start
+ }, true);
} else
mpctx->stop_play = AT_END_OF_FILE;
sleeptime = 0;