ULONG DeckLinkDevice::Release() { long ret = os_atomic_dec_long(&refCount); if (ret == 0) delete this; return ret; }
void obs_source_deactivate(obs_source_t source, enum view_type type) { if (!source) return; if (os_atomic_dec_long(&source->show_refs) == 0) { hide_source(source); obs_source_enum_tree(source, hide_tree, NULL); } if (type == MAIN_VIEW) { if (os_atomic_dec_long(&source->activate_refs) == 0) { deactivate_source(source); obs_source_enum_tree(source, deactivate_tree, NULL); obs_source_set_present_volume(source, 0.0f); } } }
static void hide_tree(obs_source_t parent, obs_source_t child, void *param) { if (os_atomic_dec_long(&child->show_refs) == 0) hide_source(child); UNUSED_PARAMETER(parent); UNUSED_PARAMETER(param); }
void obs_source_release(obs_source_t source) { if (!source) return; if (os_atomic_dec_long(&source->refs) == 0) obs_source_destroy(source); }
static void apply_scene_item_audio_actions(struct obs_scene_item *item, float **p_buf, uint64_t ts, size_t sample_rate) { bool cur_visible = item->visible; uint64_t frame_num = 0; size_t deref_count = 0; float *buf = NULL; if (p_buf) { if (!*p_buf) *p_buf = malloc(AUDIO_OUTPUT_FRAMES * sizeof(float)); buf = *p_buf; } pthread_mutex_lock(&item->actions_mutex); for (size_t i = 0; i < item->audio_actions.num; i++) { struct item_action action = item->audio_actions.array[i]; uint64_t timestamp = action.timestamp; uint64_t new_frame_num; if (timestamp < ts) timestamp = ts; new_frame_num = (timestamp - ts) * (uint64_t)sample_rate / 1000000000ULL; if (ts && new_frame_num >= AUDIO_OUTPUT_FRAMES) break; da_erase(item->audio_actions, i--); item->visible = action.visible; if (!item->visible) deref_count++; if (buf && new_frame_num > frame_num) { for (; frame_num < new_frame_num; frame_num++) buf[frame_num] = cur_visible ? 1.0f : 0.0f; } cur_visible = item->visible; } if (buf) { for (; frame_num < AUDIO_OUTPUT_FRAMES; frame_num++) buf[frame_num] = cur_visible ? 1.0f : 0.0f; } pthread_mutex_unlock(&item->actions_mutex); while (deref_count--) { if (os_atomic_dec_long(&item->active_refs) == 0) { obs_source_remove_active_child(item->parent->source, item->source); } } }
static void deactivate_tree(obs_source_t parent, obs_source_t child, void *param) { if (os_atomic_dec_long(&child->activate_refs) == 0) deactivate_source(child); UNUSED_PARAMETER(parent); UNUSED_PARAMETER(param); }
ULONG STDMETHODCALLTYPE DeckLinkDeviceInstance::Release(void) { const long newRefCount = os_atomic_dec_long(&refCount); if (newRefCount == 0) { delete this; return 0; } return newRefCount; }
void DeckLinkOutput::Deactivate(void) { std::lock_guard<std::recursive_mutex> lock(deviceMutex); if (instance) instance->StopOutput(); instance = nullptr; os_atomic_dec_long(&activateRefs); }
void gs_leavecontext(void) { if (thread_graphics) { if (!os_atomic_dec_long(&thread_graphics->ref)) { graphics_t graphics = thread_graphics; graphics->exports.device_leavecontext(graphics->device); pthread_mutex_unlock(&graphics->mutex); thread_graphics = NULL; } } }
static inline void handle_ts_jump(obs_source_t source, uint64_t expected, uint64_t ts, uint64_t diff) { blog(LOG_DEBUG, "Timestamp for source '%s' jumped by '%"PRIu64"', " "expected value %"PRIu64", input value %"PRIu64, source->context.name, diff, expected, ts); /* if has video, ignore audio data until reset */ if (source->info.output_flags & OBS_SOURCE_ASYNC) os_atomic_dec_long(&source->av_sync_ref); else reset_audio_timing(source, ts); }
void obs_source_enum_sources(obs_source_t source, obs_source_enum_proc_t enum_callback, void *param) { if (!source || !source->info.enum_sources || source->enum_refs) return; obs_source_addref(source); os_atomic_inc_long(&source->enum_refs); source->info.enum_sources(source->context.data, enum_callback, param); os_atomic_dec_long(&source->enum_refs); obs_source_release(source); }
static void enum_source_tree_callback(obs_source_t parent, obs_source_t child, void *param) { struct source_enum_data *data = param; if (child->info.enum_sources && !child->enum_refs) { os_atomic_inc_long(&child->enum_refs); child->info.enum_sources(child->context.data, enum_source_tree_callback, data); os_atomic_dec_long(&child->enum_refs); } data->enum_callback(parent, child, data->param); }
bool obs_output_actual_start(obs_output_t *output) { bool success = false; output->stopped = false; if (output->context.data) success = output->info.start(output->context.data); if (success && output->video) { output->starting_frame_count = video_output_get_total_frames(output->video); output->starting_skipped_frame_count = video_output_get_skipped_frames(output->video); } if (output->delay_restart_refs) os_atomic_dec_long(&output->delay_restart_refs); return success; }
bool obs_output_actual_start(obs_output_t *output) { bool success = false; os_event_wait(output->stopping_event); output->stop_code = 0; if (output->context.data) success = output->info.start(output->context.data); if (success && output->video) { output->starting_frame_count = video_output_get_total_frames(output->video); output->starting_skipped_frame_count = video_output_get_skipped_frames(output->video); output->starting_drawn_count = obs->video.total_frames; output->starting_lagged_count = obs->video.lagged_frames; } if (os_atomic_load_long(&output->delay_restart_refs)) os_atomic_dec_long(&output->delay_restart_refs); return success; }