Mercurial > mplayer.hg
comparison libao2/ao_plugin.c @ 3194:1648d11fc36c
commandline configuration of audio plugins now through struct, format conversion plugin added
author | anders |
---|---|
date | Thu, 29 Nov 2001 12:44:06 +0000 |
parents | ef2287ccc42b |
children | d6ea11bed983 |
comparison
equal
deleted
inserted
replaced
3193:53a6d2fc1498 | 3194:1648d11fc36c |
---|---|
1 #include <stdio.h> | 1 #include <stdio.h> |
2 #include <stdlib.h> | 2 #include <stdlib.h> |
3 | 3 |
4 #include "../config.h" | 4 #include "../config.h" |
5 | 5 |
6 #include "afmt.h" | |
6 #include "audio_out.h" | 7 #include "audio_out.h" |
7 #include "audio_out_internal.h" | 8 #include "audio_out_internal.h" |
8 | 9 |
9 #include "audio_plugin.h" | 10 #include "audio_plugin.h" |
10 | 11 |
19 LIBAO_EXTERN(plugin) | 20 LIBAO_EXTERN(plugin) |
20 | 21 |
21 #define plugin(i) (ao_plugin_local_data.plugins[i]) | 22 #define plugin(i) (ao_plugin_local_data.plugins[i]) |
22 #define driver() (ao_plugin_local_data.driver) | 23 #define driver() (ao_plugin_local_data.driver) |
23 | 24 |
24 #define NPL 2 //Number of PLugins | |
25 | |
26 extern ao_plugin_functions_t audio_plugin_delay; | |
27 | |
28 // local data | 25 // local data |
29 typedef struct ao_plugin_local_data_s | 26 typedef struct ao_plugin_local_data_s |
30 { | 27 { |
31 char* cfg_plugins; // List of plugins read from cfg-file | |
32 ao_functions_t* driver; // Output driver set in mplayer.c | 28 ao_functions_t* driver; // Output driver set in mplayer.c |
33 ao_plugin_functions_t** plugins; // List of used plugins | 29 ao_plugin_functions_t** plugins; // List of used plugins |
34 ao_plugin_functions_t* available_plugins[NPL]; // List of abailabel plugins | 30 ao_plugin_functions_t* available_plugins[NPL]; // List of available plugins |
35 } ao_plugin_local_data_t; | 31 } ao_plugin_local_data_t; |
36 | 32 |
37 ao_plugin_local_data_t ao_plugin_local_data={ | 33 ao_plugin_local_data_t ao_plugin_local_data={NULL,NULL,AO_PLUGINS}; |
38 NULL, | |
39 NULL, | |
40 NULL, | |
41 { | |
42 &audio_plugin_delay, | |
43 NULL | |
44 } | |
45 }; | |
46 | 34 |
47 // gloabal data | 35 // gloabal data |
48 ao_plugin_data_t ao_plugin_data; | 36 ao_plugin_data_t ao_plugin_data; // data used by the plugins |
49 | 37 ao_plugin_cfg_t ao_plugin_cfg=CFG_DEFAULTS; // cfg data set in cfg-mplayer.h |
50 | 38 |
51 // to set/get/query special features/parameters | 39 // to set/get/query special features/parameters |
52 static int control(int cmd,int arg){ | 40 static int control(int cmd,int arg){ |
53 switch(cmd){ | 41 switch(cmd){ |
54 case AOCONTROL_SET_PLUGIN_DRIVER: | 42 case AOCONTROL_SET_PLUGIN_DRIVER: |
55 ao_plugin_local_data.driver=(ao_functions_t*)arg; | 43 ao_plugin_local_data.driver=(ao_functions_t*)arg; |
56 return CONTROL_OK; | |
57 case AOCONTROL_SET_PLUGIN_LIST: | |
58 ao_plugin_local_data.cfg_plugins=(char*)arg; | |
59 return CONTROL_OK; | 44 return CONTROL_OK; |
60 default: | 45 default: |
61 return driver()->control(cmd,arg); | 46 return driver()->control(cmd,arg); |
62 } | 47 } |
63 return CONTROL_UNKNOWN; | 48 return CONTROL_UNKNOWN; |
117 static int init(int rate,int channels,int format,int flags){ | 102 static int init(int rate,int channels,int format,int flags){ |
118 int ok=1; | 103 int ok=1; |
119 | 104 |
120 /* Create list of plugins from cfg option */ | 105 /* Create list of plugins from cfg option */ |
121 int i=0; | 106 int i=0; |
122 if(ao_plugin_local_data.cfg_plugins){ | 107 if(ao_plugin_cfg.plugin_list){ |
123 if(!add_plugin(i,ao_plugin_local_data.cfg_plugins)) | 108 if(!add_plugin(i,ao_plugin_cfg.plugin_list)) |
124 return 0; | 109 return 0; |
125 } | 110 } |
126 | 111 |
127 /* Set input parameters and itterate through plugins each plugin | 112 /* Set input parameters and itterate through plugins each plugin |
128 changes the parameters according to its output */ | 113 changes the parameters according to its output */ |
151 | 136 |
152 /* Now that the driver is initialized we can calculate and set the | 137 /* Now that the driver is initialized we can calculate and set the |
153 input and output buffers for each plugin */ | 138 input and output buffers for each plugin */ |
154 ao_plugin_data.len=driver()->get_space(); | 139 ao_plugin_data.len=driver()->get_space(); |
155 while((i>0) && ok) | 140 while((i>0) && ok) |
156 ok=plugin(--i)->control(AOCONTROL_PLUGIN_SET_LEN,ao_plugin_data.len); | 141 ok=plugin(--i)->control(AOCONTROL_PLUGIN_SET_LEN,0); |
157 | 142 |
158 if(!ok) return 0; | 143 if(!ok) return 0; |
159 | 144 |
160 return 1; | 145 return 1; |
161 } | 146 } |