Commit 4de6117
committed
mp.input: allow specifying which input request to terminate
This commit adds a new argument to the `input.terminate()` function
which allows specifying the specific input request to cancel.
Previosuly, there was no way to guarantee that the input request being
terminated was the one intended; the asynchronous nature of the API
meant that it was always possible (though unlikely) that another client
may have activated its own input request while the termination request
was in transit.
This commit provides a backwards compatible way to terminate specific
requests. Now `input.get` and `input.select` return an opaque id object
which can be optionally passed into `input.terminate()` to specify which
input request should be terminated.
One advantage of this approach is that it is backwards compatible; a
script passing id values will work without issue on older versions of
mpv as `input.terminate()` previously ignored all of its arguments.
The documentation has been updated to show an example of using these id
values and to promote safe handling of async terminations.
This approach is based on the behaviour of `mp.command_native_async` and
`mp.abort_async_command`.1 parent 103df92 commit 4de6117
File tree
5 files changed
+62
-9
lines changed- DOCS/man
- player
- javascript
- lua
5 files changed
+62
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
199 | | - | |
| 199 | + | |
200 | 200 | | |
201 | | - | |
| 201 | + | |
202 | 202 | | |
203 | | - | |
| 203 | + | |
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
975 | 975 | | |
976 | 976 | | |
977 | 977 | | |
978 | | - | |
979 | | - | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
980 | 1007 | | |
981 | 1008 | | |
982 | 1009 | | |
| |||
1027 | 1054 | | |
1028 | 1055 | | |
1029 | 1056 | | |
| 1057 | + | |
| 1058 | + | |
| 1059 | + | |
1030 | 1060 | | |
1031 | 1061 | | |
1032 | 1062 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
684 | 684 | | |
685 | 685 | | |
686 | 686 | | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
687 | 691 | | |
688 | | - | |
689 | | - | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
690 | 697 | | |
691 | 698 | | |
692 | 699 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1663 | 1663 | | |
1664 | 1664 | | |
1665 | 1665 | | |
| 1666 | + | |
| 1667 | + | |
| 1668 | + | |
| 1669 | + | |
| 1670 | + | |
| 1671 | + | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + | |
1666 | 1675 | | |
1667 | 1676 | | |
1668 | 1677 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
64 | 68 | | |
65 | 69 | | |
66 | 70 | | |
67 | 71 | | |
68 | | - | |
69 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
70 | 77 | | |
71 | 78 | | |
72 | 79 | | |
| |||
0 commit comments