diff options
Diffstat (limited to 'player/misc.c')
-rw-r--r-- | player/misc.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/player/misc.c b/player/misc.c index 1b265e11fa..f5cbc2f0ce 100644 --- a/player/misc.c +++ b/player/misc.c @@ -15,10 +15,11 @@ * License along with mpv. If not, see <http://www.gnu.org/licenses/>. */ -#include <stddef.h> -#include <stdbool.h> -#include <errno.h> #include <assert.h> +#include <errno.h> +#include <math.h> +#include <stdbool.h> +#include <stddef.h> #include "mpv_talloc.h" @@ -191,17 +192,18 @@ void update_vo_playback_state(struct MPContext *mpctx) { if (mpctx->video_out && mpctx->video_out->config_ok) { struct voctrl_playback_state oldstate = mpctx->vo_playback_state; + double pos = get_current_pos_ratio(mpctx, false); struct voctrl_playback_state newstate = { - .taskbar_progress = mpctx->opts->vo->taskbar_progress, + .taskbar_progress = mpctx->opts->vo->taskbar_progress && pos >= 0, .playing = mpctx->playing, .paused = mpctx->paused, - .percent_pos = get_percent_pos(mpctx), + .position = pos > 0 ? lrint(pos * UINT8_MAX) : 0, }; if (oldstate.taskbar_progress != newstate.taskbar_progress || oldstate.playing != newstate.playing || oldstate.paused != newstate.paused || - oldstate.percent_pos != newstate.percent_pos) + oldstate.position != newstate.position) { // Don't update progress bar if it was and still is hidden if ((oldstate.playing && oldstate.taskbar_progress) || @@ -266,21 +268,23 @@ void error_on_track(struct MPContext *mpctx, struct track *track) int stream_dump(struct MPContext *mpctx, const char *source_filename) { struct MPOpts *opts = mpctx->opts; + bool ok = false; + stream_t *stream = stream_create(source_filename, STREAM_ORIGIN_DIRECT | STREAM_READ, mpctx->playback_abort, mpctx->global); - if (!stream) - return -1; + if (!stream || stream->is_directory) + goto done; int64_t size = stream_get_size(stream); FILE *dest = fopen(opts->stream_dump, "wb"); if (!dest) { MP_ERR(mpctx, "Error opening dump file: %s\n", mp_strerror(errno)); - return -1; + goto done; } - bool ok = true; + ok = true; while (mpctx->stop_play == KEEP_PLAYING && ok) { if (!opts->quiet && ((stream->pos / (1024 * 1024)) % 2) == 1) { @@ -300,6 +304,7 @@ int stream_dump(struct MPContext *mpctx, const char *source_filename) } ok &= fclose(dest) == 0; +done: free_stream(stream); return ok ? 0 : -1; } |