[alsa-devel] alsa compliance test: H340 (USB audio) playback / capture rate asymmetry bug?

Hin-Tak Leung htl10 at users.sourceforge.net
Mon Sep 16 12:25:58 CEST 2019


 

On Friday, 13 September 2019, 18:26:10 BST, Yu-Hsuan Hsu <yuhsuan at chromium.org> wrote:

> Thanks for the feedback! It seems that there is a small difference
> between the measured rate and the expected rate. 7 frames difference
> means if we use that device to play audio about 44100/7 = 6300
> seconds, it will be one second delay. (It can be fixed if an audio
> service has the rate estimation or other similar handlers.) I'm not
> sure it is the hardware or software issue. Maybe you can try to test
> other USB devices or test it without DKMS modules and then compare the
> results. Besides, in my experience, playback and capture having
> different results is normal. They may  go through different paths and
> codecs.

I agree 7/44100 for a consumer device is quite acceptable. The DKMS modules don't really do much - the major addition is the focusrite quirks (which I am specifically interested in) - and shouldn't affect most devices compared to stock up-to-date mainline kernel.

For our specific use - capturing audio, processing, and send it right back for playback at real-time - we'd like the capture and playback rate to agree, even if both are off. Preferably off in the same way.
 
> For more details, the measured rate is computed by linear regression
> for each point when the device consumes audio samples. You can use
> "alsa_conformance_test -P {DEVICE_NAME} -r 44100 -c 2 -f S16_LE -d 1
> --debug" to see when a device consumes samples(TIME_DIFF) and how many
> samples it plays(DIFF). If you want to find out the root cause, this
> information may be helpful.

> Feel free to contact me if you still have questions. Thanks.

I followed your advice and ran the command you suggested. Detail below. How do I make sense of the output?
 
