Repository navigation
Conversation
…pers Add compress pipeline tracking across sof-tplgreader.py, case-lib/pipeline.sh, and test-case/verify-pcm-list.sh: - Expose pipeline['compress'] and map compress:1 nodes to /dev/snd/comprC*D*. - Exclude compress:1 streams from default PCM pipeline blocks and from /proc/asound/pcm matching in verify-pcm-list.sh. - Preserve the compress field when deduplicating or sorting pipelines. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add compressed audio testing infrastructure and test cases for upstream FFmpeg decoders/encoders (ffmpeg_dec / ffmpeg_enc): - tools/sof-compr-tool.py: Python ALSA compress ioctl helper supporting playback, capture, pause/resume, SND_AUDIOCODEC_BESPOKE framing, and GET_CAPS queries across flac, mp3, aac, opus, alac, sbc, msbc, g722, and aptx. - case-lib/compress.sh: shared codec capability/default mapping, ffmpeg test vector generation, header/container verification, and cplay/crecord mode selection. - test-case/check-compr-decode.sh: compressed decode test across cplay and sof-compr-tool.py with optional pause/resume stress. - test-case/check-compr-encode.sh: compressed capture test across crecord and sof-compr-tool.py with header and host decode verification. - test-case/check-compr-roundtrip.sh: concurrent compress playback and capture validation. Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
There was a problem hiding this comment.
🟡 Changes recommended
The Python playback drain has no deadline, so a hang can stall the default decode run indefinitely instead of reporting failure and collecting logs.
7 open issues
Bound playback drain time to prevent indefinite hangs · New Treat only unsupported-codec errors as skippable · New Raw ALAC capture can succeed without producing the requested WAV · New Reject cplay mode when pause/resume cycles are requested · New Derive the playback watchdog from the requested duration · New Normalize timeout status beforeset -eexits · New Include duration in cached codec vector filenames · New
What changed in this PR
Adds compressed-audio testing for SOF’s FFmpeg decoders and encoders, while keeping compressed devices separate from regular PCM tests. The PR remains draft pending the firmware fixes described in its validation notes.
Changes:
- Expose compressed pipeline metadata and exclude compressed devices from regular PCM checks.
- Add a direct ALSA compress ioctl utility and shared codec generation, routing, and validation helpers.
- Add decode, encode, and concurrent playback/capture tests, with optional decode pause/resume and loopback checks.
| File | Description |
|---|---|
tools/sof-tplgreader.py |
Exposes compress metadata, maps device nodes, and updates filtering. |
tools/sof-compr-tool.py |
Adds capability queries, compressed playback, and capture through ioctls. |
test-case/verify-pcm-list.sh |
Excludes compressed devices from PCM-list comparisons. |
test-case/check-compr-roundtrip.sh |
Tests concurrent compressed playback and capture. |
test-case/check-compr-encode.sh |
Tests encoding, stream validation, and optional loopback tone checks. |
test-case/check-compr-decode.sh |
Tests decoding, pause/resume, and optional loopback capture. |
case-lib/pipeline.sh |
Preserves compress metadata during pipeline copying and sorting. |
case-lib/compress.sh |
Provides shared codec defaults, vectors, validation, and backend routing. |
Review effort: Balanced
| fcntl.ioctl(fd, SNDRV_COMPRESS_RESUME) | ||
| paused_done += 1 | ||
|
|
||
| fcntl.ioctl(fd, SNDRV_COMPRESS_DRAIN) |
There was a problem hiding this comment.
Fixed in 9283c3e: sof-compr-tool.py play now bounds SNDRV_COMPRESS_DRAIN with --drain-timeout-ms (default 15000 ms) via SIGALRM + ITIMER_REAL, triggering SNDRV_COMPRESS_STOP on timeout, and func_compr_run_play also wraps Python playback in an outer timeout -k 5 watchdog. Verified against the G.722 hang on Ladybird (~2.47s clean failure).
| python3 "$COMPR_TOOL" caps -D "$snd_dev" --direction "$direction" \ | ||
| --has-codec "$codec" >/dev/null 2>&1 |
There was a problem hiding this comment.
Fixed in 9283c3e: func_compr_dev_supports_codec now captures tool output and returns 1 only when sof-compr-tool.py caps exits 2 (unsupported codec); any other non-zero exit logs diagnostics and returns 2 so check-compr-decode.sh, check-compr-encode.sh, and check-compr-roundtrip.sh fail instead of silently skipping.
| if [ "${alac_mode%% *}" != "caf" ]; then | ||
| dlogi "Verified alac magic cookie + raw frames ($fsize B, ${alac_mode#raw })" | ||
| return 0 |
There was a problem hiding this comment.
Fixed in 9283c3e: func_compr_verify_encoded_file now returns 2 for raw header-only ALAC verification (and removes any stale target WAV), allowing check-compr-encode.sh to fail explicitly if -L tone verification was requested and check-compr-roundtrip.sh to treat rc=2 as valid header-only capture without requesting a WAV.
| local rate ch bitrate fmt cplay_codec _ | ||
| read -r rate ch bitrate fmt cplay_codec _ <<< "$defaults" | ||
|
|
||
| if [ "$tool_mode" = "cplay" ] || { [ "$tool_mode" = "auto" ] && [ "$pause_cycles" -eq 0 ] && func_compr_cplay_supports "$codec"; }; then |
There was a problem hiding this comment.
Fixed in 9283c3e: check-compr-decode.sh and func_compr_run_play now reject cplay mode when --pause_resume > 0, and -m all -P >0 skips cplay cleanly while still exercising compr-tool.
| return 1 | ||
| } | ||
| dlogc "timeout -s INT 30 cplay -c $COMPR_CARD -d $COMPR_DEV -I $cplay_codec $in_file" | ||
| timeout -s INT 30 cplay -c "$COMPR_CARD" -d "$COMPR_DEV" -I "$cplay_codec" "$in_file" |
There was a problem hiding this comment.
Fixed in 9283c3e: func_compr_run_play now takes duration and computes the timeout -k 5 watchdog as duration + 30 + pause_cycles * 2 seconds for both cplay and sof-compr-tool.py (callers in check-compr-decode.sh and check-compr-roundtrip.sh pass $duration).
| "${rec_cmd[@]}" > "$out_file" | ||
| local rc=$? |
There was a problem hiding this comment.
Fixed in 9283c3e: func_compr_run_record now captures crecord exit status via "${rec_cmd[@]}" > "$out_file" || rc=$? so normal timeout status 124/130 is normalized cleanly even under set -e background invocations.
| vec_file="${work_dir}/dec_${codec}_${rate}hz_${ch}ch.${codec}" | ||
| if [ "$codec" = "alac" ]; then | ||
| vec_file="${work_dir}/dec_alac_${rate}hz_${ch}ch.m4a" | ||
| elif [ "$codec" = "msbc" ]; then | ||
| vec_file="${work_dir}/dec_msbc_${rate}hz_${ch}ch.sbc" |
There was a problem hiding this comment.
Fixed in 9283c3e: check-compr-decode.sh (and check-compr-roundtrip.sh) now include ${duration}s in cached codec vector filenames.
- tools/sof-compr-tool.py: bound blocking SNDRV_COMPRESS_DRAIN with SIGALRM
(--drain-timeout-ms), add StreamConfig dataclass and per-codec default
bitrates, and satisfy pylint rules cleanly.
- tools/sof-tplgreader.py: wrap CLI entrypoint in main(), extract helpers,
use sys.exit, and satisfy pylint rules cleanly.
- case-lib/compress.sh: export codec list globals (SC2034), distinguish
device/ioctl errors (rc != 2) from unsupported codecs in GET_CAPS checks,
return rc=2 for raw ALAC header-only validation when no WAV is produced,
reject cplay mode when pause_cycles > 0, derive playback watchdog from
duration, and normalize timeout status safely under set -e.
- test-case/check-compr-{decode,encode,roundtrip}.sh: include duration in
cached vector names, handle GET_CAPS errors and raw ALAC tone checks
explicitly, skip/reject cplay with -P > 0, and avoid SC2015 warnings.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
…eader - tools/sof-compr-tool.py: split BufferConfig out of StreamConfig to keep instance attributes within pylint limits (R0902). - tools/sof-tplgreader.py: extract _build_arg_parser and _print_pipeline_output helpers from main() to reduce branches (R0912). Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>


