diff options
author | Christoph Heinrich <christoph.heinrich@student.tugraz.at> | 2023-02-26 17:28:50 +0100 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2023-02-27 11:21:49 +0100 |
commit | c5265381b555766a9d1f931c5371b987292ee41a (patch) | |
tree | f7802abfcb18a8d605e1e5ef9ca9c6ac544a0a5b | |
parent | a265da9f25ed613212a00b8143a9b6f76d341440 (diff) | |
download | mpv-c5265381b555766a9d1f931c5371b987292ee41a.tar.bz2 mpv-c5265381b555766a9d1f931c5371b987292ee41a.tar.xz |
client API: reintroduce CONF_TYPE_FLAG for type conversion
Changing the CONF_TYPE_FLAG was a bad idea because mpv_node.u.flag
continues to be an int, leading to a mismatch in type sizes which can
lead to problems with memcpy().
ref. #11373
This partially reverts commit 17d91b9d4d2d208f4a847395198cdbbcad18de93.
-rw-r--r-- | options/m_option.h | 2 | ||||
-rw-r--r-- | player/client.c | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/options/m_option.h b/options/m_option.h index f179c75494..bcdc1f9fcc 100644 --- a/options/m_option.h +++ b/options/m_option.h @@ -213,6 +213,7 @@ struct m_sub_options { }; #define CONF_TYPE_BOOL (&m_option_type_bool) +#define CONF_TYPE_FLAG (&m_option_type_flag) #define CONF_TYPE_INT (&m_option_type_int) #define CONF_TYPE_INT64 (&m_option_type_int64) #define CONF_TYPE_FLOAT (&m_option_type_float) @@ -232,6 +233,7 @@ struct m_sub_options { // size/alignment requirements for option values in general. union m_option_value { bool bool_; + int flag; // not the C type "bool"! int int_; int64_t int64; float float_; diff --git a/player/client.c b/player/client.c index cf2483b4c2..9b4c83b861 100644 --- a/player/client.c +++ b/player/client.c @@ -970,7 +970,7 @@ void mpv_wakeup(mpv_handle *ctx) // map client API types to internal types static const struct m_option type_conv[] = { [MPV_FORMAT_STRING] = { .type = CONF_TYPE_STRING }, - [MPV_FORMAT_FLAG] = { .type = CONF_TYPE_BOOL }, + [MPV_FORMAT_FLAG] = { .type = CONF_TYPE_FLAG }, [MPV_FORMAT_INT64] = { .type = CONF_TYPE_INT64 }, [MPV_FORMAT_DOUBLE] = { .type = CONF_TYPE_DOUBLE }, [MPV_FORMAT_NODE] = { .type = CONF_TYPE_NODE }, |