当前位置: 首页>>代码示例>>C++>>正文


C++ psf_fseek函数代码示例

本文整理汇总了C++中psf_fseek函数的典型用法代码示例。如果您正苦于以下问题:C++ psf_fseek函数的具体用法?C++ psf_fseek怎么用?C++ psf_fseek使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了psf_fseek函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: pvf_write_header

static int
pvf_write_header (SF_PRIVATE *psf, int UNUSED (calc_length))
{	sf_count_t	current ;

	if (psf->pipeoffset > 0)
		return 0 ;

	current = psf_ftell (psf) ;

	/* Reset the current header length to zero. */
	psf->header [0] = 0 ;
	psf->headindex = 0 ;

	if (psf->is_pipe == SF_FALSE)
		psf_fseek (psf, 0, SEEK_SET) ;

	snprintf ((char*) psf->header, sizeof (psf->header), "PVF1\n%d %d %d\n",
		psf->sf.channels, psf->sf.samplerate, psf->bytewidth * 8) ;

	psf->headindex = strlen ((char*) psf->header) ;

	/* Header construction complete so write it out. */
	psf_fwrite (psf->header, psf->headindex, 1, psf) ;

	if (psf->error)
		return psf->error ;

	psf->dataoffset = psf->headindex ;

	if (current > 0)
		psf_fseek (psf, current, SEEK_SET) ;

	return psf->error ;
} /* pvf_write_header */
开发者ID:5in4,项目名称:libsox.dll,代码行数:34,代码来源:pvf.c

示例2: psf_get_filelen

/* Win32 */ sf_count_t
psf_get_filelen (SF_PRIVATE *psf)
{
#if 0
	/* 
	** Windoze is SOOOOO FUCKED!!!!!!!
	** This code should work but doesn't. Why?
	** Code below does work.
	*/
	struct _stati64 statbuf ;

	if (_fstati64 (psf->filedes, &statbuf))
	{	psf_log_syserr (psf, errno) ;
		return (sf_count_t) -1 ;
		} ;

	return statbuf.st_size ;
#else
	sf_count_t  current, len ;
	
	current = psf_fseek (psf, 0, SEEK_CUR) ;
	len = psf_fseek (psf, 0, SEEK_END) ;
	psf_fseek (psf, current, SEEK_SET) ;
	
	return len ;
#endif
} /* psf_get_filelen */
开发者ID:ruthmagnus,项目名称:audacity,代码行数:27,代码来源:file_io.c

示例3: caf_write_tailer

static int
caf_write_tailer (SF_PRIVATE *psf)
{
	/* Reset the current header buffer length to zero. */
	psf->header [0] = 0 ;
	psf->headindex = 0 ;

	if (psf->bytewidth > 0 && psf->sf.seekable == SF_TRUE)
	{	psf->datalength = psf->sf.frames * psf->bytewidth * psf->sf.channels ;
		psf->dataend = psf->dataoffset + psf->datalength ;
		} ;

	if (psf->dataend > 0)
		psf_fseek (psf, psf->dataend, SEEK_SET) ;
	else
		psf->dataend = psf_fseek (psf, 0, SEEK_END) ;

	if (psf->dataend & 1)
		psf_binheader_writef (psf, "z", 1) ;

	if (psf->strings.flags & SF_STR_LOCATE_END)
		caf_write_strings (psf, SF_STR_LOCATE_END) ;

	/* Write the tailer. */
	if (psf->headindex > 0)
		psf_fwrite (psf->header, psf->headindex, 1, psf) ;

	return 0 ;
} /* caf_write_tailer */
开发者ID:weiwei22844,项目名称:sox,代码行数:29,代码来源:caf.c

示例4: psf_fseek

static int	
voc_close	(SF_PRIVATE  *psf)
{	
	if (psf->mode == SFM_WRITE || psf->mode == SFM_RDWR)
	{	/*  Now we know for certain the length of the file we can re-write 
		**	correct values for the FORM, 8SVX and BODY chunks.
		*/
		unsigned byte = VOC_TERMINATOR ;
		
		
		psf_fseek (psf, 0, SEEK_END) ;
		
		/* Write terminator */
		psf_fwrite (&byte, 1, 1, psf) ;
		
		psf->filelength = psf_ftell (psf) ;
		psf_fseek (psf, 0, SEEK_SET) ;
		
		psf->datalength = psf->filelength - psf->dataoffset ;
 		psf->sf.frames = psf->datalength / (psf->bytewidth * psf->sf.channels) ;
		
		voc_write_header (psf, SF_FALSE) ;
		} ;

	return 0 ;
} /* voc_close */
开发者ID:Kirushanr,项目名称:audacity,代码行数:26,代码来源:voc.c

