⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 utils.c

📁 Audacity是一款用於錄音和編輯聲音的、免費的開放源碼軟體。它可以執行於Mac OS X、Microsoft Windows、GNU/Linux和其它作業系統
💻 C
📖 第 1 页 / 共 2 页
字号:
		} ;	if (file == NULL)	{	printf ("\n\nLine %d: %s (%s) failed : %s\n\n", line_num, func_name, modestr, sf_strerror (NULL)) ;		dump_log_buffer (file) ;		exit (1) ;		} ;	return file ;} /* test_open_file_or_die */voidtest_read_write_position_or_die (SNDFILE *file, int line_num, int pass, sf_count_t read_pos, sf_count_t write_pos){	sf_count_t pos ;	/* Check the current read position. */	if (read_pos >= 0 && (pos = sf_seek (file, 0, SEEK_CUR | SFM_READ)) != read_pos)	{	printf ("\n\nLine %d ", line_num) ;		if (pass > 0)			printf ("(pass %d): ", pass) ;		printf ("Read position (%ld) should be %ld.\n", SF_COUNT_TO_LONG (pos), SF_COUNT_TO_LONG (read_pos)) ;		exit (1) ;		} ;	/* Check the current write position. */	if (write_pos >= 0 && (pos = sf_seek (file, 0, SEEK_CUR | SFM_WRITE)) != write_pos)	{	printf ("\n\nLine %d", line_num) ;		if (pass > 0)			printf (" (pass %d)", pass) ;		printf (" : Write position (%ld) should be %ld.\n",						SF_COUNT_TO_LONG (pos), SF_COUNT_TO_LONG (write_pos)) ;		exit (1) ;		} ;	return ;} /* test_read_write_position */voidtest_seek_or_die (SNDFILE *file, sf_count_t offset, int whence, sf_count_t new_pos, int channels, int line_num){	sf_count_t	position ;	const char	*channel_name, *whence_name ;	switch (whence)	{	case SEEK_SET :				whence_name = "SEEK_SET" ;				break ;		case SEEK_CUR :				whence_name = "SEEK_CUR" ;				break ;		case SEEK_END :				whence_name = "SEEK_END" ;				break ;		/* SFM_READ */		case SEEK_SET | SFM_READ :				whence_name = "SFM_READ | SEEK_SET" ;				break ;		case SEEK_CUR | SFM_READ :				whence_name = "SFM_READ | SEEK_CUR" ;				break ;		case SEEK_END | SFM_READ :				whence_name = "SFM_READ | SEEK_END" ;				break ;		/* SFM_WRITE */		case SEEK_SET | SFM_WRITE :				whence_name = "SFM_WRITE | SEEK_SET" ;				break ;		case SEEK_CUR | SFM_WRITE :				whence_name = "SFM_WRITE | SEEK_CUR" ;				break ;		case SEEK_END | SFM_WRITE :				whence_name = "SFM_WRITE | SEEK_END" ;				break ;		default :				printf ("\n\nLine %d: bad whence parameter.\n", line_num) ;				exit (1) ;		} ;	channel_name = (channels == 1) ? "Mono" : "Stereo" ;	if ((position = sf_seek (file, offset, whence)) != new_pos)	{	printf ("\n\nLine %d : %s : sf_seek (file, %ld, %s) returned %ld (should be %ld).\n\n",					line_num, channel_name, SF_COUNT_TO_LONG (offset), whence_name,					SF_COUNT_TO_LONG (position), SF_COUNT_TO_LONG (new_pos)) ;		exit (1) ;		} ;} /* test_seek_or_die */voidtest_read_short_or_die (SNDFILE *file, int pass, short *test, sf_count_t items, int line_num){	sf_count_t count ;	if ((count = sf_read_short (file, test, items)) != items)	{	printf ("\n\nLine %d", line_num) ;		if (pass > 0)			printf (" (pass %d)", pass) ;		printf (" : sf_read_short failed with short read (%ld => %ld).\n",						SF_COUNT_TO_LONG (items), SF_COUNT_TO_LONG (count)) ;		fflush (stdout) ;		puts (sf_strerror (file)) ;		exit (1) ;		} ;	return ;} /* test_read_short */voidtest_read_int_or_die (SNDFILE *file, int pass, int *test, sf_count_t items, int line_num){	sf_count_t count ;	if ((count = sf_read_int (file, test, items)) != items)	{	printf ("\n\nLine %d", line_num) ;		if (pass > 0)			printf (" (pass %d)", pass) ;		printf (" : sf_read_int failed with short read (%ld => %ld).\n",						SF_COUNT_TO_LONG (items), SF_COUNT_TO_LONG (count)) ;		fflush (stdout) ;		puts (sf_strerror (file)) ;		exit (1) ;		} ;	return ;} /* test_read_int */voidtest_read_float_or_die (SNDFILE *file, int pass, float *test, sf_count_t items, int line_num){	sf_count_t count ;	if ((count = sf_read_float (file, test, items)) != items)	{	printf ("\n\nLine %d", line_num) ;		if (pass > 0)			printf (" (pass %d)", pass) ;		printf (" : sf_read_float failed with short read (%ld => %ld).\n",						SF_COUNT_TO_LONG (items), SF_COUNT_TO_LONG (count)) ;		fflush (stdout) ;		puts (sf_strerror (file)) ;		exit (1) ;		} ;	return ;} /* test_read_float */voidtest_read_double_or_die (SNDFILE *file, int pass, double *test, sf_count_t items, int line_num){	sf_count_t count ;	if ((count = sf_read_double (file, test, items)) != items)	{	printf ("\n\nLine %d", line_num) ;		if (pass > 0)			printf (" (pass %d)", pass) ;		printf (" : sf_read_double failed with short read (%ld => %ld).\n",						SF_COUNT_TO_LONG (items), SF_COUNT_TO_LONG (count)) ;		fflush (stdout) ;		puts (sf_strerror (file)) ;		exit (1) ;		} ;	return ;} /* test_read_double */voidtest_readf_short_or_die (SNDFILE *file, int pass, short *test, sf_count_t frames, int line_num){	sf_count_t count ;	if ((count = sf_readf_short (file, test, frames)) != frames)	{	printf ("\n\nLine %d", line_num) ;		if (pass > 0)			printf (" (pass %d)", pass) ;		printf (" : sf_readf_short failed with short readf (%ld => %ld).\n",						SF_COUNT_TO_LONG (frames), SF_COUNT_TO_LONG (count)) ;		fflush (stdout) ;		puts (sf_strerror (file)) ;		exit (1) ;		} ;	return ;} /* test_readf_short */voidtest_readf_int_or_die (SNDFILE *file, int pass, int *test, sf_count_t frames, int line_num){	sf_count_t count ;	if ((count = sf_readf_int (file, test, frames)) != frames)	{	printf ("\n\nLine %d", line_num) ;		if (pass > 0)			printf (" (pass %d)", pass) ;		printf (" : sf_readf_int failed with short readf (%ld => %ld).\n",						SF_COUNT_TO_LONG (frames), SF_COUNT_TO_LONG (count)) ;		fflush (stdout) ;		puts (sf_strerror (file)) ;		exit (1) ;		} ;	return ;} /* test_readf_int */voidtest_readf_float_or_die (SNDFILE *file, int pass, float *test, sf_count_t frames, int line_num){	sf_count_t count ;	if ((count = sf_readf_float (file, test, frames)) != frames)	{	printf ("\n\nLine %d", line_num) ;		if (pass > 0)			printf (" (pass %d)", pass) ;		printf (" : sf_readf_float failed with short readf (%ld => %ld).\n",						SF_COUNT_TO_LONG (frames), SF_COUNT_TO_LONG (count)) ;		fflush (stdout) ;		puts (sf_strerror (file)) ;		exit (1) ;		} ;	return ;} /* test_readf_float */voidtest_readf_double_or_die (SNDFILE *file, int pass, double *test, sf_count_t frames, int line_num){	sf_count_t count ;	if ((count = sf_readf_double (file, test, frames)) != frames)	{	printf ("\n\nLine %d", line_num) ;		if (pass > 0)			printf (" (pass %d)", pass) ;		printf (" : sf_readf_double failed with short readf (%ld => %ld).\n",						SF_COUNT_TO_LONG (frames), SF_COUNT_TO_LONG (count)) ;		fflush (stdout) ;		puts (sf_strerror (file)) ;		exit (1) ;		} ;	return ;} /* test_readf_double */voidtest_write_short_or_die (SNDFILE *file, int pass, short *test, sf_count_t items, int line_num){	sf_count_t count ;	if ((count = sf_write_short (file, test, items)) != items)	{	printf ("\n\nLine %d", line_num) ;		if (pass > 0)			printf (" (pass %d)", pass) ;		printf (" : sf_write_short failed with short write (%ld => %ld).\n",						SF_COUNT_TO_LONG (items), SF_COUNT_TO_LONG (count)) ;		fflush (stdout) ;		puts (sf_strerror (file)) ;		exit (1) ;		} ;	return ;} /* test_write_short */voidtest_write_int_or_die (SNDFILE *file, int pass, int *test, sf_count_t items, int line_num){	sf_count_t count ;	if ((count = sf_write_int (file, test, items)) != items)	{	printf ("\n\nLine %d", line_num) ;		if (pass > 0)			printf (" (pass %d)", pass) ;		printf (" : sf_write_int failed with short write (%ld => %ld).\n",						SF_COUNT_TO_LONG (items), SF_COUNT_TO_LONG (count)) ;		fflush (stdout) ;		puts (sf_strerror (file)) ;		exit (1) ;		} ;	return ;} /* test_write_int */voidtest_write_float_or_die (SNDFILE *file, int pass, float *test, sf_count_t items, int line_num){	sf_count_t count ;	if ((count = sf_write_float (file, test, items)) != items)	{	printf ("\n\nLine %d", line_num) ;		if (pass > 0)			printf (" (pass %d)", pass) ;		printf (" : sf_write_float failed with short write (%ld => %ld).\n",						SF_COUNT_TO_LONG (items), SF_COUNT_TO_LONG (count)) ;		fflush (stdout) ;		puts (sf_strerror (file)) ;		exit (1) ;		} ;	return ;} /* test_write_float */voidtest_write_double_or_die (SNDFILE *file, int pass, double *test, sf_count_t items, int line_num){	sf_count_t count ;	if ((count = sf_write_double (file, test, items)) != items)	{	printf ("\n\nLine %d", line_num) ;		if (pass > 0)			printf (" (pass %d)", pass) ;		printf (" : sf_write_double failed with short write (%ld => %ld).\n",						SF_COUNT_TO_LONG (items), SF_COUNT_TO_LONG (count)) ;		fflush (stdout) ;		puts (sf_strerror (file)) ;		exit (1) ;		} ;	return ;} /* test_write_double */voidtest_writef_short_or_die (SNDFILE *file, int pass, short *test, sf_count_t frames, int line_num){	sf_count_t count ;	if ((count = sf_writef_short (file, test, frames)) != frames)	{	printf ("\n\nLine %d", line_num) ;		if (pass > 0)			printf (" (pass %d)", pass) ;		printf (" : sf_writef_short failed with short writef (%ld => %ld).\n",						SF_COUNT_TO_LONG (frames), SF_COUNT_TO_LONG (count)) ;		fflush (stdout) ;		puts (sf_strerror (file)) ;		exit (1) ;		} ;	return ;} /* test_writef_short */voidtest_writef_int_or_die (SNDFILE *file, int pass, int *test, sf_count_t frames, int line_num){	sf_count_t count ;	if ((count = sf_writef_int (file, test, frames)) != frames)	{	printf ("\n\nLine %d", line_num) ;		if (pass > 0)			printf (" (pass %d)", pass) ;		printf (" : sf_writef_int failed with short writef (%ld => %ld).\n",						SF_COUNT_TO_LONG (frames), SF_COUNT_TO_LONG (count)) ;		fflush (stdout) ;		puts (sf_strerror (file)) ;		exit (1) ;		} ;	return ;} /* test_writef_int */voidtest_writef_float_or_die (SNDFILE *file, int pass, float *test, sf_count_t frames, int line_num){	sf_count_t count ;	if ((count = sf_writef_float (file, test, frames)) != frames)	{	printf ("\n\nLine %d", line_num) ;		if (pass > 0)			printf (" (pass %d)", pass) ;		printf (" : sf_writef_float failed with short writef (%ld => %ld).\n",						SF_COUNT_TO_LONG (frames), SF_COUNT_TO_LONG (count)) ;		fflush (stdout) ;		puts (sf_strerror (file)) ;		exit (1) ;		} ;	return ;} /* test_writef_float */voidtest_writef_double_or_die (SNDFILE *file, int pass, double *test, sf_count_t frames, int line_num){	sf_count_t count ;	if ((count = sf_writef_double (file, test, frames)) != frames)	{	printf ("\n\nLine %d", line_num) ;		if (pass > 0)			printf (" (pass %d)", pass) ;		printf (" : sf_writef_double failed with short writef (%ld => %ld).\n",						SF_COUNT_TO_LONG (frames), SF_COUNT_TO_LONG (count)) ;		fflush (stdout) ;		puts (sf_strerror (file)) ;		exit (1) ;		} ;	return ;} /* test_writef_double */voiddelete_file (int format, const char *filename){	char rsrc_name [512], *fname ;	unlink (filename) ;	if ((format & SF_FORMAT_TYPEMASK) != SF_FORMAT_SD2)		return ;	/*	** Now try for a resource fork stored as a separate file.	** Grab the un-adulterated filename again.	*/	snprintf (rsrc_name, sizeof (rsrc_name), "%s", filename) ;	if ((fname = strrchr (rsrc_name, '/')) != NULL)		fname ++ ;	else if ((fname = strrchr (rsrc_name, '\\')) != NULL)		fname ++ ;	else		fname = rsrc_name ;	memmove (fname + 2, fname, strlen (fname) + 1) ;	fname [0] = '.' ;	fname [1] = '_' ;	unlink (rsrc_name) ;} /* delete_file */static int allowed_open_files = -1;voidcount_open_files (void){#if (defined (WIN32) || defined (_WIN32))	return ;#else	int k, count = 0 ;	struct stat statbuf ;	if (allowed_open_files > 0)		return ;	for (k = 0 ; k < 1024 ; k++)		if (fstat (k, &statbuf) == 0)			count ++ ;	allowed_open_files = count ;#endif} /* count_open_files */voidincrement_open_file_count (void){	allowed_open_files ++ ;} /* increment_open_file_count */voidcheck_open_file_count_or_die (int lineno){#if (defined (WIN32) || defined (_WIN32))	lineno = 0 ;	return ;#else	int k, count = 0 ;	struct stat statbuf ;	if (allowed_open_files < 0)		count_open_files () ;	for (k = 0 ; k < 1024 ; k++)		if (fstat (k, &statbuf) == 0)			count ++ ;	if (count > allowed_open_files)	{	printf ("\nLine %d : number of open files (%d) > allowed (%d).\n\n", lineno, count, allowed_open_files) ;		exit (1) ;		} ;#endif} /* check_open_file_count_or_die */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -