alsa-project / alsa-lib

The Advanced Linux Sound Architecture (ALSA) - library
GNU Lesser General Public License v2.1
344 stars 173 forks source link

UCM Path condition type does not support variables as file path #395

Closed singalsu closed 2 months ago

singalsu commented 2 months ago

To control audio processing in SOF I want to do do this:

Define.SpeakerIirBlob "${ConfTopDir}/sof/ipc4/eq_iir/highpass_100hz_0db_48khz.blob"
Define.SpeakerFirBlob "${ConfTopDir}/sof/ipc4/eq_fir/pass.blob"
Define.SpeakerDrcBlob "${ConfTopDir}/sof/ipc4/drc/spk_default.blob"
Define.HeadphoneIirBlob "${ConfTopDir}/sof/ipc4/eq_iir/pass.blob"
Define.HeadphoneFirBlob "${ConfTopDir}/sof/ipc4/eq_fir/pass.blob"
Define.ProductConfigSOF "/sof/product_configs/${CardLongName}.conf"
Define.FullPathToIt "${ConfTopDir}${var:ProductConfigSOF}"

If.HasProductConfig {
        Condition {
                Type Path
                Mode read
                Path "${var:FullPathToIt}"
        }
        True {
                Include.product-config.File "${var:ProductConfigSOF}"
        }
}

However if I replace line as "Path "/usr/share/alsa/ucm2/sof/product_configs/ACME-2000--foobar.conf" (product name obfuscated for confidentiality) the True condition is achieved. It looks like Path is not evaluating variables.

This feature was added in commit 2f57b404b1c1c376316ca0c6bb5e789e2066298f where the usage is explained.

singalsu commented 2 months ago

@perexg The inclusion of .conf file if such is available would be useful to define bespoke SOF algo blobs for the model. Otherwise use defaults. It would avoid bloat of UCM script with explicit If conditions for all possible ${CardLongName} so it would be nice to get this working. Am I doing something wrong?

perexg commented 2 months ago

Unfortunately, the Path was not substituted. I fixed this in ef6463a20914e4cdcd22917d3206a06b86718c3f .

singalsu commented 2 months ago

@perexg It's almost fixed, but you need to change the eaccess() and access()to use s, not the unsubstituted path. Can you check and fix please. Thanks!

perexg commented 2 months ago

Fixed in 3fd24db22dd3b09fd70de2ae1c58804251737ff4 . Thanks.

singalsu commented 2 months ago

Great, thanks a lot @perexg !!

perexg commented 2 months ago

A little note: The substitutions will be available for 'Syntax 7' to notify people using older alsa-lib that they should upgrade. See above commit.