* [ptxdist] [PATCH] alsa-utils: fix build without rawmidi
@ 2022-12-02 11:38 Philipp Zabel
2022-12-05 12:53 ` [ptxdist] [APPLIED] " Michael Olbrich
0 siblings, 1 reply; 2+ messages in thread
From: Philipp Zabel @ 2022-12-02 11:38 UTC (permalink / raw)
To: ptxdist; +Cc: Philipp Zabel
Pick up [1] to allow building with ALSA_LIB_RAWMIDI=n. Fixes the
following build error:
info.c:83:44: error: unknown type name 'snd_rawmidi_stream_t'; did you mean 'snd_pcm_stream_t'?
[1] https://lore.kernel.org/r/20220717172240.1386150-1-thomas.petazzoni@bootlin.com
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
...ix-conditionals-on-__ALSA_PCM_H-and-.patch | 103 ++++++++++++++++++
patches/alsa-utils-1.2.8/series | 4 +
2 files changed, 107 insertions(+)
create mode 100644 patches/alsa-utils-1.2.8/0001-alsactl-info.c-fix-conditionals-on-__ALSA_PCM_H-and-.patch
create mode 100644 patches/alsa-utils-1.2.8/series
diff --git a/patches/alsa-utils-1.2.8/0001-alsactl-info.c-fix-conditionals-on-__ALSA_PCM_H-and-.patch b/patches/alsa-utils-1.2.8/0001-alsactl-info.c-fix-conditionals-on-__ALSA_PCM_H-and-.patch
new file mode 100644
index 000000000000..2298f0037eae
--- /dev/null
+++ b/patches/alsa-utils-1.2.8/0001-alsactl-info.c-fix-conditionals-on-__ALSA_PCM_H-and-.patch
@@ -0,0 +1,103 @@
+From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
+Date: Sun, 17 Jul 2022 19:22:40 +0200
+Subject: [PATCH] alsactl/info.c: fix conditionals on __ALSA_PCM_H and
+ __ALSA_RAWMIDI_H
+
+Commit bbc74a61ac7c35e506c3d7f76ecf943cb55736a6 ("alsactl: implement
+'info' command") implemented an alsactl info command. In this
+implementation, there was an attempt to properly address optional
+features from alsa-lib by using conditions on __ALSA_PCM_H,
+__ALSA_RAWMIDI_H.
+
+Unfortunately, this attempt does not work entirely: only the code
+inside pcm_device_list(), rawmidi_device_list() was conditionally
+compiled, but their very prototype also use type definitions provided
+in pcm.h and rawmidi.h. So really, it's the entire function that needs
+to be conditionally implemented.
+
+Also, snd_rawmidi_stream_name() was not handled properly, for the same
+reason.
+
+This commit implements pcm_device_list() only if __ALSA_PCM_H is
+defined, and implements snd_rawmidi_stream_name() and
+rawmidi_device_list() only if __ALSA_RAWMIDI_H is defined.
+
+general_card_info() is modified to not call the PCM or raw MIDI
+functions when support is not available.
+
+Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
+---
+ alsactl/info.c | 14 ++++++++++----
+ 1 file changed, 10 insertions(+), 4 deletions(-)
+
+diff --git a/alsactl/info.c b/alsactl/info.c
+index 3e4b9486d720..af55206b8484 100644
+--- a/alsactl/info.c
++++ b/alsactl/info.c
+@@ -22,9 +22,9 @@
+ #include "aconfig.h"
+ #include "alsactl.h"
+
++#ifdef __ALSA_PCM_H
+ static int pcm_device_list(snd_ctl_t *ctl, snd_pcm_stream_t stream, bool *first)
+ {
+-#ifdef __ALSA_PCM_H
+ int err, dev, idx;
+ unsigned int count;
+ snd_pcm_info_t *pcminfo;
+@@ -76,10 +76,12 @@ static int pcm_device_list(snd_ctl_t *ctl, snd_pcm_stream_t stream, bool *first)
+ idx, snd_pcm_info_get_subdevice_name(pcminfo));
+ }
+ }
+-#endif
++
+ return 0;
+ }
++#endif
+
++#ifdef __ALSA_RAWMIDI_H
+ static const char *snd_rawmidi_stream_name(snd_rawmidi_stream_t stream)
+ {
+ if (stream == SND_RAWMIDI_STREAM_INPUT)
+@@ -91,7 +93,6 @@ static const char *snd_rawmidi_stream_name(snd_rawmidi_stream_t stream)
+
+ static int rawmidi_device_list(snd_ctl_t *ctl, snd_rawmidi_stream_t stream, bool *first)
+ {
+-#ifdef __ALSA_RAWMIDI_H
+ int err, dev, idx;
+ unsigned int count;
+ snd_rawmidi_info_t *info;
+@@ -143,9 +144,10 @@ static int rawmidi_device_list(snd_ctl_t *ctl, snd_rawmidi_stream_t stream, bool
+ idx, snd_rawmidi_info_get_subdevice_name(info));
+ }
+ }
+-#endif
++
+ return 0;
+ }
++#endif
+
+ static int hwdep_device_list(snd_ctl_t *ctl)
+ {
+@@ -228,17 +230,21 @@ int general_card_info(int cardno)
+ }
+ err = card_info(ctl);
+
++#ifdef __ALSA_PCM_H
+ first = true;
+ if (err >= 0)
+ err = pcm_device_list(ctl, SND_PCM_STREAM_PLAYBACK, &first);
+ if (err >= 0)
+ err = pcm_device_list(ctl, SND_PCM_STREAM_CAPTURE, &first);
++#endif
+
++#ifdef __ALSA_RAWMIDI_H
+ first = true;
+ if (err >= 0)
+ err = rawmidi_device_list(ctl, SND_PCM_STREAM_PLAYBACK, &first);
+ if (err >= 0)
+ err = rawmidi_device_list(ctl, SND_PCM_STREAM_CAPTURE, &first);
++#endif
+
+ if (err >= 0)
+ err = hwdep_device_list(ctl);
diff --git a/patches/alsa-utils-1.2.8/series b/patches/alsa-utils-1.2.8/series
new file mode 100644
index 000000000000..b39a77d00d87
--- /dev/null
+++ b/patches/alsa-utils-1.2.8/series
@@ -0,0 +1,4 @@
+# generated by git-ptx-patches
+#tag:base --start-number 1
+0001-alsactl-info.c-fix-conditionals-on-__ALSA_PCM_H-and-.patch
+# 33c3f6b9e58007dd7e241f57feb385ac - git-ptx-patches magic
--
2.30.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [ptxdist] [APPLIED] alsa-utils: fix build without rawmidi
2022-12-02 11:38 [ptxdist] [PATCH] alsa-utils: fix build without rawmidi Philipp Zabel
@ 2022-12-05 12:53 ` Michael Olbrich
0 siblings, 0 replies; 2+ messages in thread
From: Michael Olbrich @ 2022-12-05 12:53 UTC (permalink / raw)
To: ptxdist; +Cc: Philipp Zabel
Thanks, applied as 99ae5094ee1d541a84c353bc9a7eb7b15f4ef0c3.
Michael
[sent from post-receive hook]
On Mon, 05 Dec 2022 13:53:56 +0100, Philipp Zabel <p.zabel@pengutronix.de> wrote:
> Pick up [1] to allow building with ALSA_LIB_RAWMIDI=n. Fixes the
> following build error:
>
> info.c:83:44: error: unknown type name 'snd_rawmidi_stream_t'; did you mean 'snd_pcm_stream_t'?
>
> [1] https://lore.kernel.org/r/20220717172240.1386150-1-thomas.petazzoni@bootlin.com
>
> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
> Message-Id: <20221202113812.4017202-1-p.zabel@pengutronix.de>
> Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
>
> diff --git a/patches/alsa-utils-1.2.8/0001-alsactl-info.c-fix-conditionals-on-__ALSA_PCM_H-and-.patch b/patches/alsa-utils-1.2.8/0001-alsactl-info.c-fix-conditionals-on-__ALSA_PCM_H-and-.patch
> new file mode 100644
> index 000000000000..2298f0037eae
> --- /dev/null
> +++ b/patches/alsa-utils-1.2.8/0001-alsactl-info.c-fix-conditionals-on-__ALSA_PCM_H-and-.patch
> @@ -0,0 +1,103 @@
> +From: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
> +Date: Sun, 17 Jul 2022 19:22:40 +0200
> +Subject: [PATCH] alsactl/info.c: fix conditionals on __ALSA_PCM_H and
> + __ALSA_RAWMIDI_H
> +
> +Commit bbc74a61ac7c35e506c3d7f76ecf943cb55736a6 ("alsactl: implement
> +'info' command") implemented an alsactl info command. In this
> +implementation, there was an attempt to properly address optional
> +features from alsa-lib by using conditions on __ALSA_PCM_H,
> +__ALSA_RAWMIDI_H.
> +
> +Unfortunately, this attempt does not work entirely: only the code
> +inside pcm_device_list(), rawmidi_device_list() was conditionally
> +compiled, but their very prototype also use type definitions provided
> +in pcm.h and rawmidi.h. So really, it's the entire function that needs
> +to be conditionally implemented.
> +
> +Also, snd_rawmidi_stream_name() was not handled properly, for the same
> +reason.
> +
> +This commit implements pcm_device_list() only if __ALSA_PCM_H is
> +defined, and implements snd_rawmidi_stream_name() and
> +rawmidi_device_list() only if __ALSA_RAWMIDI_H is defined.
> +
> +general_card_info() is modified to not call the PCM or raw MIDI
> +functions when support is not available.
> +
> +Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
> +---
> + alsactl/info.c | 14 ++++++++++----
> + 1 file changed, 10 insertions(+), 4 deletions(-)
> +
> +diff --git a/alsactl/info.c b/alsactl/info.c
> +index 3e4b9486d720..af55206b8484 100644
> +--- a/alsactl/info.c
> ++++ b/alsactl/info.c
> +@@ -22,9 +22,9 @@
> + #include "aconfig.h"
> + #include "alsactl.h"
> +
> ++#ifdef __ALSA_PCM_H
> + static int pcm_device_list(snd_ctl_t *ctl, snd_pcm_stream_t stream, bool *first)
> + {
> +-#ifdef __ALSA_PCM_H
> + int err, dev, idx;
> + unsigned int count;
> + snd_pcm_info_t *pcminfo;
> +@@ -76,10 +76,12 @@ static int pcm_device_list(snd_ctl_t *ctl, snd_pcm_stream_t stream, bool *first)
> + idx, snd_pcm_info_get_subdevice_name(pcminfo));
> + }
> + }
> +-#endif
> ++
> + return 0;
> + }
> ++#endif
> +
> ++#ifdef __ALSA_RAWMIDI_H
> + static const char *snd_rawmidi_stream_name(snd_rawmidi_stream_t stream)
> + {
> + if (stream == SND_RAWMIDI_STREAM_INPUT)
> +@@ -91,7 +93,6 @@ static const char *snd_rawmidi_stream_name(snd_rawmidi_stream_t stream)
> +
> + static int rawmidi_device_list(snd_ctl_t *ctl, snd_rawmidi_stream_t stream, bool *first)
> + {
> +-#ifdef __ALSA_RAWMIDI_H
> + int err, dev, idx;
> + unsigned int count;
> + snd_rawmidi_info_t *info;
> +@@ -143,9 +144,10 @@ static int rawmidi_device_list(snd_ctl_t *ctl, snd_rawmidi_stream_t stream, bool
> + idx, snd_rawmidi_info_get_subdevice_name(info));
> + }
> + }
> +-#endif
> ++
> + return 0;
> + }
> ++#endif
> +
> + static int hwdep_device_list(snd_ctl_t *ctl)
> + {
> +@@ -228,17 +230,21 @@ int general_card_info(int cardno)
> + }
> + err = card_info(ctl);
> +
> ++#ifdef __ALSA_PCM_H
> + first = true;
> + if (err >= 0)
> + err = pcm_device_list(ctl, SND_PCM_STREAM_PLAYBACK, &first);
> + if (err >= 0)
> + err = pcm_device_list(ctl, SND_PCM_STREAM_CAPTURE, &first);
> ++#endif
> +
> ++#ifdef __ALSA_RAWMIDI_H
> + first = true;
> + if (err >= 0)
> + err = rawmidi_device_list(ctl, SND_PCM_STREAM_PLAYBACK, &first);
> + if (err >= 0)
> + err = rawmidi_device_list(ctl, SND_PCM_STREAM_CAPTURE, &first);
> ++#endif
> +
> + if (err >= 0)
> + err = hwdep_device_list(ctl);
> diff --git a/patches/alsa-utils-1.2.8/series b/patches/alsa-utils-1.2.8/series
> new file mode 100644
> index 000000000000..b39a77d00d87
> --- /dev/null
> +++ b/patches/alsa-utils-1.2.8/series
> @@ -0,0 +1,4 @@
> +# generated by git-ptx-patches
> +#tag:base --start-number 1
> +0001-alsactl-info.c-fix-conditionals-on-__ALSA_PCM_H-and-.patch
> +# 33c3f6b9e58007dd7e241f57feb385ac - git-ptx-patches magic
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-12-05 12:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-02 11:38 [ptxdist] [PATCH] alsa-utils: fix build without rawmidi Philipp Zabel
2022-12-05 12:53 ` [ptxdist] [APPLIED] " Michael Olbrich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox