From c4b7f976ea416168581b9d65ca7f2029895c6550 Mon Sep 17 00:00:00 2001 From: thor Date: Mon, 12 Apr 2021 06:01:39 +0000 Subject: [PATCH] examples: update for mpg123_init() and sensible copyright git-svn-id: svn://scm.orgis.org/mpg123/trunk@4831 35dc7657-300d-0410-a2e5-dc2837fedb53 --- NEWS | 2 ++ doc/examples/dumb_decoder.c | 7 ++++++- doc/examples/dump_seekindex.c | 12 +++++++----- doc/examples/extract_frames.c | 10 ++++++---- doc/examples/feedseek.c | 9 ++++++--- doc/examples/id3dump.c | 10 ++++++---- doc/examples/mpg123_to_out123.c | 10 ++++++---- doc/examples/mpg123_to_wav_replaced_io.c | 9 ++++++--- doc/examples/mpglib.c | 10 ++++++---- doc/examples/scan.c | 8 ++++---- 10 files changed, 55 insertions(+), 32 deletions(-) diff --git a/NEWS b/NEWS index c719585e..7d2b0001 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,8 @@ - libmpg123: Running on precomputed tables now, no need to call mpg123_init() anymore. That and mpg123_exit() are both just empty shells now. +- examples: Update for dropped mpg123_init(), more sensible + copyright notes. 1.26.5 ------ diff --git a/doc/examples/dumb_decoder.c b/doc/examples/dumb_decoder.c index 35ea996d..659e092b 100644 --- a/doc/examples/dumb_decoder.c +++ b/doc/examples/dumb_decoder.c @@ -2,6 +2,8 @@ A simple and dumb decoder that does not even query the mpg123 output format. It shall get MPG123_NEW_FORMAT once, but after that data! + This is example code only sensible to be considered in the public domain. + Beware: It writes raw audio to standard out! */ @@ -17,7 +19,11 @@ int main(int argc, char **argv) int i; int err; mpg123_handle* mh; +#if MPG123_API_VERSION < 46 + // Newer versions of the library don't need that anymore, but it is safe + // to have the no-op call present for compatibility with old versions. mpg123_init(); +#endif mh = mpg123_new(NULL, NULL); for(i=1; i @@ -23,7 +22,11 @@ int main(int argc, char **argv) fprintf(stderr, "\nUsage: %s \n\n", argv[0]); return -1; } - mpg123_init(); +#if MPG123_API_VERSION < 46 + // Newer versions of the library don't need that anymore, but it is safe + // to have the no-op call present for compatibility with old versions. + mpg123_init(); +#endif m = mpg123_new(NULL, NULL); mpg123_param(m, MPG123_RESYNC_LIMIT, -1, 0); mpg123_param(m, MPG123_INDEX_SIZE, -1, 0); @@ -37,6 +40,5 @@ int main(int argc, char **argv) mpg123_close(m); mpg123_delete(m); - mpg123_exit(); return 0; } diff --git a/doc/examples/extract_frames.c b/doc/examples/extract_frames.c index a830c5ac..c20ff514 100644 --- a/doc/examples/extract_frames.c +++ b/doc/examples/extract_frames.c @@ -1,9 +1,8 @@ /* extract_frams: utlize the framebyframe API and mpg123_framedata to extract the MPEG frames out of a stream (strip off anything else). - copyright 2011 by the mpg123 project - free software under the terms of the LGPL 2.1 - see COPYING and AUTHORS files in distribution or http://mpg123.org - initially written by Thomas Orgis + This is example code only sensible to be considered in the public domain. + Initially written by Thomas Orgis. */ #include @@ -26,7 +25,11 @@ int main(int argc, char **argv) int ret = 0; mpg123_handle *m; +#if MPG123_API_VERSION < 46 + // Newer versions of the library don't need that anymore, but it is safe + // to have the no-op call present for compatibility with old versions. mpg123_init(); +#endif m = mpg123_new(NULL, &ret); if(m == NULL) @@ -53,7 +56,6 @@ int main(int argc, char **argv) mpg123_delete(m); /* Closes, too. */ } - mpg123_exit(); return ret; } diff --git a/doc/examples/feedseek.c b/doc/examples/feedseek.c index 8335e152..4e1d843d 100644 --- a/doc/examples/feedseek.c +++ b/doc/examples/feedseek.c @@ -1,7 +1,7 @@ /* feedseek: test program for libmpg123, showing how to use fuzzy seeking in feeder mode - copyright 2008 by the mpg123 project - free software under the terms of the LGPL 2.1 - see COPYING and AUTHORS files in distribution or http://mpg123.org + + This is example code only sensible to be considered in the public domain. */ #include @@ -110,7 +110,11 @@ int main(int argc, char **argv) return -1; } +#if MPG123_API_VERSION < 46 + // Newer versions of the library don't need that anymore, but it is safe + // to have the no-op call present for compatibility with old versions. mpg123_init(); +#endif m = mpg123_new(NULL, &ret); if(m == NULL) @@ -233,6 +237,5 @@ int main(int argc, char **argv) fclose(out); fclose(in); mpg123_delete(m); - mpg123_exit(); return 0; } diff --git a/doc/examples/id3dump.c b/doc/examples/id3dump.c index 649e3314..0f05173c 100644 --- a/doc/examples/id3dump.c +++ b/doc/examples/id3dump.c @@ -1,9 +1,8 @@ /* id3dump: Print ID3 tags of files, scanned using libmpg123. - copyright 2007 by the mpg123 project - free software under the terms of the LGPL 2.1 - see COPYING and AUTHORS files in distribution or http://mpg123.org - initially written by Thomas Orgis + This is example code only sensible to be considered in the public domain. + Initially written by Thomas Orgis. */ #include "mpg123.h" @@ -141,7 +140,11 @@ int main(int argc, char **argv) fprintf(stderr, "\nUsage: %s \n\n", argv[0]); return -1; } +#if MPG123_API_VERSION < 46 + // Newer versions of the library don't need that anymore, but it is safe + // to have the no-op call present for compatibility with old versions. mpg123_init(); +#endif m = mpg123_new(NULL, NULL); for(i=1; i < argc; ++i) @@ -173,6 +176,5 @@ int main(int argc, char **argv) mpg123_close(m); } mpg123_delete(m); - mpg123_exit(); return 0; } diff --git a/doc/examples/mpg123_to_out123.c b/doc/examples/mpg123_to_out123.c index 2031ab94..b5cc8a31 100644 --- a/doc/examples/mpg123_to_out123.c +++ b/doc/examples/mpg123_to_out123.c @@ -1,9 +1,8 @@ /* mpg123_to_wav.c - copyright 2007-2016 by the mpg123 project - free software under the terms of the LGPL 2.1 - see COPYING and AUTHORS files in distribution or http://mpg123.org - initially written by Nicholas Humfrey + This is example code only sensible to be considered in the public domain. + Initially written by Nicholas Humfrey. The most complicated part is about the choices to make about output format, and prepare for the unlikely case a bastard mp3 might file change it. @@ -29,7 +28,6 @@ void cleanup(mpg123_handle *mh, out123_handle *ao) /* It's really to late for error checks here;-) */ mpg123_close(mh); mpg123_delete(mh); - mpg123_exit(); } int main(int argc, char *argv[]) @@ -62,7 +60,11 @@ int main(int argc, char *argv[]) printf("Output driver: %s\n", driver ? driver : " (default)"); printf("Output file: %s\n", outfile ? outfile : " (default)"); +#if MPG123_API_VERSION < 46 + // Newer versions of the library don't need that anymore, but it is safe + // to have the no-op call present for compatibility with old versions. err = mpg123_init(); +#endif if(err != MPG123_OK || (mh = mpg123_new(NULL, &err)) == NULL) { fprintf(stderr, "Basic setup goes wrong: %s", mpg123_plain_strerror(err)); diff --git a/doc/examples/mpg123_to_wav_replaced_io.c b/doc/examples/mpg123_to_wav_replaced_io.c index 4f035560..03ac99dd 100644 --- a/doc/examples/mpg123_to_wav_replaced_io.c +++ b/doc/examples/mpg123_to_wav_replaced_io.c @@ -1,9 +1,8 @@ /* mpg123_to_wav_replaced_io.c - copyright 2007-2015 by the mpg123 project - free software under the terms of the LGPL 2.1 - see COPYING and AUTHORS files in distribution or http://mpg123.org - initially written by Nicholas Humfrey (moved to handle I/O by Thomas Orgis) + This is example code only sensible to be considered in the public domain. + Initially written by Nicholas Humfrey (moved to handle I/O by Thomas Orgis). This example program demonstrates how to use libmpg123 to decode a file to WAV (writing via libsndfile), while doing the I/O (read and seek) with custom callback functions. This should cater for any situation where you have some special means to get to the data (like, mmapped files / plain buffers in memory, funky network streams). @@ -105,7 +104,11 @@ int main(int argc, char *argv[]) printf( "Input file: %s\n", argv[1]); printf( "Output file: %s\n", argv[2]); +#if MPG123_API_VERSION < 46 + // Newer versions of the library don't need that anymore, but it is safe + // to have the no-op call present for compatibility with old versions. err = mpg123_init(); +#endif errno = 0; iohandle = malloc(sizeof(struct ioh)); diff --git a/doc/examples/mpglib.c b/doc/examples/mpglib.c index 4ee1a1d7..889876ae 100644 --- a/doc/examples/mpglib.c +++ b/doc/examples/mpglib.c @@ -1,9 +1,8 @@ /* mpglib: test program for libmpg123, in the style of the legacy mpglib test program - copyright 2007 by the mpg123 project - free software under the terms of the LGPL 2.1 - see COPYING and AUTHORS files in distribution or http://mpg123.org - initially written by Thomas Orgis + This is example code only sensible to be considered in the public domain. + Initially written by Thomas Orgis. */ #include @@ -40,7 +39,11 @@ _setmode(_fileno(stdin),_O_BINARY); _setmode(_fileno(stdout),_O_BINARY); #endif +#if MPG123_API_VERSION < 46 + // Newer versions of the library don't need that anymore, but it is safe + // to have the no-op call present for compatibility with old versions. mpg123_init(); +#endif m = mpg123_new(argc > 1 ? argv[1] : NULL, &ret); if(m == NULL) { @@ -87,6 +90,5 @@ _setmode(_fileno(stdout),_O_BINARY); /* Done decoding, now just clean up and leave. */ mpg123_delete(m); - mpg123_exit(); return 0; } diff --git a/doc/examples/scan.c b/doc/examples/scan.c index df9b999c..e858c249 100644 --- a/doc/examples/scan.c +++ b/doc/examples/scan.c @@ -1,9 +1,8 @@ /* scan: Estimate length (sample count) of a mpeg file and compare to length from exact scan. - copyright 2007 by the mpg123 project - free software under the terms of the LGPL 2.1 - see COPYING and AUTHORS files in distribution or http://mpg123.org - initially written by Thomas Orgis + This is example code only sensible to be considered in the public domain. + Initially written by Thomas Orgis */ /* Note the lack of error checking here. @@ -23,7 +22,9 @@ int main(int argc, char **argv) fprintf(stderr, "\nUsage: %s \n\n", argv[0]); return -1; } +#if MPG123_API_VERSION < 46 mpg123_init(); +#endif m = mpg123_new(NULL, NULL); mpg123_param(m, MPG123_RESYNC_LIMIT, -1, 0); /* New in library version 0.0.1 . */ for(i = 1; i < argc; ++i) @@ -42,6 +43,5 @@ int main(int argc, char **argv) } mpg123_delete(m); - mpg123_exit(); return 0; }