diff options
author | wm4 <wm4@mplayer2.org> | 2012-01-18 04:18:41 +0100 |
---|---|---|
committer | wm4 <wm4@mplayer2.org> | 2012-01-18 04:18:41 +0100 |
commit | f341b21a90d27977562645fb80f0cbbc2a17af7b (patch) | |
tree | af4b95b39fa865ddcaa5a448b7e04a0f5e220f57 /mplayer.c | |
parent | 4e76c7514f847648cdc9740d6ef997d1653effa8 (diff) | |
parent | c4093e7d872d2daa485029b8b36661411387ef37 (diff) | |
download | mpv-f341b21a90d27977562645fb80f0cbbc2a17af7b.tar.bz2 mpv-f341b21a90d27977562645fb80f0cbbc2a17af7b.tar.xz |
Merge remote-tracking branch 'origin/master' into my_master
Diffstat (limited to 'mplayer.c')
-rw-r--r-- | mplayer.c | 122 |
1 files changed, 59 insertions, 63 deletions
@@ -62,7 +62,6 @@ #include "m_option.h" #include "m_config.h" #include "mplayer.h" -#include "access_mpcontext.h" #include "m_property.h" #include "libavutil/avstring.h" @@ -348,36 +347,6 @@ int use_filename_title; #include "metadata.h" -void *mpctx_get_video_out(MPContext *mpctx) -{ - return mpctx->video_out; -} - -void *mpctx_get_demuxer(MPContext *mpctx) -{ - return mpctx->demuxer; -} - -void *mpctx_get_playtree_iter(MPContext *mpctx) -{ - return mpctx->playtree_iter; -} - -void *mpctx_get_mixer(MPContext *mpctx) -{ - return &mpctx->mixer; -} - -int mpctx_get_global_sub_size(MPContext *mpctx) -{ - return mpctx->global_sub_size; -} - -int mpctx_get_osd_function(MPContext *mpctx) -{ - return mpctx->osd_function; -} - static float get_relative_time(struct MPContext *mpctx) { unsigned int new_time = GetTimer(); @@ -1367,6 +1336,8 @@ static void print_status(struct MPContext *mpctx, double a_pos, bool at_frame) mp_msg(MSGT_STATUSLINE, MSGL_STATUS, "%s\r", line); } free(line); + + mpctx->status_printed = true; } struct stream_dump_progress { @@ -2936,7 +2907,7 @@ static double update_video(struct MPContext *mpctx) int in_size = 0; unsigned char *buf = NULL; pts = MP_NOPTS_VALUE; - struct demux_packet *pkt = ds_get_packet2(mpctx->d_video); + struct demux_packet *pkt = ds_get_packet2(mpctx->d_video, false); if (pkt) { in_size = pkt->len; buf = pkt->buffer; @@ -3004,6 +2975,48 @@ static double update_video(struct MPContext *mpctx) return frame_time; } +static int get_cache_fill(struct MPContext *mpctx) +{ +#ifdef CONFIG_STREAM_CACHE + if (stream_cache_size > 0) + return cache_fill_status(mpctx->stream); +#endif + return -1; +} + +static void update_pause_message(struct MPContext *mpctx) +{ + struct MPOpts *opts = &mpctx->opts; + + if (opts->quiet) + return; + + int cache_fill = get_cache_fill(mpctx); + bool cache_changed = cache_fill != mpctx->paused_cache_fill; + + if (!mpctx->status_printed && !cache_changed) + return; + + char *msg = mp_gtext(" ===== PAUSE ====="); + char *tmpmem = NULL; + if (cache_fill >= 0) + msg = tmpmem = talloc_asprintf(NULL, "%s %d%%", msg, cache_fill); + + if (opts->term_osd && !mpctx->sh_video) { + set_osd_msg(OSD_MSG_PAUSE, 1, 0, "%s", msg); + update_osd_msg(mpctx); + } else { + if (mpctx->status_printed) + mp_msg(MSGT_CPLAYER, MSGL_STATUS, "\n"); + mp_msg(MSGT_CPLAYER, MSGL_STATUS, "%s\r", msg); + } + + mpctx->paused_cache_fill = cache_fill; + mpctx->status_printed = false; + + talloc_free(tmpmem); +} + void pause_player(struct MPContext *mpctx) { if (mpctx->paused) @@ -3011,12 +3024,20 @@ void pause_player(struct MPContext *mpctx) mpctx->paused = 1; mpctx->step_frames = 0; mpctx->time_frame -= get_relative_time(mpctx); + mpctx->osd_function = OSD_PAUSE; if (mpctx->video_out && mpctx->sh_video && mpctx->video_out->config_ok) vo_control(mpctx->video_out, VOCTRL_PAUSE, NULL); if (mpctx->ao && mpctx->sh_audio) ao_pause(mpctx->ao); // pause audio, keep data if possible + + mpctx->paused_cache_fill = get_cache_fill(mpctx); + mpctx->status_printed = true; + update_pause_message(mpctx); + + if (!mpctx->opts.quiet) + mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_PAUSED\n"); } void unpause_player(struct MPContext *mpctx) @@ -3024,6 +3045,8 @@ void unpause_player(struct MPContext *mpctx) if (!mpctx->paused) return; mpctx->paused = 0; + if (!mpctx->step_frames) + mpctx->osd_function = OSD_PLAY; if (mpctx->ao && mpctx->sh_audio) ao_resume(mpctx->ao); @@ -3059,21 +3082,9 @@ void add_step_frame(struct MPContext *mpctx) static void pause_loop(struct MPContext *mpctx) { - struct MPOpts *opts = &mpctx->opts; mp_cmd_t *cmd; -#ifdef CONFIG_STREAM_CACHE - int old_cache_fill = stream_cache_size > 0 ? - cache_fill_status(mpctx->stream) : 0; -#endif - if (!opts->quiet) { - if (opts->term_osd && !mpctx->sh_video) { - set_osd_tmsg(OSD_MSG_PAUSE, 1, 0, " ===== PAUSE ====="); - update_osd_msg(mpctx); - } else - mp_msg(MSGT_CPLAYER, MSGL_STATUS, "\n%s\r", - mp_gtext(" ===== PAUSE =====")); - mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_PAUSED\n"); - } + + update_pause_message(mpctx); while ((cmd = mp_input_get_cmd(mpctx->input, 20, 1)) == NULL || cmd->id == MP_CMD_SET_MOUSE_POS || cmd->pausing == 4) { @@ -3090,23 +3101,7 @@ static void pause_loop(struct MPContext *mpctx) vo_osd_changed(hack); if (hack || mpctx->sh_video && mpctx->video_out->want_redraw) break; -#ifdef CONFIG_STREAM_CACHE - if (!opts->quiet && stream_cache_size > 0) { - int new_cache_fill = cache_fill_status(mpctx->stream); - if (new_cache_fill != old_cache_fill) { - if (opts->term_osd && !mpctx->sh_video) { - set_osd_tmsg(OSD_MSG_PAUSE, 1, 0, "%s %d%%", - mp_gtext(" ===== PAUSE ====="), - new_cache_fill); - update_osd_msg(mpctx); - } else - mp_msg(MSGT_CPLAYER, MSGL_STATUS, "%s %d%%\r", - mp_gtext(" ===== PAUSE ====="), - new_cache_fill); - old_cache_fill = new_cache_fill; - } - } -#endif + update_pause_message(mpctx); } } @@ -3991,6 +3986,7 @@ int main(int argc, char *argv[]) .set_of_sub_pos = -1, .file_format = DEMUXER_TYPE_UNKNOWN, .last_dvb_step = 1, + .paused_cache_fill = -1, }; InitTimer(); |