22# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
33# SPDX-License-Identifier: BSD-3-Clause-Clear
44#
5- # Audio Record/Playback Validation using GStreamer (8 tests total)
5+ # Audio Record/Playback Validation using GStreamer (10 tests total)
66#
77# Test Sequence:
88# ENCODE PHASE (4 tests):
1111# 3. record_pulsesrc_wav - pulsesrc HW → wavenc → file
1212# 4. record_pulsesrc_flac- pulsesrc HW → flacenc → file
1313#
14- # DECODE PHASE (4 tests):
14+ # DECODE PHASE (6 tests):
1515# 5. playback_wav - file → wavparse → pulsesink
1616# 6. playback_flac - file → flacparse → flacdec → pulsesink
1717# 7. playback_pulsesrc_wav - file → wavparse → pulsesink
1818# 8. playback_pulsesrc_flac - file → flacparse → flacdec → pulsesink
19+ # 9. playback_sample_ogg - file → oggdemux → vorbisdec → pulsesink
20+ # 10. playback_sample_mp3 - file → mpegaudioparse → mpg123audiodec → pulsesink
1921#
2022# Features:
2123# - audiotestsrc: Synthetic audio generation (uses num-buffers for duration control)
2224# - pulsesrc: Hardware audio capture (uses timeout for duration control)
2325# - pulsesink: Audio playback
24- # - Formats: WAV (wavenc/wavparse), FLAC (flacenc/flacparse/flacdec)
26+ # - Formats: WAV (wavenc/wavparse), FLAC (flacenc/flacparse/flacdec), OGG (oggdemux/vorbisdec), MP3 (mpegaudioparse/mpg123audiodec)
27+ # - Test file provisioning via URL download or local path
2528# - Duration control via AUDIO_DURATION env var (default: 10 seconds)
2629#
2730# Logs everything to console and local log files.
@@ -96,6 +99,8 @@ testMode="${AUDIO_TEST_MODE:-all}"
9699formatList=" ${AUDIO_FORMATS:- wav,flac} "
97100duration=" ${AUDIO_DURATION:- ${RUNTIMESEC:- 10} } "
98101gstDebugLevel=" ${AUDIO_GST_DEBUG:- ${GST_DEBUG_LEVEL:- 2} } "
102+ clipUrl=" ${AUDIO_CLIP_URL:- https:// github.com/ qualcomm-linux/ qcom-linux-testkit/ releases/ download/ GST-Audio-Files-v1.0/ audio_clips_gst.tar.gz} "
103+ clipPath=" ${AUDIO_CLIP_PATH:- } "
99104
100105# Calculate num_buffers based on duration
101106# Formula: num_buffers = (sample_rate * duration) / samples_per_buffer
@@ -191,6 +196,26 @@ while [ $# -gt 0 ]; do
191196 shift 2
192197 ;;
193198
199+ --clip-url)
200+ if [ $# -lt 2 ] || [ " ${2# --} " != " $2 " ]; then
201+ log_warn " Missing/invalid value for --clip-url"
202+ echo " $TESTNAME SKIP" > " $RES_FILE "
203+ exit 0
204+ fi
205+ [ -n " $2 " ] && clipUrl=" $2 "
206+ shift 2
207+ ;;
208+
209+ --clip-path)
210+ if [ $# -lt 2 ] || [ " ${2# --} " != " $2 " ]; then
211+ log_warn " Missing/invalid value for --clip-path"
212+ echo " $TESTNAME SKIP" > " $RES_FILE "
213+ exit 0
214+ fi
215+ [ -n " $2 " ] && clipPath=" $2 "
216+ shift 2
217+ ;;
218+
194219 -h|--help)
195220 echo " $TESTNAME SKIP" > " $RES_FILE "
196221 exit 0
@@ -563,11 +588,152 @@ run_playback_pulsesrc_test() {
563588 fi
564589}
565590
591+ # -------------------- Test file playback test function (OGG/MP3) --------------------
592+ run_playback_ogg_mp3_test () {
593+ fmt=" $1 "
594+
595+ testname=" playback_sample_${fmt} "
596+ log_info " =========================================="
597+ log_info " Running: $testname "
598+ log_info " =========================================="
599+
600+ # Determine input file based on format
601+ case " $fmt " in
602+ ogg)
603+ input_file=" $OUTDIR /sample_audio.ogg"
604+ ;;
605+ mp3)
606+ input_file=" $OUTDIR /sample_audio.mp3"
607+ ;;
608+ * )
609+ log_warn " $testname : SKIP - unsupported format: $fmt "
610+ skip_count=$(( skip_count + 1 ))
611+ return 1
612+ ;;
613+ esac
614+
615+ if [ ! -f " $input_file " ]; then
616+ log_warn " $testname : SKIP - Test file not found: $input_file "
617+ skip_count=$(( skip_count + 1 ))
618+ return 1
619+ fi
620+
621+ # Check if file has minimum content
622+ file_size=" $( gstreamer_file_size_bytes " $input_file " ) "
623+ if [ " $file_size " -le 1000 ]; then
624+ log_warn " $testname : SKIP - Test file too small: $file_size bytes"
625+ skip_count=$(( skip_count + 1 ))
626+ return 1
627+ fi
628+
629+ test_log=" $OUTDIR /${testname} .log"
630+ : > " $test_log "
631+
632+ pipeline=" $( gstreamer_build_audio_playback_pipeline " $fmt " " $input_file " ) "
633+
634+ if [ -z " $pipeline " ]; then
635+ log_fail " $testname : FAIL (could not build playback pipeline - format not supported or elements missing)"
636+ fail_count=$(( fail_count + 1 ))
637+ return 1
638+ fi
639+
640+ log_info " Pipeline: $pipeline "
641+
642+ # Run playback
643+ if gstreamer_run_gstlaunch_timeout " $(( duration + 10 )) " " $pipeline " >> " $test_log " 2>&1 ; then
644+ gstRc=0
645+ else
646+ gstRc=$?
647+ fi
648+
649+ log_info " Playback exit code: $gstRc "
650+
651+ # Check for GStreamer errors in log
652+ if ! gstreamer_validate_log " $test_log " " $testname " ; then
653+ log_fail " $testname : FAIL (GStreamer errors detected)"
654+ fail_count=$(( fail_count + 1 ))
655+ return 1
656+ fi
657+
658+ # Check for successful completion
659+ if [ " $gstRc " -eq 0 ] || [ " $gstRc " -eq 124 ] || [ " $gstRc " -eq 143 ]; then
660+ log_pass " $testname : PASS"
661+ pass_count=$(( pass_count + 1 ))
662+ return 0
663+ else
664+ log_fail " $testname : FAIL (rc=$gstRc )"
665+ fail_count=$(( fail_count + 1 ))
666+ return 1
667+ fi
668+ }
669+
566670# -------------------- GStreamer debug capture --------------------
567671export GST_DEBUG_NO_COLOR=1
568672export GST_DEBUG=" $gstDebugLevel "
569673export GST_DEBUG_FILE=" $GST_LOG "
570674
675+ # -------------------- Test file provisioning (OGG/MP3) --------------------
676+ provision_test_files () {
677+ log_info " =========================================="
678+ log_info " TEST FILE PROVISIONING"
679+ log_info " =========================================="
680+
681+ sample_ogg=" $OUTDIR /sample_audio.ogg"
682+ sample_mp3=" $OUTDIR /sample_audio.mp3"
683+
684+ # Check if Test files already exist
685+ if [ -f " $sample_ogg " ] && [ -f " $sample_mp3 " ]; then
686+ log_info " Test files already exist"
687+ else
688+ # Try to get Test files from provided path or URL
689+ if [ -n " $clipPath " ]; then
690+ log_info " Attempting to get Test files from local path: $clipPath "
691+ if [ -f " $clipPath /sample_audio.ogg" ]; then
692+ cp " $clipPath /sample_audio.ogg" " $sample_ogg " 2> /dev/null || true
693+ log_info " Sample OGG file copied from local path"
694+ fi
695+ if [ -f " $clipPath /sample_audio.mp3" ]; then
696+ cp " $clipPath /sample_audio.mp3" " $sample_mp3 " 2> /dev/null || true
697+ log_info " Sample MP3 file copied from local path"
698+ fi
699+ fi
700+
701+ # If not found locally, try URL download
702+ if [ ! -f " $sample_ogg " ] || [ ! -f " $sample_mp3 " ]; then
703+ log_info " Test files not found locally; attempting download from URL..."
704+ if extract_tar_from_url " $clipUrl " " $OUTDIR " ; then
705+ log_pass " Test files downloaded and extracted successfully"
706+ else
707+ log_warn " Test file download failed (offline or URL issue)"
708+ fi
709+ fi
710+ fi
711+
712+ # Check what we have
713+ have_ogg=0
714+ have_mp3=0
715+
716+ if [ -f " $sample_ogg " ]; then
717+ size=$( gstreamer_file_size_bytes " $sample_ogg " )
718+ if [ " $size " -gt 1000 ]; then
719+ have_ogg=1
720+ log_info " OGG Test file available (size: $size bytes)"
721+ fi
722+ fi
723+
724+ if [ -f " $sample_mp3 " ]; then
725+ size=$( gstreamer_file_size_bytes " $sample_mp3 " )
726+ if [ " $size " -gt 1000 ]; then
727+ have_mp3=1
728+ log_info " MP3 Test file available (size: $size bytes)"
729+ fi
730+ fi
731+
732+ if [ " $have_ogg " -eq 0 ] && [ " $have_mp3 " -eq 0 ]; then
733+ log_warn " No Test files (OGG/MP3) available for playback tests"
734+ fi
735+ }
736+
571737# -------------------- Main test execution --------------------
572738log_info " Starting audio record/playback tests..."
573739
@@ -579,6 +745,9 @@ if ! check_required_elements; then
579745fi
580746log_info " Required GStreamer elements verified"
581747
748+ # Provision Test files for OGG/MP3 playback tests
749+ provision_test_files
750+
582751# Parse format list
583752formats=$( printf ' %s' " $formatList " | tr ' ,' ' ' )
584753
@@ -622,6 +791,13 @@ if [ "$testMode" = "all" ] || [ "$testMode" = "playback" ]; then
622791 total_tests=$(( total_tests + 1 ))
623792 run_playback_pulsesrc_test " $fmt " || true
624793 done
794+
795+ # 5. Playback Test files (2 tests: ogg, mp3)
796+ log_info " Playing back Test files (OGG/MP3)..."
797+ for fmt in ogg mp3; do
798+ total_tests=$(( total_tests + 1 ))
799+ run_playback_ogg_mp3_test " $fmt " || true
800+ done
625801fi
626802
627803# -------------------- Dmesg error scan --------------------
0 commit comments