1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-20 22:02:59 +00:00

change list traversal so the loop begins at the first filter after removing

one, instead at the second


git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@15192 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
henry 2005-04-16 16:48:15 +00:00
parent 9946de0944
commit 4ad21b2d7e

View File

@ -224,13 +224,18 @@ void af_remove(af_stream_t* s, af_instance_t* af)
failure */ failure */
int af_reinit(af_stream_t* s, af_instance_t* af) int af_reinit(af_stream_t* s, af_instance_t* af)
{ {
if(!af)
return AF_ERROR;
do{ do{
af_data_t in; // Format of the input to current filter af_data_t in; // Format of the input to current filter
int rv=0; // Return value int rv=0; // Return value
// Check if there are any filters left in the list
if(NULL == af){
if(!(af=af_append(s,s->first,"dummy")))
return AF_UNKNOWN;
else
return AF_ERROR;
}
// Check if this is the first filter // Check if this is the first filter
if(!af->prev) if(!af->prev)
memcpy(&in,&(s->input),sizeof(af_data_t)); memcpy(&in,&(s->input),sizeof(af_data_t));
@ -243,6 +248,7 @@ int af_reinit(af_stream_t* s, af_instance_t* af)
rv = af->control(af,AF_CONTROL_REINIT,&in); rv = af->control(af,AF_CONTROL_REINIT,&in);
switch(rv){ switch(rv){
case AF_OK: case AF_OK:
af = af->next;
break; break;
case AF_FALSE:{ // Configuration filter is needed case AF_FALSE:{ // Configuration filter is needed
// Do auto insertion only if force is not specified // Do auto insertion only if force is not specified
@ -286,7 +292,7 @@ int af_reinit(af_stream_t* s, af_instance_t* af)
"This error should never uccur, please send bugreport.\n"); "This error should never uccur, please send bugreport.\n");
return AF_ERROR; return AF_ERROR;
} }
af=new; af=new->next;
} }
break; break;
} }
@ -296,7 +302,7 @@ int af_reinit(af_stream_t* s, af_instance_t* af)
af_instance_t* aft=af->prev; af_instance_t* aft=af->prev;
af_remove(s,af); af_remove(s,af);
if(aft) if(aft)
af=aft; af=aft->next;
else else
af=s->first; // Restart configuration af=s->first; // Restart configuration
} }
@ -307,13 +313,6 @@ int af_reinit(af_stream_t* s, af_instance_t* af)
" filter '%s' returned error code %i\n",af->info->name,rv); " filter '%s' returned error code %i\n",af->info->name,rv);
return AF_ERROR; return AF_ERROR;
} }
// Check if there are any filters left in the list
if(NULL == af){
if(!(af=af_append(s,s->first,"dummy")))
return -1;
}
else
af=af->next;
}while(af); }while(af);
return AF_OK; return AF_OK;
} }
@ -402,7 +401,7 @@ int af_init(af_stream_t* s, int force_output)
af = af_append(s,s->last,resampler); af = af_append(s,s->last,resampler);
} }
// Init the new filter // Init the new filter
if(!af || (AF_OK != af->control(af,AF_CONTROL_RESAMPLE_RATE, if(!af || (AF_OK != af->control(af,AF_CONTROL_RESAMPLE_RATE | AF_CONTROL_SET,
&(s->output.rate)))) &(s->output.rate))))
return -1; return -1;
// Use lin int if the user wants fast // Use lin int if the user wants fast