diff options
| -rwxr-xr-x | bin/audio_bluetooth_loopback_test | 57 | ||||
| -rw-r--r-- | jobs/bluetooth.txt.in | 2 |
2 files changed, 58 insertions, 1 deletions
diff --git a/bin/audio_bluetooth_loopback_test b/bin/audio_bluetooth_loopback_test new file mode 100755 index 0000000..9661ec4 --- /dev/null +++ b/bin/audio_bluetooth_loopback_test @@ -0,0 +1,57 @@ +#!/bin/bash +# +# This file is part of Checkbox. +# +# Copyright 2014 Canonical Ltd. +# +# Authors: Daniel Manrique <roadmr@ubuntu.com> +# +# Checkbox is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 3, +# as published by the Free Software Foundation. +# +# Checkbox is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Checkbox. If not, see <http://www.gnu.org/licenses/>. +# +# This simple script finds a bluetooth source and sink, and records from the +# source for 6 seconds, playing the recording back into the sink. It helps a +# human validate that record/playback is working, human can speak into +# microphone and just ensure the speech can be heard instantly in the headset. + +[ -x "`which pactl`" ] || exit 1 +[ -x "`which pacat`" ] || exit 1 + +SINK=$(pactl list | sed -n '/monitor/d;s/Name: \(bluez_sink\.\)/\1/p') +SOURCE=$(pactl list | sed -n '/monitor/d;s/Name: \(bluez_source\.\)/\1/p') + + +if [ -n "$SINK" ] && [ -n "$SOURCE" ]; then + PLAYBACK_LOG=$(mktemp --tmpdir audio_bluetooth_loopback.XXXXX) + RECORD_LOG=$(mktemp --tmpdir audio_bluetooth_loopback.XXXXX) + trap "rm $PLAYBACK_LOG $RECORD_LOG" EXIT + # ensure we exit with failure if parec fails, and not with pacat + # --playback's error code + set -o pipefail + # Use a short latency parameter so time between speech and hearing it is + # short, makes for a nicer interactive experience + LATENCY="--latency-msec=50" + # time out after 6 seconds, forcibly kill after 8 seconds if pacat didn't + # respond + echo "Recording and playing back, please speak into bluetooth microphone" + timeout -k 8 6 pacat $LATENCY --record -v -d $SOURCE 2>$RECORD_LOG | \ + pacat $LATENCY --playback -v -d $SINK 2>$PLAYBACK_LOG + + echo "RECORD LOG" + cat $RECORD_LOG + echo "" + echo "PLAYBACK LOG" + cat $PLAYBACK_LOG +else + echo "No bluetooth audio device found" + exit 1 +fi diff --git a/jobs/bluetooth.txt.in b/jobs/bluetooth.txt.in index 1ca359e..da371fb 100644 --- a/jobs/bluetooth.txt.in +++ b/jobs/bluetooth.txt.in @@ -84,7 +84,7 @@ plugin: user-interact-verify id: bluetooth/audio depends: bluetooth/detect-output estimated_duration: 120.0 -command: arecord -d 5 -D bluetooth -f S16_LE | aplay -D bluetooth -f S16_LE +command: audio_bluetooth_loopback_test _description: PURPOSE: This test will check that you can record and hear audio using a bluetooth audio device |
