Skip to content

Commit 71a15b4

Browse files
committed
Support FLOAT_LE, U8, MU_LAW, A_LAW in format to bit depth conversion
Expand ALSA text to bit depth conversion function with support for FLOAT_LE, U8, MU_LAW, and A_LAW. Signed-off-by: Arkadiusz Cholewinski <arkadiuszx.cholewinski@intel.com>
1 parent 4a5a1d9 commit 71a15b4

1 file changed

Lines changed: 30 additions & 2 deletions

File tree

case-lib/lib.sh

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -774,8 +774,36 @@ 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+
case "$format_string" in
780+
U8)
781+
printf '8'
782+
;;
783+
S16_LE)
784+
printf '16'
785+
;;
786+
S24_LE)
787+
printf '24'
788+
;;
789+
S32_LE)
790+
printf '32'
791+
;;
792+
FLOAT_LE)
793+
# Standard float is 32-bit (single precision).
794+
printf '32'
795+
;;
796+
# Compressed formats (typically operate on 8-bit samples)
797+
MU_LAW)
798+
printf '8'
799+
;;
800+
A_LAW)
801+
printf '8'
802+
;;
803+
*)
804+
die "Unknown format"
805+
;;
806+
esac
779807
}
780808

781809
# Initialize the parameters using for audio testing.

0 commit comments

Comments
 (0)