alsa-project / alsa-lib

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

conf: refine check for snd_config_is_array #158

Closed ranj063 closed 3 years ago

ranj063 commented 3 years ago

Apart from checking the index, also check if the node is not compound to qualify a config as an array.

For ex:

mixer [ "mixer1" ]

is an array but

mixer.0 { name "mixer 1" }

is not an array even though the id is 0.

Signed-off-by: Ranjani Sridharan ranjani.sridharan@linux.intel.com

perexg commented 3 years ago

It's valid array:

mixer.0 {
    name    "mixer 1"
}

# equal to

mixer [
        name "mixer 1"
]
ranj063 commented 3 years ago

It's valid array:

mixer.0 {
  name    "mixer 1"
}

# equal to

mixer [
        name "mixer 1"
]

@perex is there a way for me to avoid a config like this being called an array mixer.0 { name "mixer 1" }

so when I merge the the config below with snd_config_merge() mixer.0 { max 32 },

I get the compound with an integer and a string config as below: mixer.0 { name "mixer 1" max 32 }

instead of an array with 2 strings? mixer [ name "mixer 1" max 32 ]

perexg commented 3 years ago

Just add a dummy id to the mixer compound:

mixer.comment "Something"
mixer.0.name "mixer 1"
mixer.0.max 32
ranj063 commented 3 years ago

Just add a dummy id to the mixer compound:

mixer.comment "Something"
mixer.0.name "mixer 1"
mixer.0.max 32

Thanks @perex. I got around the problem by starting my mixer ID's with a 1 instead of starting with a 0.

perexg commented 3 years ago

Yes, it's another option.