示例5: mat4_write_header

static int
mat4_write_header (SF_PRIVATE *psf, int calc_length)
{	sf_count_t	current ;
	int			encoding ;
	double		samplerate ;

	current = psf_ftell (psf) ;

	if (calc_length)
	{	psf->filelength = psf_get_filelen (psf) ;

		psf->datalength = psf->filelength - psf->dataoffset ;
		if (psf->dataend)
			psf->datalength -= psf->filelength - psf->dataend ;

		psf->sf.frames = psf->datalength / (psf->bytewidth * psf->sf.channels) ;
		} ;

	encoding = mat4_format_to_encoding (SF_CODEC (psf->sf.format), psf->endian) ;

	if (encoding == -1)
		return SFE_BAD_OPEN_FORMAT ;

	/* Reset the current header length to zero. */
	psf->header [0] = 0 ;
	psf->headindex = 0 ;
	psf_fseek (psf, 0, SEEK_SET) ;

	/* Need sample rate as a double for writing to the header. */
	samplerate = psf->sf.samplerate ;

	if (psf->endian == SF_ENDIAN_BIG)
	{	psf_binheader_writef (psf, "Em444", MAT4_BE_DOUBLE, 1, 1, 0) ;
		psf_binheader_writef (psf, "E4bd", 11, "samplerate", make_size_t (11), samplerate) ;
		psf_binheader_writef (psf, "tEm484", encoding, psf->sf.channels, psf->sf.frames, 0) ;
		psf_binheader_writef (psf, "E4b", 9, "wavedata", make_size_t (9)) ;
		}
	else if (psf->endian == SF_ENDIAN_LITTLE)
	{	psf_binheader_writef (psf, "em444", MAT4_LE_DOUBLE, 1, 1, 0) ;
		psf_binheader_writef (psf, "e4bd", 11, "samplerate", make_size_t (11), samplerate) ;
		psf_binheader_writef (psf, "tem484", encoding, psf->sf.channels, psf->sf.frames, 0) ;
		psf_binheader_writef (psf, "e4b", 9, "wavedata", make_size_t (9)) ;
		}
	else
		return SFE_BAD_OPEN_FORMAT ;

	/* Header construction complete so write it out. */
	psf_fwrite (psf->header, psf->headindex, 1, psf) ;

	if (psf->error)
		return psf->error ;

	psf->dataoffset = psf->headindex ;

	if (current > 0)
		psf_fseek (psf, current, SEEK_SET) ;

	return psf->error ;
} /* mat4_write_header */
开发者ID:dpalkowski,项目名称:iSuperColliderKit,代码行数:59,代码来源:mat4.c

示例6: wav_w64_analyze

void
wav_w64_analyze (SF_PRIVATE *psf)
{   AUDIO_DETECT ad ;
    int format = 0 ;

    if (psf->is_pipe)
    {   psf_log_printf (psf, "*** Error : Reading from a pipe. Can't analyze data section to figure out real data format.\n\n") ;
        return ;
    } ;

    psf_log_printf (psf, "---------------------------------------------------\n"
                    "Format is known to be broken. Using detection code.\n") ;

    /* Code goes here. */
    ad.endianness = SF_ENDIAN_LITTLE ;
    ad.channels = psf->sf.channels ;

    psf_fseek (psf, 3 * 4 * 50, SEEK_SET) ;

    while (psf_fread (psf->u.ucbuf, 1, 4096, psf) == 4096)
    {   format = audio_detect (psf, &ad, psf->u.ucbuf, 4096) ;
        if (format != 0)
            break ;
    } ;

    /* Seek to start of DATA section. */
    psf_fseek (psf, psf->dataoffset, SEEK_SET) ;

    if (format == 0)
    {   psf_log_printf (psf, "wav_w64_analyze : detection failed.\n") ;
        return ;
    } ;

    switch (format)
    {
    case SF_FORMAT_PCM_32 :
    case SF_FORMAT_FLOAT :
        psf_log_printf (psf, "wav_w64_analyze : found format : 0x%X\n", format) ;
        psf->sf.format = (psf->sf.format & ~SF_FORMAT_SUBMASK) + format ;
        psf->bytewidth = 4 ;
        psf->blockwidth = psf->sf.channels * psf->bytewidth ;
        break ;

    case SF_FORMAT_PCM_24 :
        psf_log_printf (psf, "wav_w64_analyze : found format : 0x%X\n", format) ;
        psf->sf.format = (psf->sf.format & ~SF_FORMAT_SUBMASK) + format ;
        psf->bytewidth = 3 ;
        psf->blockwidth = psf->sf.channels * psf->bytewidth ;
        break ;

    default :
        psf_log_printf (psf, "wav_w64_analyze : unhandled format : 0x%X\n", format) ;
        break ;
    } ;

    return ;
} /* wav_w64_analyze */
开发者ID:jasonbourneh0810,项目名称:FreeSWITCH,代码行数:57,代码来源:wav_w64.c

示例7: avr_write_header

static int
avr_write_header (SF_PRIVATE *psf, int calc_length)
{	sf_count_t	current ;
	int			sign, datalength ;

	if (psf->pipeoffset > 0)
		return 0 ;

	current = psf_ftell (psf) ;

	if (calc_length)
	{	psf->filelength = psf_get_filelen (psf) ;

		psf->datalength = psf->filelength - psf->dataoffset ;
		if (psf->dataend)
			psf->datalength -= psf->filelength - psf->dataend ;

		psf->sf.frames = psf->datalength / (psf->bytewidth * psf->sf.channels) ;
		} ;

	/* Reset the current header length to zero. */
	psf->header [0] = 0 ;
	psf->headindex = 0 ;

	/*
	** Only attempt to seek if we are not writng to a pipe. If we are
	** writing to a pipe we shouldn't be here anyway.
	*/
	if (psf->is_pipe == SF_FALSE)
		psf_fseek (psf, 0, SEEK_SET) ;

	datalength = (int) (psf->datalength & 0x7FFFFFFF) ;

	psf_binheader_writef (psf, "Emz22", TWOBIT_MARKER, (size_t) 8,
			psf->sf.channels == 2 ? 0xFFFF : 0, psf->bytewidth * 8) ;

	sign = ((psf->sf.format & SF_FORMAT_SUBMASK) == SF_FORMAT_PCM_U8) ? 0 : 0xFFFF ;

	psf_binheader_writef (psf, "E222", sign, 0, 0xFFFF) ;
	psf_binheader_writef (psf, "E4444", psf->sf.samplerate, psf->sf.frames, 0, 0) ;

	psf_binheader_writef (psf, "E222zz", 0, 0, 0, (size_t) 20, (size_t) 64) ;

	/* Header construction complete so write it out. */
	psf_fwrite (psf->header, psf->headindex, 1, psf) ;

	if (psf->error)
		return psf->error ;

	psf->dataoffset = psf->headindex ;

	if (current > 0)
		psf_fseek (psf, current, SEEK_SET) ;

	return psf->error ;
} /* avr_write_header */
开发者ID:andreipaga,项目名称:audacity,代码行数:56,代码来源:avr.c

示例8: ircam_write_header

static int
ircam_write_header (SF_PRIVATE *psf, int UNUSED (calc_length))
{	int			encoding ;
	float		samplerate ;
	sf_count_t	current ;

	if (psf->pipeoffset > 0)
		return 0 ;

	current = psf_ftell (psf) ;

	/* This also sets psf->endian. */
	encoding = get_encoding (SF_CODEC (psf->sf.format)) ;

	if (encoding == 0)
		return SFE_BAD_OPEN_FORMAT ;

	/* Reset the current header length to zero. */
	psf->header [0] = 0 ;
	psf->headindex = 0 ;

	if (psf->is_pipe == SF_FALSE)
		psf_fseek (psf, 0, SEEK_SET) ;

	samplerate = psf->sf.samplerate ;

	switch (psf->endian)
	{	case SF_ENDIAN_BIG :
			psf_binheader_writef (psf, "Emf", IRCAM_02B_MARKER, samplerate) ;
			psf_binheader_writef (psf, "E44", psf->sf.channels, encoding) ;
			break ;

		case SF_ENDIAN_LITTLE :
			psf_binheader_writef (psf, "emf", IRCAM_03L_MARKER, samplerate) ;
			psf_binheader_writef (psf, "e44", psf->sf.channels, encoding) ;
			break ;

		default :
			return SFE_BAD_OPEN_FORMAT ;
	} ;

	psf_binheader_writef (psf, "z", (size_t) (IRCAM_DATA_OFFSET - psf->headindex)) ;

	/* Header construction complete so write it out. */
	psf_fwrite (psf->header, psf->headindex, 1, psf) ;

	if (psf->error)
		return psf->error ;

	if (current > 0)
		psf_fseek (psf, current, SEEK_SET) ;

	return psf->error ;
} /* ircam_write_header */
开发者ID:stohrendorf,项目名称:libsndfile,代码行数:54,代码来源:ircam.c

