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 17d91b9d4d.
This commit is contained in:
Christoph Heinrich 2023-02-26 17:28:50 +01:00 committed by sfan5
parent a265da9f25
commit c5265381b5
2 changed files with 3 additions and 1 deletions

View File

@ -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_;

View File

@ -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 },