summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/tech/slave.txt1
-rw-r--r--command.c37
-rw-r--r--m_config.c4
-rw-r--r--m_option.h6
4 files changed, 46 insertions, 2 deletions
diff --git a/DOCS/tech/slave.txt b/DOCS/tech/slave.txt
index e923232689..be0ebf9937 100644
--- a/DOCS/tech/slave.txt
+++ b/DOCS/tech/slave.txt
@@ -513,6 +513,7 @@ name type min max get set step comment
osdlevel int 0 3 X X X as -osdlevel
speed float 0.01 100 X X X as -speed
loop int -1 X X X as -loop
+pts_association_mode string X X X as -pts-association-mode
pause flag 0 1 X 1 if paused, use with pausing_keep_force
filename string X file playing wo path
path string X file playing
diff --git a/command.c b/command.c
index 489cd2d047..247af1b9d1 100644
--- a/command.c
+++ b/command.c
@@ -34,6 +34,7 @@
#include "libvo/sub.h"
#include "m_option.h"
#include "m_property.h"
+#include "m_config.h"
#include "metadata.h"
#include "libmpcodecs/vf.h"
#include "libmpcodecs/vd.h"
@@ -226,6 +227,39 @@ static void log_sub(struct MPContext *mpctx)
/// \ingroup Properties
///@{
+static int mp_property_generic_option(struct m_option *prop, int action,
+ void *arg, MPContext *mpctx)
+{
+ char *optname = prop->priv;
+ const struct m_option *opt = m_config_get_option(mpctx->mconfig, optname);
+ void *valptr = m_option_get_ptr(opt, &mpctx->opts);
+
+ switch (action) {
+ case M_PROPERTY_GET_TYPE:
+ *(const struct m_option **)arg = opt;
+ return M_PROPERTY_OK;
+ case M_PROPERTY_GET:
+ m_option_copy(opt, arg, valptr);
+ return M_PROPERTY_OK;
+ case M_PROPERTY_SET:
+ m_option_copy(opt, valptr, arg);
+ return M_PROPERTY_OK;
+ case M_PROPERTY_STEP_UP:
+ if (opt->type == &m_option_type_choice) {
+ int v = *(int *) valptr;
+ int best = v;
+ struct m_opt_choice_alternatives *alt;
+ for (alt = opt->priv; alt->name; alt++)
+ if ((unsigned) alt->value - v - 1 < (unsigned) best - v - 1)
+ best = alt->value;
+ *(int *) valptr = best;
+ return M_PROPERTY_OK;
+ }
+ break;
+ }
+ return M_PROPERTY_NOT_IMPLEMENTED;
+}
+
/// OSD level (RW)
static int mp_property_osdlevel(m_option_t *prop, int action, void *arg,
MPContext *mpctx)
@@ -2189,6 +2223,8 @@ static const m_option_t mp_properties[] = {
M_OPT_RANGE, 0, 1, NULL },
{ "capturing", mp_property_capture, CONF_TYPE_FLAG,
M_OPT_RANGE, 0, 1, NULL },
+ { "pts_association_mode", mp_property_generic_option, &m_option_type_choice,
+ 0, 0, 0, "pts-association-mode" },
// Audio
{ "volume", mp_property_volume, CONF_TYPE_FLOAT,
@@ -2362,6 +2398,7 @@ static struct property_osd_display {
{ "loop", 0, -1, _("Loop: %s") },
{ "chapter", -1, -1, NULL },
{ "capturing", 0, -1, _("Capturing: %s") },
+ { "pts_association_mode", 0, -1, "PTS association mode: %s" },
// audio
{ "volume", OSD_VOLUME, -1, _("Volume") },
{ "mute", 0, -1, _("Mute: %s") },
diff --git a/m_config.c b/m_config.c
index 266ee10323..2752ced85f 100644
--- a/m_config.c
+++ b/m_config.c
@@ -150,7 +150,7 @@ static void m_option_save(const m_config_t *config, const m_option_t *opt,
void *dst)
{
if (opt->type->save) {
- const void *src = opt->new ? (char*)config->optstruct + opt->offset : opt->p;
+ const void *src = m_option_get_ptr(opt, config->optstruct);
opt->type->save(opt, dst, src);
}
}
@@ -159,7 +159,7 @@ static void m_option_set(const m_config_t *config, const m_option_t *opt,
const void *src)
{
if (opt->type->set) {
- void *dst = opt->new ? (char*)config->optstruct + opt->offset : opt->p;
+ void *dst = m_option_get_ptr(opt, config->optstruct);
opt->type->set(opt, dst, src);
}
}
diff --git a/m_option.h b/m_option.h
index ed2b30de75..05d5751ceb 100644
--- a/m_option.h
+++ b/m_option.h
@@ -493,6 +493,12 @@ struct m_option {
*/
const m_option_t* m_option_list_find(const m_option_t* list,const char* name);
+static inline void *m_option_get_ptr(const struct m_option *opt,
+ void *optstruct)
+{
+ return opt->new ? (char *) optstruct + opt->offset : opt->p;
+}
+
/// Helper to parse options, see \ref m_option_type::parse.
inline static int
m_option_parse(const m_option_t* opt,const char *name, const char *param, void* dst, int src) {