+ sd_event_source *evtSource;
+ int err;
+
+ /* Read and parse XML file */
+ ucsContext.ucsConfig = ParseFile(filename);
+ if (NULL == ucsContext.ucsConfig) {
+ AFB_ERROR ("Cannot access or load file: '%s'", filename);
+ goto OnErrorExit;
+ }
+
+ /* When ucsContextS is set, do not initalize UNICENS, CDEVs or system hooks, just load new XML */
+ if (!ucsContextS)
+ {
+ if (!ucsContextS && !InitializeCdevs(&ucsContext)) {
+ AFB_ERROR ("Fail to initialise device [rx=%s tx=%s]", CONTROL_CDEV_RX, CONTROL_CDEV_TX);
+ goto OnErrorExit;
+ }
+
+ /* Initialise UNICENS Config Data Structure */
+ UCSI_Init(&ucsContext.ucsiData, &ucsContext);
+
+ /* register aplayHandle file fd into binder mainloop */
+ err = sd_event_add_io(afb_daemon_get_event_loop(), &evtSource, ucsContext.rx.fileHandle, EPOLLIN, onReadCB, &ucsContext);
+ if (err < 0) {
+ AFB_ERROR ("Cannot hook events to mainloop");
+ goto OnErrorExit;
+ }
+
+ /* save this in a statical variable until ucs2vol move to C */
+ ucsContextS = &ucsContext;
+ }
+ /* Initialise UNICENS with parsed config */
+ if (!UCSI_NewConfig(&ucsContext.ucsiData, ucsContext.ucsConfig)) {
+ AFB_ERROR ("Fail to initialize UNICENS");
+ goto OnErrorExit;
+ }