summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvi Halachmi (:avih) <avihpit@yahoo.com>2021-05-01 15:26:50 +0300
committerAvi Halachmi (:avih) <avihpit@yahoo.com>2021-05-01 16:07:04 +0300
commitf3b2ea9de533ac3ee0ebdaaf6411c97212f5a86b (patch)
treed3111c0fb7a74af78a3a73a93aad63e2c1fa40d9
parent7df9ebda6c9828b75b814facd4267c8da0eca736 (diff)
downloadmpv-f3b2ea9de533ac3ee0ebdaaf6411c97212f5a86b.tar.bz2
mpv-f3b2ea9de533ac3ee0ebdaaf6411c97212f5a86b.tar.xz
command: new property: pid (process id)
Fixes #7562
-rw-r--r--DOCS/man/input.rst3
-rw-r--r--player/command.c9
2 files changed, 12 insertions, 0 deletions
diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst
index 25f52e3c10..6d396e12e2 100644
--- a/DOCS/man/input.rst
+++ b/DOCS/man/input.rst
@@ -1821,6 +1821,9 @@ Property list
.. note:: This is only an estimate. (It's computed from two unreliable
quantities: fps and possibly rounded timestamps.)
+``pid``
+ Process-id of mpv.
+
``path``
Full path of the currently played file. Usually this is exactly the same
string you pass on the mpv command line or the ``loadfile`` command, even
diff --git a/player/command.c b/player/command.c
index 12a5f75282..d1cd1c7010 100644
--- a/player/command.c
+++ b/player/command.c
@@ -54,6 +54,7 @@
#include "options/m_option.h"
#include "options/m_property.h"
#include "options/m_config_frontend.h"
+#include "osdep/getpid.h"
#include "video/out/vo.h"
#include "video/csputils.h"
#include "video/hwdec.h"
@@ -426,6 +427,13 @@ static int mp_property_display_sync_active(void *ctx, struct m_property *prop,
return m_property_flag_ro(action, arg, mpctx->display_sync_active);
}
+static int mp_property_pid(void *ctx, struct m_property *prop,
+ int action, void *arg)
+{
+ // 32 bit on linux/windows - which C99 `int' is not guaranteed to hold
+ return m_property_int64_ro(action, arg, mp_getpid());
+}
+
/// filename with path (RO)
static int mp_property_path(void *ctx, struct m_property *prop,
int action, void *arg)
@@ -3500,6 +3508,7 @@ static int mp_property_script_props(void *ctx, struct m_property *prop,
// Base list of properties. This does not include option-mapped properties.
static const struct m_property mp_properties_base[] = {
// General
+ {"pid", mp_property_pid},
{"speed", mp_property_playback_speed},
{"audio-speed-correction", mp_property_av_speed_correction, .priv = "a"},
{"video-speed-correction", mp_property_av_speed_correction, .priv = "v"},