Пример #1
0
static void obs_source_destroy(obs_source_t source)
{
	size_t i;

	if (source->filter_parent)
		obs_source_filter_remove(source->filter_parent, source);

	for (i = 0; i < source->filters.num; i++)
		obs_source_release(source->filters.array[i]);

	for (i = 0; i < source->audio_wait_buffer.num; i++)
		audiobuf_free(source->audio_wait_buffer.array+i);
	for (i = 0; i < source->video_frames.num; i++)
		source_frame_destroy(source->video_frames.array[i]);

	gs_entercontext(obs->video.graphics);
	texture_destroy(source->output_texture);
	gs_leavecontext();

	if (source->data)
		source->callbacks.destroy(source->data);

	bfree(source->audio_data.data);
	audio_line_destroy(source->audio_line);
	audio_resampler_destroy(source->resampler);

	da_free(source->video_frames);
	da_free(source->audio_wait_buffer);
	da_free(source->filters);
	pthread_mutex_destroy(&source->filter_mutex);
	pthread_mutex_destroy(&source->audio_mutex);
	pthread_mutex_destroy(&source->video_mutex);
	dstr_free(&source->settings);
	bfree(source);
}
Пример #2
0
void gs_vertexbuffer_destroy(gs_vertbuffer_t *vb)
{
    if (vb) {
        if (vb->vertex_buffer)
            gl_delete_buffers(1, &vb->vertex_buffer);
        if (vb->normal_buffer)
            gl_delete_buffers(1, &vb->normal_buffer);
        if (vb->tangent_buffer)
            gl_delete_buffers(1, &vb->tangent_buffer);
        if (vb->color_buffer)
            gl_delete_buffers(1, &vb->color_buffer);
        if (vb->uv_buffers.num)
            gl_delete_buffers((GLsizei)vb->uv_buffers.num,
                              vb->uv_buffers.array);

        if (vb->vao)
            gl_delete_vertex_arrays(1, &vb->vao);

        da_free(vb->uv_sizes);
        da_free(vb->uv_buffers);
        gs_vbdata_destroy(vb->data);

        bfree(vb);
    }
}
Пример #3
0
void audio_output_close(audio_t audio)
{
	void *thread_ret;
	struct audio_line *line;

	if (!audio)
		return;

	if (audio->initialized) {
		os_event_signal(audio->stop_event);
		pthread_join(audio->thread, &thread_ret);
	}

	line = audio->first_line;
	while (line) {
		struct audio_line *next = line->next;
		audio_line_destroy_data(line);
		line = next;
	}

	for (size_t i = 0; i < audio->inputs.num; i++)
		audio_input_free(audio->inputs.array+i);

	for (size_t i = 0; i < MAX_AV_PLANES; i++)
		da_free(audio->mix_buffers[i]);

	da_free(audio->inputs);
	os_event_destroy(audio->stop_event);
	pthread_mutex_destroy(&audio->line_mutex);
	bfree(audio);
}
Пример #4
0
static void obs_encoder_actually_destroy(obs_encoder_t *encoder)
{
	if (encoder) {
		pthread_mutex_lock(&encoder->outputs_mutex);
		for (size_t i = 0; i < encoder->outputs.num; i++) {
			struct obs_output *output = encoder->outputs.array[i];
			obs_output_remove_encoder(output, encoder);
		}
		da_free(encoder->outputs);
		pthread_mutex_unlock(&encoder->outputs_mutex);

		blog(LOG_INFO, "encoder '%s' destroyed", encoder->context.name);

		free_audio_buffers(encoder);

		if (encoder->context.data)
			encoder->info.destroy(encoder->context.data);
		da_free(encoder->callbacks);
		pthread_mutex_destroy(&encoder->init_mutex);
		pthread_mutex_destroy(&encoder->callbacks_mutex);
		pthread_mutex_destroy(&encoder->outputs_mutex);
		obs_context_data_free(&encoder->context);
		if (encoder->owns_info_id)
			bfree((void*)encoder->info.id);
		bfree(encoder);
	}
}
Пример #5
0
void gs_renderstop(enum gs_draw_mode mode)
{
	graphics_t graphics = thread_graphics;
	size_t i, num = graphics->verts.num;

	if (!num) {
		if (!graphics->using_immediate) {
			da_free(graphics->verts);
			da_free(graphics->norms);
			da_free(graphics->colors);
			for (i = 0; i < 16; i++)
				da_free(graphics->texverts[i]);
			vbdata_destroy(graphics->vbd);
		}

		return;
	}

	if (graphics->norms.num &&
	    (graphics->norms.num != graphics->verts.num)) {
		blog(LOG_WARNING, "gs_renderstop: normal count does "
		                  "not match vertex count");
		num = min_size(num, graphics->norms.num);
	}

	if (graphics->colors.num &&
	    (graphics->colors.num != graphics->verts.num)) {
		blog(LOG_WARNING, "gs_renderstop: color count does "
		                  "not match vertex count");
		num = min_size(num, graphics->colors.num);
	}

	if (graphics->texverts[0].num &&
	    (graphics->texverts[0].num  != graphics->verts.num)) {
		blog(LOG_WARNING, "gs_renderstop: texture vertex count does "
		                  "not match vertex count");
		num = min_size(num, graphics->texverts[0].num);
	}

	if (graphics->using_immediate) {
		vertexbuffer_flush(graphics->immediate_vertbuffer, false);

		gs_load_vertexbuffer(graphics->immediate_vertbuffer);
		gs_load_indexbuffer(NULL);
		gs_draw(mode, 0, (uint32_t)num);

		reset_immediate_arrays(graphics);
	} else {
		vertbuffer_t vb = gs_rendersave();

		gs_load_vertexbuffer(vb);
		gs_load_indexbuffer(NULL);
		gs_draw(mode, 0, 0);

		vertexbuffer_destroy(vb);
	}

	graphics->vbd = NULL;
}
Пример #6
0
void obs_shutdown(void)
{
	if (!obs)
		return;

	da_free(obs->input_types);
	da_free(obs->filter_types);
	da_free(obs->encoder_types);
	da_free(obs->transition_types);
	da_free(obs->output_types);
	da_free(obs->service_types);
	da_free(obs->modal_ui_callbacks);
	da_free(obs->modeless_ui_callbacks);

	stop_video();

	obs_free_data();
	obs_free_video();
	obs_free_graphics();
	obs_free_audio();
	proc_handler_destroy(obs->procs);
	signal_handler_destroy(obs->signals);

	for (size_t i = 0; i < obs->modules.num; i++)
		free_module(obs->modules.array+i);
	da_free(obs->modules);

	bfree(obs->locale);
	bfree(obs);
	obs = NULL;
}
Пример #7
0
void free_servparm(servparm_t *serv)
{
	free(serv->uptest_cmd);
	free(serv->query_test_name);
	free(serv->label);
	da_free(serv->atup_a);
	free_slist_array(serv->alist);
	da_free(serv->reject_a4);
#if ALLOW_LOCAL_AAAA
	da_free(serv->reject_a6);
#endif
}
Пример #8
0
/*
 * call-seq:
 *   read(filename_base) -> Trie
 *
 * Returns a new trie with data as read from disk.
 */
static VALUE rb_trie_read(VALUE self, VALUE filename_base) {
	VALUE da_filename = rb_str_dup(filename_base);
	VALUE tail_filename = rb_str_dup(filename_base);
	rb_str_concat(da_filename, rb_str_new2(".da"));
	rb_str_concat(tail_filename, rb_str_new2(".tail"));
	StringValue(tail_filename);
    StringValue(da_filename);
	Trie *trie = trie_new();

	VALUE obj;
	obj = Data_Wrap_Struct(self, 0, trie_free, trie);

	DArray *old_da = trie->da;
	Tail *old_tail = trie->tail;

	FILE *da_file = fopen(RSTRING_PTR(da_filename), "r");
	if (da_file == NULL)
		raise_ioerror("Error reading .da file.");

	trie->da = da_read(da_file);
	fclose(da_file);

	FILE *tail_file = fopen(RSTRING_PTR(tail_filename), "r");
	if (tail_file == NULL)
		raise_ioerror("Error reading .tail file.");

	trie->tail = tail_read(tail_file);
	fclose(tail_file);

	da_free(old_da);
	tail_free(old_tail);

	return obj;
}
Пример #9
0
/**
 * @brief Create a new trie
 *
 * @param   alpha_map   : the alphabet set for the trie
 *
 * @return a pointer to the newly created trie, NULL on failure
 *
 * Create a new empty trie object based on the given @a alpha_map alphabet
 * set. The trie contents can then be added and deleted with trie_store() and
 * trie_delete() respectively.
 *
 * The created object must be freed with trie_free().
 */
