summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/4a-gst3
-rwxr-xr-xbin/4a-play56
-rwxr-xr-xbin/4a-speaker-test1
-rwxr-xr-xbin/gst-play56
-rw-r--r--bin/lib4a-tools.sh3
5 files changed, 50 insertions, 69 deletions
diff --git a/bin/4a-gst b/bin/4a-gst
deleted file mode 100755
index 9a06c83..0000000
--- a/bin/4a-gst
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-
-gst-launch-1.0 -v uridecodebin uri=file:///media/OrchestralBackgroundMusic.mp3 ! audioconvert ! audioresample ! alsasink device=hw:Loopback,0,2
diff --git a/bin/4a-play b/bin/4a-play
index 483b892..620f311 100755
--- a/bin/4a-play
+++ b/bin/4a-play
@@ -4,14 +4,54 @@
. $(dirname $BASH_SOURCE)/lib4a-tools.sh
function usage() {
- log "Usage: $0 <role:file1> [role:file2 ...]"
- log "Available roles:"
- exit 1
+ log "$0 <file> [device] [role]"
+ log " - 'device' can be hw:X where X is a number or the device name."
+ log " It can also be hw:X,Y,Z, it is used when playing on the loopback card"
+ log " which is the 4a default sink."
+ log " Default: hw:Loopback,0,2"
+ log " - 'role' is the 4a role to use. In future version it will be guessed"
+ log " based on the device. Use '4a-api roles' to get a list of known roles"
+ log " Default: multimedia"
}
-[[ $# == 0 ]] && usage
+if [ "$#" == "0" ]; then
+ error "No file to play!"
+ usage
+fi
+
+FILEPATH="$( realpath "$1" )"
+DEVICE=${2:-'hw:Loopback,0,2'}
+ROLE=${3:-'multimedia'}
+
+CARDID=$( echo "$DEVICE" | cut -d':' -f2 | cut -d',' -f1 )
+
+log "Play '$FILEPATH' on '$DEVICE'"
+
+LOOPBACK_CARDID=$( LANG="C" aplay -l | grep -oEe "^card\\s+[0-9]: Loopback" | uniq | grep -oEe "[0-9]+" )
+if [ "$CARDID" == "Loopback" ] || [ "$CARDID" == "$LOOPBACK_CARDID" ]; then
+ IS_4A_DEVICE=1
+else
+ IS_4A_DEVICE=0
+fi
+
+if [ "$IS_4A_DEVICE" == "1" ]; then
+ log "The selected card (hw:$CARDID) is handle by 4a, call open on '$ROLE'"
+ 4a-client ahl-4a "$ROLE" '{ "action": "open" }'
+
+ # BUG: afb-client-demo does not exit an exit code different from zero when api return an error
+ #if [ "$?" -ne "0" ]; then
+ # exit -1
+ #fi
+fi
+
+if [ "$DEBUG" == "1" ]; then
+ gst-launch-1.0 -v uridecodebin uri="file://$FILEPATH" ! audioconvert ! audioresample ! alsasink device="$DEVICE"
+else
+ gst-launch-1.0 -v uridecodebin uri="file://$FILEPATH" ! audioconvert ! audioresample ! alsasink device="$DEVICE" > /dev/null
+fi
+
+if [ "$IS_4A_DEVICE" == "1" ]; then
+ log "The selected card (hw;$CARDID) is handled by 4a, call close on '$ROLE'"
+ 4a-client ahl-4a "$ROLE" '{ "action": "close" }'
+fi
-for x in "$@"; do
- log "Playing $x ..."
- aplay -D Loopback,0,2 $x
-done
diff --git a/bin/4a-speaker-test b/bin/4a-speaker-test
deleted file mode 100755
index 770ddfd..0000000
--- a/bin/4a-speaker-test
+++ /dev/null
@@ -1 +0,0 @@
-# TODO: run speaker test
diff --git a/bin/gst-play b/bin/gst-play
deleted file mode 100755
index 46a6c4a..0000000
--- a/bin/gst-play
+++ /dev/null
@@ -1,56 +0,0 @@
-#!/bin/bash
-
-# load shell lib
-. $(dirname $BASH_SOURCE)/lib4a-tools.sh
-
-function usage() {
- log "$0 <file> [device] [role]"
- log " - 'device' can be hw:X where X is a number or the device name."
- log " It can also be hw:X,Y,Z, it is used when playing on the loopback card"
- log " which is the 4a default sink."
- log " Default: hw:Loopback,0,2"
- log " - 'role' is the 4a role to use. In future version it will be guessed"
- log " based on the device. Use '4a-api roles' to get a list of known roles"
- log " Default: multimedia"
-}
-
-if [ "$#" == "0" ]; then
- error "No file to play!"
- usage
-fi
-
-FILEPATH="$( realpath "$1" )"
-DEVICE=${2:-'hw:Loopback,0,2'}
-ROLE=${3:-'multimedia'}
-
-CARDID=$( echo "$DEVICE" | cut -d':' -f2 | cut -d',' -f1 )
-
-log "Play '$FILEPATH' on '$DEVICE'"
-
-LOOPBACK_CARDID=$( LANG="C" aplay -l | grep -oEe "^card\\s+[0-9]: Loopback" | uniq | grep -oEe "[0-9]+" )
-if [ "$CARDID" == "Loopback" ] || [ "$CARDID" == "$LOOPBACK_CARDID" ]; then
- IS_4A_DEVICE=1
-else
- IS_4A_DEVICE=0
-fi
-
-if [ "$IS_4A_DEVICE" == "1" ]; then
- log "The selected card (hw:$CARDID) is handle by 4a, call open on '$ROLE'"
- 4a-client ahl-4a "$ROLE" '{ "action": "open" }'
-
- # BUG: afb-client-demo does not exit an exit code different from zero when api return an error
- #if [ "$?" -ne "0" ]; then
- # exit -1
- #fi
-fi
-
-if [ "$DEBUG" == "1" ]; then
- gst-launch-1.0 -v uridecodebin uri="file://$FILEPATH" ! audioconvert ! audioresample ! alsasink device="$DEVICE"
-else
- gst-launch-1.0 -v uridecodebin uri="file://$FILEPATH" ! audioconvert ! audioresample ! alsasink device="$DEVICE" > /dev/null
-fi
-
-if [ "$IS_4A_DEVICE" == "1" ]; then
- log "The selected card (hw;$CARDID) is handled by 4a, call close on '$ROLE'"
- 4a-client ahl-4a "$ROLE" '{ "action": "close" }'
-fi
diff --git a/bin/lib4a-tools.sh b/bin/lib4a-tools.sh
index ab0ee18..776b1c0 100644
--- a/bin/lib4a-tools.sh
+++ b/bin/lib4a-tools.sh
@@ -26,8 +26,9 @@ function 4a-client() {
# get port for audio service
local port=""
local token="HELLO"
+ local unitfile=$( ls /var/local/lib/systemd/system/afm-service-agl-service-audio-4a*.service )
- if [ -f "/var/local/lib/systemd/system/afm-service-agl-service-audio-4a*.service" ]; then
+ if [ -f "$unitfile" ]; then
log "Detected systemd unit file!"
port=$( grep -sr X-AFM-http /var/local/lib/systemd/system/afm-service-agl-service-audio-4a*.service | cut -f2 -d'=' )
log "Port detected: $port"