0001-alsactl-info.c-fix-conditionals-on-__ALSA_PCM_H-and-.patch 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. From 4bfd1f15114550e1be7e43ae37a61906e1bff809 Mon Sep 17 00:00:00 2001
  2. From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
  3. Date: Sun, 17 Jul 2022 18:59:48 +0200
  4. Subject: [PATCH] alsactl/info.c: fix conditionals on __ALSA_PCM_H and
  5. __ALSA_RAWMIDI_H
  6. Commit bbc74a61ac7c35e506c3d7f76ecf943cb55736a6 ("alsactl: implement
  7. 'info' command") implemented an alsactl info command. In this
  8. implementation, there was an attempt to properly address optional
  9. features from alsa-lib by using conditions on __ALSA_PCM_H,
  10. __ALSA_RAWMIDI_H.
  11. Unfortunately, this attempt does not work entirely: only the code
  12. inside pcm_device_list(), rawmidi_device_list() was conditionally
  13. compiled, but their very prototype also use type definitions provided
  14. in pcm.h and rawmidi.h. So really, it's the entire function that needs
  15. to be conditionally implemented.
  16. Also, snd_rawmidi_stream_name() was not handled properly, for the same
  17. reason.
  18. This commit implements pcm_device_list() only if __ALSA_PCM_H is
  19. defined, and implements snd_rawmidi_stream_name() and
  20. rawmidi_device_list() only if __ALSA_RAWMIDI_H is defined.
  21. general_card_info() is modified to not call the PCM or raw MIDI
  22. functions when support is not available.
  23. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
  24. Upstream: https://mailman.alsa-project.org/pipermail/alsa-devel/2022-July/203846.html
  25. [Bernd: update patch for 1.2.10]
  26. Signed-off-by: Bernd Kuhls <bernd@kuhls.net>
  27. ---
  28. alsactl/info.c | 14 ++++++++++----
  29. 1 file changed, 10 insertions(+), 4 deletions(-)
  30. diff --git a/alsactl/info.c b/alsactl/info.c
  31. index 253539d..9bd72af 100644
  32. --- a/alsactl/info.c
  33. +++ b/alsactl/info.c
  34. @@ -22,9 +22,9 @@
  35. #include "aconfig.h"
  36. #include "alsactl.h"
  37. +#ifdef __ALSA_PCM_H
  38. static int pcm_device_list(snd_ctl_t *ctl, snd_pcm_stream_t stream, bool *first)
  39. {
  40. -#ifdef __ALSA_PCM_H
  41. int err, dev, idx;
  42. unsigned int count;
  43. snd_pcm_info_t *pcminfo;
  44. @@ -76,10 +76,12 @@ static int pcm_device_list(snd_ctl_t *ctl, snd_pcm_stream_t stream, bool *first)
  45. idx, snd_pcm_info_get_subdevice_name(pcminfo));
  46. }
  47. }
  48. -#endif
  49. +
  50. return 0;
  51. }
  52. +#endif
  53. +#ifdef __ALSA_RAWMIDI_H
  54. static const char *snd_rawmidi_stream_name(snd_rawmidi_stream_t stream)
  55. {
  56. if (stream == SND_RAWMIDI_STREAM_INPUT)
  57. @@ -91,7 +93,6 @@ static const char *snd_rawmidi_stream_name(snd_rawmidi_stream_t stream)
  58. static int rawmidi_device_list(snd_ctl_t *ctl, snd_rawmidi_stream_t stream, bool *first)
  59. {
  60. -#ifdef __ALSA_RAWMIDI_H
  61. int err, dev, idx;
  62. unsigned int count;
  63. snd_rawmidi_info_t *info;
  64. @@ -143,9 +144,10 @@ static int rawmidi_device_list(snd_ctl_t *ctl, snd_rawmidi_stream_t stream, bool
  65. idx, snd_rawmidi_info_get_subdevice_name(info));
  66. }
  67. }
  68. -#endif
  69. +
  70. return 0;
  71. }
  72. +#endif
  73. static int hwdep_device_list(snd_ctl_t *ctl)
  74. {
  75. @@ -227,17 +229,21 @@ int general_card_info(int cardno)
  76. }
  77. err = card_info(ctl);
  78. +#ifdef __ALSA_PCM_H
  79. first = true;
  80. if (err >= 0)
  81. err = pcm_device_list(ctl, SND_PCM_STREAM_PLAYBACK, &first);
  82. if (err >= 0)
  83. err = pcm_device_list(ctl, SND_PCM_STREAM_CAPTURE, &first);
  84. +#endif
  85. +#ifdef __ALSA_RAWMIDI_H
  86. first = true;
  87. if (err >= 0)
  88. err = rawmidi_device_list(ctl, SND_RAWMIDI_STREAM_INPUT, &first);
  89. if (err >= 0)
  90. err = rawmidi_device_list(ctl, SND_RAWMIDI_STREAM_OUTPUT, &first);
  91. +#endif
  92. if (err >= 0)
  93. err = hwdep_device_list(ctl);
  94. --
  95. 2.36.1