void obs_view_set_source(obs_view_t *view, uint32_t channel, obs_source_t *source) { struct obs_source *prev_source; assert(channel < MAX_CHANNELS); if (!view) return; if (channel >= MAX_CHANNELS) return; pthread_mutex_lock(&view->channels_mutex); obs_source_addref(source); prev_source = view->channels[channel]; view->channels[channel] = source; pthread_mutex_unlock(&view->channels_mutex); if (source) obs_source_activate(source, AUX_VIEW); if (prev_source) { obs_source_deactivate(prev_source, AUX_VIEW); obs_source_release(prev_source); } }
void obs_source_remove_child(obs_source_t parent, obs_source_t child) { if (!parent || !child) return; for (int i = 0; i < parent->show_refs; i++) { enum view_type type; type = (i < parent->activate_refs) ? MAIN_VIEW : AUX_VIEW; obs_source_deactivate(child, type); } }
void obs_view_free(struct obs_view *view) { if (!view) return; 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_release(source); } } memset(view->channels, 0, sizeof(view->channels)); pthread_mutex_destroy(&view->channels_mutex); }
void obs_set_output_source(uint32_t channel, obs_source_t *source) { assert(channel < MAX_CHANNELS); if (!obs) return; if (channel >= MAX_CHANNELS) return; struct obs_source *prev_source; struct obs_view *view = &obs->data.main_view; struct calldata params = {0}; pthread_mutex_lock(&view->channels_mutex); obs_source_addref(source); prev_source = view->channels[channel]; calldata_set_int(¶ms, "channel", channel); calldata_set_ptr(¶ms, "prev_source", prev_source); calldata_set_ptr(¶ms, "source", source); signal_handler_signal(obs->signals, "channel_change", ¶ms); calldata_get_ptr(¶ms, "source", &source); calldata_free(¶ms); view->channels[channel] = source; pthread_mutex_unlock(&view->channels_mutex); if (source) obs_source_activate(source, MAIN_VIEW); if (prev_source) { obs_source_deactivate(prev_source, MAIN_VIEW); obs_source_release(prev_source); } }