Skip to content

Commit

Permalink
libobs: Add obs_save_sources_filtered (skip)
Browse files Browse the repository at this point in the history
(Note: This commit breaks UI compilation.  Skip if bisecting)

Adds a means of saving specific sources that the front-end chooses,
rather than being forced to use the now-removed "user list".
  • Loading branch information
palana authored and jp9000 committed Dec 22, 2015
1 parent 70fec7a commit ec86bda
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
18 changes: 16 additions & 2 deletions libobs/obs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1572,7 +1572,8 @@ obs_data_t *obs_save_source(obs_source_t *source)
return source_data;
}

obs_data_array_t *obs_save_sources(void)
obs_data_array_t *obs_save_sources_filtered(obs_save_source_filter_cb cb,
void *data_)
{
struct obs_core_data *data = &obs->data;
obs_data_array_t *array;
Expand All @@ -1587,7 +1588,8 @@ obs_data_array_t *obs_save_sources(void)
source = data->first_source;

while (source) {
if ((source->info.type == OBS_SOURCE_TYPE_INPUT) != 0) {
if ((source->info.type == OBS_SOURCE_TYPE_INPUT) != 0 &&
cb(data_, source)) {
obs_data_t *source_data = obs_save_source(source);

obs_data_array_push_back(array, source_data);
Expand All @@ -1602,6 +1604,18 @@ obs_data_array_t *obs_save_sources(void)
return array;
}

static bool save_source_filter(void *data, obs_source_t *source)
{
UNUSED_PARAMETER(data);
UNUSED_PARAMETER(source);
return true;
}

obs_data_array_t *obs_save_sources(void)
{
return obs_save_sources_filtered(save_source_filter, NULL);
}

/* ensures that names are never blank */
static inline char *dup_name(const char *name)
{
Expand Down
4 changes: 4 additions & 0 deletions libobs/obs.h
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,10 @@ EXPORT void obs_load_sources(obs_data_array_t *array);
/** Saves sources to a data array */
EXPORT obs_data_array_t *obs_save_sources(void);

typedef bool (*obs_save_source_filter_cb)(void *data, obs_source_t *source);
EXPORT obs_data_array_t *obs_save_sources_filtered(obs_save_source_filter_cb cb,
void *data);


/* ------------------------------------------------------------------------- */
/* View context */
Expand Down

0 comments on commit ec86bda

Please sign in to comment.