diff --git a/doc/examples/feedseek.c b/doc/examples/feedseek.c index 8e4a26a1..8f68d172 100644 --- a/doc/examples/feedseek.c +++ b/doc/examples/feedseek.c @@ -168,6 +168,7 @@ int main(int argc, char **argv) out = fopen(argv[2], "wb"); if(out == NULL) { + fclose(in); fprintf(stderr,"Unable to open output file %s\n", argv[2]); return -1; } diff --git a/doc/examples/mpg123_to_wav.c b/doc/examples/mpg123_to_wav.c index c68cb234..0dd0ab39 100644 --- a/doc/examples/mpg123_to_wav.c +++ b/doc/examples/mpg123_to_wav.c @@ -67,11 +67,6 @@ int main(int argc, char *argv[]) mpg123_format_none(mh); mpg123_format(mh, rate, channels, encoding); - /* Buffer could be almost any size here, mpg123_outblock() is just some recommendation. - Important, especially for sndfile writing, is that the size is a multiple of sample size. */ - buffer_size = mpg123_outblock( mh ); - buffer = malloc( buffer_size ); - bzero(&sfinfo, sizeof(sfinfo) ); sfinfo.samplerate = rate; sfinfo.channels = channels; @@ -81,6 +76,11 @@ int main(int argc, char *argv[]) sndfile = sf_open(argv[2], SFM_WRITE, &sfinfo); if(sndfile == NULL){ fprintf(stderr, "Cannot open output file!\n"); cleanup(mh); return -2; } + /* Buffer could be almost any size here, mpg123_outblock() is just some recommendation. + Important, especially for sndfile writing, is that the size is a multiple of sample size. */ + buffer_size = mpg123_outblock( mh ); + buffer = malloc( buffer_size ); + do { err = mpg123_read( mh, buffer, buffer_size, &done );