~ubuntu-branches/ubuntu/lucid/lastfm/lucid

« back to all changes in this revision

Viewing changes to src/transcode/mpglib/mpglib/main.c

  • Committer: Bazaar Package Importer
  • Author(s): Pedro Fragoso
  • Date: 2007-12-31 09:49:54 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20071231094954-ix1amvcsj9pk61ya
Tags: 1:1.4.1.57486.dfsg-1ubuntu1
* Merge from Debian unstable (LP: #180254), remaining changes:
  - debian/rules;
    - Added dh_icons
  - Modify Maintainer value to match Debian-Maintainer-Field Spec

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "stdlib.h"
 
2
#include "unistd.h"
 
3
#include "mpg123.h"
 
4
#include "mpglib.h"
 
5
 
 
6
char buf[16384];
 
7
struct mpstr mp;
 
8
 
 
9
int main(int argc,char **argv)
 
10
{
 
11
        int size;
 
12
        char out[8192];
 
13
        char swapped;
 
14
        int len,ret;
 
15
        int i;
 
16
        FILE *fp;       
 
17
 
 
18
        InitMP3(&mp);
 
19
 
 
20
        fp = fopen( "lala.wav", "w" );
 
21
 
 
22
        printf( "starting\n" );
 
23
 
 
24
        while(1) {
 
25
                len = read(0,buf,16384);
 
26
                if(len <= 0)
 
27
                        break;
 
28
 
 
29
                ret = decodeMP3(&mp,buf,len,out,8192,&size);
 
30
 
 
31
                printf( "samplerate: %d - channels: %d\n", freqs[mp.fr.sampling_frequency], mp.fr.stereo );
 
32
                
 
33
                while(ret == MP3_OK) {
 
34
                        printf( "written: %d\n", size );
 
35
                        
 
36
                        for ( i = 0; i < ( size / 2 ); i++ )
 
37
                        {
 
38
                                fputc( out[i*2 + 1], fp );
 
39
                                fputc( out[i*2], fp );
 
40
                        }
 
41
                        
 
42
                        ret = decodeMP3(&mp,NULL,0,out,8192,&size);
 
43
                }
 
44
        }
 
45
 
 
46
        fclose( fp );
 
47
        return 0;
 
48
}
 
49