File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -774,9 +774,24 @@ 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.
776776extract_format_number () {
777- # (e.g., extracting '16' from 'S16_LE')
778- printf ' %s' " $1 " | grep ' [0-9]\+' -o
779- }
777+ local format_string=" $1 "
778+ local extracted_num
779+
780+ if [[ " $format_string " =~ ^[SU][0-9]+ (_.* )? $ ]]; then
781+ extracted_num=$( printf ' %s' " ${format_string} " | sed -E ' s/^[SU]([0-9]+).*$/\1/' )
782+ printf ' %s' " $extracted_num "
783+ elif [[ " $format_string " =~ ^FLOAT[0-9]* $ ]]; then
784+ extracted_num=$( printf ' %s' " ${format_string} " | sed -E ' s/^FLOAT([0-9]*).*$/\1/' )
785+ # If extracted_num is empty (i.e., just "FLOAT"), default to 32
786+ if [[ -z " $extracted_num " ]]; then
787+ printf ' 32'
788+ else
789+ printf ' %s' " $extracted_num "
790+ fi
791+ else
792+ die " Error: Unknown format: %s\n"
793+ fi
794+ }
780795
781796# Initialize the parameters using for audio testing.
782797# shellcheck disable=SC2034
You can’t perform that action at this time.
0 commit comments