-
Notifications
You must be signed in to change notification settings - Fork 59
tinyalsa: fix: format conversion #1282
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tinyalsa: fix: format conversion #1282
Conversation
case-lib/lib.sh
Outdated
| FLOAT) | ||
| printf '32' # Assuming 32-bit float | ||
| ;; | ||
| *) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are other format strings now also possible, e.g.
Device Information
Name: hw:sofnocodec,0
Card: sofnocodec[sof-nocodec]
Device: Port0 (*)[]
Stream: CAPTURE
Format: ['U8', 'S16_LE', 'S24_LE', 'S32_LE', 'FLOAT_LE', 'MU_LAW', 'A_LAW']
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the above is just an example from one configuration, but there could be other
https://www.alsa-project.org/alsa-doc/alsa-lib/group___p_c_m.html#gaa14b7f26877a812acbb39811364177f8
ie. currently this test can handle '[0-9]+_BE`, but with this change it will not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think _[SU]([0-9])+_ and _FLOAT([0-9]+)_ should cover many formats and the rest (like 'FLOAT', '*_LAW') can be hardcoded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So how about this one:
case "$format_string" in
# 8-bit formats (Signed/Unsigned)
S8 | U8)
printf '8'
;;
# 16-bit formats (Signed/Unsigned, various endianness)
S16_LE | S16_BE | U16_LE | U16_BE | S16 | U16)
printf '16'
;;
# 18-bit formats (3-byte container, various endianness)
S18_3LE | S18_3BE | U18_3LE | U18_3BE)
printf '18'
;;
# 20-bit formats (in 4-byte or 3-byte containers, various endianness)
S20_LE | S20_BE | U20_LE | U20_BE | S20 | U20 | \
S20_3LE | S20_3BE | U20_3LE | U20_3BE)
printf '20'
;;
# 24-bit formats (in 4-byte or 3-byte containers, various endianness)
S24_LE | S24_BE | U24_LE | U24_BE | S24 | U24 | \
S24_3LE | S24_3BE | U24_3LE | U24_3BE)
printf '24'
;;
# 32-bit integer formats (Signed/Unsigned, various endianness)
S32_LE | S32_BE | U32_LE | U32_BE | S32 | U32)
printf '32'
;;
# 32-bit Floating-point formats
FLOAT_LE | FLOAT_BE | FLOAT)
printf '32' # Standard single-precision float
;;
# 64-bit Floating-point formats
FLOAT64_LE | FLOAT64_BE | FLOAT64)
printf '64' # Double-precision float
;;
# Compressed / Encoded formats (typically handled as 8-bit for raw stream)
MU_LAW | A_LAW | IMA_ADPCM | MPEG | GSM)
printf '8'
;;
# IEC958 (S/PDIF) subframe formats
IEC958_SUBFRAME_LE | IEC958_SUBFRAME_BE | IEC958_SUBFRAME)
printf '24' # IEC958 commonly carries up to 24-bit audio data
;;
# Formats without a direct, standard bit depth mapping or needing special handling
UNKNOWN | SPECIAL) # Assuming 'UNKNOWN' corresponds to SND_PCM_FORMAT_UNKNOWN
printf '' # No direct bit depth, or requires specific codec/driver handling
;;
# Default case for any unlisted or unrecognized formats
*)
# echo "ERROR: Unrecognized format encountered: $format_string" >&2
printf ''
;;
esac
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please check against https://github.com/alsa-project/alsa-lib/blob/master/src/pcm/pcm_misc.c#L210
and squeeze it with patterns following the naming convention, whether possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note: we are never going to encounter most of these formats (GSM, U/S18, *_BE)
I'm uncertain what is the meaning of bits in tiny-world...
S24_LE is 24bit audio in 32bit container, LSB aligned
S24_3LE s 24bit audio in 24bit container (sort of packed, no padding)
S32_LE + MSBITS_24 is 24bit audio in 32bit container, MSB aligned (we don't yet have support for this in SOF)
which of these -b24 will result? My guess is S24_LE, but I'm not sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming that, I've confirmed that expanding the supported format list to allow FLOAT makes the test pass.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note: we are never going to encounter most of these formats (GSM, U/S18, *_BE)
Let's implement it as explicit case selection for only these formats we use for validation.
golowanow
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please extend your commit's summary with more details, e.g.
Expand ALSA text to bit size format conversion function with FLOAT_LE and ....
9a64f81 to
71a15b4
Compare
71a15b4 to
4532d4f
Compare
4532d4f to
81f84fe
Compare
|
SOFCI TEST |
golowanow
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to update the commit message to what is actually done with refactoring other format's handling in addition to FLOAT.
Improved handling of standard formats (e.g., S16_LE) and added support for FLOAT types with defaulting to 32-bit when unspecified. Signed-off-by: Arkadiusz Cholewinski <arkadiuszx.cholewinski@intel.com>
81f84fe to
3a685a2
Compare
Expand ALSA text to bit depth conversion function with support for FLOAT_LE, U8, MU_LAW, and A_LAW.
Justification.
The check-capture test uses format that doesn't contain the digit. " e.g., FLOAT_LE".
As a result, the converting function returns an empty string, which the shell interprets as 0. This causes the tinycap command to fail with the following error:
tinycap /dev/null -D 0 -d 0 -c 2 -t 3 -r 48000 -b 0 bits is not supported.