Trie *
trie_new (const AlphaMap *alpha_map)
{
    Trie *trie;

    trie = (Trie *) malloc (sizeof (Trie));
    if (!trie)
        return NULL;

    trie->alpha_map = alpha_map_clone (alpha_map);
    if (!trie->alpha_map)
        goto exit_trie_created;

    trie->da = da_new ();
    if (!trie->da)
        goto exit_alpha_map_created;

    trie->tail = tail_new ();
    if (!trie->tail)
        goto exit_da_created;

    trie->is_dirty = TRUE;
    return trie;

exit_da_created:
    da_free (trie->da);
exit_alpha_map_created:
    alpha_map_free (trie->alpha_map);
exit_trie_created:
    free (trie);
    return NULL;
}
Пример #10
0
/**
 * @brief Create a new trie by loading from a file
 *
 * @param path  : the path to the file
 *
 * @return a pointer to the created trie, NULL on failure
 *
 * Create a new trie and initialize its contents by loading from the file at
 * given @a path.
 *
 * The created object must be freed with trie_free().
 */
Trie *
trie_new_from_file (const char *path)
{
    Trie       *trie;
    FILE       *trie_file;

    trie_file = fopen (path, "r");
    if (!trie_file)
        return NULL;

    trie = (Trie *) malloc (sizeof (Trie));
    if (!trie)
        goto exit_file_openned;

    if (NULL == (trie->alpha_map = alpha_map_read_bin (trie_file)))
        goto exit_trie_created;
    if (NULL == (trie->da   = da_read (trie_file)))
        goto exit_alpha_map_created;
    if (NULL == (trie->tail = tail_read (trie_file)))
        goto exit_da_created;

    fclose (trie_file);
    trie->is_dirty = FALSE;
    return trie;

exit_da_created:
    da_free (trie->da);
exit_alpha_map_created:
    alpha_map_free (trie->alpha_map);
exit_trie_created:
    free (trie);
exit_file_openned:
    fclose (trie_file);
    return NULL;
}
Пример #11
0
static void remove_all_items(struct obs_scene *scene)
{
	struct obs_scene_item *item;
	DARRAY(struct obs_scene_item*) items;

	da_init(items);

	full_lock(scene);

	item = scene->first_item;

	while (item) {
		struct obs_scene_item *del_item = item;
		item = item->next;

		remove_without_release(del_item);
		da_push_back(items, &del_item);
	}

	full_unlock(scene);

	for (size_t i = 0; i < items.num; i++)
		obs_sceneitem_release(items.array[i]);
	da_free(items);
}
Пример #12
0
static void free_server_data(servparm_array sa)
{
	int i,n=DA_NEL(sa);
	for(i=0;i<n;++i)
		free_servparm(&DA_INDEX(sa,i));
	da_free(sa);
}
Пример #13
0
/**
 * @brief Create a new trie by reading from an open file
 *
 * @param file  : the handle of the open file
 *
 * @return a pointer to the created trie, NULL on failure
 *
 * Create a new trie and initialize its contents by reading from the open
 * @a file. After reading, the file pointer is left at the end of the trie data.
 * This can be useful for reading embedded trie index as part of a file data.
 *
 * The created object must be freed with trie_free().
 *
 * Available since: 0.2.4
 */
