summaryrefslogtreecommitdiffstats
path: root/command.c
diff options
context:
space:
mode:
authorUoti Urpala <uau@glyph.nonexistent.invalid>2010-11-08 00:54:32 +0200
committerUoti Urpala <uau@glyph.nonexistent.invalid>2010-11-08 18:05:12 +0200
commit9a663ffec62720931f34ae2742a32652d1de5f8e (patch)
tree6fe61b81610e178b760f3a5f4e0403fe4690d23b /command.c
parent3628a903f40943740ff97a03a106d9a5208fae76 (diff)
downloadmpv-9a663ffec62720931f34ae2742a32652d1de5f8e.tar.bz2
mpv-9a663ffec62720931f34ae2742a32652d1de5f8e.tar.xz
core: move video pos/length query functions from demux to core
Move functions to query current playback position, percentage position and total video length from from the demuxer layer to top level. The functions need access to playback state that doesn't belong on the demuxing level. Make the new functions more capable and simplify some code that can now rely on them. This fixes some errors in displayed in OSD and slave mode information when using timeline (ordered chapters).
Diffstat (limited to 'command.c')
-rw-r--r--command.c30
1 files changed, 11 insertions, 19 deletions
diff --git a/command.c b/command.c
index 1d1e9f016c..f669c19fff 100644
--- a/command.c
+++ b/command.c
@@ -389,7 +389,7 @@ static int mp_property_length(m_option_t *prop, int action, void *arg,
double len;
if (!mpctx->demuxer ||
- !(int) (len = demuxer_get_time_length(mpctx->demuxer)))
+ !(int) (len = get_time_length(mpctx)))
return M_PROPERTY_UNAVAILABLE;
return m_property_time_ro(prop, action, arg, len);
@@ -411,14 +411,13 @@ static int mp_property_percent_pos(m_option_t *prop, int action,
break;
case M_PROPERTY_STEP_UP:
case M_PROPERTY_STEP_DOWN:
- pos = demuxer_get_percent_pos(mpctx->demuxer);
+ pos = get_percent_pos(mpctx);
pos += (arg ? *(int*)arg : 10) *
(action == M_PROPERTY_STEP_UP ? 1 : -1);
M_PROPERTY_CLAMP(prop, pos);
break;
default:
- return m_property_int_ro(prop, action, arg,
- demuxer_get_percent_pos(mpctx->demuxer));
+ return m_property_int_ro(prop, action, arg, get_percent_pos(mpctx));
}
mpctx->abs_seek_pos = SEEK_ABSOLUTE | SEEK_FACTOR;
@@ -445,9 +444,7 @@ static int mp_property_time_pos(m_option_t *prop, int action,
(action == M_PROPERTY_STEP_UP ? 1.0 : -1.0);
return M_PROPERTY_OK;
}
- return m_property_time_ro(prop, action, arg,
- mpctx->sh_video ? mpctx->sh_video->pts :
- playing_audio_pts(mpctx));
+ return m_property_time_ro(prop, action, arg, get_current_time(mpctx));
}
/// Current chapter (RW)
@@ -2795,8 +2792,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
case MP_CMD_EDL_MARK:
if (edl_fd) {
- float v = sh_video ? sh_video->pts :
- playing_audio_pts(mpctx);
+ float v = get_current_time(mpctx);
if (mpctx->begin_skip == MP_NOPTS_VALUE) {
mpctx->begin_skip = v;
mp_tmsg(MSGT_CPLAYER, MSGL_INFO, "EDL skip start, press 'i' again to end block.\n");
@@ -3021,9 +3017,9 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
break;
case MP_CMD_OSD_SHOW_PROGRESSION:{
- int len = demuxer_get_time_length(mpctx->demuxer);
- int pts = demuxer_get_current_time(mpctx->demuxer);
- set_osd_bar(mpctx, 0, "Position", 0, 100, demuxer_get_percent_pos(mpctx->demuxer));
+ int len = get_time_length(mpctx);
+ int pts = get_current_time(mpctx);
+ set_osd_bar(mpctx, 0, "Position", 0, 100, get_percent_pos(mpctx));
set_osd_msg(OSD_MSG_TEXT, 1, osd_duration,
"%c %02d:%02d:%02d / %02d:%02d:%02d",
mpctx->osd_function, pts/3600, (pts/60)%60, pts%60,
@@ -3280,7 +3276,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
case MP_CMD_GET_TIME_LENGTH:{
mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_LENGTH=%.2f\n",
- demuxer_get_time_length(mpctx->demuxer));
+ get_time_length(mpctx));
}
break;
@@ -3415,15 +3411,11 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
case MP_CMD_GET_PERCENT_POS:
mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_PERCENT_POSITION=%d\n",
- demuxer_get_percent_pos(mpctx->demuxer));
+ get_percent_pos(mpctx));
break;
case MP_CMD_GET_TIME_POS:{
- float pos = 0;
- if (sh_video)
- pos = sh_video->pts;
- else if (sh_audio && mpctx->audio_out)
- pos = playing_audio_pts(mpctx);
+ float pos = get_current_time(mpctx);
mp_msg(MSGT_GLOBAL, MSGL_INFO, "ANS_TIME_POSITION=%.1f\n", pos);
}
break;