Mercurial > mplayer.hg
annotate libao2/ao_mpegpes.c @ 4464:89369725b561
overwrite old info
author | nexus |
---|---|
date | Fri, 01 Feb 2002 13:45:06 +0000 |
parents | ce1e3668fa2b |
children | d678ce495a75 |
rev | line source |
---|---|
2708 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 | |
4 #include "audio_out.h" | |
5 #include "audio_out_internal.h" | |
6 | |
7 #include "afmt.h" | |
8 | |
9 static ao_info_t info = | |
10 { | |
11 "mpeg-pes audio output", | |
12 "mpegpes", | |
13 "A'rpi", | |
14 "" | |
15 }; | |
16 | |
17 LIBAO_EXTERN(mpegpes) | |
18 | |
19 | |
20 // to set/get/query special features/parameters | |
21 static int control(int cmd,int arg){ | |
22 return -1; | |
23 } | |
24 | |
4331 | 25 static int freq=0; |
4300
4ebab79785b7
passing samplerate to LPCM writer - 44, 32 and 96khz are also supported from now
arpi
parents:
3095
diff
changeset
|
26 static int freq_id=0; |
4ebab79785b7
passing samplerate to LPCM writer - 44, 32 and 96khz are also supported from now
arpi
parents:
3095
diff
changeset
|
27 |
2708 | 28 // open & setup audio device |
29 // return: 1=success 0=fail | |
30 static int init(int rate,int channels,int format,int flags){ | |
31 | |
3095 | 32 ao_data.outburst=2000; |
33 ao_data.format=format; | |
4331 | 34 freq=rate; |
4300
4ebab79785b7
passing samplerate to LPCM writer - 44, 32 and 96khz are also supported from now
arpi
parents:
3095
diff
changeset
|
35 |
4ebab79785b7
passing samplerate to LPCM writer - 44, 32 and 96khz are also supported from now
arpi
parents:
3095
diff
changeset
|
36 switch(rate){ |
4ebab79785b7
passing samplerate to LPCM writer - 44, 32 and 96khz are also supported from now
arpi
parents:
3095
diff
changeset
|
37 case 48000: freq_id=0;break; |
4ebab79785b7
passing samplerate to LPCM writer - 44, 32 and 96khz are also supported from now
arpi
parents:
3095
diff
changeset
|
38 case 96000: freq_id=1;break; |
4ebab79785b7
passing samplerate to LPCM writer - 44, 32 and 96khz are also supported from now
arpi
parents:
3095
diff
changeset
|
39 case 44100: freq_id=2;break; |
4ebab79785b7
passing samplerate to LPCM writer - 44, 32 and 96khz are also supported from now
arpi
parents:
3095
diff
changeset
|
40 case 32000: freq_id=3;break; |
4ebab79785b7
passing samplerate to LPCM writer - 44, 32 and 96khz are also supported from now
arpi
parents:
3095
diff
changeset
|
41 default: |
4ebab79785b7
passing samplerate to LPCM writer - 44, 32 and 96khz are also supported from now
arpi
parents:
3095
diff
changeset
|
42 fprintf(stderr,"ao_mpegpes: %d Hz not supported, try to resample (RTFM)\n",rate); |
4ebab79785b7
passing samplerate to LPCM writer - 44, 32 and 96khz are also supported from now
arpi
parents:
3095
diff
changeset
|
43 return 0; |
4ebab79785b7
passing samplerate to LPCM writer - 44, 32 and 96khz are also supported from now
arpi
parents:
3095
diff
changeset
|
44 } |
2708 | 45 |
46 return 1; | |
47 } | |
48 | |
49 // close audio device | |
50 static void uninit(){ | |
51 | |
52 } | |
53 | |
54 // stop playing and empty buffers (for seeking/pause) | |
55 static void reset(){ | |
56 | |
57 } | |
58 | |
59 // stop playing, keep buffers (for pause) | |
60 static void audio_pause() | |
61 { | |
62 // for now, just call reset(); | |
63 reset(); | |
64 } | |
65 | |
66 // resume playing, after audio_pause() | |
67 static void audio_resume() | |
68 { | |
69 } | |
70 | |
71 void send_pes_packet(unsigned char* data,int len,int id,int timestamp); | |
4300
4ebab79785b7
passing samplerate to LPCM writer - 44, 32 and 96khz are also supported from now
arpi
parents:
3095
diff
changeset
|
72 void send_lpcm_packet(unsigned char* data,int len,int id,int timestamp,int freq_id); |
2708 | 73 extern int vo_pts; |
74 | |
75 // return: how many bytes can be played without blocking | |
76 static int get_space(){ | |
4331 | 77 float x=(float)(vo_pts-ao_data.pts)/90000.0; |
2708 | 78 int y; |
79 if(x<=0) return 0; | |
4331 | 80 y=freq*4*x;y/=ao_data.outburst;y*=ao_data.outburst; |
81 if(y>32000) y=32000; | |
2708 | 82 // printf("diff: %5.3f -> %d \n",x,y); |
83 return y; | |
84 } | |
85 | |
86 // plays 'len' bytes of 'data' | |
87 // it should round it down to outburst*n | |
88 // return: number of bytes played | |
89 static int play(void* data,int len,int flags){ | |
3095 | 90 if(ao_data.format==AFMT_MPEG) |
91 send_pes_packet(data,len,0x1C0,ao_data.pts); | |
2708 | 92 else { |
93 int i; | |
94 unsigned short *s=data; | |
4300
4ebab79785b7
passing samplerate to LPCM writer - 44, 32 and 96khz are also supported from now
arpi
parents:
3095
diff
changeset
|
95 // if(len>2000) len=2000; |
4305 | 96 // printf("ao_mpegpes: len=%d \n",len); |
2708 | 97 for(i=0;i<len/2;i++) s[i]=(s[i]>>8)|(s[i]<<8); // le<->be |
4300
4ebab79785b7
passing samplerate to LPCM writer - 44, 32 and 96khz are also supported from now
arpi
parents:
3095
diff
changeset
|
98 send_lpcm_packet(data,len,0xA0,ao_data.pts,freq_id); |
2708 | 99 } |
100 return len; | |
101 } | |
102 | |
3095 | 103 // return: delay in seconds between first and last sample in buffer |
104 static float get_delay(){ | |
2708 | 105 |
3095 | 106 return 0.0; |
2708 | 107 } |
108 |