diff --git a/libobs/obs-internal.h b/libobs/obs-internal.h index ae7863389..c1a3f2a37 100644 --- a/libobs/obs-internal.h +++ b/libobs/obs-internal.h @@ -215,12 +215,19 @@ void obs_hotkey_name_map_free(void); /* ------------------------------------------------------------------------- */ /* views */ +enum view_type { + INVALID_VIEW, + MAIN_VIEW, + AUX_VIEW, +}; + struct obs_view { pthread_mutex_t channels_mutex; obs_source_t *channels[MAX_CHANNELS]; + enum view_type type; }; -extern bool obs_view_init(struct obs_view *view); +extern bool obs_view_init(struct obs_view *view, enum view_type type); extern void obs_view_free(struct obs_view *view); /* ------------------------------------------------------------------------- */ @@ -911,11 +918,6 @@ extern obs_source_t *obs_source_create_set_last_ver(const char *id, const char * extern void obs_source_destroy(struct obs_source *source); extern void obs_source_addref(obs_source_t *source); -enum view_type { - MAIN_VIEW, - AUX_VIEW, -}; - static inline void obs_source_dosignal(struct obs_source *source, const char *signal_obs, const char *signal_source) { struct calldata data; diff --git a/libobs/obs-view.c b/libobs/obs-view.c index fd97e2636..df91c107f 100644 --- a/libobs/obs-view.c +++ b/libobs/obs-view.c @@ -18,7 +18,7 @@ #include "obs.h" #include "obs-internal.h" -bool obs_view_init(struct obs_view *view) +bool obs_view_init(struct obs_view *view, enum view_type type) { if (!view) return false; @@ -30,6 +30,7 @@ bool obs_view_init(struct obs_view *view) return false; } + view->type = type; return true; } @@ -37,7 +38,7 @@ obs_view_t *obs_view_create(void) { struct obs_view *view = bzalloc(sizeof(struct obs_view)); - if (!obs_view_init(view)) { + if (!obs_view_init(view, AUX_VIEW)) { bfree(view); view = NULL; } @@ -53,7 +54,7 @@ void obs_view_free(struct obs_view *view) for (size_t i = 0; i < MAX_CHANNELS; i++) { struct obs_source *source = view->channels[i]; if (source) { - obs_source_deactivate(source, AUX_VIEW); + obs_source_deactivate(source, view->type); obs_source_release(source); } } @@ -106,10 +107,10 @@ void obs_view_set_source(obs_view_t *view, uint32_t channel, obs_source_t *sourc pthread_mutex_unlock(&view->channels_mutex); if (source) - obs_source_activate(source, AUX_VIEW); + obs_source_activate(source, view->type); if (prev_source) { - obs_source_deactivate(prev_source, AUX_VIEW); + obs_source_deactivate(prev_source, view->type); obs_source_release(prev_source); } }