Esempio n. 1
0
/* format_new_match */
AsmFormat * format_new_match(char const * filename, FILE * fp)
{
	char const path[] = LIBDIR "/" PACKAGE "/format";
	DIR * dir;
	struct dirent * de;
	size_t len;
#ifdef __APPLE__
	char const ext[] = ".dylib";
#else
	char const ext[] = ".so";
#endif
	int hasflat = 0;
	AsmFormat * format = NULL;

#ifdef DEBUG
	fprintf(stderr, "DEBUG: %s(\"%s\")\n", __func__, filename);
#endif
	if((dir = opendir(path)) == NULL)
	{
		error_set_code(1, "%s: %s", path, strerror(errno));
		return NULL;
	}
	while((de = readdir(dir)) != NULL)
	{
		if((len = strlen(de->d_name)) < sizeof(ext))
			continue;
		if(strcmp(&de->d_name[len - sizeof(ext) + 1], ext) != 0)
			continue;
		de->d_name[len - sizeof(ext) + 1] = '\0';
		if(strcmp(de->d_name, "flat") == 0)
			hasflat = 1;
		if((format = format_new(de->d_name)) == NULL)
			continue;
		if(format_init(format, NULL, filename, fp) == 0
				&& format_match(format) == 1)
			break;
		format_delete(format);
		format = NULL;
	}
	closedir(dir);
	/* fallback on the "flat" format plug-in if necessary and available */
	if(format == NULL && hasflat && (format = format_new("flat")) != NULL
			&& format_init(format, NULL, filename, fp) != 0)
		{
			format_delete(format);
			format = NULL;
		}
	return format;
}
Esempio n. 2
0
mix_t *mix_new() {
	mix_t *mix = g_slice_alloc0(sizeof(*mix));
	format_init(&mix->format);
	mix->sink_frame = av_frame_alloc();

	for (int i = 0; i < NUM_INPUTS; i++)
		mix->pts_offs[i] = (uint64_t) -1LL;

	return mix;
}
Esempio n. 3
0
static void mix_shutdown(mix_t *mix) {
	if (mix->amix_ctx)
		avfilter_free(mix->amix_ctx);
	mix->amix_ctx = NULL;

	if (mix->sink_ctx)
		avfilter_free(mix->sink_ctx);
	mix->sink_ctx = NULL;

	for (int i = 0; i < NUM_INPUTS; i++) {
		if (mix->src_ctxs[i])
			avfilter_free(mix->src_ctxs[i]);
		mix->src_ctxs[i] = NULL;
	}

	resample_shutdown(&mix->resample);
	avfilter_graph_free(&mix->graph);

	format_init(&mix->format);
}