1 |
|
---|
2 | // gcc -g BMediaTrack-weirdness.cpp -lbe -lmedia -lroot_debug
|
---|
3 | // LD_PRELOAD=libroot_debug.so ./BMediaTrack-weirdness
|
---|
4 |
|
---|
5 | #include <stdio.h>
|
---|
6 | #include <string.h>
|
---|
7 | #include <media/MediaFile.h>
|
---|
8 | #include <media/MediaTrack.h>
|
---|
9 | #include <storage/Entry.h>
|
---|
10 | //#include <malloc_debug.h>
|
---|
11 |
|
---|
12 |
|
---|
13 |
|
---|
14 | int main()
|
---|
15 | {
|
---|
16 | entry_ref ref;
|
---|
17 | #error replace this with a path of your own before compiling
|
---|
18 | get_ref_for_path( "/boot/home/Desktop/Savatage-Hall_of_the_Mountain_King-Remastered-2011-GRAVEWISH/04-savatage-strange_wings.mp3", &ref );
|
---|
19 |
|
---|
20 | BMediaFile file( &ref );
|
---|
21 | BMediaTrack * track = file.TrackAt( 0 );
|
---|
22 | media_format format;
|
---|
23 | memset( &format, 0, sizeof(format) );
|
---|
24 | track->DecodedFormat( &format );
|
---|
25 |
|
---|
26 | //adapt this to your file's heading silence's duration
|
---|
27 | int count = 22;
|
---|
28 |
|
---|
29 | for( int j = 0; j < count*2; j++ )
|
---|
30 | {
|
---|
31 | if( j == count )
|
---|
32 | {
|
---|
33 | bigtime_t time = 0;
|
---|
34 | status_t s = track->SeekToTime( &time );
|
---|
35 | printf("\n\n=============================== calling SeekToTime(0) (status 0x%x) =============\n\n", s);
|
---|
36 | }
|
---|
37 |
|
---|
38 | printf( "\nFrames for CurrentTime %Ld:\n", track->CurrentTime() );
|
---|
39 |
|
---|
40 | char buffer[ format.u.raw_audio.buffer_size ];
|
---|
41 | memset( buffer, '\0', sizeof(buffer) );
|
---|
42 | int64 frames = 0;
|
---|
43 | track->ReadFrames( buffer, &frames );
|
---|
44 |
|
---|
45 | for( int i = 0; i < 128; i++ )
|
---|
46 | {
|
---|
47 | if(i%8==0) printf(" ");
|
---|
48 | if(i%32==0) printf("\n");
|
---|
49 |
|
---|
50 | printf("%2.2x", (unsigned char)buffer[i]);
|
---|
51 | }
|
---|
52 | printf("\n(...)\n");
|
---|
53 | }
|
---|
54 | }
|
---|
55 |
|
---|