#
./alsa_conformance_test -P hw:CARD=H340 -r 44100 -c 2 -f S16_LE -d 1 --debug
Enable debug mode!
TIME_DIFF(s) HW_LEVEL PLAYED DIFF RATE
0.005430243 348 132 132 24308.304435
0.003994567 215 265 133 33295.223237
0.004015126 323 397 132 32875.680614
0.003987230 235 485 88 22070.459943
0.002998205 342 618 133 44359.875325
0.003003294 210 750 132 43951.740988
0.002996517 318 882 132 44051.143377
0.002003483 230 970 88 43923.507212
0.003027899 337 1103 133 43924.846899
0.002972103 205 1235 132 44412.996454
0.003009504 357 1323 88 29240.698800
0.002000923 225 1455 132 65969.555050
0.002986115 332 1588 133 44539.476879
0.003004640 200 1720 132 43932.051760
0.001998524 352 1808 88 44032.495982
0.002999979 220 1940 132 44000.308002
0.003001799 327 2073 133 44306.764044
0.003013686 239 2161 88 29200.122375
0.001984467 347 2293 132 66516.601183
0.003011683 214 2426 133 44161.354299
0.002990406 322 2558 132 44141.163441
0.001997315 234 2646 88 44059.149408
0.002998010 342 2778 132 44029.206040
0.003034682 209 2911 133 43826.667835
0.002965906 317 3043 132 44505.793508
0.002009807 229 3131 88 43785.298787
0.003002182 337 3263 132 43968.020593
0.002993070 204 3396 133 44435.980448
0.003004042 356 3484 88 29293.864733
0.002006646 224 3616 132 65781.408380
0.002988824 331 3749 133 44499.107341
0.002997473 199 3881 132 44037.093912
0.001999848 351 3969 88 44003.344254
0.003002735 219 4101 132 43959.923203
0.003000291 326 4234 133 44329.033417
0.003015281 238 4322 88 29184.676320
0.001984028 346 4454 132 66531.319114
0.003002370 214 4586 132 43965.267439
0.002996582 321 4719 133 44383.901392
0.001998930 233 4807 88 44023.552601
0.003000710 341 4939 132 43989.589131
0.003001708 208 5072 133 44308.107251
0.003004647 360 5160 88 29287.966274
0.002002956 228 5292 132 65902.595963
0.002991735 336 5424 132 44121.554884
0.003001741 203 5557 133 44307.620144
0.001997910 355 5645 88 44046.028099
0.003003398 223 5777 132 43950.219052
0.003001832 331 5909 132 43973.147065
0.002990969 198 6042 133 44467.194411
0.002017580 350 6130 88 43616.609998
0.002993904 218 6262 132 44089.590047
0.003005396 325 6395 133 44253.735614
0.002996781 237 6483 88 29364.841809
0.001999088 345 6615 132 66030.109730
0.003003623 213 6747 132 43946.926761
0.003008525 320 6880 133 44207.709758
0.001990401 232 6968 88 44212.196437
0.002998966 340 7100 132 44015.170562
0.002996325 208 7232 132 44053.966108
0.002998461 359 7321 89 29681.893478
0.002004415 227 7453 132 65854.625913
0.003003548 335 7585 132 43948.024137
0.003026783 202 7718 133 43941.042354
0.001970358 354 7806 88 44661.934532
0.007963476 90 8070 264 33151.352500
0.001056066 197 8203 133 125939.098503
0.001984588 349 8291 88 44341.697118
0.003005455 217 8423 132 43920.138548
0.002997977 325 8555 132 44029.690688
0.003000093 236 8644 89 29665.747029
0.002004834 344 8776 132 65840.862635
0.002986293 212 8908 132 44201.958750
0.003011136 319 9041 133 44169.376607
0.001998691 231 9129 88 44028.816861
0.002997105 339 9261 132 44042.501013
0.002982757 207 9393 132 44254.359306
0.003019317 358 9482 89 29476.865132
0.001981985 226 9614 132 66599.898587
0.003018215 334 9746 132 43734.458943
0.002993772 202 9878 132 44091.534025
0.002000766 353 9967 89 44482.963025
0.003002190 221 10099 132 43967.903430
0.003001842 329 10231 132 43973.000578
0.002994049 196 10364 133 44421.450684
0.001998387 348 10452 88 44035.514643
0.003003006 216 10584 132 43955.956132
0.002998575 324 10716 132 44020.909932
0.002997109 235 10805 89 29695.283021
0.002005381 343 10937 132 65822.903478
0.002994094 211 11069 132 44086.792198
0.003004432 319 11201 132 43935.093222
0.002000598 230 11290 89 44486.698477
0.002997486 338 11422 132 44036.902925
0.003000794 206 11554 132 43988.357748
0.003003795 358 11642 88 29296.273547
0.001994127 225 11775 133 66695.852370
0.002999544 333 11907 132 44006.689017
0.003002587 201 12039 132 43962.090024
0.002005781 352 12128 89 44371.743475
0.003000787 220 12260 132 43988.460361
0.002988848 328 12392 132 44164.172952
0.002991002 240 12480 88 29421.578454
0.002006309 347 12613 133 66290.885402
0.003001108 215 12745 132 43983.755333
0.003001255 323 12877 132 43981.601030
0.002007748 235 12965 88 43830.201798
0.002994714 342 13098 133 44411.586549
0.003003090 210 13230 132 43954.726632
0.002995270 318 13362 132 44069.482885
0.001997720 229 13451 89 44550.787898
0.003011510 337 13583 132 43831.831872
0.002994187 205 13715 132 44085.422854
0.002998887 357 13803 88 29344.220039
0.002006101 224 13936 133 66297.758687
0.002991219 332 14068 132 44129.166069
0.003004694 200 14200 132 43931.262218
0.001999518 352 14288 88 44010.606556
0.002994953 219 14421 133 44408.042463
0.003001350 327 14553 132 43980.208906
0.003004723 239 14641 88 29287.225478
0.002000490 346 14774 133 66483.711491
0.002996381 214 14906 132 44053.142775
0.003000136 322 15038 132 43998.005424
0.001997613 234 15126 88 44052.576750
0.003000893 341 15259 133 44320.140705
0.003062583 209 15391 132 43100.872695
0.002934100 317 15523 132 44988.241710
0.001993689 229 15611 88 44139.281503
0.003005677 336 15744 133 44249.598343
0.003015689 204 15876 132 43771.091780
0.002985389 356 15964 88 29476.895641
0.002021856 223 16097 133 65781.143662
0.002978295 331 16229 132 44320.659975
0.002995599 199 16361 132 44064.642831
0.002020642 351 16449 88 43550.515133
0.002990162 218 16582 133 44479.195442
0.002999847 326 16714 132 44002.244114
0.002999430 238 16802 88 29338.907726
0.002001704 346 16934 132 65943.815869
0.003001737 213 17067 133 44307.679187
0.003007379 321 17199 132 43892.040212
0.001987528 233 17287 88 44276.105796
0.003004166 340 17420 133 44271.854485
0.002996259 208 17552 132 44054.936506
0.003001239 360 17640 88 29321.223668
0.001993731 228 17772 132 66207.527495
0.003012137 335 17905 133 44154.698143
0.003024652 203 18037 132 43641.384199
0.001970487 355 18125 88 44659.010691
0.002994201 223 18257 132 44085.216724
0.003028092 330 18390 133 43922.047283
0.002974280 198 18522 132 44380.488723
0.002035851 350 18610 88 43225.167264
0.002966989 217 18743 133 44826.590190
0.003002751 325 18875 132 43959.688965
0.003001185 237 18963 88 29321.751242
0.002008197 345 19095 132 65730.603123
0.002990335 212 19228 133 44476.622184
0.003016043 320 19360 132 43765.954265
0.001991167 232 19448 88 44195.188048
0.002989553 340 19580 132 44153.758104
0.003004878 207 19713 133 44261.364355
0.002988708 359 19801 88 29444.161156
0.002008192 227 19933 132 65730.766779
0.003007800 334 20066 133 44218.365583
0.002993277 202 20198 132 44098.825468
0.002001295 354 20286 88 43971.528435
0.003000325 222 20418 132 43995.233850
0.003003403 329 20551 133 44283.101535
0.002988700 197 20683 132 44166.359956
0.002004534 349 20771 88 43900.477617
0.003000290 217 20903 132 43995.747078
0.003001877 324 21036 133 44305.612788
0.002990959 236 21124 88 29422.001438
0.002011009 344 21256 132 65638.691821
0.002997094 211 21389 133 44376.319195
0.003000379 319 21521 132 43994.442035
0.001995538 231 21609 88 44098.383494
0.003002741 339 21741 132 43959.835364
0.002999003 206 21874 133 44348.071676
0.003007911 358 21962 88 29256.184774
0.001988276 226 22094 132 66389.173334
0.003006227 334 22226 132 43908.859843
0.002997745 201 22359 133 44366.682290
0.001995925 353 22447 88 44089.833035
0.003003493 221 22579 132 43948.828914
0.003003228 328 22712 133 44285.681940
0.002989227 240 22800 88 29439.048958
0.002011201 348 22932 132 65632.425600
0.002987473 216 23064 132 44184.499743
0.003008639 323 23197 133 44206.034689
0.002003508 235 23285 88 43922.959130
0.002998549 343 23417 132 44021.291631
0.002999240 211 23549 132 44011.149491
0.003008298 318 23682 133 44211.045581
0.001994085 230 23770 88 44130.516001
0.003003866 338 23902 132 43943.371642
0.003000247 205 24035 133 44329.683523
0.002999352 357 24123 88 29339.670702
0.001998944 225 24255 132 66034.866409
0.002991548 333 24387 132 44124.312898
0.003006510 200 24520 133 44237.338309
0.001995132 352 24608 88 44107.357308
0.003024995 220 24740 132 43636.435763
0.002983258 328 24872 132 44246.927353
0.002998787 239 24961 89 29678.666741
0.001994877 347 25093 132 66169.493157
0.002997504 215 25225 132 44036.638483
0.003000932 322 25358 133 44319.564722
0.002003201 234 25446 88 43929.690530
0.002995926 342 25578 132 44059.833254
0.003005432 210 25710 132 43920.474661
0.003023489 317 25843 133 43988.914793
0.001996411 229 25931 88 44079.099945
0.003004428 337 26063 132 43935.151716
0.002971067 205 26195 132 44428.483101
0.003033970 356 26284 89 29334.502319
0.001971450 224 26416 132 66955.793959
0.003011592 332 26548 132 43830.638413
0.002992930 199 26681 133 44438.059026
0.001992528 351 26769 88 44165.000442
0.002988242 219 26901 132 44173.129218
0.003015947 327 27033 132 43767.347370
0.003006309 238 27122 89 29604.408595
0.001993204 346 27254 132 66225.032661
0.003026800 214 27386 132 43610.413638
0.002969772 322 27518 132 44447.856603
0.001999861 233 27607 89 44503.092965
0.003004348 341 27739 132 43936.321625
0.002995807 209 27871 132 44061.583406
0.002999431 316 28004 133 44341.743484
0.002036323 228 28092 88 43215.148088
0.002990877 336 28224 132 44134.212139
0.002972342 204 28356 132 44409.425295
0.002997129 355 28445 89 29695.084863
0.002011277 223 28577 132 65629.945552
0.002988743 331 28709 132 44165.724520
0.002999353 199 28841 132 44009.491380
0.002000712 350 28930 89 44484.163638
0.003004180 218 29062 132 43938.778635
0.002998575 326 29194 132 44020.909932
0.002999358 238 29282 88 29339.612010
0.002002064 345 29415 133 66431.442751
0.002991189 213 29547 132 44129.608661
0.003011937 321 29679 132 43825.617867
0.002004155 232 29768 89 44407.742914
0.002985318 340 29900 132 44216.395037
0.003005694 208 30032 132 43916.646206
0.003020700 360 30120 88 29132.320323
0.001977942 227 30253 133 67241.607691
0.003002999 335 30385 132 43956.058593
0.002998144 203 30517 132 44027.238185
0.002000036 355 30605 88 43999.208014
0.003005536 222 30738 133 44251.674244
0.003000512 330 30870 132 43992.491948
0.002996091 198 31002 132 44057.406801
0.001998982 349 31091 89 44522.662035
0.002999723 217 31223 132 44004.063042
0.002997533 325 31355 132 44036.212445
0.002999462 237 31443 88 29338.594721
0.002003274 344 31576 133 66391.317413
0.003001963 212 31708 132 43971.228160
0.003031461 320 31840 132 43543.360776
0.001963933 232 31928 88 44808.045896
0.003030691 339 32061 133 43884.381483
0.002989896 207 32193 132 44148.692797
0.002986111 359 32281 88 29469.768538
0.001995534 226 32414 133 66648.826830
0.002988957 334 32546 132 44162.562392
0.003012870 202 32678 132 43812.046321
0.002015425 354 32766 88 43663.247206
0.002983727 221 32899 133 44575.123662
0.002993522 329 33031 132 44095.216270
0.003012041 197 33163 132 43824.104652
0.001996496 349 33251 88 44077.223295
0.002991341 216 33384 133 44461.664518
0.002999408 324 33516 132 44008.684380
0.003004041 236 33604 88 29293.874484
0.002003733 344 33736 132 65877.040504
0.002996082 211 33869 133 44391.308382
0.003000496 319 34001 132 43992.726536
0.002007016 231 34089 88 43846.187574
0.002993934 338 34222 133 44423.156957
0.003001091 206 34354 132 43984.004484
0.003001348 358 34442 88 29320.158809
0.002002840 226 34574 132 65906.412894
0.003001192 333 34707 133 44315.725219
0.002991764 201 34839 132 44121.127201
0.002006403 353 34927 88 43859.583543
0.002995786 221 35059 132 44061.892271
0.002993399 328 35192 133 44431.096556
0.003005857 240 35280 88 29276.176478
0.001994581 348 35412 132 66179.312848
0.003003686 215 35545 133 44278.929289
0.002996266 323 35677 132 44054.833583
0.002002654 235 35765 88 43941.689378
0.003001975 343 35897 132 43971.052391
0.002994876 210 36030 133 44409.184220
0.002998315 318 36162 132 44024.727222
0.002006702 230 36250 88 43853.048435
0.002999885 338 36382 132 44001.686731
0.002997607 205 36515 133 44368.724786
0.003006922 357 36603 88 29265.807360
0.001989451 225 36735 132 66349.962879
0.003031752 332 36868 133 43869.023588
0.002974591 200 37000 132 44375.848646
0.001997964 352 37088 88 44044.837645
0.003002888 220 37220 132 43957.683403
0.003013163 327 37353 133 44139.663204
0.002975668 239 37441 88 29573.191633
0.002028510 347 37573 132 65072.393037
0.002972508 215 37705 132 44406.945246
0.003000742 322 37838 133 44322.370934
0.002010587 234 37926 88 43768.312438
0.003025099 342 38058 132 43634.935584
0.002994347 209 38191 133 44417.029823
0.002975184 317 38323 132 44367.003856
0.001998458 229 38411 88 44033.950176
0.002999423 337 38543 132 44008.464295
0.003020329 204 38676 133 44034.937916
0.002975905 356 38764 88 29570.836435
0.002010450 224 38896 132 65656.942476
0.002988420 332 39028 132 44170.498123
0.002998866 199 39161 133 44350.097670
0.002018655 351 39249 88 43593.382723
0.002981112 219 39381 132 44278.779194
0.003003865 326 39514 133 44276.290712
0.003001118 238 39602 88 29322.405850
0.001994970 346 39734 132 66166.408517
0.003044535 214 39866 132 43356.374619
0.002966379 321 39999 133 44835.808236
0.001990519 233 40087 88 44209.575493
0.003000822 341 40219 132 43987.947302
0.002997942 209 40351 132 44030.204720
0.003029890 360 40440 89 29374.003677
0.001971321 228 40572 132 66960.175436
0.003004381 336 40704 132 43935.839030
0.003002016 203 40837 133 44303.561340
0.002005037 355 40925 88 43889.464384
0.003011571 223 41057 132 43830.944049
0.002980915 331 41189 132 44281.705450
0.002996333 198 41322 133 44387.589764
0.002000685 350 41410 88 43984.935160
0.002999090 218 41542 132 44013.350716
0.003013839 326 41674 132 43797.960010
0.002989500 237 41763 89 29770.864693
0.002001516 345 41895 132 65950.009893
0.003003032 213 42027 132 43955.575565
0.003003136 320 42160 133 44287.038616
0.001994225 232 42248 88 44127.417919
0.002993930 340 42380 132 44089.207162
0.002998975 208 42512 132 44015.038471
0.003000960 360 42600 88 29323.949669
0.001997505 227 42733 133 66583.062370
0.003003471 335 42865 132 43949.150832
0.003025824 203 42997 132 43624.480472
0.001977811 354 43086 89 44999.244114
0.002997971 222 43218 132 44029.778807
0.003002990 330 43350 132 43956.190330
0.003019352 198 43482 132 43717.989820
0.001980195 349 43571 89 44945.068541
0.002995978 217 43703 132 44059.068525
0.003002690 325 43835 132 43960.582011
0.002997367 237 43923 88 29359.100838
---------PRINT PARAMS---------
PCM name: hw:CARD=H340
stream: PLAYBACK
access type: MMAP_INTERLEAVED
format: S16_LE
channels: 2
rate: 44100 fps
period time: 5442 us
period size: 240 frames
buffer time: 5572789 us
buffer size: 245760 frames
---------TIMER RESULT---------
 Total_time(s) Counts Averages(s)
snd_pcm_open 0.003035610 1 0.003036
snd_pcm_hw_params 0.000538065 1 0.000538
snd_pcm_hw_params_any 0.000008570 1 0.000009
snd_pcm_sw_params 0.000001464 1 0.000001
snd_pcm_start 0.000002914 1 0.000003
snd_pcm_avail 0.831696213 354373 0.000002
precision: 0.000000001
----------RUN RESULT----------
number of recorders: 1
number of points: 365
step average: 120.304945
step min: 88
step max: 264
step standard deviation: 21.190473
rate: 44093.453980
rate error: 19.453632
number of underrun: 0
number of overrun: 0
#

  


More information about the Alsa-devel mailing list