mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-07-14 23:34:08 +00:00
libobs: Add ability to create private services
This is a band-aid solution to be able to create temporary services without logging them and keep them out of enumeration functions. This is a band-aid solution -- 'master obs context lists' should not be kept by the core. Logging of object creation/destruction should also be controlled by the front-end instead of the core.
This commit is contained in:
parent
8af2c168cf
commit
5920778572
|
@ -33,8 +33,9 @@ const char *obs_service_get_display_name(const char *id)
|
|||
return (info != NULL) ? info->get_name(info->type_data) : NULL;
|
||||
}
|
||||
|
||||
obs_service_t *obs_service_create(const char *id, const char *name,
|
||||
obs_data_t *settings, obs_data_t *hotkey_data)
|
||||
static obs_service_t *obs_service_create_internal(const char *id,
|
||||
const char *name, obs_data_t *settings, obs_data_t *hotkey_data,
|
||||
bool private)
|
||||
{
|
||||
const struct obs_service_info *info = find_service(id);
|
||||
struct obs_service *service;
|
||||
|
@ -47,7 +48,7 @@ obs_service_t *obs_service_create(const char *id, const char *name,
|
|||
service = bzalloc(sizeof(struct obs_service));
|
||||
|
||||
if (!obs_context_data_init(&service->context, OBS_OBJ_TYPE_SERVICE,
|
||||
settings, name, hotkey_data, false)) {
|
||||
settings, name, hotkey_data, private)) {
|
||||
bfree(service);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -74,10 +75,24 @@ obs_service_t *obs_service_create(const char *id, const char *name,
|
|||
&obs->data.services_mutex,
|
||||
&obs->data.first_service);
|
||||
|
||||
blog(LOG_INFO, "service '%s' (%s) created", name, id);
|
||||
blog(private ? LOG_DEBUG : LOG_INFO, "service '%s' (%s) created",
|
||||
name, id);
|
||||
return service;
|
||||
}
|
||||
|
||||
obs_service_t *obs_service_create(const char *id,
|
||||
const char *name, obs_data_t *settings, obs_data_t *hotkey_data)
|
||||
{
|
||||
return obs_service_create_internal(id, name, settings, hotkey_data,
|
||||
false);
|
||||
}
|
||||
|
||||
obs_service_t *obs_service_create_private(const char *id,
|
||||
const char *name, obs_data_t *settings)
|
||||
{
|
||||
return obs_service_create_internal(id, name, settings, NULL, true);
|
||||
}
|
||||
|
||||
static void actually_destroy_service(struct obs_service *service)
|
||||
{
|
||||
if (service->context.data)
|
||||
|
@ -86,7 +101,8 @@ static void actually_destroy_service(struct obs_service *service)
|
|||
if (service->output)
|
||||
service->output->service = NULL;
|
||||
|
||||
blog(LOG_INFO, "service '%s' destroyed", service->context.name);
|
||||
blog(service->context.private ? LOG_DEBUG : LOG_INFO,
|
||||
"service '%s' destroyed", service->context.name);
|
||||
|
||||
obs_context_data_free(&service->context);
|
||||
if (service->owns_info_id)
|
||||
|
|
|
@ -1648,6 +1648,9 @@ EXPORT const char *obs_service_get_display_name(const char *id);
|
|||
EXPORT obs_service_t *obs_service_create(const char *id, const char *name,
|
||||
obs_data_t *settings, obs_data_t *hotkey_data);
|
||||
|
||||
EXPORT obs_service_t *obs_service_create_private(const char *id,
|
||||
const char *name, obs_data_t *settings);
|
||||
|
||||
/**
|
||||
* Adds/releases a reference to a service. When the last reference is
|
||||
* released, the service is destroyed.
|
||||
|
|
Loading…
Reference in a new issue