Skip to content

Commit 5a40b13

Browse files
committed
Modified Audio scripts based on comments received
Signed-off-by: nitinn <nitinn@qti.qualcomm.com>
1 parent 15aedf4 commit 5a40b13

4 files changed

Lines changed: 60 additions & 53 deletions

File tree

Runner/suites/Multimedia/GSTreamer/Audio/Audio_Record_Playback/Audio_Record_Playback.yaml

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ metadata:
55
Audio record/playback validation using GStreamer (gst-launch-1.0).
66
Tests 10 scenarios: 4 encode (2 audiotestsrc + 2 pulsesrc) + 6 decode (4 playback + 2 OGG/MP3).
77
Supports WAV, FLAC, OGG, and MP3 formats with both synthetic audio (audiotestsrc) and hardware capture (pulsesrc).
8-
Duration controlled via AUDIO_DURATION (default 10s): audiotestsrc uses num-buffers, pulsesrc uses timeout.
8+
Duration controlled via AUDIO_DURATION (default 10s): audiotestsrc uses num-buffers calculated after argument parsing, pulsesrc uses timeout.
9+
Uses AUDIO_SHARED_RECORDED_DIR for shared artifact storage across test runs.
910
os:
1011
- linux
1112
scope:
@@ -21,27 +22,8 @@ params:
2122
run:
2223
steps:
2324
- REPO_PATH="$PWD"
24-
- cd Runner/suites/Multimedia/GSTreamer/Audio/Audio_Record_Playback/
25-
- |
26-
# Set shared directory to a fixed location outside test-specific paths
27-
# This ensures all tests (regardless of LAVA test number) use the same directory
28-
if [ -d "/home" ]; then
29-
# LAVA environment: use /home/shared
30-
AUDIO_SHARED_ENCODE_DIR="/home/shared/audio-record-playback"
31-
else
32-
# Local/non-LAVA: use standard shared path
33-
AUDIO_SHARED_ENCODE_DIR="${REPO_PATH%%/tests/*}/shared/audio-record-playback"
34-
fi
35-
mkdir -p "$AUDIO_SHARED_ENCODE_DIR" || true
36-
export AUDIO_SHARED_ENCODE_DIR
37-
- export AUDIO_TEST_MODE AUDIO_TEST_NAME AUDIO_FORMATS AUDIO_DURATION AUDIO_GST_DEBUG
38-
- |
39-
# Build command based on whether test-name is specified
40-
if [ -n "${AUDIO_TEST_NAME}" ]; then
41-
# Individual test mode
42-
./run.sh --test-name "${AUDIO_TEST_NAME}" --duration "${AUDIO_DURATION}" --gst-debug "${AUDIO_GST_DEBUG}" || true
43-
else
44-
# Grouped test mode (original behavior)
45-
./run.sh --mode "${AUDIO_TEST_MODE}" --formats "${AUDIO_FORMATS}" --duration "${AUDIO_DURATION}" --gst-debug "${AUDIO_GST_DEBUG}" || true
46-
fi
25+
- cd "$REPO_PATH/Runner/suites/Multimedia/GSTreamer/Audio/Audio_Record_Playback"
26+
- AUDIO_SHARED_RECORDED_DIR="${REPO_PATH%%/tests/*}/shared/audio-record-playback"
27+
- export REPO_PATH AUDIO_SHARED_RECORDED_DIR AUDIO_TEST_MODE AUDIO_TEST_NAME AUDIO_FORMATS AUDIO_DURATION AUDIO_GST_DEBUG
28+
- ./run.sh || true
4729
- $REPO_PATH/Runner/utils/send-to-lava.sh Audio_Record_Playback.res

Runner/suites/Multimedia/GSTreamer/Audio/Audio_Record_Playback/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,14 +537,19 @@ fi
537537
The test supports these environment variables (can be set in LAVA job definition):
538538

539539
- `AUDIO_TEST_MODE` - Test mode (all/record/playback) (default: all)
540+
- `AUDIO_TEST_NAME` - Individual test name for single test execution (optional)
540541
- `AUDIO_FORMATS` - Comma-separated format list (default: `wav,flac`)
541542
- `AUDIO_DURATION` - Recording duration in seconds (default: 10)
542543
- `RUNTIMESEC` - Alternative to AUDIO_DURATION (for backward compatibility)
543544
- `AUDIO_GST_DEBUG` - GStreamer debug level (default: 2)
544545
- `GST_DEBUG_LEVEL` - Alternative to AUDIO_GST_DEBUG
546+
- `AUDIO_SHARED_RECORDED_DIR` - Shared directory for recorded audio artifacts (optional)
547+
- `REPO_PATH` - Repository root path (set by YAML, used for path resolution)
545548