示例9:

int
au_nh_open	(SF_PRIVATE *psf)
{
	if (psf->mode == SFM_RDWR)
		return SFE_BAD_OPEN_FORMAT ;

	if (psf_fseek (psf, psf->dataoffset, SEEK_SET))
		return SFE_BAD_SEEK ;

	psf_log_printf (psf, "Header-less u-law encoded file.\n") ;
	psf_log_printf (psf, "Setting up for 8kHz, mono, u-law.\n") ;

	psf->sf.format = SF_FORMAT_AU | SF_FORMAT_ULAW ;

 	psf->dataoffset		= 0 ;
	psf->endian			= 0 ;	/* Irrelevant but it must be something. */
	psf->sf.samplerate	= 8000 ;
	psf->sf.channels	= 1 ;
	psf->bytewidth		= 1 ;	/* Before decoding */

	ulaw_init (psf) ;

	psf->close = au_close ;

	psf->blockwidth = 1 ;
	psf->sf.frames = psf->filelength ;
	psf->datalength = psf->filelength - AU_DATA_OFFSET ;

	return 0 ;
} /* au_nh_open */
开发者ID:andreipaga,项目名称:audacity,代码行数:30,代码来源:au.c

示例10: file_seek_with_offset_test

static void
file_seek_with_offset_test (const char *filename)
{	SF_PRIVATE sf_data, *psf ;
	sf_count_t real_end ;
	const size_t fileoffset = 64 ;

	print_test_name ("Testing seek with offset") ;

	/* Open the file created by the previous test for reading. */
	memset (&sf_data, 0, sizeof (sf_data)) ;
	psf = &sf_data ;
	psf->file.mode = SFM_READ ;
	snprintf (psf->file.path.c, sizeof (psf->file.path.c), "%s", filename) ;
	test_open_or_die (psf, __LINE__) ;

	/* Gather basic info before setting offset. */
	real_end = psf_fseek (psf, 0, SEEK_END) ;
	test_tell_or_die (psf, real_end, __LINE__) ;

	/* Set the fileoffset (usually in a real system this is due to an id3 tag). */
	psf->fileoffset = fileoffset ;

	/* Check tell respects offset. */
	test_tell_or_die (psf, real_end - fileoffset, __LINE__) ;

	/* Check seeking works as expected. */
	test_seek_or_die (psf, 0, SEEK_SET, 0, __LINE__) ;
	test_seek_or_die (psf, 0, SEEK_CUR, 0, __LINE__) ;
	test_seek_or_die (psf, 0, SEEK_CUR, 0, __LINE__) ;
	test_seek_or_die (psf, 0, SEEK_END, real_end - fileoffset, __LINE__) ;

	test_close_or_die (psf, __LINE__) ;

	puts ("ok") ;
} /* file_seek_with_offset_test */
开发者ID:erikd,项目名称:libsndfile,代码行数:35,代码来源:test_file_io.c

示例11: ircam_write_header

static int
ircam_write_header (SF_PRIVATE *psf, int calc_length)
{	int			encoding ;
	float		samplerate ;
	sf_count_t	current ;

	current = psf_ftell (psf) ;

	calc_length = calc_length ;

	/* This also sets psf->endian. */
	encoding = get_encoding (psf->sf.format & SF_FORMAT_SUBMASK) ;
	
	if (! encoding)
		return SFE_BAD_OPEN_FORMAT ;

	/* Reset the current header length to zero. */
	psf->header [0] = 0 ;
	psf->headindex = 0 ;
	psf_fseek (psf, 0, SEEK_SET) ;
	
	samplerate = psf->sf.samplerate ;

	if (psf->endian == SF_ENDIAN_BIG)
	{	psf_binheader_writef (psf, "Emf", IRCAM_02B_MARKER, samplerate) ;
		psf_binheader_writef (psf, "E44", psf->sf.channels, encoding) ;
		}
	else if  (psf->endian == SF_ENDIAN_LITTLE)
	{	psf_binheader_writef (psf, "emf", IRCAM_03L_MARKER, samplerate) ;
		psf_binheader_writef (psf, "e44", psf->sf.channels, encoding) ;
		}
	else
		return SFE_BAD_OPEN_FORMAT ;

	psf_binheader_writef (psf, "z", IRCAM_DATA_OFFSET - psf->headindex) ;
	
	/* Header construction complete so write it out. */
	psf_fwrite (psf->header, psf->headindex, 1, psf) ;

	if (psf->error)
		return psf->error ;

	if (current > 0)
		psf_fseek (psf, current, SEEK_SET) ;
		
	return psf->error ;
} /* ircam_write_header */ 
开发者ID:Kirushanr,项目名称:audacity,代码行数:47,代码来源:ircam.c