Trie *
trie_fread (FILE *file)
{
    Trie       *trie;

    trie = (Trie *) malloc (sizeof (Trie));
    if (!trie)
        return NULL;

    if (NULL == (trie->alpha_map = alpha_map_fread_bin (file)))
        goto exit_trie_created;
    if (NULL == (trie->da   = da_fread (file)))
        goto exit_alpha_map_created;
    if (NULL == (trie->tail = tail_fread (file)))
        goto exit_da_created;

    trie->is_dirty = FALSE;
    return trie;

exit_da_created:
    da_free (trie->da);
exit_alpha_map_created:
    alpha_map_free (trie->alpha_map);
exit_trie_created:
    free (trie);
    return NULL;
}
Пример #14
0
void update_info_destroy(struct update_info *info)
{
	if (!info)
		return;

	if (info->thread_created)
		pthread_join(info->thread, NULL);

	da_free(info->file_data);
	bfree(info->log_prefix);
	bfree(info->user_agent);
	bfree(info->temp);
	bfree(info->cache);
	bfree(info->local);
	bfree(info->url);

	if (info->header)
		curl_slist_free_all(info->header);
	if (info->curl)
		curl_easy_cleanup(info->curl);
	if (info->local_package)
		obs_data_release(info->local_package);
	if (info->cache_package)
		obs_data_release(info->cache_package);
	if (info->remote_package)
		obs_data_release(info->remote_package);
	bfree(info);
}
Пример #15
0
void device_destroy(device_t device)
{
	if (device) {
		size_t i;
		for (i = 0; i < device->fbos.num; i++)
			fbo_info_destroy(device->fbos.array[i]);

		if (device->pipeline)
			glDeleteProgramPipelines(1, &device->pipeline);

		da_free(device->proj_stack);
		da_free(device->fbos);
		gl_platform_destroy(device->plat);
		bfree(device);
	}
}
Пример #16
0
static void vaapi_destroy(void *data)
{
	struct vaapi_encoder *enc = data;

	if (enc->initialized) {
		AVPacket pkt   = {0};
		int      r_pkt = 1;

		while (r_pkt) {
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(57, 40, 101)
			if (avcodec_receive_packet(enc->context, &pkt) < 0)
				break;
#else
			if (avcodec_encode_video2(enc->context, &pkt, NULL,
					    &r_pkt) < 0)
				break;
#endif

			if (r_pkt)
				av_packet_unref(&pkt);
		}
	}

	avcodec_close(enc->context);
	av_frame_unref(enc->vframe);
	av_frame_free(&enc->vframe);
	av_buffer_unref(&enc->vaframes_ref);
	av_buffer_unref(&enc->vadevice_ref);
	da_free(enc->buffer);
	bfree(enc->header);
	bfree(enc->sei);

	bfree(enc);
}
Пример #17
0
static void send_first_video_packet(struct obs_encoder *encoder,
		struct encoder_callback *cb, struct encoder_packet *packet)
{
	struct encoder_packet first_packet;
	DARRAY(uint8_t)       data;
	uint8_t               *sei;
	size_t                size;

	/* always wait for first keyframe */
	if (!packet->keyframe)
		return;

	da_init(data);

	if (!get_sei(encoder, &sei, &size)) {
		cb->new_packet(cb->param, packet);
		cb->sent_first_packet = true;
		return;
	}

	da_push_back_array(data, sei, size);
	da_push_back_array(data, packet->data, packet->size);

	first_packet      = *packet;
	first_packet.data = data.array;
	first_packet.size = data.num;

	cb->new_packet(cb->param, &first_packet);
	cb->sent_first_packet = true;