546549
**Priority order for duration**: `AUDIO_DURATION` > `RUNTIMESEC` > default (10)
547550

551+
**Shared Artifact Directory**: The test uses `AUDIO_SHARED_RECORDED_DIR` to store recorded audio files in a shared location across multiple test runs. If not set, the test will automatically determine the appropriate directory based on the environment (LAVA vs local).
552+
548553
### Test Counting
549554

550555
- **Total tests**: 10 (when running with default wav,flac formats in all mode)

Runner/suites/Multimedia/GSTreamer/Audio/Audio_Record_Playback/run.sh

Lines changed: 45 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -47,26 +47,6 @@ OUTDIR="$LOG_DIR/$TESTNAME"
4747
GST_LOG="$OUTDIR/gst.log"
4848
DMESG_DIR="$OUTDIR/dmesg"
4949

50-
# Use the shared recorded directory if AUDIO_SHARED_ENCODE_DIR is set; otherwise use function or default.
51-
if [ -n "${AUDIO_SHARED_ENCODE_DIR:-}" ]; then
52-
RECORDED_DIR="$AUDIO_SHARED_ENCODE_DIR"
53-
elif command -v gstreamer_shared_recorded_dir >/dev/null 2>&1; then
54-
RECORDED_DIR="$(gstreamer_shared_recorded_dir "$SCRIPT_DIR" "$OUTDIR")"
55-
else
56-
RECORDED_DIR="$OUTDIR/recorded"
57-
fi
58-
59-
if ! mkdir -p "$OUTDIR" "$DMESG_DIR" "$RECORDED_DIR"; then
60-
log_error "Failed to create required directories:"
61-
log_error " OUTDIR=$OUTDIR"
62-
log_error " DMESG_DIR=$DMESG_DIR"
63-
log_error " RECORDED_DIR=$RECORDED_DIR"
64-
echo "$TESTNAME FAIL" >"$RES_FILE" 2>/dev/null || true
65-
exit 0
66-
fi
67-
: >"$RES_FILE"
68-
: >"$GST_LOG"
69-
7050
INIT_ENV=""
7151
SEARCH="$SCRIPT_DIR"
7252
while [ "$SEARCH" != "/" ]; do
@@ -95,6 +75,46 @@ fi
9575
# shellcheck disable=SC1091
9676
. "$TOOLS/lib_gstreamer.sh"
9777

78+
# Create required directories now that log functions are available
79+
if ! mkdir -p "$OUTDIR" "$DMESG_DIR"; then
80+
log_error "Failed to create required directories:"
81+
log_error " OUTDIR=$OUTDIR"
82+
log_error " DMESG_DIR=$DMESG_DIR"
83+
echo "$TESTNAME FAIL" >"$RES_FILE" 2>/dev/null || true
84+
exit 0
85+
fi
86+
: >"$RES_FILE"
87+
: >"$GST_LOG"
88+
89+
# -------------------- Set up shared recorded directory --------------------
90+
# Set shared directory to a fixed location outside test-specific paths
91+
# This ensures all tests (regardless of LAVA test number) use the same directory
92+
if [ -z "${AUDIO_SHARED_RECORDED_DIR:-}" ]; then
93+
if [ -d "/home" ]; then
94+
# LAVA environment: use /home/shared
95+
AUDIO_SHARED_RECORDED_DIR="/home/shared/audio-record-playback"
96+
else
97+
# Local/non-LAVA: use standard shared path
98+
AUDIO_SHARED_RECORDED_DIR="${REPO_PATH%%/tests/*}/shared/audio-record-playback"
99+
fi
100+
fi
101+
102+
# Use the shared recorded directory if AUDIO_SHARED_RECORDED_DIR is set; otherwise use function or default.
103+
if [ -n "${AUDIO_SHARED_RECORDED_DIR:-}" ]; then
104+
RECORDED_DIR="$AUDIO_SHARED_RECORDED_DIR"
105+
elif command -v gstreamer_shared_recorded_dir >/dev/null 2>&1; then
106+
RECORDED_DIR="$(gstreamer_shared_recorded_dir "$SCRIPT_DIR" "$OUTDIR")"
107+
else
108+
RECORDED_DIR="$OUTDIR/recorded"
109+
fi
110+
111+
# Create the recorded directory
112+
if ! mkdir -p "$RECORDED_DIR"; then
113+
log_error "Failed to create recorded directory: $RECORDED_DIR"
114+
echo "$TESTNAME FAIL" >"$RES_FILE"
115+
exit 0
116+
fi
117+
98118
result="FAIL"
99119
reason="unknown"
100120
pass_count=0
@@ -111,11 +131,6 @@ gstDebugLevel="${AUDIO_GST_DEBUG:-${GST_DEBUG_LEVEL:-2}}"
111131
clipUrl="${AUDIO_CLIP_URL:-https://github.com/qualcomm-linux/qcom-linux-testkit/releases/download/GST-Audio-Files-v1.0/audio_clips_gst.tar.gz}"
112132
clipPath="${AUDIO_CLIP_PATH:-}"
113133

