[Mplayer-cvslog] CVS: main/libaf af.c,1.9,1.10 af.h,1.5,1.6 af_channels.c,1.4,1.5 af_delay.c,1.1,1.2 af_dummy.c,1.1,1.2 af_format.c,1.2,1.3 af_resample.c,1.6,1.7

Anders Johansson anders at mplayerhq.hu
Sun Oct 6 13:26:17 CEST 2002


Update of /cvsroot/mplayer/main/libaf
In directory mail:/var/tmp.root/cvs-serv9126

Modified Files:
	af.c af.h af_channels.c af_delay.c af_dummy.c af_format.c 
	af_resample.c 
Log Message:
Adding Support for non-reentrant audio filters

Index: af.c
===================================================================
RCS file: /cvsroot/mplayer/main/libaf/af.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- af.c	6 Oct 2002 10:42:24 -0000	1.9
+++ af.c	6 Oct 2002 11:26:14 -0000	1.10
@@ -41,8 +41,23 @@
   return NULL;
 } 
 
+/* Find filter in the dynamic filter list using it's name This
+   function is used for finding already initialized filters */
+af_instance_t* af_get(af_stream_t* s, char* name)
+{
+  af_instance_t* af=s->first; 
+  // Find the filter
+  while(af != NULL){
+    printf("%s\n",af->info->name);
+    if(!strcmp(af->info->name,name))
+      return af;
+    af=af->next;
+  }
+  return NULL;
+}
+
 // Function for creating a new filter of type name
-af_instance_t* af_create(char* name)
+af_instance_t* af_create(af_stream_t* s, char* name)
 {
   // Allocate space for the new filter and reset all pointers
   af_instance_t* new=malloc(sizeof(af_instance_t));
@@ -53,10 +68,20 @@
   memset(new,0,sizeof(af_instance_t));
 
   // Find filter from name
-  new->info=af_find(name);
-    
+  if(NULL == (new->info=af_find(name)))
+    return NULL;
+
+  // Make sure that the filter is not already in the list if it is non-reentrant
+  if(new->info->flags & AF_FLAGS_NOT_REENTRANT){
+    if(af_get(s,name)){
+      mp_msg(MSGT_AFILTER,MSGL_ERR,"There can only be one instance of the filter '%s' in each stream\n",name);  
+      free(new);
+      return NULL;
+    }
+  }
+
   // Initialize the new filter
-  if(new->info && (AF_OK==new->info->open(new))) 
+  if(AF_OK==new->info->open(new)) 
     return new;
 
   free(new);
@@ -70,7 +95,7 @@
 af_instance_t* af_prepend(af_stream_t* s, af_instance_t* af, char* name)
 {
   // Create the new filter and make sure it is OK
-  af_instance_t* new=af_create(name);
+  af_instance_t* new=af_create(s,name);
   if(!new)
     return NULL;
   // Update pointers
@@ -94,7 +119,7 @@
 af_instance_t* af_append(af_stream_t* s, af_instance_t* af, char* name)
 {
   // Create the new filter and make sure it is OK
-  af_instance_t* new=af_create(name);
+  af_instance_t* new=af_create(s,name);
   if(!new)
     return NULL;
   // Update pointers
@@ -211,19 +236,6 @@
     af=af->next;
   }while(af);
   return AF_OK;
-}
-
-/* Find filter in the dynamic filter list using it's name This
-   function is used for finding already initialized filters */
-af_instance_t* af_get(af_stream_t* s, char* name)
-{
-  af_instance_t* af=s->first; 
-  while(af->next != NULL){
-    if(!strcmp(af->info->name,name))
-      return af;
-    af=af->next;
-  }
-  return NULL;
 }
 
 // Uninit and remove all filters

Index: af.h
===================================================================
RCS file: /cvsroot/mplayer/main/libaf/af.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- af.h	5 Oct 2002 11:02:39 -0000	1.5
+++ af.h	6 Oct 2002 11:26:14 -0000	1.6
@@ -21,6 +21,10 @@
   int d; // Denominator
 } frac_t;
 
+// Flags used for defining the behavour of an audio filter
+#define AF_FLAGS_REENTRANT 	0x00000000
+#define AF_FLAGS_NOT_REENTRANT 	0x00000001
+
 /* Audio filter information not specific for current instance, but for
    a specific filter */ 
 typedef struct af_info_s 
@@ -29,6 +33,7 @@
   const char *name;
   const char *author;
   const char *comment;
+  const int flags;
   int (*open)(struct af_instance_s* vf);
 } af_info_t;
 

Index: af_channels.c
===================================================================
RCS file: /cvsroot/mplayer/main/libaf/af_channels.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- af_channels.c	3 Oct 2002 12:43:39 -0000	1.4
+++ af_channels.c	6 Oct 2002 11:26:14 -0000	1.5
@@ -168,5 +168,6 @@
   "channels",
   "Anders",
   "",
+  AF_FLAGS_REENTRANT,
   open
 };

Index: af_delay.c
===================================================================
RCS file: /cvsroot/mplayer/main/libaf/af_delay.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- af_delay.c	1 Oct 2002 06:45:08 -0000	1.1
+++ af_delay.c	6 Oct 2002 11:26:14 -0000	1.2
@@ -140,6 +140,7 @@
     "delay",
     "Anders",
     "",
+    AF_FLAGS_REENTRANT,
     open
 };
 

Index: af_dummy.c
===================================================================
RCS file: /cvsroot/mplayer/main/libaf/af_dummy.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- af_dummy.c	1 Oct 2002 06:45:08 -0000	1.1
+++ af_dummy.c	6 Oct 2002 11:26:14 -0000	1.2
@@ -56,5 +56,6 @@
     "dummy",
     "Anders",
     "",
+    AF_FLAGS_REENTRANT,
     open
 };

Index: af_format.c
===================================================================
RCS file: /cvsroot/mplayer/main/libaf/af_format.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- af_format.c	1 Oct 2002 12:53:30 -0000	1.2
+++ af_format.c	6 Oct 2002 11:26:14 -0000	1.3
@@ -287,5 +287,6 @@
   "format",
   "Anders",
   "",
+  AF_FLAGS_REENTRANT,
   open
 };

Index: af_resample.c
===================================================================
RCS file: /cvsroot/mplayer/main/libaf/af_resample.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- af_resample.c	5 Oct 2002 22:53:21 -0000	1.6
+++ af_resample.c	6 Oct 2002 11:26:14 -0000	1.7
@@ -331,6 +331,7 @@
   "resample",
   "Anders",
   "",
+  AF_FLAGS_REENTRANT,
   open
 };
 




More information about the MPlayer-cvslog mailing list