Summary
Add
cplay/crecordand ALSA compress ioctl (tools/sof-compr-tool.py) test cases for upstream FFmpeg compressed audio decoders and encoders (ffmpeg_dec/ffmpeg_enc):tools/sof-tplgreader.py,case-lib/pipeline.sh,test-case/verify-pcm-list.sh:compresspipeline metadata and mapcompress:1nodes to/dev/snd/comprC*D*.compress:1pipelines by default in regular PCM test filters and exclude them from/proc/asound/pcmcomparison inverify-pcm-list.sh.tools/sof-compr-tool.py:play,record,caps) supporting pause/resume stress,SND_AUDIOCODEC_BESPOKEframing, andGET_CAPSacrossflac,mp3,aac,opus,alac,sbc,msbc,g722, andaptx.case-lib/compress.sh:ffmpegvector generation, encoded header/container validation (including raw 36-byte QuickTime'alac'atom captures), andcplay/crecordmode routing.test-case/check-compr-decode.sh,check-compr-encode.sh,check-compr-roundtrip.sh:-m cplay|crecord|compr-tool|auto|alland optional-Ppause/resume cycles.Validation Status (Ladybird / WCL-U)
Tested on Ladybird (
WCL-U,sof-wcl-rt722-ffmpeg.tplg, FW2.15.99.1built withCONFIG_COMP_FFMPEG_DEC=y/CONFIG_SOF_ZEPHYR_HEAP_SIZE=0x84000/ Core 0 test topology):check-compr-encode.sh -m all -d 2): PASS across all 9 runs (mp3,aac,flacviacrecord&sof-compr-tool.py,alac,sbc,msbc,g722,aptx), 0 mtrace errors.check-compr-decode.sh -C opus,alac -m compr-tool -P 1 -d 2): PASS (0 mtrace errors).cplay/compr-tool) remaining FW items:flac,mp3,aac,sbc,msbcplay throughEOS: compress drain completecleanly in bothcplayandsof-compr-tool.py, but DSP FW currently logs EOS flush<err>lines (avcodec_send_packet/avcodec_receive_frame) that triggermtracecheck failure.g722decode currently hangs inSNDRV_COMPRESS_DRAINin FW (ffmpeg_dec_is_ready_to_process()does not re-enter whenpcm_avail == 0 && avail == 0at EOS).aptxdecode currently fails on packet test-case: add verify-ucm-config.sh #1 in FW (unparsed packet reassembly buffer full or invalid block/-5).check-compr-roundtrip.sh -d 2): blocked by non-modular builtin FW memory OOM (-ENOMEM) during concurrent compress playback + capture (requires modular=mLLEXTz_errno_wrapshim fix in SOF FW).check-playback.sh -d 1 -l 1 -S id:0): PASS.Marked Draft while tracking the corresponding SOF firmware fixes before CI promotion.
Signed-off-by: Liam Girdwood liam.r.girdwood@linux.intel.com