Repository navigation
941 lines (889 loc) · 47.5 KB
/
Copy pathLinux-samples-audio.yml
File metadata and controls
941 lines (889 loc) · 47.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
name: CI Linux samples/audio
on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:
permissions:
contents: read
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/master' }}
jobs:
samples-audio:
name: Build and run samples/audio
runs-on: ubuntu-latest
timeout-minutes: 25
steps:
- name: Install dependencies
timeout-minutes: 5
run: |
pkgs="build-essential libasound2-dev libsdl2-dev libopenal-dev"
if dpkg -s $pkgs >/dev/null 2>&1; then
echo "All packages already present on runner image; skipping apt."
exit 0
fi
for i in 1 2 3; do
sudo timeout 90 apt-get update -y \
-o Acquire::Retries=3 -o Acquire::http::Timeout=30 && break
echo "apt-get update failed (attempt $i); retrying in 10s"
sleep 10
done
sudo apt-get install -y \
-o Acquire::Retries=3 -o Acquire::http::Timeout=30 \
$pkgs
- name: Checkout
uses: actions/checkout@v5
- name: Restore ccache
uses: actions/cache@v4
with:
path: ~/.ccache
key: ccache-${{ github.workflow }}-${{ github.job }}-${{ github.sha }}
restore-keys: |
ccache-${{ github.workflow }}-${{ github.job }}-
- name: Enable ccache
run: |
set -eu
command -v ccache >/dev/null 2>&1 || sudo apt-get install -y -qq ccache
export CCACHE_DIR="$HOME/.ccache"
echo "CCACHE_DIR=$CCACHE_DIR" >> "$GITHUB_ENV"
echo "/usr/lib/ccache" >> "$GITHUB_PATH"
ccache -M 500M
ccache -z
- name: Build and run mixer_lock_test (ASan + UBSan, TSan)
shell: bash
working-directory: samples/audio/mixer_lock
run: |
set -eu
# Includes audio/audio_driver.c and drives the mixer's public
# entry points with a real state lock in place. The lock is a
# plain mutex, so any path that reaches a locking entry point
# while already holding it parks the thread against itself;
# loading the first menu sound did exactly that
# (libretro/RetroArch#19485). Every case runs on a watchdog:
# a reintroduced recursive acquisition aborts with a stack
# instead of hanging the job. Also covers the lock being
# released on out-of-range slots and a NULL stream name
# surviving removal.
make clean && make -j$(nproc) all SANITIZER=address,undefined
test -x mixer_lock_test
ASAN_OPTIONS=detect_leaks=1:detect_stack_use_after_return=1 \
UBSAN_OPTIONS=print_stacktrace=1 timeout 120 \
./mixer_lock_test
echo "[pass] mixer_lock_test (ASan)"
make clean && make -j$(nproc) all SANITIZER=thread
TSAN_OPTIONS=halt_on_error=1 timeout 300 ./mixer_lock_test
echo "[pass] mixer_lock_test (TSan)"
- name: Build and run thread_handshake_test (ASan + UBSan, TSan)
shell: bash
working-directory: samples/audio/thread_handshake
run: |
set -eu
# Links audio/audio_thread_wrapper.c against a scripted
# driver. The wrapped thread parks in one of two waits and
# the main thread's block() needs stopped_ack from either; a
# stop() landing between start()'s signal and the thread's
# re-check used to leave it in the one wait that never
# acknowledged. Two thousand start/stop round-trips hit that
# window on the previous wrapper on every run. The scripted
# device can also stop returning from a call: a stop must
# then still complete once the call does, and must be
# reported exactly once meanwhile - prompt handshakes are
# asserted not to be reported.
make clean && make -j$(nproc) all SANITIZER=address,undefined
test -x thread_handshake_test
ASAN_OPTIONS=detect_leaks=1:detect_stack_use_after_return=1 \
UBSAN_OPTIONS=print_stacktrace=1 timeout 300 \
./thread_handshake_test
echo "[pass] thread_handshake_test (ASan)"
make clean && make -j$(nproc) all SANITIZER=thread
TSAN_OPTIONS=halt_on_error=1 timeout 600 ./thread_handshake_test
echo "[pass] thread_handshake_test (TSan)"
- name: Build and run graph_clock_test (ASan + UBSan)
shell: bash
working-directory: samples/audio/graph_clock
run: |
set -eu
# The two conversions the JACK and PipeWire clock fits add.
# Neither a JACK server nor a PipeWire daemon can be started
# here, so unlike alsa_clock this mirrors the arithmetic
# rather than driving the drivers - a weaker check, said
# plainly, and aimed at the parts where being wrong is
# silent.
#
# JACK's current_frames is 32 bits and wraps in about a day
# at 48 kHz, sooner if the server was up before RetroArch
# started, since the counter is the server's. The difference
# is taken in 32 bits where the wrap cancels; widening first
# turns one wrap into a four-billion-frame jump. A run is
# started two seconds short of the wrap so it goes round
# mid-measurement.
#
# PipeWire's ticks are in units of pw_time.rate, a fraction
# that is 1/samplerate. The same physical drift has to read
# the same ppm at 44.1k and 48k, which is what the fraction
# is there for.
make clean && make -j$(nproc) all SANITIZER=address,undefined
test -x graph_clock_test
ASAN_OPTIONS=detect_leaks=1 UBSAN_OPTIONS=print_stacktrace=1 timeout 60 \
./graph_clock_test
echo "[pass] graph_clock_test (ASan)"
- name: Build and run alsa_clock_test (ASan + UBSan)
shell: bash
working-directory: samples/audio/alsa_clock
run: |
set -eu
# The ALSA device-clock estimate, driving the shipping
# audio/drivers/alsa.c on a real PCM opened on the null
# device. The four libasound calls the estimate is built from
# are scripted via --wrap, so a device can be made to run at a
# chosen offset and the driver's own answer read back out of
# what it logs - what is asserted is the line a user sees.
#
# Two clocks are covered. The audio timestamp, where a driver
# counts one, is the DMA or link clock compared straight
# against the system clock and needs neither a rate nor a
# delay. Where there is none - the null PCM reports none, and
# nor do plenty of real devices - the position is fitted
# against the timestamp it was taken with. That position is
# inferred from the write count less the delay, so one case
# puts an absurd but constant delay in: it shifts the line
# and leaves its slope alone, which is why this is a fit and
# not a difference of two samples.
make clean && make -j$(nproc) all SANITIZER=address,undefined
test -x alsa_clock_test
ASAN_OPTIONS=detect_leaks=0 UBSAN_OPTIONS=print_stacktrace=1 timeout 60 \
./alsa_clock_test
echo "[pass] alsa_clock_test (ASan)"
make clean && make -j$(nproc) all SANITIZER=thread
timeout 60 ./alsa_clock_test
echo "[pass] alsa_clock_test (TSan)"
- name: Build and run alsa_wait_writable_test (ASan + UBSan, TSan)
shell: bash
working-directory: samples/audio/alsa_wait_writable
run: |
set -eu
# Links the shipping audio/drivers/alsa.c and interposes the
# five libasound calls alsa_wait_writable() makes via
# -Wl,--wrap, so the devices no stock PCM can produce on
# demand are scripted: a running stream whose poll never
# signals, a prepared stream reporting no space, a start that
# lands in an underrun storm, and wakes that never deliver
# space. Each must return 0 within a bounded lap and wall-time
# budget rather than parking the audio thread; the previous
# wait was an unbounded snd_pcm_wait(-1). The conforming path
# runs end-to-end on the null PCM, and the harness skips
# cleanly if no ALSA configuration is available at all.
make clean && make -j$(nproc) all SANITIZER=address,undefined
test -x alsa_wait_writable_test
ASAN_OPTIONS=detect_leaks=1:detect_stack_use_after_return=1 \
UBSAN_OPTIONS=print_stacktrace=1 timeout 120 \
./alsa_wait_writable_test
echo "[pass] alsa_wait_writable_test (ASan)"
make clean && make -j$(nproc) all SANITIZER=thread
TSAN_OPTIONS=halt_on_error=1 timeout 300 ./alsa_wait_writable_test
echo "[pass] alsa_wait_writable_test (TSan)"
- name: Build and run alsa_lifecycle_test (ASan + UBSan, TSan)
shell: bash
working-directory: samples/audio/alsa_lifecycle
run: |
set -eu
# Links the shipping audio/drivers/alsa.c against the null PCM
# and scripts the libasound calls that decide stop/start and
# the blocking write - can_pause, pause, drop, prepare, writei,
# wait, recover - via -Wl,--wrap. alive() must follow stop()
# and start() on a device that can pause, one that cannot, and
# one that says it can and refuses; the blocking write must
# write first, wait only on EAGAIN, and never without a bound.
make clean && make -j$(nproc) all SANITIZER=address,undefined
test -x alsa_lifecycle_test
ASAN_OPTIONS=detect_leaks=1:detect_stack_use_after_return=1 \
UBSAN_OPTIONS=print_stacktrace=1 timeout 120 \
./alsa_lifecycle_test
echo "[pass] alsa_lifecycle_test (ASan)"
make clean && make -j$(nproc) all SANITIZER=thread
TSAN_OPTIONS=halt_on_error=1 timeout 300 ./alsa_lifecycle_test
echo "[pass] alsa_lifecycle_test (TSan)"
- name: Build and run pipeline_stall_test (ASan + UBSan, TSan)
shell: bash
working-directory: samples/audio/pipeline_stall
run: |
set -eu
# Includes audio/audio_driver.c and runs the threaded pipeline's
# shipping producer and consumer against a scripted driver whose
# write_raw() path reaches the device without the resampler or
# the arenas. The device is then made to stop taking audio. The
# consumer must take nothing from the ring it cannot deliver and
# report no progress it did not make; the producer must record
# the stall after one bounded wait and drop at once thereafter;
# and both must recover when the device returns. The previous
# consumer took the chunk first, threw it away on finding no
# room, and cleared the stall - the frontend paced at one frame
# per failed pass for as long as the device was stuck.
make clean && make -j$(nproc) all SANITIZER=address,undefined
test -x pipeline_stall_test
ASAN_OPTIONS=detect_leaks=1:detect_stack_use_after_return=1 \
UBSAN_OPTIONS=print_stacktrace=1 timeout 180 \
./pipeline_stall_test
echo "[pass] pipeline_stall_test (ASan)"
make clean && make -j$(nproc) all SANITIZER=thread
TSAN_OPTIONS=halt_on_error=1 timeout 400 ./pipeline_stall_test
echo "[pass] pipeline_stall_test (TSan)"
- name: Build and run upmix_test (plain, ASan + UBSan)
shell: bash
working-directory: samples/audio/upmix
run: |
set -eu
# The stereo-to-wider stage at the last step before a device
# opened with a wider speaker layout. A layout is a mask of
# positions in ascending bit order, never a count: 5.1 with
# the rear pair at the back and 5.1 with it at the sides are
# two layouts whose slots differ. The fronts carry the stereo
# unchanged, the rear pair -3 dB in its own slots, the centre
# the -6 dB sum, the LFE the bass through a 120 Hz low-pass and
# none of the treble; stereo is a copy; a mask the stage
# cannot fill is refused.
make clean && make -j$(nproc) all
./upmix_test
echo "[pass] upmix_test"
make clean && make -j$(nproc) all SANITIZER=address,undefined
ASAN_OPTIONS=detect_leaks=1 UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./upmix_test
echo "[pass] upmix_test (ASan)"
- name: Build and run discrete_multichannel_test (plain, ASan + UBSan)
shell: bash
working-directory: samples/audio/discrete_multichannel
run: |
set -eu
# A core's 5.1 through the multi-channel batch entry to a 5.1
# device without the fold and the upmix in between: each
# device channel carries its core channel's tone and none of
# the others', in all four format pairings, through the
# resampler off unity; over the threaded ring; recorded; and
# to a stereo device, the fold at the BS.775 gains with the
# LFE dropped. The last case runs the shipping WASAPI driver
# over the fake device from wasapi_exclusive_pacing, so a
# 5.1 core reaches a Dolby Digital decoder as AC-3 bursts
# that decode back to its own channels. Includes the
# shipping audio_driver.c.
make clean && make -j$(nproc) all
./discrete_multichannel_test
echo "[pass] discrete_multichannel_test"
make clean && make -j$(nproc) all SANITIZER=address,undefined
ASAN_OPTIONS=detect_leaks=0 UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./discrete_multichannel_test
echo "[pass] discrete_multichannel_test (ASan)"
- name: Build and run embedded_alsa_test (the embedded ALSA driver, mock kernel device)
shell: bash
working-directory: samples/audio/embedded_alsa
run: |
set -eu
# The "tinyalsa" driver in audio/drivers/alsa.c talks the
# kernel PCM ioctls directly. abi_check compares its copy of
# that ABI - extracted from the driver itself, so it cannot
# go stale - against <sound/asound.h>: every struct size and
# offset, constant and ioctl number. The test then runs the
# driver against a mock device that refines parameters the
# way the kernel does.
make clean && make -j$(nproc) check
echo "[pass] embedded_alsa_test"
make clean && make -j$(nproc) check SANITIZER=address,undefined
echo "[pass] embedded_alsa_test (ASan)"
- name: Build and run ealsa_test (the embedded ALSA driver against a mock PCM device)
shell: bash
working-directory: samples/audio/ealsa
run: |
set -eu
# The embedded driver in audio/drivers/alsa.c talks to the
# kernel's PCM ABI through one seam - open, ioctl, close,
# poll - so a scripted device that answers the way a card
# does runs it with no card present, and can refuse a rate, a
# format, a channel count or a period grid, which is where a
# negotiation goes wrong. Built with HAVE_TINYALSA alone, so
# the build never sees an alsa-lib header either. It also
# carries what tinyalsa_write_test used to check of the
# driver this one replaced: a full device refusing in both
# modes, a device that never signals, a poll cut short by a
# signal, and the first write reporting what it took.
make clean && make -j$(nproc) all
./ealsa_test
echo "[pass] ealsa_test"
make clean && make -j$(nproc) all SANITIZER=address,undefined
ASAN_OPTIONS=detect_leaks=1 UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./ealsa_test
echo "[pass] ealsa_test (ASan)"
- name: Build and run bitstream_test (plain, ASan + UBSan)
shell: bash
working-directory: samples/audio/bitstream
run: |
set -eu
sudo apt-get update -qq
sudo apt-get install -y -qq ffmpeg
# audio/audio_bitstream.c: a coded stream on its way to a
# receiver, which the PCM pipeline has no place for. Real
# DTS and AC-3 from ffmpeg, handed over frame by frame:
# bursts leave whole and never partial, the queue paces the
# source rather than the source running ahead, a gap
# produces the pause burst the standard has for it rather
# than silence (which makes a receiver drop its lock), and
# the PCM frames reported are the device time the bytes
# occupy.
make clean && make -j$(nproc) all
./bitstream_test
echo "[pass] bitstream_test"
make clean && make -j$(nproc) all SANITIZER=address,undefined
ASAN_OPTIONS=detect_leaks=1 UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./bitstream_test
echo "[pass] bitstream_test (ASan)"
- name: Build and run opensl_test (the Android driver against a mock OpenSL player)
shell: bash
working-directory: samples/audio/opensl
run: |
set -eu
# audio/drivers/opensl.c is Android-only and has no build
# here, so it is built against stand-in <SLES/*.h> over a
# scripted player whose queue a thread drains: the block
# arithmetic at the latencies of issue #6405 and below, the
# queue accounting the hang there came from, float and
# 16-bit, a full queue, and a device that stops consuming.
make clean && make -j$(nproc) all
./opensl_test
echo "[pass] opensl_test"
make clean && make -j$(nproc) all SANITIZER=address,undefined
ASAN_OPTIONS=detect_leaks=1 UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./opensl_test
echo "[pass] opensl_test (ASan)"
make clean && make -j$(nproc) all SANITIZER=thread
TSAN_OPTIONS=halt_on_error=1 ./opensl_test
echo "[pass] opensl_test (TSan)"
- name: Build and run qsa_test (the QNX driver against a mock QSA device)
shell: bash
working-directory: samples/audio/qsa
run: |
set -eu
# audio/drivers/alsa_qsa.c is QNX-only and has no build here,
# so it is built against a stand-in <sys/asoundlib.h> over a
# scripted device: init and its failure path, the rate it
# reports back, blocking and non-blocking writes, stop and
# start, underrun recovery, and a device that stops draining.
# Not a substitute for a QNX build; it is the coverage the
# driver had none of.
make clean && make -j$(nproc) all
./qsa_test
echo "[pass] qsa_test"
make clean && make -j$(nproc) all SANITIZER=address,undefined
ASAN_OPTIONS=detect_leaks=1 UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./qsa_test
echo "[pass] qsa_test (ASan)"
- name: Build and run live_drivers_test (a live PulseAudio server, a null ALSA PCM)
shell: bash
working-directory: samples/audio/live_drivers
run: |
set -eu
sudo apt-get update -qq
sudo apt-get install -y -qq libasound2-dev libpulse-dev pulseaudio
# A server with a null sink, and an ALSA config naming a null
# PCM: the real drivers against the real libraries, no
# hardware. Pulse's telemetry is cached from the server
# thread's callbacks; ALSA is run once as the device reports
# itself and once told it cannot pause, the fallback from
# snd_pcm_pause to snd_pcm_drop.
export XDG_RUNTIME_DIR=/tmp/xdg
mkdir -p "$XDG_RUNTIME_DIR/pulse"
printf 'pcm.nullpcm { type null }\n' > "$HOME/.asoundrc"
pulseaudio --daemonize=no --exit-idle-time=-1 --disallow-exit -n \
-L "module-null-sink sink_name=nullsink rate=48000 channels=2" \
-L "module-native-protocol-unix auth-anonymous=1 socket=$XDG_RUNTIME_DIR/pulse/native" \
--log-target=file:/tmp/pa.log &
PA_PID=$!
sleep 3
make clean && make -j$(nproc) all
./live_drivers_test
echo "[pass] live_drivers_test"
make clean && make -j$(nproc) all SANITIZER=address,undefined
ASAN_OPTIONS=detect_leaks=0 UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./live_drivers_test
echo "[pass] live_drivers_test (ASan)"
kill $PA_PID || true
- name: Build and run binaural_test (plain, ASan + UBSan)
shell: bash
working-directory: samples/audio/binaural
run: |
set -eu
# A layout rendered to two ears for headphones: a left speaker
# arrives at the left ear first, louder and brighter; the rear
# pair duller than the front; centre and LFE alike to both
# ears; a centred source keeps its level and a full-scale one
# leaves at full scale; the two 5.1s render their rear pair
# from different directions; stereo is a mild crossfeed.
make clean && make -j$(nproc) all
./binaural_test
echo "[pass] binaural_test"
make clean && make -j$(nproc) all SANITIZER=address,undefined
ASAN_OPTIONS=detect_leaks=1 UBSAN_OPTIONS=print_stacktrace=1:halt_on_error=1 ./binaural_test
echo "[pass] binaural_test (ASan)"
- name: Build and run pipeline_rate_control_test (ASan + UBSan, TSan)
shell: bash
working-directory: samples/audio/pipeline_rate_control
run: |
set -eu
# Includes audio/audio_driver.c and runs the threaded pipeline's
# shipping producer, consumer and rate controller against a
# device whose 8 ms buffer drains at exactly 48000 frames a
# second of wall-clock time, fed one 800-frame video frame every
# 1/60 s on an absolute schedule, audio sync off. The clocks
# match, so the right ratio is 1.0: after a four-second settle
# the mean rate adjustment over three seconds must be within
# 500 ppm of it, and the device must have taken 99.5% of what
# was produced. Rate control on the pipeline samples pipe and
# device together, at the producer; reading the device alone,
# which the consumer holds between half and full, pins the
# ratio at a bound and the pipe overflows behind it. Real time,
# so a loaded runner can shift the mean; the tolerance is ten
# times the settled residual.
make clean && make -j$(nproc) all SANITIZER=address,undefined
test -x pipeline_rate_control_test
ASAN_OPTIONS=detect_leaks=0 UBSAN_OPTIONS=print_stacktrace=1 timeout 120 \
./pipeline_rate_control_test
echo "[pass] pipeline_rate_control_test (ASan)"
# A core late by 60 ms every 2 s, audio sync off: the silence is
# the stalls' own and no more, the late audio is not kept, and
# rate control is not pinned against a backlog. And with sync on:
# the writer waits, nothing is dropped.
ASAN_OPTIONS=detect_leaks=0 timeout 120 ./pipeline_rate_control_test 12 4 jitter
ASAN_OPTIONS=detect_leaks=0 timeout 120 ./pipeline_rate_control_test 12 4 sync-jitter
echo "[pass] pipeline_rate_control_test (late core, ASan)"
# The 64 ms default buffer, sync off, a steady core and a late one:
# the consumer's chunks are whole publishes and the pipe's fill
# swings by one with the phase; nothing is dropped from a steady
# core at any phase.
ASAN_OPTIONS=detect_leaks=0 timeout 120 ./pipeline_rate_control_test 16 4 big
ASAN_OPTIONS=detect_leaks=0 timeout 120 ./pipeline_rate_control_test 16 4 big-jitter
echo "[pass] pipeline_rate_control_test (64 ms device, ASan)"
# The producer held 4 ms every five seconds, as a loaded runner
# holds it: a publish pushed across a sink window boundary. The
# estimate must settle and apply about zero, not the shift.
ASAN_OPTIONS=detect_leaks=0 timeout 120 ./pipeline_rate_control_test 16 4 big-stall
echo "[pass] pipeline_rate_control_test (stalled producer, ASan)"
# A float core on a float ring into a float device: a signal a
# tenth of an int16 LSB high arrives as published, not as zero.
ASAN_OPTIONS=detect_leaks=0 timeout 120 ./pipeline_rate_control_test 16 4 float
echo "[pass] pipeline_rate_control_test (float core, ASan)"
make clean && make -j$(nproc) all SANITIZER=thread
TSAN_OPTIONS=halt_on_error=1 timeout 240 ./pipeline_rate_control_test
echo "[pass] pipeline_rate_control_test (TSan)"
- name: Build and run resampler_reset_test (ASan + UBSan)
shell: bash
working-directory: samples/audio/resampler_reset
run: |
set -eu
# Every resampler backend's reset(): after it the stream
# continues as a freshly initialised backend would, to the
# sample, at the ratios the frontend meets - and the reset
# makes no allocation, counted through wrapped malloc, calloc
# and memalign_alloc.
make clean && make -j$(nproc) all SANITIZER=address,undefined
test -x resampler_reset_test
ASAN_OPTIONS=detect_leaks=1 UBSAN_OPTIONS=print_stacktrace=1 timeout 60 ./resampler_reset_test
echo "[pass] resampler_reset_test (ASan)"
- name: Build and run ff_speedup_test (ASan + UBSan, TSan)
shell: bash
working-directory: samples/audio/ff_speedup
run: |
set -eu
# Includes audio/audio_driver.c with the clock replaced by a
# counter. The fast-forward speedup multiplier must follow the
# core's cadence on both pipelines: measured at the flush inline,
# and by the producer at its publish cadence on the threaded
# pipeline, where the consumer's own flush interval is the device
# draining the previous chunk and would only confirm the previous
# multiplier. Re-entry after an idle spell must start from unity
# rather than read the idle time as one flush interval.
make clean && make -j$(nproc) all SANITIZER=address,undefined
test -x ff_speedup_test
ASAN_OPTIONS=detect_leaks=1:detect_stack_use_after_return=1 \
UBSAN_OPTIONS=print_stacktrace=1 timeout 120 ./ff_speedup_test
echo "[pass] ff_speedup_test (ASan)"
make clean && make -j$(nproc) all SANITIZER=thread
TSAN_OPTIONS=halt_on_error=1 timeout 120 ./ff_speedup_test
echo "[pass] ff_speedup_test (TSan)"
- name: Build and run device_list_driver_test (ASan + UBSan)
shell: bash
working-directory: samples/audio/device_list_driver
run: |
set -eu
# Includes audio/audio_driver.c with the alsa and null drivers in
# the table. Picking a driver in the menu writes the setting but
# does not reinitialise audio, and the Device list - rebuilt on
# each open - was asked of the running driver, so it showed the
# old driver's devices under the new driver's name until a
# restart. The list now comes from the configured driver, and
# is freed by the driver that built it. Cases: configured and
# running agree; configured differs from running; back again;
# nothing running; and release by the builder, once.
make clean && make -j$(nproc) all SANITIZER=address,undefined
test -x device_list_driver_test
ASAN_OPTIONS=detect_leaks=1:detect_stack_use_after_return=1 \
UBSAN_OPTIONS=print_stacktrace=1 timeout 120 \
./device_list_driver_test
echo "[pass] device_list_driver_test (ASan)"
- name: Build and run device_label_path_test (ASan + UBSan)
shell: bash
working-directory: samples/audio/device_label_path
run: |
set -eu
# A device list entry with the hardware's name after the path,
# "/dev/dsp0 (HDA Intel)", is stored by the menu as shown and
# comes back to init as the device string; oss opened it as a
# path and failed, so a device picked from the list could not
# be used. Compiles oss and audioio whole with open() redirected
# to a recorder, and checks each reaches it with the path.
make clean && make -j$(nproc) all SANITIZER=address,undefined
test -x device_label_path_test
ASAN_OPTIONS=detect_leaks=1:detect_stack_use_after_return=1 \
UBSAN_OPTIONS=print_stacktrace=1 timeout 60 \
./device_label_path_test
echo "[pass] device_label_path_test (ASan)"
- name: Build and run rate_control_bounds_test (ASan + UBSan)
shell: bash
working-directory: samples/audio/rate_control_bounds
run: |
set -eu
# Includes audio/audio_driver.c and runs the rate control's
# shipping computation against a scripted driver. At the
# setpoint, empty and full it must give 1.0 and the band's two
# edges; with write_avail() reporting five times buffer_size()
# it must give the upper edge and no more. Before the clamp an
# over-reporting driver drove it nine times past the band.
make clean && make -j$(nproc) all SANITIZER=address,undefined
test -x rate_control_bounds_test
ASAN_OPTIONS=detect_leaks=1:detect_stack_use_after_return=1 \
UBSAN_OPTIONS=print_stacktrace=1 timeout 60 \
./rate_control_bounds_test
echo "[pass] rate_control_bounds_test (ASan)"
- name: Build and run latency_contract_test (ASan + UBSan, TSan)
shell: bash
working-directory: samples/audio/latency_contract
run: |
set -eu
# Real drivers on backends that need no hardware - the ALSA null
# PCM, SDL's dummy audio, OpenAL Soft's null device - opened at
# 64 and 32 ms and checked against audio_driver.h's contract:
# buffer_size() is the setting in bytes of the output format,
# write_avail() never exceeds it, a buffer's worth offered takes
# room, and the room comes back as the device plays. The sdl
# driver before fdda5f7 reports 42.7 ms against 64 here.
make clean && make -j$(nproc) all SANITIZER=address,undefined
test -x latency_contract_test
ASAN_OPTIONS=detect_leaks=1:detect_stack_use_after_return=1 \
UBSAN_OPTIONS=print_stacktrace=1 timeout 120 \
./latency_contract_test
echo "[pass] latency_contract_test (ASan)"
make clean && make -j$(nproc) all SANITIZER=thread
TSAN_OPTIONS=halt_on_error=1:suppressions=$PWD/tsan.supp \
timeout 300 ./latency_contract_test
echo "[pass] latency_contract_test (TSan)"
- name: Build and run asio_convert_test (ASan + UBSan)
shell: bash
working-directory: samples/audio/asio_convert
run: |
set -eu
# audio/drivers/asio_convert.h is the ASIO driver's sample
# conversion, pure C, so it runs here without Windows. Every
# ASIOSampleType the specification defines is converted for full
# scale, zero, half and one 16-bit step in both signs and checked
# byte for byte against the layout the specification gives - the
# Int32LSB16..24 family as low-aligned, sign-extended words, the
# MSB types big-endian. Saturation and the silence fill past the
# supplied frames are checked too. The converter this replaced
# wrote five types and memset the rest to silence.
make clean && make -j$(nproc) all SANITIZER=address,undefined
test -x asio_convert_test
ASAN_OPTIONS=detect_leaks=1 UBSAN_OPTIONS=print_stacktrace=1 timeout 60 \
./asio_convert_test
echo "[pass] asio_convert_test (ASan)"
- name: Build and run coreaudio_clock_test (ASan + UBSan)
shell: bash
working-directory: samples/audio/coreaudio_clock
run: |
set -eu
# The device clock fitted from the timestamp the render
# callback is handed, which the driver used to discard.
#
# The fit is the same shape as the ASIO one and is checked
# there. What is different is the time axis: mHostTime is in
# mach absolute units, not nanoseconds, and the ratio is one
# to one on Intel and 125 to 3 on Apple silicon. Ignoring it
# reads a 48 kHz device as 1152 Hz - invisible on Intel and
# wrong on every Mac since 2020 - so the same clock is driven
# through both timebases here.
#
# Also mRateScalar, which is the HAL's own figure for the
# same thing, read only where it is flagged valid.
#
# Arithmetic only, so it runs here without a Mac.
make clean && make -j$(nproc) all SANITIZER=address,undefined
test -x coreaudio_clock_test
ASAN_OPTIONS=detect_leaks=1 UBSAN_OPTIONS=print_stacktrace=1 timeout 60 \
./coreaudio_clock_test
echo "[pass] coreaudio_clock_test (ASan)"
- name: Build and run coreaudio_ring_test (ASan + UBSan)
shell: bash
working-directory: samples/audio/coreaudio_ring
run: |
set -eu
# The CoreAudio ring keeps a frame's channels together. Its
# capacity is the sample count rounded up to a power of two,
# which for six channels is not a whole number of frames, so
# the cursors wrap mid-frame - and that does not matter,
# because a FIFO returns samples in the order they went in
# wherever they sit. This runs the traffic for every layout,
# then forces every transfer across the wrap, to keep that
# answer honest rather than assumed.
#
# What does rotate the channels is a transfer whose count is
# not a whole number of frames, which is why the callback
# trims short reads. The last case does that on purpose and
# fails if it goes unnoticed, so the trim has a guard.
#
# Arithmetic only, so it runs here without a Mac.
make clean && make -j$(nproc) all SANITIZER=address,undefined
test -x coreaudio_ring_test
ASAN_OPTIONS=detect_leaks=1 UBSAN_OPTIONS=print_stacktrace=1 timeout 60 \
./coreaudio_ring_test
echo "[pass] coreaudio_ring_test (ASan)"
- name: Build and run asio_clock_test (ASan + UBSan)
shell: bash
working-directory: samples/audio/asio_clock
run: |
set -eu
# The device clock read from the driver's own time
# information, rather than from when its callbacks arrived.
#
# Two things here do not need an interface. The ASIOTime
# layout is an ABI: the sample position and system time are
# 64-bit values the SDK splits into 32-bit halves on Windows,
# and getting that wrong does not fail to build, it reads a
# driver's numbers as garbage in a real-time callback. The
# offsets are asserted against the SDK's, and asio.c carries
# the same assertions for the compiler that sees the real
# Windows ABI.
#
# And the estimate itself: a clock at a known offset is fed
# in with scheduling jitter on the timestamps, and the answer
# has to be the clock. A two-point estimate fails that - the
# anchor's own noise divided by the window reads as drift,
# 50 ppm for half a millisecond at ten seconds - which is why
# it is a least-squares fit over every callback instead.
make clean && make -j$(nproc) all SANITIZER=address,undefined
test -x asio_clock_test
ASAN_OPTIONS=detect_leaks=1 UBSAN_OPTIONS=print_stacktrace=1 timeout 60 \
./asio_clock_test
echo "[pass] asio_clock_test (ASan)"
- name: Build and run asio_ring_test (ASan + UBSan)
shell: bash
working-directory: samples/audio/asio_ring
run: |
set -eu
# Also the write's frame alignment: the callback reads the
# ring a frame at a time, so a write must end on one, and
# the rule is checked for every layout the driver can open.
#
# audio/drivers/asio_ring.h sizes the ring in front of the ASIO
# device: the latency setting less the device's reported stage,
# floored at four periods where that is under 6 ms, 6 ms where it
# is over, two periods at the least. Arithmetic only, so it runs
# here without Windows. The expected frames are worked by hand
# from those rules for the devices that set them - ASIO4ALL at 64
# frames, a wrapper locked at 528, a USB DAC at 8 and 128 - and
# the two points where the rules meet.
make clean && make -j$(nproc) all SANITIZER=address,undefined
test -x asio_ring_test
ASAN_OPTIONS=detect_leaks=1 UBSAN_OPTIONS=print_stacktrace=1 timeout 60 \
./asio_ring_test
echo "[pass] asio_ring_test (ASan)"
- name: Build and run dsound_pump_test (MinGW, under wine)
shell: bash
working-directory: samples/audio/dsound_pump
run: |
set -eu
# audio/drivers/dsound.c end to end on wine's DirectSound, fed
# by an ALSA null PCM, which plays at real-time pace on a
# runner with no sound card. Pins that the pump - which now
# waits for the play cursor to move the distance it needs,
# worked out from the rate, instead of retrying every
# millisecond - still moves audio through blocking writes,
# fills silence when the writer stops, and lets free() return
# at once while it waits.
if ! command -v x86_64-w64-mingw32-gcc >/dev/null 2>&1 \
|| ! command -v wine >/dev/null 2>&1; then
sudo apt-get install -y -qq gcc-mingw-w64-x86-64 wine64 \
-o Acquire::Retries=3 -o Acquire::http::Timeout=30
fi
printf 'pcm.!default { type null }\nctl.!default { type hw card 0 }\n' > ~/.asoundrc
make clean all
WINEDEBUG=-all timeout 300 make check
echo "[pass] dsound_pump_test (wine)"
- name: Build and run wdmks_loop_test (MinGW, under wine)
shell: bash
working-directory: samples/audio/wdmks_loop
run: |
set -eu
# audio/drivers/wdmks.c compiled whole, its WaveRT loop driven
# by hand: the test owns the driver's state, points the
# position register at a word of its own and moves the
# hardware itself, so nothing reaches the kernel and wine
# needs no sound card. Pins that every byte the cursor passes
# is cleared, so the loop plays silence when the frontend
# stops writing - a pause, a menu, a stall - instead of the
# last loop of audio round and round; that a write after
# that lands a margin ahead of the hardware rather than a
# loop behind it; that a full loop is not taken for an
# overrun; and that a start puts the model back at the top
# of the loop with the hardware; and that the resync margin is
# the FIFO the pin reports plus half a millisecond, two
# milliseconds where it reports none; and that gaps in the
# audio are counted once each, neither a start nor every
# sample of a pause.
if ! command -v x86_64-w64-mingw32-gcc >/dev/null 2>&1 \
|| ! command -v wine >/dev/null 2>&1; then
sudo apt-get install -y -qq gcc-mingw-w64-x86-64 wine64 \
-o Acquire::Retries=3 -o Acquire::http::Timeout=30
fi
make clean all
WINEDEBUG=-all timeout 120 make check
echo "[pass] wdmks_loop_test (wine)"
- name: Build and run wasapi_exclusive_pacing_test (ASan + UBSan, then TSan)
shell: bash
working-directory: samples/audio/wasapi_exclusive_pacing
run: |
set -eu
# audio/drivers/wasapi.c, unmodified but for its Windows include
# lines, against a fake device on a real-time clock: exclusive
# and event-driven, one period per endpoint buffer, every period
# taken or counted unanswered. The writer is a frontend with audio
# sync off: one frame of core audio per non-blocking write, no rate
# control. Passes when no period goes unanswered in either mode and
# nothing is dropped once the buffer holds a frame. Before the pump
# thread and the drain-first shared write this run gave 3-10% of
# periods unanswered; the first smaller-period attempt without the
# pump gave 75%.
make clean && make -j$(nproc) all SANITIZER=address,undefined
test -x wasapi_exclusive_pacing_test
ASAN_OPTIONS=detect_leaks=1 UBSAN_OPTIONS=print_stacktrace=1 timeout 120 \
./wasapi_exclusive_pacing_test 3
echo "[pass] wasapi_exclusive_pacing_test (ASan)"
make clean && make -j$(nproc) all SANITIZER=thread
timeout 180 ./wasapi_exclusive_pacing_test 3
echo "[pass] wasapi_exclusive_pacing_test (TSan)"
- name: Build and run sink_rate_test (ASan + UBSan)
shell: bash
working-directory: samples/audio/sink_rate
run: |
set -eu
# The frontend's sink rate estimator against a scripted driver
# on a synthetic clock: a device 120 ppm fast and 80 ppm slow are
# measured and the resampling bias converges onto them; 5000 ppm
# stops at the clamp; with rate control on the bias absorbs rate
# control's mean adjustment; a paused window, a count that went
# backwards, and a stalled window move nothing; disabled, nothing
# moves at all.
make clean && make -j$(nproc) all SANITIZER=address,undefined
test -x sink_rate_test
ASAN_OPTIONS=detect_leaks=1 UBSAN_OPTIONS=print_stacktrace=1 timeout 60 ./sink_rate_test
echo "[pass] sink_rate_test (ASan)"
- name: Build and run pacing_test (ASan + UBSan)
shell: bash
working-directory: samples/runloop/pacing
run: |
set -eu
# The three pacing decisions the runloop makes every
# iteration, run from runloop.h so this is the shipping code
# rather than a copy of it. The gap limiter over all 128
# combinations of the pace bits by nonblocking by fastmotion -
# exactly one may engage, because engaging next to another
# source double-paces and engaging under fast-forward
# throttles it to 1x, and both look like performance bugs
# rather than pacing bugs. The frame period over the rates a
# core can report including zero and a million, bounded and
# monotonic. And the filter on the measured loop rate, which
# has to reject a stall: one 0.9 s sample used to pull a 60
# fps reading to 8 and take several frames to recover.
make clean && make -j$(nproc) all SANITIZER=address,undefined
test -x pacing_test
ASAN_OPTIONS=detect_leaks=1 UBSAN_OPTIONS=print_stacktrace=1 timeout 60 ./pacing_test
echo "[pass] pacing_test (ASan)"
- name: Build the ALSA objects through configure (--enable-alsa)
shell: bash
run: |
set -eu
# The harnesses above compile audio/drivers/alsa.c with
# -DHAVE_ALSA on the command line. A distribution build takes
# HAVE_ALSA from config.h instead, and the file gates its
# alsa-lib includes on it, so build the objects that way too:
# configure with ALSA on, then compile them. That covers the
# object a distribution ships as well as the ones the
# harnesses build (libretro/RetroArch#19525). The embedded
# driver takes its define the same way and shares the file,
# so the arrangements below cover it too.
./configure --enable-alsa --disable-qt --disable-ffmpeg \
--disable-x11 --disable-wayland
grep -q '^HAVE_ALSA = 1' config.mk
make obj-unix/release/audio/drivers/alsa.o \
obj-unix/release/audio/common/alsa.o
echo "[pass] alsa-lib alone, through configure"
# The embedded driver is in the same file behind its own
# define, and configure puts HAVE_TINYALSA in config.h as
# well as on the command line - so it has the same question
# to answer as HAVE_ALSA did, and one object serves both
# drivers. The two arrangements a distribution can ask for:
# the embedded driver with no alsa-lib anywhere, and both in
# the one object.
rm -f obj-unix/release/audio/drivers/alsa.o
./configure --enable-tinyalsa --disable-alsa --disable-qt \
--disable-ffmpeg --disable-x11 --disable-wayland
grep -q '^HAVE_TINYALSA = 1' config.mk
grep -q '^HAVE_ALSA = 0' config.mk
make obj-unix/release/audio/drivers/alsa.o
echo "[pass] the embedded driver alone, through configure"
rm -f obj-unix/release/audio/drivers/alsa.o \
obj-unix/release/audio/common/alsa.o
./configure --enable-alsa --enable-tinyalsa --disable-qt \
--disable-ffmpeg --disable-x11 --disable-wayland
grep -q '^HAVE_TINYALSA = 1' config.mk
grep -q '^HAVE_ALSA = 1' config.mk
make obj-unix/release/audio/drivers/alsa.o \
obj-unix/release/audio/common/alsa.o
echo "[pass] both drivers in the one object, through configure"
- name: Build and run stretch and native SRC chain (C89, ASan + UBSan)
working-directory: samples/audio/stretch
run: |
make -j$(nproc) check SANITIZER=address,undefined
- name: Build and run WSOLA kernel tests (C89, ASan + UBSan)
working-directory: samples/audio/wsola_search
run: |
make -j$(nproc) check SANITIZER=address,undefined
- name: Build and run native speed LPF tests (C89, ASan + UBSan)
working-directory: samples/audio/speed_lpf
run: make check SANITIZER=address,undefined
- name: Build and run experimental sinc HQ tests (C89, ASan + UBSan)
working-directory: samples/audio/sinc_hq
run: |
make -j$(nproc) check SANITIZER=address,undefined
- name: Build and run sinc AVX tests (C89, ASan + UBSan)
working-directory: samples/audio/sinc_hq
run: |
if grep -qw avx /proc/cpuinfo; then
make clean
make -j$(nproc) check CC="gcc -mavx" SANITIZER=address,undefined
else
echo "AVX unavailable on this runner; scalar/SSE tests ran above."
fi
- name: Build and run extra-channel capacity test (ASan + UBSan)
working-directory: samples/audio/extra_capacity
run: |
make -j$(nproc) check SANITIZER=address,undefined
make clean
make -j$(nproc) check SIMD_MASK=RESAMPLER_SIMD_SSE SANITIZER=address,undefined
- name: Build and run resampler option tests (C89, ASan + UBSan)
working-directory: samples/audio/resampler_options
run: |
make -j$(nproc) check SANITIZER=address,undefined