sACN  HEAD (unstable)
Implementation of ANSI E1.31 (Streaming ACN)
View other versions:
Loading...
Searching...
No Matches
Global Initialization and Destruction

The sACN library has overall init and deinit functions that should be called once each at application startup and shutdown time. These functions interface with the EtcPal log (Logging) API to configure what happens when the sACN library logs messages. Optionally pass an EtcPalLogParams structure to use this functionality. This structure can be shared across different ETC library modules.

// During startup:
// Initialize log_params...
sacn_init(&log_params, NULL);
// Or, to init without worrying about logs from the sACN library...
sacn_init(NULL, NULL);
// During shutdown:
#define ETCPAL_LOG_PARAMS_INIT
etcpal_error_t sacn_init(const EtcPalLogParams *log_params, const SacnNetintConfig *sys_netint_config)
Initialize all features of the sACN library.
Definition common.c:75
void sacn_deinit(void)
Deinitialize all features of the sACN library.
Definition common.c:479

// During startup:
// Initialize logger...
sacn::Init(logger);
// Or, to init without worrying about logs from the sACN library...
// During shutdown:
etcpal::Error Init(sacn_features_t features=SACN_FEATURES_ALL, const LibrarySettings &settings={})
Initialize the sACN library.
Definition common.h:183
void Deinit(sacn_features_t features=SACN_FEATURES_ALL)
Deinitialize features of the sACN library.
Definition common.h:438

Individual features can also be initialized separately. The rest can then be initialized separately, since redundant initialization is handled to allow cases such as the following:

// Later on, initialize everything else
sacn_init(NULL, NULL);
// During shutdown (redundant init tracking keeps DMX merger alive):
// Then clean up DMX merger
void sacn_deinit_features(sacn_features_t features)
Deinitialize specific features of the sACN library.
Definition common.c:496
#define SACN_FEATURE_DMX_MERGER
Use the sacn/dmx_merger module.
Definition common.h:205
etcpal_error_t sacn_init_features(const EtcPalLogParams *log_params, const SacnNetintConfig *sys_netint_config, sacn_features_t features)
Initialize specific features of the sACN library.
Definition common.c:124

// Later on, initialize everything else
// During shutdown (redundant init tracking keeps DMX merger alive):
// Then clean up DMX merger

You could also flip the init or deinit calls - order doesn't matter here (beyond calling init before deinit of course).