Mercurial > mplayer.hg
annotate libao2/pl_format.c @ 3222:71a3d16f344f
hmm many things.. (sorry now i'm a bit confused:)
author | gabucino |
---|---|
date | Fri, 30 Nov 2001 17:19:11 +0000 |
parents | 62d797a16f72 |
children | d6ea11bed983 |
rev | line source |
---|---|
3194
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
1 /* This is a null audio out plugin it doesnt't really do anything |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
2 useful but serves an example of how audio plugins work. It delays |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
3 the output signal by the nuber of samples set by aop_delay n |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
4 where n is the number of bytes. |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
5 */ |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
6 #define PLUGIN |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
7 |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
8 #include <stdio.h> |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
9 #include <stdlib.h> |
3195 | 10 #include <unistd.h> |
3194
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
11 |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
12 #include "audio_out.h" |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
13 #include "audio_plugin.h" |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
14 #include "audio_plugin_internal.h" |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
15 #include "afmt.h" |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
16 |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
17 static ao_info_t info = |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
18 { |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
19 "Sample format conversion audio plugin", |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
20 "format", |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
21 "Anders", |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
22 "" |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
23 }; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
24 |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
25 LIBAO_PLUGIN_EXTERN(format) |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
26 |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
27 // local data |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
28 typedef struct pl_format_s |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
29 { |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
30 void* data; // local audio data block |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
31 int len; // local buffer length |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
32 int in; // Input fomat |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
33 int out; // Output fomat |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
34 double sz_mult; // data size multiplier |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
35 } pl_format_t; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
36 |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
37 static pl_format_t pl_format={NULL,0,0,0,1}; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
38 |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
39 // Number of bits |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
40 #define B08 0 |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
41 #define B16 1 |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
42 #define B32 2 |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
43 #define NBITS_MASK 3 |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
44 |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
45 // Endianess |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
46 #define BE (0<<3) // Big endian |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
47 #define LE (1<<3) // Little endian |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
48 #define END_MASK (1<<3) |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
49 |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
50 // Signed |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
51 #define US (0<<4) |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
52 #define SI (1<<4) |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
53 #define SIGN_MASK (1<<4) |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
54 |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
55 // to set/get/query special features/parameters |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
56 static int control(int cmd,int arg){ |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
57 switch(cmd){ |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
58 case AOCONTROL_PLUGIN_SET_LEN: |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
59 if(pl_format.data) |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
60 uninit(); |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
61 pl_format.len = ao_plugin_data.len; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
62 pl_format.data=(void*)malloc(ao_plugin_data.len); |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
63 ao_plugin_data.len=(int)((double)ao_plugin_data.len*pl_format.sz_mult); |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
64 return CONTROL_OK; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
65 } |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
66 return -1; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
67 } |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
68 |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
69 // open & setup audio device |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
70 // return: 1=success 0=fail |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
71 static int init(){ |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
72 int i=0; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
73 int sign=0; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
74 int nbits=8; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
75 int be_le=BE; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
76 |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
77 // Sheck input format |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
78 switch(ao_plugin_data.format){ |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
79 case(AFMT_U8): |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
80 pl_format.in=LE|B08|US; break; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
81 case(AFMT_S8): |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
82 pl_format.in=LE|B08|SI; break; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
83 case(AFMT_S16_LE): |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
84 pl_format.in=LE|B16|US; break; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
85 case(AFMT_S16_BE): |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
86 pl_format.in=BE|B16|SI; break; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
87 case(AFMT_U16_LE): |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
88 pl_format.in=LE|B16|US; break; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
89 case(AFMT_U16_BE): |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
90 pl_format.in=BE|B16|US; break; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
91 case(AFMT_S32_LE): |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
92 pl_format.in=LE|B32|SI; break; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
93 case(AFMT_S32_BE): |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
94 pl_format.in=BE|B32|SI; break; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
95 case(AFMT_IMA_ADPCM): |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
96 case(AFMT_MU_LAW): |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
97 case(AFMT_A_LAW): |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
98 case(AFMT_MPEG): |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
99 case(AFMT_AC3): |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
100 printf("[pl_format] Audio format not yet suported \n"); |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
101 return 0; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
102 default: |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
103 printf("[pl_format] Unsupported audio format\n"); // Should never happen... |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
104 return 0; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
105 } |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
106 // Sheck output format |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
107 switch(ao_plugin_cfg.pl_format_type){ |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
108 case(AFMT_U8): |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
109 pl_format.in=LE|B08|US; break; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
110 case(AFMT_S8): |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
111 pl_format.in=LE|B08|SI; break; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
112 case(AFMT_S16_LE): |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
113 pl_format.in=LE|B16|US; break; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
114 case(AFMT_S16_BE): |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
115 pl_format.in=BE|B16|SI; break; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
116 case(AFMT_U16_LE): |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
117 pl_format.in=LE|B16|US; break; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
118 case(AFMT_U16_BE): |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
119 pl_format.in=BE|B16|US; break; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
120 case(AFMT_S32_LE): |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
121 pl_format.in=LE|B32|SI; break; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
122 case(AFMT_S32_BE): |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
123 pl_format.in=BE|B32|SI; break; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
124 case(AFMT_IMA_ADPCM): |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
125 case(AFMT_MU_LAW): |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
126 case(AFMT_A_LAW): |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
127 case(AFMT_MPEG): |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
128 case(AFMT_AC3): |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
129 printf("[pl_format] Audio format not yet suported \n"); |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
130 return 0; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
131 default: |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
132 printf("[pl_format] Unsupported audio format\n"); // Should never happen... |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
133 return 0; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
134 } |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
135 // We are changing the format |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
136 ao_plugin_data.format=ao_plugin_cfg.pl_format_type; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
137 |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
138 // And perhaps the buffer size |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
139 pl_format.sz_mult=1; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
140 if((pl_format.in&NBITS_MASK) < (pl_format.out&NBITS_MASK)) |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
141 pl_format.sz_mult/=(double)(1<<(pl_format.out-pl_format.in)); |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
142 if((pl_format.in&NBITS_MASK) > (pl_format.out&NBITS_MASK)) |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
143 pl_format.sz_mult*=(double)(1<<(pl_format.out-pl_format.in)); |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
144 ao_plugin_data.sz_mult*=pl_format.sz_mult; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
145 return 1; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
146 } |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
147 |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
148 // close plugin |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
149 static void uninit(){ |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
150 if(pl_format.data) |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
151 free(pl_format.data); |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
152 } |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
153 |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
154 // empty buffers |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
155 static void reset(){ |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
156 int i = 0; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
157 for(i=0;i<pl_format.len;i++) |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
158 ((char*)pl_format.data)[i]=0; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
159 } |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
160 |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
161 // processes 'ao_plugin_data.len' bytes of 'data' |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
162 // called for every block of data |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
163 static int play(){ |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
164 register int i=0; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
165 void* in_data=ao_plugin_data.data; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
166 void* out_data=pl_format.data; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
167 int in_len=((int)(double)pl_format.len*pl_format.sz_mult); |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
168 in_len>>=pl_format.in&NBITS_MASK; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
169 |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
170 if((pl_format.in&END_MASK)!=(pl_format.out&END_MASK)){ |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
171 switch(pl_format.in&NBITS_MASK){ |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
172 case(B16):{ |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
173 register int16_t s; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
174 for(i=1;i<in_len;i++){ |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
175 s=((int16_t*)in_data)[i]; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
176 ((int16_t*)in_data)[i]=(int16_t)(((s&0x00FF)<<8) | (s&0xFF00)>>8); |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
177 } |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
178 break; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
179 } |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
180 case(B32):{ |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
181 register int32_t s; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
182 for(i=1;i<in_len;i++){ |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
183 s=((int32_t*)in_data)[i]; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
184 ((int32_t*)in_data)[i]=(int32_t)(((s&0x000000FF)<<24) | ((s&0x0000FF00)<<8) | |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
185 ((s&0x00FF0000)>>8) | ((s&0xFF000000)>>24)); |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
186 } |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
187 break; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
188 } |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
189 } |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
190 } |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
191 |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
192 return 1; |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
193 } |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
194 |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
195 |
1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff
changeset
|
196 |