1
0
mirror of http://mpg123.de/trunk/.git synced 2025-07-31 13:24:22 +03:00

examples: update for mpg123_init() and sensible copyright

git-svn-id: svn://scm.orgis.org/mpg123/trunk@4831 35dc7657-300d-0410-a2e5-dc2837fedb53
This commit is contained in:
thor
2021-04-12 06:01:39 +00:00
parent 72e0f830c5
commit c4b7f976ea
10 changed files with 55 additions and 32 deletions

2
NEWS
View File

@ -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
------

View File

@ -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<argc; ++i)
{
@ -31,7 +37,6 @@ int main(int argc, char **argv)
}
else fprintf(stderr, "Failed to open file: %s\n", mpg123_strerror(mh));
}
mpg123_exit();
}
void decode_track(mpg123_handle *mh)

View File

@ -1,9 +1,8 @@
/*
dump_seekindex: Scan a mpeg file and dump its seek index.
copyright 2010 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 Patrick Dehne
This is example code only sensible to be considered in the public domain.
Initially written by Patrick Dehne.
*/
#include <mpg123.h>
@ -23,7 +22,11 @@ int main(int argc, char **argv)
fprintf(stderr, "\nUsage: %s <mpeg audio file>\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;
}

View File

@ -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 <mpg123.h>
@ -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;
}

View File

@ -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 <mpg123.h>
@ -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;
}

View File

@ -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 <mpeg audio file list>\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;
}

View File

@ -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 : "<nil> (default)");
printf("Output file: %s\n", outfile ? outfile : "<nil> (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));

View File

@ -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));

View File

@ -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 <mpg123.h>
@ -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;
}

View File

@ -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 <mpeg audio file list>\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;
}