Exemple #1
0
void input_flac::open(std::string path)
{
  FLAC__StreamDecoderInitStatus status = init(path);

  if (status != FLAC__STREAM_DECODER_INIT_STATUS_OK) {
    throw new input_error("failed to initialize decoder");
  }

  process_until_end_of_metadata();
}
Exemple #2
0
uint16_t flacReader::reset( const char * filename, int alignUnit )
{
	if( is_valid() )
		finish();

	state = 0;

#if !defined(FLAC_API_VERSION_CURRENT) || FLAC_API_VERSION_CURRENT <= 7
	set_filename( filename );
	if ( init() != FLAC__FILE_DECODER_OK )
#else // flac 1.1.3+
	if ( init( filename ) != FLAC__STREAM_DECODER_INIT_STATUS_OK )
#endif
	{
		ERR( "Failed to initialize flac decoder\n" );
		return( 1 );
	}

	fName = filename;
	state |= named;

	if ( ! process_until_end_of_metadata() )
	{
		ERR( "Failed to read flac file metadata\n" );
		return( 1 );
	}

	soundCheck( this );

	unsent = 0;
	alignment = alignUnit ? alignUnit :
		fmeta.data.stream_info.channels *
		fmeta.data.stream_info.bits_per_sample / 8;

	maxFrame = fmeta.data.stream_info.max_blocksize *
		fmeta.data.stream_info.channels *
		fmeta.data.stream_info.bits_per_sample / 8;

	if( reserve ) delete reserve;
	reserve = new char[ maxFrame ];

	pos.max = unread = flacHeader::bytesUncompressed( &fmeta );
	surplus = ( alignment ? unread % alignment : 0 );
	gcount = bufPos = 0;

	return 0;
}