summaryrefslogtreecommitdiff
path: root/bin
diff options
authorDaniel Manrique <roadmr@ubuntu.com>2014-09-17 20:56:34 +0000
committerDaniel Manrique <>2014-09-17 20:56:34 +0000
commitc184ad319fa1f1df99e581efc640bb8ce7b21e7f (patch)
tree696f7122cfc66149c70f19041a0ce85fedcdbcce /bin
parent3e6d94f155bb59b95b5e484d21349f785a73bcb2 (diff)
parentbd73d49e9fa8d2c90c6102b9c0efc0bdd5f78e28 (diff)
"providers:checkbox: convert bluetooth/audio to use pulseaudio. [r=roadmr,cypressyew][bug=1361720][author=roadmr]"
Diffstat (limited to 'bin')
-rwxr-xr-xbin/audio_bluetooth_loopback_test57
1 files changed, 57 insertions, 0 deletions
diff --git a/bin/audio_bluetooth_loopback_test b/bin/audio_bluetooth_loopback_test
new file mode 100755
index 00000000..9661ec47
--- /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