diff --git a/driver.h b/driver.h index b215953f5a..98fb7f6a83 100644 --- a/driver.h +++ b/driver.h @@ -191,7 +191,6 @@ enum typedef struct driver { - const ui_companion_driver_t *ui_companion; const camera_driver_t *camera; const location_driver_t *location; const record_driver_t *recording; @@ -203,7 +202,6 @@ typedef struct driver void *location_data; void *recording_data; void *netplay_data; - void *ui_companion_data; bool camera_active; bool location_active; diff --git a/frontend/frontend.c b/frontend/frontend.c index 23e57dbb32..f468b1d84c 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -74,6 +74,7 @@ void main_exit(void *args) frontend_driver_shutdown(false); driver_free(); + ui_companion_driver_free(); frontend_driver_free(); } diff --git a/ui/ui_companion_driver.c b/ui/ui_companion_driver.c index 274e3183b3..395072f1b5 100644 --- a/ui/ui_companion_driver.c +++ b/ui/ui_companion_driver.c @@ -24,7 +24,6 @@ #include "../config.h" #endif -static bool main_ui_companion_is_on_foreground; static const ui_companion_driver_t *ui_companion_drivers[] = { #if defined(_WIN32) && !defined(_XBOX) @@ -43,6 +42,10 @@ static const ui_companion_driver_t *ui_companion_drivers[] = { NULL }; +static bool main_ui_companion_is_on_foreground; +static const ui_companion_driver_t *ui_companion; +static void *ui_companion_data; + /** * ui_companion_find_driver: * @ident : Identifier name of driver to find. @@ -93,71 +96,68 @@ const ui_companion_driver_t *ui_companion_init_first(void) const ui_companion_driver_t *ui_companion_get_ptr(void) { - driver_t *driver = driver_get_ptr(); - if (!driver) - return NULL; - return driver->ui_companion; + return ui_companion; } void ui_companion_event_command(enum event_command action) { - driver_t *driver = driver_get_ptr(); const ui_companion_driver_t *ui = ui_companion_get_ptr(); - if (driver && ui && ui->event_command) - ui->event_command(driver->ui_companion_data, action); + if (ui && ui->event_command) + ui->event_command(ui_companion_data, action); } void ui_companion_driver_deinit(void) { - driver_t *driver = driver_get_ptr(); const ui_companion_driver_t *ui = ui_companion_get_ptr(); if (!ui) return; if (ui->deinit) - ui->deinit(driver->ui_companion_data); + ui->deinit(ui_companion_data); + ui_companion_data = NULL; } void ui_companion_driver_init_first(void) { settings_t *settings = config_get_ptr(); - driver_t *driver = driver_get_ptr(); - if (driver) - driver->ui_companion = (ui_companion_driver_t*)ui_companion_init_first(); - if (driver->ui_companion && driver->ui_companion->toggle) + ui_companion = (ui_companion_driver_t*)ui_companion_init_first(); + + if (ui_companion && ui_companion->toggle) { if (settings->ui.companion_start_on_boot) - driver->ui_companion->toggle(driver->ui_companion_data); + ui_companion->toggle(ui_companion_data); } } void ui_companion_driver_notify_refresh(void) { - driver_t *driver = driver_get_ptr(); const ui_companion_driver_t *ui = ui_companion_get_ptr(); if (!ui) return; if (ui->notify_refresh) - ui->notify_refresh(driver->ui_companion_data); + ui->notify_refresh(ui_companion_data); } void ui_companion_driver_notify_list_loaded(file_list_t *list, file_list_t *menu_list) { - driver_t *driver = driver_get_ptr(); const ui_companion_driver_t *ui = ui_companion_get_ptr(); if (!ui) return; if (ui->notify_list_loaded) - ui->notify_list_loaded(driver->ui_companion_data, list, menu_list); + ui->notify_list_loaded(ui_companion_data, list, menu_list); } void ui_companion_driver_notify_content_loaded(void) { - driver_t *driver = driver_get_ptr(); const ui_companion_driver_t *ui = ui_companion_get_ptr(); if (!ui) return; if (ui->notify_content_loaded) - ui->notify_content_loaded(driver->ui_companion_data); + ui->notify_content_loaded(ui_companion_data); +} + +void ui_companion_driver_free(void) +{ + ui_companion = NULL; } diff --git a/ui/ui_companion_driver.h b/ui/ui_companion_driver.h index 7d49689a4f..127ffd0377 100644 --- a/ui/ui_companion_driver.h +++ b/ui/ui_companion_driver.h @@ -90,6 +90,8 @@ void ui_companion_driver_notify_list_loaded(file_list_t *list, file_list_t *menu void ui_companion_driver_notify_content_loaded(void); +void ui_companion_driver_free(void); + #ifdef __cplusplus } #endif