comparison libaf/af.c @ 7745:1d3a3dc1f488

Adding volume control and moving control() call parameters to a seperate file
author anders
date Wed, 16 Oct 2002 01:49:40 +0000
parents fbd5445cc853
children db1f16543379
comparison
equal deleted inserted replaced
7744:6d41f5e905e2 7745:1d3a3dc1f488
78 return NULL; 78 return NULL;
79 } 79 }
80 } 80 }
81 81
82 // Initialize the new filter 82 // Initialize the new filter
83 if(AF_OK==new->info->open(new)) 83 if(AF_OK == new->info->open(new) &&
84 AF_ERROR < new->control(new,AF_CONTROL_POST_CREATE,&s->cfg))
84 return new; 85 return new;
85 86
86 free(new); 87 free(new);
87 mp_msg(MSGT_AFILTER,MSGL_ERR,"Couldn't create audio filter '%s'\n",name); 88 mp_msg(MSGT_AFILTER,MSGL_ERR,"Couldn't create audio filter '%s'\n",name);
88 return NULL; 89 return NULL;
89 } 90 }
90 91
138 139
139 // Uninit and remove the filter "af" 140 // Uninit and remove the filter "af"
140 void af_remove(af_stream_t* s, af_instance_t* af) 141 void af_remove(af_stream_t* s, af_instance_t* af)
141 { 142 {
142 if(!af) return; 143 if(!af) return;
144
145 // Notify filter before changing anything
146 af->control(af,AF_CONTROL_PRE_DESTROY,0);
143 147
144 // Detach pointers 148 // Detach pointers
145 if(af->prev) 149 if(af->prev)
146 af->prev->next=af->next; 150 af->prev->next=af->next;
147 else 151 else
253 reentrant i.e. if called with an already initialized stream the 257 reentrant i.e. if called with an already initialized stream the
254 stream will be reinitialized. The return value is 0 if success and 258 stream will be reinitialized. The return value is 0 if success and
255 -1 if failure */ 259 -1 if failure */
256 int af_init(af_stream_t* s) 260 int af_init(af_stream_t* s)
257 { 261 {
258 int cfg=SLOW; // configuration type
259 int i=0; 262 int i=0;
260 263
261 // Sanity check 264 // Sanity check
262 if(!s) return -1; 265 if(!s) return -1;
263 266
264 // Precaution in case caller is misbehaving 267 // Precaution in case caller is misbehaving
265 s->input.audio = s->output.audio = NULL; 268 s->input.audio = s->output.audio = NULL;
266 s->input.len = s->output.len = 0; 269 s->input.len = s->output.len = 0;
267 270
268 // Figure out how fast the machine is 271 // Figure out how fast the machine is
269 if(s->cfg.force) 272 if(AF_INIT_AUTO == (AF_INIT_TYPE_MASK & s->cfg.force)){
270 cfg=s->cfg.force;
271 else{
272 # if defined(HAVE_SSE) || defined(HAVE_3DNOWEX) 273 # if defined(HAVE_SSE) || defined(HAVE_3DNOWEX)
273 cfg=FAST; 274 s->cfg.force = (s->cfg.force & ~AF_INIT_TYPE_MASK) | AF_INIT_FAST;
274 # else 275 # else
275 cfg=SLOW; 276 s->cfg.force = (s->cfg.force & ~AF_INIT_TYPE_MASK) | AF_INIT_SLOW;
276 # endif 277 # endif
277 } 278 }
278 279
279 // Check if this is the first call 280 // Check if this is the first call
280 if(!s->first){ 281 if(!s->first){
294 // Init filters 295 // Init filters
295 if(AF_OK != af_reinit(s,s->first)) 296 if(AF_OK != af_reinit(s,s->first))
296 return -1; 297 return -1;
297 298
298 // Check output format 299 // Check output format
299 if(cfg!=FORCE){ 300 if((AF_INIT_TYPE_MASK & s->cfg.force) != AF_INIT_FORCE){
300 af_instance_t* af = NULL; // New filter 301 af_instance_t* af = NULL; // New filter
301 // Check output frequency if not OK fix with resample 302 // Check output frequency if not OK fix with resample
302 if(s->last->data->rate!=s->output.rate){ 303 if(s->last->data->rate!=s->output.rate){
303 if(NULL==(af=af_get(s,"resample"))){ 304 if(NULL==(af=af_get(s,"resample"))){
304 if(cfg==SLOW){ 305 if((AF_INIT_TYPE_MASK & s->cfg.force) == AF_INIT_SLOW){
305 if(!strcmp(s->first->info->name,"format")) 306 if(!strcmp(s->first->info->name,"format"))
306 af = af_append(s,s->first,"resample"); 307 af = af_append(s,s->first,"resample");
307 else 308 else
308 af = af_prepend(s,s->first,"resample"); 309 af = af_prepend(s,s->first,"resample");
309 } 310 }