[vlc-devel] [PATCH 03/14] input: name input event structs
Romain Vimont
rom1v at videolabs.io
Thu Aug 16 16:02:00 CEST 2018
Some input event structs contain enums, whose values can be accessed
globally in C, but need a qualified access in C++. Since these enums are
defined inside unamed union and structs, there was no way to use them
from C++ code.
To avoid the problem, declare named structs for every event type
requiring more than one field.
---
include/vlc_input.h | 102 +++++++++++++++++++++++++-------------------
1 file changed, 58 insertions(+), 44 deletions(-)
diff --git a/include/vlc_input.h b/include/vlc_input.h
index 1e47b96772..396449e755 100644
--- a/include/vlc_input.h
+++ b/include/vlc_input.h
@@ -397,6 +397,58 @@ typedef enum input_event_type_e
#define VLC_INPUT_CAPABILITIES_REWINDABLE (1<<3)
#define VLC_INPUT_CAPABILITIES_RECORDABLE (1<<4)
+struct vlc_input_event_position
+{
+ float percentage;
+ vlc_tick_t ms;
+};
+
+struct vlc_input_event_chapter
+{
+ int title;
+ int seekpoint;
+};
+
+struct vlc_input_event_program {
+ enum {
+ VLC_INPUT_PROGRAM_ADDED,
+ VLC_INPUT_PROGRAM_DELETED,
+ VLC_INPUT_PROGRAM_SELECTED,
+ VLC_INPUT_PROGRAM_SCRAMBLED,
+ } action;
+ int id;
+ union {
+ const char *title;
+ bool scrambled;
+ };
+};
+
+struct vlc_input_event_es {
+ enum {
+ VLC_INPUT_ES_ADDED,
+ VLC_INPUT_ES_DELETED,
+ VLC_INPUT_ES_SELECTED,
+ } action;
+ enum es_format_category_e cat;
+ int id; /**< id == -1 will unselect */
+ const char *title;
+};
+
+struct vlc_input_event_teletext {
+ enum {
+ VLC_INPUT_TELETEXT_ADDED,
+ VLC_INPUT_TELETEXT_DELETED,
+ VLC_INPUT_TELETEXT_SELECTED,
+ } action;
+ int id; /**< id == -1 will unselect */
+ const char *title;
+};
+
+struct vlc_input_event_signal {
+ float quality;
+ float strength;
+};
+
struct vlc_input_event
{
input_event_type_e type;
@@ -409,61 +461,23 @@ struct vlc_input_event
/* INPUT_EVENT_CAPABILITIES */
int capabilities; /**< cf. VLC_INPUT_CAPABILITIES_* bitwise flags */
/* INPUT_EVENT_POSITION */
- struct {
- float percentage;
- vlc_tick_t ms;
- } position;
+ struct vlc_input_event_position position;
/* INPUT_EVENT_LENGTH */
vlc_tick_t length;
/* INPUT_EVENT_TITLE */
int title;
/* INPUT_EVENT_CHAPTER */
- struct {
- int title;
- int seekpoint;
- } chapter;
+ struct vlc_input_event_chapter chapter;
/* INPUT_EVENT_PROGRAM */
- struct {
- enum {
- VLC_INPUT_PROGRAM_ADDED,
- VLC_INPUT_PROGRAM_DELETED,
- VLC_INPUT_PROGRAM_SELECTED,
- VLC_INPUT_PROGRAM_SCRAMBLED,
- } action;
- int id;
- union {
- const char *title;
- bool scrambled;
- };
- } program;
+ struct vlc_input_event_program program;
/* INPUT_EVENT_ES */
- struct {
- enum {
- VLC_INPUT_ES_ADDED,
- VLC_INPUT_ES_DELETED,
- VLC_INPUT_ES_SELECTED,
- } action;
- enum es_format_category_e cat;
- int id; /**< id == -1 will unselect */
- const char *title;
- } es;
+ struct vlc_input_event_es es;
/* INPUT_EVENT_TELETEXT */
- struct {
- enum {
- VLC_INPUT_TELETEXT_ADDED,
- VLC_INPUT_TELETEXT_DELETED,
- VLC_INPUT_TELETEXT_SELECTED,
- } action;
- int id; /**< id == -1 will unselect */
- const char *title;
- } teletext;
+ struct vlc_input_event_teletext teletext;
/* INPUT_EVENT_RECORD */
bool record;
/* INPUT_EVENT_SIGNAL */
- struct {
- float quality;
- float strength;
- } signal;
+ struct vlc_input_event_signal signal;
/* INPUT_EVENT_AUDIO_DELAY */
vlc_tick_t audio_delay;
/* INPUT_EVENT_SUBTITLE_DELAY */
--
2.18.0
More information about the vlc-devel
mailing list