114-
# Calculate num_buffers based on duration
115-
# Formula: num_buffers = (sample_rate * duration) / samples_per_buffer
116-
# Example: (44100 * 10) / 1024 = 430 buffers for 10 seconds
117-
NUM_BUFFERS=$(( (SAMPLE_RATE * duration) / SAMPLES_PER_BUFFER ))
118-
119134
# Validate numeric parameters (only validate if explicitly set)
120135
for param in AUDIO_DURATION AUDIO_GST_DEBUG GST_DEBUG_LEVEL; do
121136
val=""
@@ -367,6 +382,11 @@ if [ -n "$testName" ]; then
367382
esac
368383
fi
369384

385+
# Calculate num_buffers based on final duration value
386+
# Formula: num_buffers = (sample_rate * duration) / samples_per_buffer
387+
# Example: (44100 * 10) / 1024 = 430 buffers for 10 seconds
388+
NUM_BUFFERS=$(( (SAMPLE_RATE * duration) / SAMPLES_PER_BUFFER ))
389+
370390
# -------------------- Pre-checks --------------------
371391
check_dependencies "gst-launch-1.0 gst-inspect-1.0 awk grep head sed tr stat find curl tar" >/dev/null 2>&1 || {
372392
log_skip "Missing required tools (gst-launch-1.0, gst-inspect-1.0, awk, grep, head, sed, tr, stat, find, curl, tar)"

Runner/utils/lib_gstreamer.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ GSTLAUNCHFLAGS="${GSTLAUNCHFLAGS:--e -v -m}"
2424
# gstreamer_shared_artifact_dir <env_var_name> <shared_subdir> <local_subdir> <script_dir> <outdir>
2525
# Generic function to get shared artifact directory for any test type.
2626
# Priority:
27-
# 1. Environment variable if explicitly provided (e.g., VIDEO_SHARED_ENCODE_DIR, AUDIO_SHARED_ENCODE_DIR)
27+
# 1. Environment variable if explicitly provided (e.g., VIDEO_SHARED_ENCODE_DIR, AUDIO_SHARED_RECORDED_DIR)
2828
# 2. A job-shared path derived from the common LAVA prefix before /tests/
2929
# 3. Fallback to <outdir>/<local_subdir> for local/manual runs
3030
#
@@ -37,7 +37,7 @@ GSTLAUNCHFLAGS="${GSTLAUNCHFLAGS:--e -v -m}"
3737
#
3838
# Example usage:
3939
# gstreamer_shared_artifact_dir "VIDEO_SHARED_ENCODE_DIR" "video-encode-decode" "encoded" "$SCRIPT_DIR" "$OUTDIR"
40-
# gstreamer_shared_artifact_dir "AUDIO_SHARED_ENCODE_DIR" "audio-record-playback" "recorded" "$SCRIPT_DIR" "$OUTDIR"
40+
# gstreamer_shared_artifact_dir "AUDIO_SHARED_RECORDED_DIR" "audio-record-playback" "recorded" "$SCRIPT_DIR" "$OUTDIR"
4141
gstreamer_shared_artifact_dir() {
4242
env_var_name="$1"
4343
shared_subdir="$2"
@@ -82,14 +82,14 @@ gstreamer_shared_encoded_dir() {
8282
# gstreamer_shared_recorded_dir <script_dir> <outdir>
8383
# Prints a directory path to use for recorded audio artifacts.
8484
# Priority:
85-
# 1. AUDIO_SHARED_ENCODE_DIR if explicitly provided
85+
# 1. AUDIO_SHARED_RECORDED_DIR if explicitly provided
8686
# 2. A job-shared path derived from the common LAVA prefix before /tests/
8787
# 3. Fallback to <outdir>/recorded for local/manual runs
8888
gstreamer_shared_recorded_dir() {
8989
script_dir="$1"
9090
outdir="$2"
9191

92-
gstreamer_shared_artifact_dir "AUDIO_SHARED_ENCODE_DIR" "audio-record-playback" "recorded" "$script_dir" "$outdir"
92+
gstreamer_shared_artifact_dir "AUDIO_SHARED_RECORDED_DIR" "audio-record-playback" "recorded" "$script_dir" "$outdir"
9393
}
9494
# -------------------- Element check --------------------
9595
has_element() {

0 commit comments

Comments
 (0)