History

win32: quantize taskbar playback position into uint8 range

Also, if the position is valid, set it to 1 / INF. Windows interprets 0 as non-progress. Progress is quantized into uint8 range, it is good enough for this use-case. This avoids unnecessary vo_control and ITaskbarList3::SetProgressValue calls and should be visually indistinguishable in practice. Fixes #14282

Kacper Michajłow committed 2 years ago

Commit 37127271 parent d3b251b3 files · +17 −8Browse files

Unified · Split

3 files
  1. player/misc.c +8 −6
  2. video/out/vo.h +1 −1
  3. video/out/w32_common.c +8 −1
player/misc.c+8−6
@@ -15,10 +15,11 @@ · 14 unmodified lines
15 * License along with mpv. If not, see <http://www.gnu.org/licenses/>.15 * License along with mpv. If not, see <http://www.gnu.org/licenses/>.
16 */16 */
17 17
18#include <stddef.h>
19#include <stdbool.h>
20#include <errno.h>
21#include <assert.h>18#include <assert.h>
19#include <errno.h>
20#include <math.h>
21#include <stdbool.h>
22#include <stddef.h>
22 23
23#include "mpv_talloc.h"24#include "mpv_talloc.h"
24 25
@@ -191,17 +192,18 @@ void update_vo_playback_state(struct MPContext *mpctx) · 166 unmodified lines
191{192{
192 if (mpctx->video_out && mpctx->video_out->config_ok) {193 if (mpctx->video_out && mpctx->video_out->config_ok) {
193 struct voctrl_playback_state oldstate = mpctx->vo_playback_state;194 struct voctrl_playback_state oldstate = mpctx->vo_playback_state;
195 double pos = get_current_pos_ratio(mpctx, false);
194 struct voctrl_playback_state newstate = {196 struct voctrl_playback_state newstate = {
195 .taskbar_progress = mpctx->opts->vo->taskbar_progress,197 .taskbar_progress = mpctx->opts->vo->taskbar_progress && pos >= 0,
196 .playing = mpctx->playing,198 .playing = mpctx->playing,
197 .paused = mpctx->paused,199 .paused = mpctx->paused,
198 .percent_pos = get_percent_pos(mpctx),200 .position = pos > 0 ? lrint(pos * UINT8_MAX) : 0,
199 };201 };
200 202
201 if (oldstate.taskbar_progress != newstate.taskbar_progress ||203 if (oldstate.taskbar_progress != newstate.taskbar_progress ||
202 oldstate.playing != newstate.playing ||204 oldstate.playing != newstate.playing ||
203 oldstate.paused != newstate.paused ||205 oldstate.paused != newstate.paused ||
204 oldstate.percent_pos != newstate.percent_pos)206 oldstate.position != newstate.position)
205 {207 {
206 // Don't update progress bar if it was and still is hidden208 // Don't update progress bar if it was and still is hidden
207 if ((oldstate.playing && oldstate.taskbar_progress) ||209 if ((oldstate.playing && oldstate.taskbar_progress) ||
video/out/vo.h+1−1
@@ -149,7 +149,7 @@ struct voctrl_playback_state { · 148 unmodified lines
149 bool taskbar_progress;149 bool taskbar_progress;
150 bool playing;150 bool playing;
151 bool paused;151 bool paused;
152 int percent_pos;152 uint8_t position;
153};153};
154 154
155// VOCTRL_PERFORMANCE_DATA155// VOCTRL_PERFORMANCE_DATA
video/out/w32_common.c+8−1
@@ -767,8 +767,15 @@ static void update_playback_state(struct vo_w32_state *w32) · 766 unmodified lines
767 return;767 return;
768 }768 }
769 769
770 ULONGLONG completed = pstate->position;
771 ULONGLONG total = UINT8_MAX;
772 if (!pstate->position) {
773 completed = 1;
774 total = MAXULONGLONG;
775 }
776
770 ITaskbarList3_SetProgressValue(w32->taskbar_list3, w32->window,777 ITaskbarList3_SetProgressValue(w32->taskbar_list3, w32->window,
771 pstate->percent_pos, 100);778 completed, total);
772 ITaskbarList3_SetProgressState(w32->taskbar_list3, w32->window,779 ITaskbarList3_SetProgressState(w32->taskbar_list3, w32->window,
773 pstate->paused ? TBPF_PAUSED :780 pstate->paused ? TBPF_PAUSED :
774 TBPF_NORMAL);781 TBPF_NORMAL);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t