示例12: vorbis_length

static sf_count_t
vorbis_length (SF_PRIVATE *psf)
{	sf_count_t length ;
	int error ;

	if (psf->sf.seekable == 0)
		return SF_COUNT_MAX ;

	psf_fseek (psf, 0, SEEK_SET) ;
	length = vorbis_length_aux (psf) ;

	psf_fseek (psf, 12, SEEK_SET) ;
	if ((error = vorbis_read_header (psf, 0)) != 0)
		psf->error = error ;

	return length ;
} /* vorbis_length */
开发者ID:stohrendorf,项目名称:libsndfile,代码行数:17,代码来源:ogg_vorbis.c

示例13: wve_write_header

static int
wve_write_header (SF_PRIVATE *psf, int calc_length)
{	sf_count_t	current ;
	unsigned datalen ;

	current = psf_ftell (psf) ;

	if (calc_length)
	{	psf->filelength = psf_get_filelen (psf) ;

		psf->datalength = psf->filelength - psf->dataoffset ;
		if (psf->dataend)
			psf->datalength -= psf->filelength - psf->dataend ;

		psf->sf.frames = psf->datalength / (psf->bytewidth * psf->sf.channels) ;
		} ;

	/* Reset the current header length to zero. */
	psf->header [0] = 0 ;
	psf->headindex = 0 ;
	psf_fseek (psf, 0, SEEK_SET) ;

	/* Write header. */
	datalen = psf->datalength ;
	psf_binheader_writef (psf, "Emmmm", ALAW_MARKER, SOUN_MARKER, DFIL_MARKER, ESSN_MARKER) ;
	psf_binheader_writef (psf, "E2422222", PSION_VERSION, datalen, 0, 0, 0, 0, 0) ;
	psf_fwrite (psf->header, psf->headindex, 1, psf) ;

	if (psf->sf.channels != 1)
		return SFE_CHANNEL_COUNT ;

	if (psf->error)
		return psf->error ;

	psf->dataoffset = psf->headindex ;

	if (current > 0)
		psf_fseek (psf, current, SEEK_SET) ;

	return psf->error ;
} /* wve_write_header */
开发者ID:Aicitel,项目名称:android-education-project,代码行数:41,代码来源:wve.c

示例14: caf_get_chunk_data

static int
caf_get_chunk_data (SF_PRIVATE *psf, const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info)
{	int indx ;
	sf_count_t pos ;

	if ((indx = psf_find_read_chunk_iterator (&psf->rchunks, iterator)) < 0)
		return SFE_UNKNOWN_CHUNK ;

	if (chunk_info->data == NULL)
		return SFE_BAD_CHUNK_DATA_PTR ;

	chunk_info->id_size = psf->rchunks.chunks [indx].id_size ;
	memcpy (chunk_info->id, psf->rchunks.chunks [indx].id, sizeof (chunk_info->id) / sizeof (*chunk_info->id)) ;

	pos = psf_ftell (psf) ;
	psf_fseek (psf, psf->rchunks.chunks [indx].offset, SEEK_SET) ;
	psf_fread (chunk_info->data, SF_MIN (chunk_info->datalen, psf->rchunks.chunks [indx].len), 1, psf) ;
	psf_fseek (psf, pos, SEEK_SET) ;

	return SFE_NO_ERROR ;
} /* caf_get_chunk_data */
开发者ID:weiwei22844,项目名称:sox,代码行数:21,代码来源:caf.c

示例15: test_seek_or_die

static void
test_seek_or_die (SF_PRIVATE *psf, sf_count_t offset, int whence, sf_count_t new_position, int linenum)
{	sf_count_t retval ;

	retval = psf_fseek (psf, offset, whence) ;

	if (retval != new_position)
	{	printf ("\n\nLine %d: psf_fseek() failed. New position is %ld (should be %ld).\n\n",
			linenum, (long) retval, (long) new_position) ;
		exit (1) ;
		} ;

} /* test_seek_or_die */
开发者ID:andreipaga,项目名称:audacity,代码行数:13,代码来源:test_file_io.c


注:本文中的psf_fseek函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。