Re: [PATCH v3 07/10] topology: decode: Fix decoding PCM formats and rates

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2020-07-14 17:40, Pierre-Louis Bossart wrote:


On 7/14/20 6:25 AM, Piotr Maziarz wrote:
Not checking _LAST format and rate, which are valid indexes in arrays,
makes data loss while converting binary to standard ALSA configuration
file.

I must be really thick on this one.

alsatplg converts from alsa-conf format to binary topology file.
The binary topology file is used by drivers.

In which cases would you convert from binary to alsa-conf files? And what tool would you use?

./alsatplg --decode topology.bin --output decoded_topology.conf,
This feature was added around the end of 2019. And why to use it? For binary topologies to which conf files are lost for example. It's easier to analyze and edit it in conf than directly in binary.


Signed-off-by: Piotr Maziarz <piotrx.maziarz@xxxxxxxxxxxxxxx>
---
  src/topology/pcm.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/topology/pcm.c b/src/topology/pcm.c
index b15b950..db40114 100644
--- a/src/topology/pcm.c
+++ b/src/topology/pcm.c
@@ -549,7 +549,7 @@ int tplg_save_stream_caps(snd_tplg_t *tplg ATTRIBUTE_UNUSED,
      if (err >= 0 && sc->formats) {
          err = tplg_save_printf(dst, pfx, "\tformats '");
          first = 1;
-        for (i = 0; err >= 0 && i < SND_PCM_FORMAT_LAST; i++) {
+        for (i = 0; err >= 0 && i <= SND_PCM_FORMAT_LAST; i++) {
              if (sc->formats & (1ULL << i)) {
                  s = snd_pcm_format_name(i);
                  err = tplg_save_printf(dst, NULL, "%s%s",
@@ -563,7 +563,7 @@ int tplg_save_stream_caps(snd_tplg_t *tplg ATTRIBUTE_UNUSED,
      if (err >= 0 && sc->rates) {
          err = tplg_save_printf(dst, pfx, "\trates '");
          first = 1;
-        for (i = 0; err >= 0 && i < SND_PCM_RATE_LAST; i++) {
+        for (i = 0; err >= 0 && i <= SND_PCM_RATE_LAST; i++) {
              if (sc->rates & (1ULL << i)) {
                  s = get_rate_name(i);
                  err = tplg_save_printf(dst, NULL, "%s%s",





[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Pulse Audio]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux