annotate libao2/ao_plugin.c @ 4073:5f28d9d7d346

Changed the return value of the start function. Doesn't return the fd anymore. Just -1 for fail and 0 for OK.
author bertrand
date Thu, 10 Jan 2002 01:42:31 +0000
parents 2cc5737ec923
children 1dbffed555a6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3096
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
1 #include <stdio.h>
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
2 #include <stdlib.h>
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
3
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
4 #include "../config.h"
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
5
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents: 3107
diff changeset
6 #include "afmt.h"
3096
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
7 #include "audio_out.h"
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
8 #include "audio_out_internal.h"
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
9
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
10 #include "audio_plugin.h"
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
11
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
12 static ao_info_t info =
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
13 {
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
14 "Plugin audio output",
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
15 "plugin",
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
16 "Anders",
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
17 ""
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
18 };
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
19
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
20 LIBAO_EXTERN(plugin)
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
21
3107
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
22 #define plugin(i) (ao_plugin_local_data.plugins[i])
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
23 #define driver() (ao_plugin_local_data.driver)
3096
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
24
3107
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
25 // local data
3096
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
26 typedef struct ao_plugin_local_data_s
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
27 {
3107
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
28 ao_functions_t* driver; // Output driver set in mplayer.c
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
29 ao_plugin_functions_t** plugins; // List of used plugins
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents: 3107
diff changeset
30 ao_plugin_functions_t* available_plugins[NPL]; // List of available plugins
3096
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
31 } ao_plugin_local_data_t;
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
32
3308
ea7c1bfc4391 Global variables protected using volatile
anders
parents: 3279
diff changeset
33 static ao_plugin_local_data_t ao_plugin_local_data={NULL,NULL,AO_PLUGINS};
3096
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
34
3107
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
35 // gloabal data
3308
ea7c1bfc4391 Global variables protected using volatile
anders
parents: 3279
diff changeset
36 volatile ao_plugin_data_t ao_plugin_data; // data used by the plugins
ea7c1bfc4391 Global variables protected using volatile
anders
parents: 3279
diff changeset
37 volatile ao_plugin_cfg_t ao_plugin_cfg=CFG_DEFAULTS; // cfg data set in cfg-mplayer.h
3096
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
38
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
39 // to set/get/query special features/parameters
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
40 static int control(int cmd,int arg){
3107
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
41 switch(cmd){
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
42 case AOCONTROL_SET_PLUGIN_DRIVER:
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
43 ao_plugin_local_data.driver=(ao_functions_t*)arg;
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
44 return CONTROL_OK;
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
45 default:
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
46 return driver()->control(cmd,arg);
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
47 }
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
48 return CONTROL_UNKNOWN;
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
49 }
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
50
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
51 // Recursive function for adding plugins
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
52 // return 1 for success and 0 for error
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
53 int add_plugin(int i,char* cfg){
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
54 int cnt=0;
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
55 // Find end of plugin name
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
56 while((cfg[cnt]!=',')&&(cfg[cnt]!='\0')&&(cnt<100)) cnt++;
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
57 if(cnt >= 100)
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
58 return 0;
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
59
3680
2cc5737ec923 fix comment typo
steve
parents: 3486
diff changeset
60 // Is this the last iteration or just another plugin
3107
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
61 if(cfg[cnt]=='\0'){
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
62 ao_plugin_local_data.plugins=malloc((i+1)*sizeof(ao_plugin_functions_t*));
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
63 if(ao_plugin_local_data.plugins){
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
64 ao_plugin_local_data.plugins[i+1]=NULL;
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
65 // Find the plugin matching the cfg string name
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
66 cnt=0;
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
67 while(ao_plugin_local_data.available_plugins[cnt] && cnt<20){
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
68 if(0==strcmp(ao_plugin_local_data.available_plugins[cnt]->info->short_name,cfg)){
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
69 ao_plugin_local_data.plugins[i]=ao_plugin_local_data.available_plugins[cnt];
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
70 return 1;
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
71 }
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
72 cnt++;
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
73 }
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
74 printf("[plugin]: Invalid plugin: %s \n",cfg);
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
75 return 0;
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
76 }
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
77 else
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
78 return 0;
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
79 } else {
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
80 cfg[cnt]='\0';
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
81 if(add_plugin(i+1,&cfg[cnt+1])){
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
82 cnt=0;
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
83 // Find the plugin matching the cfg string name
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
84 while(ao_plugin_local_data.available_plugins[cnt] && cnt < 20){
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
85 if(0==strcmp(ao_plugin_local_data.available_plugins[cnt]->info->short_name,cfg)){
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
86 ao_plugin_local_data.plugins[i]=ao_plugin_local_data.available_plugins[cnt];
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
87 return 1;
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
88 }
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
89 cnt++;
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
90 }
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
91 printf("[plugin]: Invalid plugin: %s \n",cfg);
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
92 return 0;
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
93 }
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
94 else
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
95 return 0;
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
96 }
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
97 return 0; // Will never happen...
3096
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
98 }
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
99
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
100 // open & setup audio device and plugins
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
101 // return: 1=success 0=fail
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
102 static int init(int rate,int channels,int format,int flags){
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
103 int ok=1;
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
104
3107
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
105 /* Create list of plugins from cfg option */
3096
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
106 int i=0;
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents: 3107
diff changeset
107 if(ao_plugin_cfg.plugin_list){
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents: 3107
diff changeset
108 if(!add_plugin(i,ao_plugin_cfg.plugin_list))
3107
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
109 return 0;
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
110 }
3096
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
111
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
112 /* Set input parameters and itterate through plugins each plugin
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
113 changes the parameters according to its output */
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
114 ao_plugin_data.rate=rate;
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
115 ao_plugin_data.channels=channels;
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
116 ao_plugin_data.format=format;
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
117 ao_plugin_data.sz_mult=1;
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
118 ao_plugin_data.sz_fix=0;
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
119 ao_plugin_data.delay_mult=1;
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
120 ao_plugin_data.delay_fix=0;
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
121 i=0;
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
122 while(plugin(i)&&ok)
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
123 ok=plugin(i++)->init();
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
124
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
125 if(!ok) return 0;
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
126
3107
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
127 // This should never happen but check anyway
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
128 if(NULL==ao_plugin_local_data.driver)
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
129 return 0;
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
130
3096
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
131 ok = driver()->init(ao_plugin_data.rate,
3107
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
132 ao_plugin_data.channels,
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
133 ao_plugin_data.format,
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
134 flags);
3096
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
135 if(!ok) return 0;
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
136
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
137 /* Now that the driver is initialized we can calculate and set the
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
138 input and output buffers for each plugin */
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
139 ao_plugin_data.len=driver()->get_space();
3107
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
140 while((i>0) && ok)
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents: 3107
diff changeset
141 ok=plugin(--i)->control(AOCONTROL_PLUGIN_SET_LEN,0);
3107
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
142
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
143 if(!ok) return 0;
3096
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
144
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
145 return 1;
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
146 }
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
147
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
148 // close audio device
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
149 static void uninit(){
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
150 int i=0;
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
151 driver()->uninit();
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
152 while(plugin(i))
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
153 plugin(i++)->uninit();
3107
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
154 if(ao_plugin_local_data.plugins)
ef2287ccc42b Changes to audio out plugin, first plugin added
anders
parents: 3096
diff changeset
155 free(ao_plugin_local_data.plugins);
3096
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
156 }
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
157
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
158 // stop playing and empty buffers (for seeking/pause)
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
159 static void reset(){
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
160 int i=0;
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
161 driver()->reset();
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
162 while(plugin(i))
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
163 plugin(i++)->reset();
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
164 }
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
165
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
166 // stop playing, keep buffers (for pause)
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
167 static void audio_pause(){
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
168 driver()->pause();
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
169 }
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
170
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
171 // resume playing, after audio_pause()
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
172 static void audio_resume(){
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
173 driver()->resume();
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
174 }
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
175
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
176 // return: how many bytes can be played without blocking
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
177 static int get_space(){
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
178 double sz=(double)(driver()->get_space());
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
179 sz*=ao_plugin_data.sz_mult;
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
180 sz+=ao_plugin_data.sz_fix;
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
181 return (int)(sz);
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
182 }
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
183
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
184 // plays 'len' bytes of 'data'
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
185 // return: number of bytes played
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
186 static int play(void* data,int len,int flags){
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
187 int i=0;
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
188 /* Due to constant buffer sizes in plugins limit length */
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
189 int tmp = get_space();
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
190 int ret_len =(tmp<len)?tmp:len;
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
191 /* Filter data */
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
192 ao_plugin_data.len=ret_len;
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
193 ao_plugin_data.data=data;
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
194 while(plugin(i))
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
195 plugin(i++)->play();
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
196 /* Send data to output */
3486
9eaee0d257e1 add missing newline in warning message
steve
parents: 3308
diff changeset
197 //fprintf(stderr, "ao_plugin: ret_len=%d, len=%d\n", ret_len, len);
3096
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
198 len=driver()->play(ao_plugin_data.data,ao_plugin_data.len,flags);
3486
9eaee0d257e1 add missing newline in warning message
steve
parents: 3308
diff changeset
199 //fprintf(stderr, "ao_plugin: returned len=%d\n", len);
3096
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
200
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
201 if(len!=ao_plugin_data.len)
3486
9eaee0d257e1 add missing newline in warning message
steve
parents: 3308
diff changeset
202 fprintf(stderr,"[ao_plugin] Warning under or over flow in sound plugin\n");
3096
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
203
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
204 return ret_len;
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
205 }
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
206
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
207 // return: delay in seconds between first and last sample in buffer
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
208 static float get_delay(){
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
209 float delay=driver()->get_delay();
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
210 delay*=ao_plugin_data.delay_mult;
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
211 delay+=ao_plugin_data.delay_fix;
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
212 return delay;
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
213 }
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
214
15abd9121737 ao_plugin.c and plugin headers added
anders
parents:
diff changeset
215
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3194
diff changeset
216
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3194
diff changeset
217