| | 353 | |
| | 354 | if((AF_INIT_TYPE_MASK & s->cfg.force) != AF_INIT_FORCE){ |
| | 355 | // Check number of output channels fix if not OK |
| | 356 | // If needed always inserted last -> easy to screw up other filters |
| | 357 | if(s->output.nch && s->last->data->nch!=s->output.nch){ |
| | 358 | if(!strcmp(s->last->info->name,"format")) |
| | 359 | new = af_prepend(s,s->last,"channels"); |
| | 360 | else |
| | 361 | new = af_append(s,s->last,"channels"); |
| | 362 | // Init the new filter |
| | 363 | if(NULL == new) |
| | 364 | return AF_ERROR; |
| | 365 | if(AF_OK != (rv = new->control(new,AF_CONTROL_CHANNELS,&(s->output.nch)))) |
| | 366 | return rv; |
| | 367 | if(AF_OK != (rv = af_reinit(s,new))) |
| | 368 | return rv; |
| | 369 | } |
| | 370 | |
| | 371 | // Check output format fix if not OK |
| | 372 | if(s->output.format != AF_FORMAT_UNKNOWN && |
| | 373 | s->last->data->format != s->output.format){ |
| | 374 | if(strcmp(s->last->info->name,"format")){ |
| | 375 | if(NULL == (new = af_append(s,s->last,"format"))) |
| | 376 | return AF_ERROR; |
| | 377 | } |
| | 378 | else |
| | 379 | new = s->last; |
| | 380 | // Set output bits per sample |
| | 381 | s->output.format |= af_bits2fmt(s->output.bps*8); |
| | 382 | if(AF_OK != (rv = new->control(new,AF_CONTROL_FORMAT_FMT,&(s->output.format)))) |
| | 383 | return rv; |
| | 384 | if(AF_OK != (rv = af_reinit(s, new))) |
| | 385 | return rv; |
| | 386 | } |
| | 387 | } |
| | 388 | |
| 458 | | // Check number of output channels fix if not OK |
| 459 | | // If needed always inserted last -> easy to screw up other filters |
| 460 | | if(s->output.nch && s->last->data->nch!=s->output.nch){ |
| 461 | | if(!strcmp(s->last->info->name,"format")) |
| 462 | | af = af_prepend(s,s->last,"channels"); |
| 463 | | else |
| 464 | | af = af_append(s,s->last,"channels"); |
| 465 | | // Init the new filter |
| 466 | | if(!af || (AF_OK != af->control(af,AF_CONTROL_CHANNELS,&(s->output.nch)))) |
| 467 | | return -1; |
| 468 | | if(AF_OK != af_reinit(s,af)) |
| 469 | | return -1; |
| 470 | | } |
| 471 | | |
| 472 | | // Check output format fix if not OK |
| 473 | | if(s->output.format != AF_FORMAT_UNKNOWN && |
| 474 | | s->last->data->format != s->output.format){ |
| 475 | | if(strcmp(s->last->info->name,"format")) |
| 476 | | af = af_append(s,s->last,"format"); |
| 477 | | else |
| 478 | | af = s->last; |
| 479 | | // Init the new filter |
| 480 | | s->output.format |= af_bits2fmt(s->output.bps*8); |
| 481 | | if(!af || (AF_OK != af->control(af,AF_CONTROL_FORMAT_FMT,&(s->output.format)))) |
| 482 | | return -1; |
| 483 | | if(AF_OK != af_reinit(s,af)) |
| 484 | | return -1; |
| 485 | | } |
| 486 | | |