	da_free(data);
}
Пример #18
0
static inline void macro_params_free(struct macro_params *params)
{
	size_t i;
	for (i = 0; i < params->params.num; i++)
		macro_param_free(params->params.array+i);
	da_free(params->params);
}
Пример #19
0
static void obs_free_data(void)
{
	struct obs_core_data *data = &obs->data;

	data->valid = false;

	obs_view_free(&data->main_view);

	blog(LOG_INFO, "Freeing OBS context data");

	if (data->user_sources.num)
		blog(LOG_INFO, "\t%d user source(s) were remaining",
				(int)data->user_sources.num);

	while (data->user_sources.num)
		obs_source_remove(data->user_sources.array[0]);
	da_free(data->user_sources);

	FREE_OBS_LINKED_LIST(source);
	FREE_OBS_LINKED_LIST(output);
	FREE_OBS_LINKED_LIST(encoder);
	FREE_OBS_LINKED_LIST(display);
	FREE_OBS_LINKED_LIST(service);

	pthread_mutex_destroy(&data->user_sources_mutex);
	pthread_mutex_destroy(&data->sources_mutex);
	pthread_mutex_destroy(&data->displays_mutex);
	pthread_mutex_destroy(&data->outputs_mutex);
	pthread_mutex_destroy(&data->encoders_mutex);
	pthread_mutex_destroy(&data->services_mutex);
}
Пример #20
0
static inline void device_list_free(struct device_list *list)
{
	for (size_t i = 0; i < list->items.num; i++)
		device_item_free(list->items.array+i);

	da_free(list->items);
}
Пример #21
0
void device_destroy(gs_device_t *device)
{
	if (device) {
		size_t i;

		for (i = 0; i < device->fbos.num; i++)
			fbo_info_destroy(device->fbos.array[i]);

		while (device->first_program)
			gs_program_destroy(device->first_program);

		da_free(device->proj_stack);
		da_free(device->fbos);
		gl_platform_destroy(device->plat);
		bfree(device);
	}
}
Пример #22
0
static void free_zones(zone_array za)
{
	int i,n=DA_NEL(za);
	for(i=0;i<n;++i)
		free(DA_INDEX(za,i));

	da_free(za);
}
Пример #23
0
void free_slist_array(slist_array sla)
{
	int j,m=DA_NEL(sla);
	for(j=0;j<m;++j)
		free(DA_INDEX(sla,j).domain);
	da_free(sla);

}
Пример #24
0
Status pool_destroy(Pool* p)
{
	// don't be picky and complain if the freelist isn't empty;
	// we don't care since it's all part of the da anyway.
	// however, zero it to prevent further allocs from succeeding.
	p->freelist = mem_freelist_Sentinel();
	return da_free(&p->da);
}
Пример #25
0
/**
 * @brief Free a trie object
 *
 * @param trie  : the trie object to free
 *
 * Destruct the @a trie and free its allocated memory.
 */
void
trie_free (Trie *trie)
{
    alpha_map_free (trie->alpha_map);
    da_free (trie->da);
    tail_free (trie->tail);
    free (trie);
}
Пример #26
0
void server_stop()
{
    da_free(rcon_data.plugin_handlers);
    //darray_free(&rcon_data.plugin_handlers);

    rcon_data.run_thread = false;
    pthread_join(rcon_data.server_thread,NULL);
    mg_destroy_server(&rcon_data.server);
}
Пример #27
0
void obs_module_unload(void)
{
	av_log_set_callback(av_log_default_callback);

#ifdef _WIN32
	pthread_mutex_destroy(&log_contexts_mutex);
#endif

	for (size_t i = 0; i < active_log_contexts.num; i++) {
		bfree(active_log_contexts.array[i]);
	}
	for (size_t i = 0; i < cached_log_contexts.num; i++) {
		bfree(cached_log_contexts.array[i]);
	}

	da_free(active_log_contexts);
	da_free(cached_log_contexts);
}
Пример #28
0
static void full_stop(struct obs_encoder *encoder)
{
	if (encoder) {
		pthread_mutex_lock(&encoder->callbacks_mutex);
		da_free(encoder->callbacks);
		remove_connection(encoder);
		pthread_mutex_unlock(&encoder->callbacks_mutex);
	}
}
Пример #29
0
void proc_handler_destroy(proc_handler_t *handler)
{
	if (handler) {
		for (size_t i = 0; i < handler->procs.num; i++)
			proc_info_free(handler->procs.array+i);
		da_free(handler->procs);
		bfree(handler);
	}
}
Пример #30
0
void obs_display_free(obs_display_t display)
{
	pthread_mutex_destroy(&display->draw_callbacks_mutex);
	da_free(display->draw_callbacks);

	if (display->swap) {
		swapchain_destroy(display->swap);
		display->swap = NULL;
	}
}