@@ -387,7 +387,7 @@ struct effect * fir_effect_init_with_filter(const struct effect_info *ei, const
387
387
return e ;
388
388
}
389
389
390
- sample_t * fir_read_filter (const struct effect_info * ei , const char * dir , const struct codec_params * p , int * channels , ssize_t * frames )
390
+ sample_t * fir_read_filter (const struct effect_info * ei , const struct stream_info * istream , const char * dir , const struct codec_params * p , int * channels , ssize_t * frames )
391
391
{
392
392
static const char coefs_str_prefix [] = "coefs:" ;
393
393
static const char file_str_prefix [] = "file:" ;
@@ -445,6 +445,7 @@ sample_t * fir_read_filter(const struct effect_info *ei, const char *dir, const
445
445
struct codec_params c_params = * p ;
446
446
c_params .path = fp ;
447
447
c_params .mode = CODEC_MODE_READ ;
448
+ if (p -> fs == 0 ) c_params .fs = istream -> fs ;
448
449
struct codec * c = init_codec (& c_params );
449
450
if (c == NULL ) {
450
451
LOG_FMT (LL_ERROR , "%s: error: failed to open filter file: %s" , ei -> name , fp );
@@ -456,10 +457,13 @@ sample_t * fir_read_filter(const struct effect_info *ei, const char *dir, const
456
457
free (fp );
457
458
* channels = c -> channels ;
458
459
* frames = c -> frames ;
459
- if (c -> fs != p -> fs ) {
460
- LOG_FMT (LL_ERROR , "%s: error: sample rate mismatch: fs=%d filter_fs=%d" , ei -> name , p -> fs , c -> fs );
461
- destroy_codec (c );
462
- return NULL ;
460
+ if (c -> fs != istream -> fs ) {
461
+ if (p -> fs > 0 ) {
462
+ LOG_FMT (LL_ERROR , "%s: error: sample rate mismatch: fs=%d filter_fs=%d" , ei -> name , istream -> fs , c -> fs );
463
+ destroy_codec (c );
464
+ return NULL ;
465
+ }
466
+ else LOG_FMT (LL_VERBOSE , "%s: info: ignoring sample rate mismatch: fs=%d filter_fs=%d" , ei -> name , istream -> fs , c -> fs );
463
467
}
464
468
data = calloc (c -> frames * c -> channels , sizeof (sample_t ));
465
469
if (c -> read (c , data , c -> frames ) != c -> frames ) {
@@ -492,16 +496,20 @@ int fir_parse_opts(const struct effect_info *ei, const struct stream_info *istre
492
496
case 'L' : p -> endian = CODEC_ENDIAN_LITTLE ; break ;
493
497
case 'N' : p -> endian = CODEC_ENDIAN_LITTLE ; break ;
494
498
case 'r' :
495
- p -> fs = lround (parse_freq (g -> arg , & endptr ));
496
- if (check_endptr (ei -> name , g -> arg , endptr , "sample rate" ))
497
- return 1 ;
498
- if (p -> fs <= 0 ) {
499
- LOG_FMT (LL_ERROR , "%s: error: sample rate must be > 0" , ei -> name );
500
- return 1 ;
501
- }
502
- if (p -> fs != istream -> fs ) {
503
- LOG_FMT (LL_ERROR , "%s: error: sample rate mismatch: stream_fs=%d requested_fs=%d" , ei -> name , istream -> fs , p -> fs );
504
- return 1 ;
499
+ if (strcmp (g -> arg , "any" ) == 0 )
500
+ p -> fs = 0 ;
501
+ else {
502
+ p -> fs = lround (parse_freq (g -> arg , & endptr ));
503
+ if (check_endptr (ei -> name , g -> arg , endptr , "sample rate" ))
504
+ return 1 ;
505
+ if (p -> fs <= 0 ) {
506
+ LOG_FMT (LL_ERROR , "%s: error: sample rate must be > 0" , ei -> name );
507
+ return 1 ;
508
+ }
509
+ if (p -> fs != istream -> fs ) {
510
+ LOG_FMT (LL_ERROR , "%s: error: sample rate mismatch: stream_fs=%d requested_fs=%d" , ei -> name , istream -> fs , p -> fs );
511
+ return 1 ;
512
+ }
505
513
}
506
514
break ;
507
515
case 'c' :
@@ -543,7 +551,7 @@ struct effect * fir_effect_init(const struct effect_info *ei, const struct strea
543
551
return NULL ;
544
552
}
545
553
c_params .path = argv [g .ind ];
546
- filter_data = fir_read_filter (ei , dir , & c_params , & filter_channels , & filter_frames );
554
+ filter_data = fir_read_filter (ei , istream , dir , & c_params , & filter_channels , & filter_frames );
547
555
if (filter_data == NULL )
548
556
return NULL ;
549
557
e = fir_effect_init_with_filter (ei , istream , channel_selector , filter_data , filter_channels , filter_frames , 0 );
0 commit comments