Skip to content

Commit 9a64f81

Browse files
committed
tinyalsa: fix: format conversion
Expand format conversion function to allow FLOAT Signed-off-by: Arkadiusz Cholewinski <arkadiuszx.cholewinski@intel.com>
1 parent 4a5a1d9 commit 9a64f81

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

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+
case "$format_string" in
780+
# Extract number for SXX_LE formats
781+
S[0-9]*_LE)
782+
printf '%s' "$format_string" | grep '[0-9]\+' -o
783+
;;
784+
# Handle FLOAT format specifically
785+
FLOAT)
786+
printf '32' # Assuming 32-bit float
787+
;;
788+
*)
789+
# Default or error handling for unsupported formats
790+
die "Unknown format"
791+
;;
792+
esac
779793
}
780794

781795
# Initialize the parameters using for audio testing.

0 commit comments

Comments
 (0)