Mercurial > mplayer.hg
annotate libao2/ao_mpegpes.c @ 4311:c9f861653fe2
Modified the output of the http_debug function.
Fixed a bug in the reading of the "reason answer"
author | bertrand |
---|---|
date | Wed, 23 Jan 2002 08:46:22 +0000 |
parents | 624c73ec1c54 |
children | ce1e3668fa2b |
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 | |
4300
4ebab79785b7
passing samplerate to LPCM writer - 44, 32 and 96khz are also supported from now
arpi
parents:
3095
diff
changeset
|
25 |
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; | |
4300
4ebab79785b7
passing samplerate to LPCM writer - 44, 32 and 96khz are also supported from now
arpi
parents:
3095
diff
changeset
|
34 |
4ebab79785b7
passing samplerate to LPCM writer - 44, 32 and 96khz are also supported from now
arpi
parents:
3095
diff
changeset
|
35 switch(rate){ |
4ebab79785b7
passing samplerate to LPCM writer - 44, 32 and 96khz are also supported from now
arpi
parents:
3095
diff
changeset
|
36 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
|
37 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
|
38 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
|
39 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
|
40 default: |
4ebab79785b7
passing samplerate to LPCM writer - 44, 32 and 96khz are also supported from now
arpi
parents:
3095
diff
changeset
|
41 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
|
42 return 0; |
4ebab79785b7
passing samplerate to LPCM writer - 44, 32 and 96khz are also supported from now
arpi
parents:
3095
diff
changeset
|
43 } |
2708 | 44 |
45 return 1; | |
46 } | |
47 | |
48 // close audio device | |
49 static void uninit(){ | |
50 | |
51 } | |
52 | |
53 // stop playing and empty buffers (for seeking/pause) | |
54 static void reset(){ | |
55 | |
56 } | |
57 | |
58 // stop playing, keep buffers (for pause) | |
59 static void audio_pause() | |
60 { | |
61 // for now, just call reset(); | |
62 reset(); | |
63 } | |
64 | |
65 // resume playing, after audio_pause() | |
66 static void audio_resume() | |
67 { | |
68 } | |
69 | |
70 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
|
71 void send_lpcm_packet(unsigned char* data,int len,int id,int timestamp,int freq_id); |
2708 | 72 extern int vo_pts; |
73 | |
74 // return: how many bytes can be played without blocking | |
75 static int get_space(){ | |
3095 | 76 float x=(float)(vo_pts-ao_data.pts)/90000.0-0.5; |
2708 | 77 int y; |
78 if(x<=0) return 0; | |
3095 | 79 y=48000*4*x;y/=ao_data.outburst;y*=ao_data.outburst; |
4300
4ebab79785b7
passing samplerate to LPCM writer - 44, 32 and 96khz are also supported from now
arpi
parents:
3095
diff
changeset
|
80 // if(y>2000) y=2000; |
2708 | 81 // printf("diff: %5.3f -> %d \n",x,y); |
82 return y; | |
83 } | |
84 | |
85 // plays 'len' bytes of 'data' | |
86 // it should round it down to outburst*n | |
87 // return: number of bytes played | |
88 static int play(void* data,int len,int flags){ | |
3095 | 89 if(ao_data.format==AFMT_MPEG) |
90 send_pes_packet(data,len,0x1C0,ao_data.pts); | |
2708 | 91 else { |
92 int i; | |
93 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
|
94 // if(len>2000) len=2000; |
4305 | 95 // printf("ao_mpegpes: len=%d \n",len); |
2708 | 96 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
|
97 send_lpcm_packet(data,len,0xA0,ao_data.pts,freq_id); |
2708 | 98 } |
99 return len; | |
100 } | |
101 | |
3095 | 102 // return: delay in seconds between first and last sample in buffer |
103 static float get_delay(){ | |
2708 | 104 |
3095 | 105 return 0.0; |
2708 | 106 } |
107 |