From 24dd246d1ee3a53434dd1f21aa2afbeb55618ead Mon Sep 17 00:00:00 2001 From: Loïc Collignon Date: Fri, 20 Jul 2018 15:56:23 +0200 Subject: Added a 4a-info script use to test if 4a can work MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test various things to check if 4a can work in this environment. Change-Id: Ica4b739d7e8c6401db05a3b9b4d6ef9048ca1002 Signed-off-by: Loïc Collignon --- bin/4a-play | 1 + 1 file changed, 1 insertion(+) create mode 100644 bin/4a-play (limited to 'bin/4a-play') diff --git a/bin/4a-play b/bin/4a-play new file mode 100644 index 0000000..894ab7f --- /dev/null +++ b/bin/4a-play @@ -0,0 +1 @@ +# TODO: play using aplay -- cgit From 28e86894895d16d1a707fd218990a0a58403bee8 Mon Sep 17 00:00:00 2001 From: Stephane Desneux Date: Sat, 21 Jul 2018 02:48:47 +0200 Subject: fix modes scripts Change-Id: I2c5d4ff7d6c3107d814bbcabe8870af18ac3c525 Signed-off-by: Stephane Desneux --- bin/4a-play | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 bin/4a-play (limited to 'bin/4a-play') diff --git a/bin/4a-play b/bin/4a-play old mode 100644 new mode 100755 -- cgit From e8b23b37394800332baf1ffc9b9777c67dc664cd Mon Sep 17 00:00:00 2001 From: Stephane Desneux Date: Sat, 21 Jul 2018 16:17:44 +0200 Subject: change media paths Change-Id: I0d4783d37da25a315073eb847c7f525ed1b51d5c Signed-off-by: Stephane Desneux --- bin/4a-play | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'bin/4a-play') diff --git a/bin/4a-play b/bin/4a-play index 894ab7f..483b892 100755 --- a/bin/4a-play +++ b/bin/4a-play @@ -1 +1,17 @@ -# TODO: play using aplay +#!/bin/bash + +# load shell lib +. $(dirname $BASH_SOURCE)/lib4a-tools.sh + +function usage() { + log "Usage: $0 [role:file2 ...]" + log "Available roles:" + exit 1 +} + +[[ $# == 0 ]] && usage + +for x in "$@"; do + log "Playing $x ..." + aplay -D Loopback,0,2 $x +done -- cgit From f43f3cb73ff3f8f9c20e8e9efe533ff19e9d3fc6 Mon Sep 17 00:00:00 2001 From: Loïc Collignon Date: Mon, 23 Jul 2018 00:48:19 +0200 Subject: Fix issue with the unit file detection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix a bug introduced by the commit e4e0b9b, due to the wildcard in the unit file. Change-Id: Iddc47378207a0ced207861433cd0ec02a52bc1a5 Signed-off-by: Loïc Collignon --- bin/4a-play | 56 ++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 8 deletions(-) (limited to 'bin/4a-play') 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:file2 ...]" - log "Available roles:" - exit 1 + log "$0 [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 -- cgit From 4d67fb6cfb56d0abd8ec1c9149b88efd4828935d Mon Sep 17 00:00:00 2001 From: Thierry Bultel Date: Wed, 24 Apr 2019 13:42:49 +0200 Subject: 4a-aplay: added avirt detection Adds the detection of avirt of electing the default playback device. Signed-off-by: Thierry Bultel --- bin/4a-play | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'bin/4a-play') diff --git a/bin/4a-play b/bin/4a-play index 620f311..7650d4d 100755 --- a/bin/4a-play +++ b/bin/4a-play @@ -19,8 +19,15 @@ if [ "$#" == "0" ]; then usage fi +avirt=$(cat /proc/modules | grep avirt_ap_loopback | head -n1 | cut -d ' ' -f 1) +if [ x$avirt == x ]; then +hwdev=Loopback,0,2 +else +hwdev=avirt,0 +fi + FILEPATH="$( realpath "$1" )" -DEVICE=${2:-'hw:Loopback,0,2'} +DEVICE=${2:-"hw:$hwdev"} ROLE=${3:-'multimedia'} CARDID=$( echo "$DEVICE" | cut -d':' -f2 | cut -d',' -f1 ) -- cgit