|
| 1 | +# GStreamer Audio Tests |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +This test suite validates GStreamer audio pipelines using PulseAudio for capture and playback on Qualcomm platforms. It tests audio encoding (capture to WAV) and decoding (WAV playback) functionality. |
| 6 | + |
| 7 | +## Test Cases |
| 8 | + |
| 9 | +### 1. audio-encode |
| 10 | +**Pipeline:** |
| 11 | +```bash |
| 12 | +gst-launch-1.0 pulsesrc ! audioconvert ! audioresample ! identity eos-after=2000 ! wavenc ! filesink location=./output_audio.wav |
| 13 | +``` |
| 14 | + |
| 15 | +**Description:** |
| 16 | +- Captures audio from PulseAudio source |
| 17 | +- Converts and resamples audio format |
| 18 | +- Uses identity element with eos-after=2000 (2 seconds) for controlled capture |
| 19 | +- Encodes to WAV format |
| 20 | +- Saves to output_audio.wav |
| 21 | + |
| 22 | +**Validation:** |
| 23 | +- Pipeline completes without errors |
| 24 | +- Output file is created |
| 25 | +- No ERROR/WARNING messages in GStreamer output |
| 26 | +- No dmesg errors (if DMESG_SCAN enabled) |
| 27 | + |
| 28 | +### 2. audio-decode |
| 29 | +**Pipeline:** |
| 30 | +```bash |
| 31 | +gst-launch-1.0 filesrc location=./output_audio.wav ! wavparse ! audioconvert ! audioresample ! pulsesink |
| 32 | +``` |
| 33 | + |
| 34 | +**Description:** |
| 35 | +- Reads WAV file created by audio-encode test |
| 36 | +- Parses WAV format |
| 37 | +- Converts and resamples audio |
| 38 | +- Plays back through PulseAudio sink |
| 39 | + |
| 40 | +**Validation:** |
| 41 | +- Pipeline completes without errors |
| 42 | +- Audio playback successful |
| 43 | +- No ERROR/WARNING messages in GStreamer output |
| 44 | +- No dmesg errors (if DMESG_SCAN enabled) |
| 45 | + |
| 46 | +## Prerequisites |
| 47 | + |
| 48 | +### Required Packages |
| 49 | +```bash |
| 50 | +# GStreamer core and plugins |
| 51 | +gstreamer1.0-tools |
| 52 | +gstreamer1.0-plugins-base |
| 53 | +gstreamer1.0-plugins-good |
| 54 | + |
| 55 | +# PulseAudio support |
| 56 | +pulseaudio |
| 57 | +gstreamer1.0-pulseaudio |
| 58 | +``` |
| 59 | + |
| 60 | +### Audio Hardware |
| 61 | +- Working audio capture device (microphone) |
| 62 | +- Working audio playback device (speakers/headphones) |
| 63 | +- PulseAudio server running |
| 64 | + |
| 65 | +### Verification |
| 66 | +```bash |
| 67 | +# Check PulseAudio status |
| 68 | +pulseaudio --check |
| 69 | +echo $? # Should return 0 |
| 70 | + |
| 71 | +# List audio sources |
| 72 | +pactl list sources short |
| 73 | + |
| 74 | +# List audio sinks |
| 75 | +pactl list sinks short |
| 76 | + |
| 77 | +# Test audio capture |
| 78 | +gst-launch-1.0 pulsesrc ! fakesink |
| 79 | + |
| 80 | +# Test audio playback |
| 81 | +gst-launch-1.0 audiotestsrc ! pulsesink |
| 82 | +``` |
| 83 | + |
| 84 | +## Usage |
| 85 | + |
| 86 | +### Run All Tests |
| 87 | +```bash |
| 88 | +./run.sh --all |
| 89 | +``` |
| 90 | + |
| 91 | +### Run Specific Test |
| 92 | +```bash |
| 93 | +./run.sh --test audio-encode |
| 94 | +./run.sh --test audio-decode |
| 95 | +``` |
| 96 | + |
| 97 | +### List Available Tests |
| 98 | +```bash |
| 99 | +./run.sh --list |
| 100 | +``` |
| 101 | + |
| 102 | +### Custom Timeout |
| 103 | +```bash |
| 104 | +./run.sh --all --timeout 180 |
| 105 | +``` |
| 106 | + |
| 107 | +### Enable Strict Mode |
| 108 | +```bash |
| 109 | +./run.sh --all --strict |
| 110 | +``` |
| 111 | + |
| 112 | +### Disable dmesg Scanning |
| 113 | +```bash |
| 114 | +./run.sh --all --no-dmesg |
| 115 | +``` |
| 116 | + |
| 117 | +## CLI Options |
| 118 | + |
| 119 | +| Option | Description | Default | |
| 120 | +|--------|-------------|---------| |
| 121 | +| `--all` | Run all audio tests | - | |
| 122 | +| `--test <name>` | Run specific test | - | |
| 123 | +| `--list` | List available tests | - | |
| 124 | +| `--timeout <sec>` | Timeout per test | 120 | |
| 125 | +| `--repeat <n>` | Repeat count | 1 | |
| 126 | +| `--repeat-policy <all\|any>` | Pass policy | all | |
| 127 | +| `--strict` | Fail on warnings | false | |
| 128 | +| `--no-dmesg` | Skip dmesg scan | false | |
| 129 | +| `--help` | Show help | - | |
| 130 | + |
| 131 | +## Output Files |
| 132 | + |
| 133 | +### Result Files |
| 134 | +- `Gstreamer_Audio_Tests.res` - Overall PASS/FAIL/SKIP status |
| 135 | +- `logs_Gstreamer_Audio_Tests/` - Detailed logs directory |
| 136 | + - `audio-encode.log` - Encode test output |
| 137 | + - `audio-decode.log` - Decode test output |
| 138 | + - `summary.txt` - Test summary |
| 139 | + - `results.csv` - CSV format results |
| 140 | + - `.junit_cases.xml` - JUnit XML for CI |
| 141 | + - `dmesg_snapshot.log` - Kernel messages |
| 142 | + - `dmesg_errors.log` - Kernel errors (if any) |
| 143 | + |
| 144 | +### Generated Files |
| 145 | +- `output_audio.wav` - Audio file created by encode test |
| 146 | + |
| 147 | +## Validation Criteria |
| 148 | + |
| 149 | +### Pass Criteria |
| 150 | +✓ Pipeline executes without errors |
| 151 | +✓ Output files created successfully |
| 152 | +✓ No ERROR messages in GStreamer output |
| 153 | +✓ No WARNING messages (if --strict enabled) |
| 154 | +✓ No kernel errors in dmesg (if DMESG_SCAN enabled) |
| 155 | +✓ Exit code 0 from gst-launch-1.0 |
| 156 | + |
| 157 | +### Fail Criteria |
| 158 | +✗ Pipeline execution fails |
| 159 | +✗ ERROR messages in GStreamer output |
| 160 | +✗ WARNING messages (in strict mode) |
| 161 | +✗ Timeout exceeded |
| 162 | +✗ Output file not created |
| 163 | +✗ Kernel errors detected |
| 164 | + |
| 165 | +## Troubleshooting |
| 166 | + |
| 167 | +### PulseAudio Not Running |
| 168 | +```bash |
| 169 | +# Start PulseAudio |
| 170 | +pulseaudio --start |
| 171 | + |
| 172 | +# Check status |
| 173 | +pulseaudio --check |
| 174 | +``` |
| 175 | + |
| 176 | +### No Audio Devices |
| 177 | +```bash |
| 178 | +# List available sources |
| 179 | +pactl list sources short |
| 180 | + |
| 181 | +# List available sinks |
| 182 | +pactl list sinks short |
| 183 | + |
| 184 | +# Set default source/sink |
| 185 | +pactl set-default-source <source-name> |
| 186 | +pactl set-default-sink <sink-name> |
| 187 | +``` |
| 188 | + |
| 189 | +### Permission Issues |
| 190 | +```bash |
| 191 | +# Add user to audio group |
| 192 | +sudo usermod -a -G audio $USER |
| 193 | + |
| 194 | +# Verify group membership |
| 195 | +groups $USER |
| 196 | +``` |
| 197 | + |
| 198 | +### Audio Capture Fails |
| 199 | +```bash |
| 200 | +# Test with audiotestsrc instead |
| 201 | +gst-launch-1.0 audiotestsrc ! audioconvert ! audioresample ! wavenc ! filesink location=test.wav |
| 202 | + |
| 203 | +# Check microphone permissions |
| 204 | +ls -la /dev/snd/ |
| 205 | + |
| 206 | +# Test with arecord |
| 207 | +arecord -d 2 -f cd test.wav |
| 208 | +``` |
| 209 | + |
| 210 | +### Audio Playback Fails |
| 211 | +```bash |
| 212 | +# Test with speaker-test |
| 213 | +speaker-test -t sine -f 440 -c 2 |
| 214 | + |
| 215 | +# Test with aplay |
| 216 | +aplay test.wav |
| 217 | + |
| 218 | +# Check volume levels |
| 219 | +pactl list sinks | grep -i volume |
| 220 | +``` |
| 221 | + |
| 222 | +### Pipeline Negotiation Errors |
| 223 | +```bash |
| 224 | +# Enable debug output |
| 225 | +GST_DEBUG=3 gst-launch-1.0 pulsesrc ! audioconvert ! audioresample ! wavenc ! filesink location=test.wav |
| 226 | + |
| 227 | +# Check supported formats |
| 228 | +gst-inspect-1.0 pulsesrc |
| 229 | +gst-inspect-1.0 wavenc |
| 230 | +``` |
| 231 | + |
| 232 | +### Common Error Messages |
| 233 | + |
| 234 | +**"Could not open audio device for recording"** |
| 235 | +- PulseAudio not running or no capture device available |
| 236 | +- Check: `pactl list sources short` |
| 237 | + |
| 238 | +**"Could not open audio device for playback"** |
| 239 | +- PulseAudio not running or no playback device available |
| 240 | +- Check: `pactl list sinks short` |
| 241 | + |
| 242 | +**"Failed to connect stream"** |
| 243 | +- PulseAudio server connection issue |
| 244 | +- Restart: `pulseaudio --kill && pulseaudio --start` |
| 245 | + |
| 246 | +**"No space left on device"** |
| 247 | +- Insufficient disk space for output file |
| 248 | +- Check: `df -h .` |
| 249 | + |
| 250 | +## Environment Variables |
| 251 | + |
| 252 | +```bash |
| 253 | +# GStreamer debug level (0-9) |
| 254 | +export GST_DEBUG=3 |
| 255 | + |
| 256 | +# PulseAudio server |
| 257 | +export PULSE_SERVER=unix:/run/user/1000/pulse/native |
| 258 | + |
| 259 | +# Audio buffer size |
| 260 | +export PULSE_LATENCY_MSEC=50 |
| 261 | +``` |
| 262 | + |
| 263 | +## CI/CD Integration |
| 264 | + |
| 265 | +### LAVA Integration |
| 266 | +```yaml |
| 267 | +- test: |
| 268 | + definitions: |
| 269 | + - repository: https://git.codelinaro.org/clo/le/le-test-automation/qcom-linux-testkit |
| 270 | + from: git |
| 271 | + path: Runner/suites/Gstreamer/Audio/Gstreamer_Audio_Tests.yaml |
| 272 | + name: gstreamer-audio-tests |
| 273 | + parameters: |
| 274 | + TIMEOUT: "120" |
| 275 | + STRICT: "false" |
| 276 | + DMESG_SCAN: "true" |
| 277 | +``` |
| 278 | +
|
| 279 | +### Standalone Execution |
| 280 | +```bash |
| 281 | +# Basic run |
| 282 | +cd /path/to/qcom-linux-testkit/Runner/suites/Gstreamer/Audio |
| 283 | +./run.sh --all |
| 284 | + |
| 285 | +# With custom parameters |
| 286 | +TIMEOUT=180 STRICT=true ./run.sh --all |
| 287 | +``` |
| 288 | + |
| 289 | +## Platform Support |
| 290 | + |
| 291 | +| Platform | Status | Notes | |
| 292 | +|----------|--------|-------| |
| 293 | +| QCS6490 | ✓ Supported | Full audio support | |
| 294 | +| QCS8550 | ✓ Supported | Full audio support | |
| 295 | +| QCS8650 | ✓ Supported | Full audio support | |
| 296 | +| SA8775P | ✓ Supported | Full audio support | |
| 297 | +| SA8650P | ✓ Supported | Full audio support | |
| 298 | +| SA8255P | ✓ Supported | Full audio support | |
| 299 | + |
| 300 | +## Known Issues |
| 301 | + |
| 302 | +1. **PulseAudio Latency**: Some platforms may experience audio latency |
| 303 | + - Workaround: Adjust `PULSE_LATENCY_MSEC` environment variable |
| 304 | + |
| 305 | +2. **Device Busy**: Audio device may be in use by another application |
| 306 | + - Workaround: Stop other audio applications or use `fuser -k /dev/snd/*` |
| 307 | + |
| 308 | +3. **Sample Rate Mismatch**: Some devices may not support default sample rates |
| 309 | + - Workaround: Explicitly set sample rate in pipeline with `audio/x-raw,rate=48000` |
| 310 | + |
| 311 | +## Additional Resources |
| 312 | + |
| 313 | +- [GStreamer Documentation](https://gstreamer.freedesktop.org/documentation/) |
| 314 | +- [PulseAudio Documentation](https://www.freedesktop.org/wiki/Software/PulseAudio/) |
| 315 | +- [GStreamer PulseAudio Plugin](https://gstreamer.freedesktop.org/documentation/pulseaudio/) |
| 316 | +- [Audio Debugging Guide](https://wiki.archlinux.org/title/PulseAudio/Troubleshooting) |
| 317 | + |
| 318 | +## License |
| 319 | + |
| 320 | +``` |
| 321 | +Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. |
| 322 | +SPDX-License-Identifier: BSD-3-Clause-Clear |
0 commit comments