Anthony Liu
2010-Feb-08 09:16 UTC
[Flac-dev] Use FLAC__stream_encoder_init_FILE instead of FLAC__stream_encoder_init_file
Hi, I use the libflac to encoder wav files to flac, my code: FLAC__StreamEncoder *encoder = 0;> > >> if((encoder = FLAC__stream_encoder_new()) == NULL) > > { > > printf(_T("ERROR: allocating encoder")); > > return; > > } > > >> FLAC__stream_encoder_set_channels ( encoder, 2 ); > > FLAC__stream_encoder_set_bits_per_sample ( encoder, 16) ; > > FLAC__stream_encoder_set_sample_rate ( encoder, 44100 ); > > FLAC__stream_encoder_set_verify( encoder, FALSE ); > > FLAC__stream_encoder_set_blocksize( encoder, 0 ); > > FLAC__stream_encoder_set_compression_level( encoder, 5); > > >> >> FLAC__StreamEncoderInitStatus InitStatus; > > InitStatus=FLAC__stream_encoder_init_file( encoder, FullFileName, NULL, >> NULL ); > > if(FLAC__STREAM_ENCODER_INIT_STATUS_OK != InitStatus ) > > { > > printf(_T("Error Code: %d"),(int)InitStatus); > > } > >The code worked for years, recently I made a unicode version of the app, it works with the "normal" filename, but not with the filename which contains some unicode characters(Error Code 6, *FLAC__STREAM_ENCODER_IO_ERRO).* * * According to the flac documents, it seems that I should useFLAC__stream_encoder_init_FILE instead of FLAC__stream_encoder_init_file,>> FLAC__StreamEncoder *encoder = 0; > > >> if((encoder = FLAC__stream_encoder_new()) == NULL) > > { > > printf(_T("ERROR: allocating encoder")); > > return; > > } > > >> FLAC__stream_encoder_set_channels ( encoder, 2 ); > > FLAC__stream_encoder_set_bits_per_sample ( encoder, 16) ; > > FLAC__stream_encoder_set_sample_rate ( encoder, 44100 ); > > FLAC__stream_encoder_set_verify( encoder, FALSE ); > > FLAC__stream_encoder_set_blocksize( encoder, 0 ); > > FLAC__stream_encoder_set_compression_level( encoder, 5); > > >> FILE* flacfile = _tfopen(FullFileName,_T("w+b")); > > if( flacfile == NULL ) > > { > > printf(_T("Error creating file %s"), FullFileName); > > return; > > } > > >> FLAC__StreamEncoderInitStatus InitStatus; > > InitStatus=FLAC__stream_encoder_init_FILE( encoder, flacfile, NULL, NULL ); >> //Crashed Here > > if(FLAC__STREAM_ENCODER_INIT_STATUS_OK != InitStatus ) > > { > > printf(_T("Error Code: %d"),(int)InitStatus); > > } > > >It crashed when I called FLAC__stream_encoder_init_FILE( encoder, flacfile, NULL, NULL ), what's wrong with the modified code, please help. -- Best Regards -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.xiph.org/pipermail/flac-dev/attachments/20100208/09c0a87a/attachment.htm