diff 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
line wrap: on
line diff
--- a/libaf/af.c	Tue Oct 15 13:51:46 2002 +0000
+++ b/libaf/af.c	Wed Oct 16 01:49:40 2002 +0000
@@ -80,9 +80,10 @@
   }
 
   // Initialize the new filter
-  if(AF_OK==new->info->open(new)) 
+  if(AF_OK == new->info->open(new) && 
+     AF_ERROR < new->control(new,AF_CONTROL_POST_CREATE,&s->cfg))
     return new;
-
+  
   free(new);
   mp_msg(MSGT_AFILTER,MSGL_ERR,"Couldn't create audio filter '%s'\n",name);  
   return NULL;
@@ -141,6 +142,9 @@
 {
   if(!af) return;
 
+  // Notify filter before changing anything
+  af->control(af,AF_CONTROL_PRE_DESTROY,0);
+
   // Detach pointers
   if(af->prev)
     af->prev->next=af->next;
@@ -255,7 +259,6 @@
    -1 if failure */
 int af_init(af_stream_t* s)
 {
-  int cfg=SLOW;  // configuration type
   int i=0;
 
   // Sanity check
@@ -266,13 +269,11 @@
   s->input.len    = s->output.len    = 0;
 
   // Figure out how fast the machine is
-  if(s->cfg.force)
-    cfg=s->cfg.force;
-  else{
+  if(AF_INIT_AUTO == (AF_INIT_TYPE_MASK & s->cfg.force)){
 #    if defined(HAVE_SSE) || defined(HAVE_3DNOWEX)
-      cfg=FAST;
+    s->cfg.force = (s->cfg.force & ~AF_INIT_TYPE_MASK) | AF_INIT_FAST;
 #    else
-      cfg=SLOW;
+    s->cfg.force = (s->cfg.force & ~AF_INIT_TYPE_MASK) | AF_INIT_SLOW;
 #    endif
   }
 
@@ -296,12 +297,12 @@
     return -1;
 
   // Check output format
-  if(cfg!=FORCE){
+  if((AF_INIT_TYPE_MASK & s->cfg.force) != AF_INIT_FORCE){
     af_instance_t* af = NULL; // New filter
     // Check output frequency if not OK fix with resample
     if(s->last->data->rate!=s->output.rate){
       if(NULL==(af=af_get(s,"resample"))){
-	if(cfg==SLOW){
+	if((AF_INIT_TYPE_MASK & s->cfg.force) == AF_INIT_SLOW){
 	  if(!strcmp(s->first->info->name,"format"))
 	    af = af_append(s,s->first,"resample");
 	  else