Mercurial > mplayer.hg
comparison libaf/af.c @ 29049:8c706ce21c6f
Remove af_msg special-casing API in libaf.
Replace it by standard mp_msg message system.
author | bircoph |
---|---|
date | Sat, 28 Mar 2009 19:57:56 +0000 |
parents | 595d419c0610 |
children | 290420c32921 |
comparison
equal
deleted
inserted
replaced
29048:584ff003cce9 | 29049:8c706ce21c6f |
---|---|
89 &af_info_scaletempo, | 89 &af_info_scaletempo, |
90 &af_info_stats, | 90 &af_info_stats, |
91 NULL | 91 NULL |
92 }; | 92 }; |
93 | 93 |
94 // Message printing | |
95 af_msg_cfg_t af_msg_cfg={0,NULL,NULL}; | |
96 | |
97 // CPU speed | 94 // CPU speed |
98 int* af_cpu_speed = NULL; | 95 int* af_cpu_speed = NULL; |
99 | 96 |
100 /* Find a filter in the static list of filters using it's name. This | 97 /* Find a filter in the static list of filters using it's name. This |
101 function is used internally */ | 98 function is used internally */ |
105 while(filter_list[i]){ | 102 while(filter_list[i]){ |
106 if(!strcmp(filter_list[i]->name,name)) | 103 if(!strcmp(filter_list[i]->name,name)) |
107 return filter_list[i]; | 104 return filter_list[i]; |
108 i++; | 105 i++; |
109 } | 106 } |
110 af_msg(AF_MSG_ERROR,"Couldn't find audio filter '%s'\n",name); | 107 mp_msg(MSGT_AFILTER, MSGL_ERR, "Couldn't find audio filter '%s'\n",name); |
111 return NULL; | 108 return NULL; |
112 } | 109 } |
113 | 110 |
114 /* Find filter in the dynamic filter list using it's name This | 111 /* Find filter in the dynamic filter list using it's name This |
115 function is used for finding already initialized filters */ | 112 function is used for finding already initialized filters */ |
133 char* cmdline = name; | 130 char* cmdline = name; |
134 | 131 |
135 // Allocate space for the new filter and reset all pointers | 132 // Allocate space for the new filter and reset all pointers |
136 af_instance_t* new=malloc(sizeof(af_instance_t)); | 133 af_instance_t* new=malloc(sizeof(af_instance_t)); |
137 if (!name || !new) { | 134 if (!name || !new) { |
138 af_msg(AF_MSG_ERROR,"[libaf] Could not allocate memory\n"); | 135 mp_msg(MSGT_AFILTER, MSGL_ERR, "[libaf] Could not allocate memory\n"); |
139 goto err_out; | 136 goto err_out; |
140 } | 137 } |
141 memset(new,0,sizeof(af_instance_t)); | 138 memset(new,0,sizeof(af_instance_t)); |
142 | 139 |
143 // Check for commandline parameters | 140 // Check for commandline parameters |
149 | 146 |
150 /* Make sure that the filter is not already in the list if it is | 147 /* Make sure that the filter is not already in the list if it is |
151 non-reentrant */ | 148 non-reentrant */ |
152 if(new->info->flags & AF_FLAGS_NOT_REENTRANT){ | 149 if(new->info->flags & AF_FLAGS_NOT_REENTRANT){ |
153 if(af_get(s,name)){ | 150 if(af_get(s,name)){ |
154 af_msg(AF_MSG_ERROR,"[libaf] There can only be one instance of" | 151 mp_msg(MSGT_AFILTER, MSGL_ERR, "[libaf] There can only be one instance of" |
155 " the filter '%s' in each stream\n",name); | 152 " the filter '%s' in each stream\n",name); |
156 goto err_out; | 153 goto err_out; |
157 } | 154 } |
158 } | 155 } |
159 | 156 |
160 af_msg(AF_MSG_VERBOSE,"[libaf] Adding filter %s \n",name); | 157 mp_msg(MSGT_AFILTER, MSGL_V, "[libaf] Adding filter %s \n",name); |
161 | 158 |
162 // Initialize the new filter | 159 // Initialize the new filter |
163 if(AF_OK == new->info->open(new) && | 160 if(AF_OK == new->info->open(new) && |
164 AF_ERROR < new->control(new,AF_CONTROL_POST_CREATE,&s->cfg)){ | 161 AF_ERROR < new->control(new,AF_CONTROL_POST_CREATE,&s->cfg)){ |
165 if(cmdline){ | 162 if(cmdline){ |
170 return new; | 167 return new; |
171 } | 168 } |
172 | 169 |
173 err_out: | 170 err_out: |
174 free(new); | 171 free(new); |
175 af_msg(AF_MSG_ERROR,"[libaf] Couldn't create or open audio filter '%s'\n", | 172 mp_msg(MSGT_AFILTER, MSGL_ERR, "[libaf] Couldn't create or open audio filter '%s'\n", |
176 name); | 173 name); |
177 free(name); | 174 free(name); |
178 return NULL; | 175 return NULL; |
179 } | 176 } |
180 | 177 |
230 void af_remove(af_stream_t* s, af_instance_t* af) | 227 void af_remove(af_stream_t* s, af_instance_t* af) |
231 { | 228 { |
232 if(!af) return; | 229 if(!af) return; |
233 | 230 |
234 // Print friendly message | 231 // Print friendly message |
235 af_msg(AF_MSG_VERBOSE,"[libaf] Removing filter %s \n",af->info->name); | 232 mp_msg(MSGT_AFILTER, MSGL_V, "[libaf] Removing filter %s \n",af->info->name); |
236 | 233 |
237 // Notify filter before changing anything | 234 // Notify filter before changing anything |
238 af->control(af,AF_CONTROL_PRE_DESTROY,0); | 235 af->control(af,AF_CONTROL_PRE_DESTROY,0); |
239 | 236 |
240 // Detach pointers | 237 // Detach pointers |
319 memcpy(&in,new->prev->data,sizeof(af_data_t)); | 316 memcpy(&in,new->prev->data,sizeof(af_data_t)); |
320 if(AF_OK != (rv = new->control(new,AF_CONTROL_REINIT,&in))) | 317 if(AF_OK != (rv = new->control(new,AF_CONTROL_REINIT,&in))) |
321 return rv; | 318 return rv; |
322 } | 319 } |
323 if(!new){ // Should _never_ happen | 320 if(!new){ // Should _never_ happen |
324 af_msg(AF_MSG_ERROR,"[libaf] Unable to correct audio format. " | 321 mp_msg(MSGT_AFILTER, MSGL_ERR, "[libaf] Unable to correct audio format. " |
325 "This error should never uccur, please send bugreport.\n"); | 322 "This error should never uccur, please send bugreport.\n"); |
326 return AF_ERROR; | 323 return AF_ERROR; |
327 } | 324 } |
328 af=new->next; | 325 af=new->next; |
329 } | 326 } |
330 else { | 327 else { |
331 af_msg(AF_MSG_ERROR, "[libaf] Automatic filter insertion disabled " | 328 mp_msg(MSGT_AFILTER, MSGL_ERR, "[libaf] Automatic filter insertion disabled " |
332 "but formats do not match. Giving up.\n"); | 329 "but formats do not match. Giving up.\n"); |
333 return AF_ERROR; | 330 return AF_ERROR; |
334 } | 331 } |
335 break; | 332 break; |
336 } | 333 } |
345 af=s->first; // Restart configuration | 342 af=s->first; // Restart configuration |
346 } | 343 } |
347 break; | 344 break; |
348 } | 345 } |
349 default: | 346 default: |
350 af_msg(AF_MSG_ERROR,"[libaf] Reinitialization did not work, audio" | 347 mp_msg(MSGT_AFILTER, MSGL_ERR, "[libaf] Reinitialization did not work, audio" |
351 " filter '%s' returned error code %i\n",af->info->name,rv); | 348 " filter '%s' returned error code %i\n",af->info->name,rv); |
352 return AF_ERROR; | 349 return AF_ERROR; |
353 } | 350 } |
354 }while(af); | 351 }while(af); |
355 return AF_OK; | 352 return AF_OK; |
496 if (!s->output.rate) s->output.rate = s->last->data->rate; | 493 if (!s->output.rate) s->output.rate = s->last->data->rate; |
497 if((s->last->data->format != s->output.format) || | 494 if((s->last->data->format != s->output.format) || |
498 (s->last->data->nch != s->output.nch) || | 495 (s->last->data->nch != s->output.nch) || |
499 (s->last->data->rate != s->output.rate)) { | 496 (s->last->data->rate != s->output.rate)) { |
500 // Something is stuffed audio out will not work | 497 // Something is stuffed audio out will not work |
501 af_msg(AF_MSG_ERROR,"[libaf] Unable to setup filter system can not" | 498 mp_msg(MSGT_AFILTER, MSGL_ERR, "[libaf] Unable to setup filter system can not" |
502 " meet sound-card demands, please send bugreport. \n"); | 499 " meet sound-card demands, please send bugreport. \n"); |
503 af_uninit(s); | 500 af_uninit(s); |
504 return -1; | 501 return -1; |
505 } | 502 } |
506 } | 503 } |
587 function should not be called directly */ | 584 function should not be called directly */ |
588 int af_resize_local_buffer(af_instance_t* af, af_data_t* data) | 585 int af_resize_local_buffer(af_instance_t* af, af_data_t* data) |
589 { | 586 { |
590 // Calculate new length | 587 // Calculate new length |
591 register int len = af_lencalc(af->mul,data); | 588 register int len = af_lencalc(af->mul,data); |
592 af_msg(AF_MSG_VERBOSE,"[libaf] Reallocating memory in module %s, " | 589 mp_msg(MSGT_AFILTER, MSGL_V, "[libaf] Reallocating memory in module %s, " |
593 "old len = %i, new len = %i\n",af->info->name,af->data->len,len); | 590 "old len = %i, new len = %i\n",af->info->name,af->data->len,len); |
594 // If there is a buffer free it | 591 // If there is a buffer free it |
595 if(af->data->audio) | 592 if(af->data->audio) |
596 free(af->data->audio); | 593 free(af->data->audio); |
597 // Create new buffer and check that it is OK | 594 // Create new buffer and check that it is OK |
598 af->data->audio = malloc(len); | 595 af->data->audio = malloc(len); |
599 if(!af->data->audio){ | 596 if(!af->data->audio){ |
600 af_msg(AF_MSG_FATAL,"[libaf] Could not allocate memory \n"); | 597 mp_msg(MSGT_AFILTER, MSGL_FATAL, "[libaf] Could not allocate memory \n"); |
601 return AF_ERROR; | 598 return AF_ERROR; |
602 } | 599 } |
603 af->data->len=len; | 600 af->data->len=len; |
604 return AF_OK; | 601 return AF_OK; |
605 } | 602 } |
617 return NULL; | 614 return NULL; |
618 } | 615 } |
619 | 616 |
620 void af_help (void) { | 617 void af_help (void) { |
621 int i = 0; | 618 int i = 0; |
622 af_msg(AF_MSG_INFO, "Available audio filters:\n"); | 619 mp_msg(MSGT_AFILTER, MSGL_INFO, "Available audio filters:\n"); |
623 while (filter_list[i]) { | 620 while (filter_list[i]) { |
624 if (filter_list[i]->comment && filter_list[i]->comment[0]) | 621 if (filter_list[i]->comment && filter_list[i]->comment[0]) |
625 af_msg(AF_MSG_INFO, " %-15s: %s (%s)\n", filter_list[i]->name, filter_list[i]->info, filter_list[i]->comment); | 622 mp_msg(MSGT_AFILTER, MSGL_INFO, " %-15s: %s (%s)\n", filter_list[i]->name, filter_list[i]->info, filter_list[i]->comment); |
626 else | 623 else |
627 af_msg(AF_MSG_INFO, " %-15s: %s\n", filter_list[i]->name, filter_list[i]->info); | 624 mp_msg(MSGT_AFILTER, MSGL_INFO, " %-15s: %s\n", filter_list[i]->name, filter_list[i]->info); |
628 i++; | 625 i++; |
629 } | 626 } |
630 } | 627 } |
631 | 628 |
632 void af_fix_parameters(af_data_t *data) | 629 void af_fix_parameters(af_data_t *data) |