Skip to content

Commit 4532d4f

Browse files
committed
Support FLOATs in format to bit depth conversion
Expand ALSA text to bit depth conversion function with support for FLOATs. Signed-off-by: Arkadiusz Cholewinski <arkadiuszx.cholewinski@intel.com>
1 parent 4a5a1d9 commit 4532d4f

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

case-lib/lib.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -774,8 +774,22 @@ parse_audio_device() {
774774
# There is passes PCM sample format while using ALSA tool (arecord)
775775
# While using TinyALSA (tinycap -b) we need to convert PCM sample fomrat to bits.
776776
extract_format_number() {
777-
# (e.g., extracting '16' from 'S16_LE')
778-
printf '%s' "$1" | grep '[0-9]\+' -o
777+
local format_string="$1"
778+
779+
if [[ "$format_string" =~ ^[SU][0-9]+(_.*)?$ ]]; then
780+
# Extract the number after S or U manually
781+
printf '%s' "${format_string}" | sed -E 's/^[SU]([0-9]+).*$/\1/'
782+
elif [[ "$format_string" =~ ^FLOAT[0-9]*$ ]]; then
783+
# Extract number after FLOAT
784+
local num="${format_string#FLOAT}"
785+
if [[ -n "$num" ]]; then
786+
printf '%s' "$num"
787+
else
788+
printf '32'
789+
fi
790+
else
791+
die "Unknown format"
792+
fi
779793
}
780794

781795
# Initialize the parameters using for audio testing.

0 commit comments

Comments
 (0)