~ubuntu-branches/ubuntu/karmic/mpg123/karmic

« back to all changes in this revision

Viewing changes to ports/MSVC++/examples/scan.c

  • Committer: Bazaar Package Importer
  • Author(s): César Muñoz Albitres
  • Date: 2009-05-03 17:55:27 UTC
  • mfrom: (6.2.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090503175527-z94edsnxmiccxpy8
Tags: 1.7.2-3ubuntu1
* Merge from debian unstable, remaining changes:
  - Remove arts from dependencies

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
        scan: Estimate length (sample count) of a mpeg file and compare to length from exact scan.
 
3
 
 
4
        copyright 2007 by the mpg123 project - free software under the terms of the LGPL 2.1
 
5
        see COPYING and AUTHORS files in distribution or http://mpg123.org
 
6
        initially written by Thomas Orgis
 
7
*/
 
8
 
 
9
/* Note the lack of error checking here.
 
10
   While it would be nicer to inform the user about troubles, libmpg123 is designed _not_ to bite you on operations with invalid handles , etc.
 
11
  You just jet invalid results on invalid operations... */
 
12
 
 
13
#include <mpg123.h>
 
14
#include <stdio.h>
 
15
 
 
16
int _tmain(int argc, _TCHAR* argv[])
 
17
{
 
18
        mpg123_handle *m;
 
19
        int i;
 
20
        if(argc < 2)
 
21
        {
 
22
                fprintf(stderr, "\nI will give you the estimated and exact sample lengths of MPEG audio files.\n");
 
23
                fprintf(stderr, "\nUsage: %s <mpeg audio file list>\n\n", argv[0]);
 
24
                return -1;
 
25
        }
 
26
        mpg123_init();
 
27
        m = mpg123_new(NULL, NULL);
 
28
        mpg123_param(m, MPG123_RESYNC_LIMIT, -1, 0); /* New in library version 0.0.1 . */
 
29
        for(i = 1; i < argc; ++i)
 
30
        {
 
31
                off_t a, b;
 
32
                
 
33
                mpg123_topen(m, argv[i]);
 
34
 
 
35
                a = mpg123_length(m);           
 
36
                mpg123_scan(m);
 
37
                b = mpg123_length(m);
 
38
 
 
39
                mpg123_tclose(m);
 
40
 
 
41
                printf("File %i: estimated %li vs. scanned %li\n", i, (long)a, (long)b);
 
42
        }
 
43
 
 
44
        mpg123_delete(m);
 
45
        mpg123_exit();
 
46
        return 0;
 
47
}