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_setint(¶ms, "channel", channel); calldata_setptr(¶ms, "prev_source", prev_source); calldata_setptr(¶ms, "source", source); signal_handler_signal(obs->signals, "channel_change", ¶ms); calldata_getptr(¶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); } }
void obs_set_output_source(uint32_t channel, obs_source_t source) { struct obs_source *prev_source; struct calldata params = {0}; assert(channel < MAX_CHANNELS); prev_source = obs->data.channels[channel]; calldata_setuint32(¶ms, "channel", channel); calldata_setptr(¶ms, "prev_source", prev_source); calldata_setptr(¶ms, "source", source); signal_handler_signal(obs->signals, "channel-change", ¶ms); calldata_getptr(¶ms, "source", &source); calldata_free(¶ms); obs->data.channels[channel] = source; if (source != prev_source) { if (source) obs_source_addref(source); if (prev_source) obs_source_release(prev_source); } }