mirror of
https://github.com/mpv-player/mpv
synced 2024-12-23 23:32:26 +00:00
Adding Support for non-reentrant audio filters
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@7616 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
735de60232
commit
ea698923eb
50
libaf/af.c
50
libaf/af.c
@ -41,8 +41,23 @@ af_info_t* af_find(char*name)
|
||||
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 @@ af_instance_t* af_create(char* name)
|
||||
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_create(char* name)
|
||||
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_prepend(af_stream_t* s, af_instance_t* af, char* name)
|
||||
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
|
||||
@ -213,19 +238,6 @@ int af_reinit(af_stream_t* s, af_instance_t* 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
|
||||
void af_uninit(af_stream_t* s)
|
||||
{
|
||||
|
@ -21,6 +21,10 @@ typedef struct frac_s
|
||||
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 @@ typedef struct af_info_s
|
||||
const char *name;
|
||||
const char *author;
|
||||
const char *comment;
|
||||
const int flags;
|
||||
int (*open)(struct af_instance_s* vf);
|
||||
} af_info_t;
|
||||
|
||||
|
@ -168,5 +168,6 @@ af_info_t af_info_channels = {
|
||||
"channels",
|
||||
"Anders",
|
||||
"",
|
||||
AF_FLAGS_REENTRANT,
|
||||
open
|
||||
};
|
||||
|
@ -140,6 +140,7 @@ af_info_t af_info_delay = {
|
||||
"delay",
|
||||
"Anders",
|
||||
"",
|
||||
AF_FLAGS_REENTRANT,
|
||||
open
|
||||
};
|
||||
|
||||
|
@ -56,5 +56,6 @@ af_info_t af_info_dummy = {
|
||||
"dummy",
|
||||
"Anders",
|
||||
"",
|
||||
AF_FLAGS_REENTRANT,
|
||||
open
|
||||
};
|
||||
|
@ -287,5 +287,6 @@ af_info_t af_info_format = {
|
||||
"format",
|
||||
"Anders",
|
||||
"",
|
||||
AF_FLAGS_REENTRANT,
|
||||
open
|
||||
};
|
||||
|
@ -331,6 +331,7 @@ af_info_t af_info_resample = {
|
||||
"resample",
|
||||
"Anders",
|
||||
"",
|
||||
AF_FLAGS_REENTRANT,
|
||||
open
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user