* [PATCH 1/2] ALSA: snd_usb_caiaq: give better shortname
@ 2009-06-02 10:36 Daniel Mack
2009-06-02 10:36 ` [PATCH 2/2] ALSA: snd_usb_caiaq: bump version number Daniel Mack
2009-06-02 11:01 ` [PATCH 1/2] ALSA: snd_usb_caiaq: give better shortname Takashi Iwai
0 siblings, 2 replies; 5+ messages in thread
From: Daniel Mack @ 2009-06-02 10:36 UTC (permalink / raw)
To: alsa-devel
If not passed as module option, provide an own card ID with the newly
introduced snd_set_card_id() call.
This will prevent ALSA from calling choose_default_name() which only
takes the last part of a name containing whitespaces. This for example
caused 'Audio 4 DJ' to be shortened to 'DJ', which was not very
descriptive.
The implementation now takes the short name and removes all whitespaces
from it which is much nicer.
Signed-off-by: Daniel Mack <daniel@caiaq.de>
---
sound/usb/caiaq/device.c | 21 +++++++++++++++++++--
1 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/sound/usb/caiaq/device.c b/sound/usb/caiaq/device.c
index 15052e4..43bd0db 100644
--- a/sound/usb/caiaq/device.c
+++ b/sound/usb/caiaq/device.c
@@ -382,10 +382,10 @@ static int create_card(struct usb_device* usb_dev, struct snd_card **cardp)
static int __devinit init_card(struct snd_usb_caiaqdev *dev)
{
- char usbpath[32];
+ char *c, usbpath[32];
struct usb_device *usb_dev = dev->chip.dev;
struct snd_card *card = dev->chip.card;
- int err;
+ int err, len;
if (usb_set_interface(usb_dev, 0, 1) != 0) {
log("can't set alt interface.\n");
@@ -427,6 +427,23 @@ static int __devinit init_card(struct snd_usb_caiaqdev *dev)
strlcpy(card->driver, MODNAME, sizeof(card->driver));
strlcpy(card->shortname, dev->product_name, sizeof(card->shortname));
+ /* if the id was not passed as module option, fill it with a shortened
+ * version of the product string which does not contain any
+ * whitespaces */
+
+ if (*card->id == '\0') {
+ char id[sizeof(card->id)];
+
+ memset(id, 0, sizeof(id));
+
+ for (c = card->shortname, len = 0;
+ *c && len < sizeof(card->id); c++)
+ if (*c != ' ')
+ id[len++] = *c;
+
+ snd_card_set_id(card, id);
+ }
+
usb_make_path(usb_dev, usbpath, sizeof(usbpath));
snprintf(card->longname, sizeof(card->longname),
"%s %s (%s)",
--
1.6.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* [PATCH 2/2] ALSA: snd_usb_caiaq: bump version number
2009-06-02 10:36 [PATCH 1/2] ALSA: snd_usb_caiaq: give better shortname Daniel Mack
@ 2009-06-02 10:36 ` Daniel Mack
2009-06-02 11:01 ` [PATCH 1/2] ALSA: snd_usb_caiaq: give better shortname Takashi Iwai
1 sibling, 0 replies; 5+ messages in thread
From: Daniel Mack @ 2009-06-02 10:36 UTC (permalink / raw)
To: alsa-devel
Signed-off-by: Daniel Mack <daniel@caiaq.de>
---
sound/usb/caiaq/device.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/sound/usb/caiaq/device.c b/sound/usb/caiaq/device.c
index 43bd0db..b9a2b31 100644
--- a/sound/usb/caiaq/device.c
+++ b/sound/usb/caiaq/device.c
@@ -35,7 +35,7 @@
#include "input.h"
MODULE_AUTHOR("Daniel Mack <daniel@caiaq.de>");
-MODULE_DESCRIPTION("caiaq USB audio, version 1.3.14");
+MODULE_DESCRIPTION("caiaq USB audio, version 1.3.15");
MODULE_LICENSE("GPL");
MODULE_SUPPORTED_DEVICE("{{Native Instruments, RigKontrol2},"
"{Native Instruments, RigKontrol3},"
--
1.6.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH 1/2] ALSA: snd_usb_caiaq: give better shortname
2009-06-02 10:36 [PATCH 1/2] ALSA: snd_usb_caiaq: give better shortname Daniel Mack
2009-06-02 10:36 ` [PATCH 2/2] ALSA: snd_usb_caiaq: bump version number Daniel Mack
@ 2009-06-02 11:01 ` Takashi Iwai
2009-06-02 11:55 ` Daniel Mack
1 sibling, 1 reply; 5+ messages in thread
From: Takashi Iwai @ 2009-06-02 11:01 UTC (permalink / raw)
To: Daniel Mack; +Cc: alsa-devel
At Tue, 2 Jun 2009 12:36:39 +0200,
Daniel Mack wrote:
>
> If not passed as module option, provide an own card ID with the newly
> introduced snd_set_card_id() call.
>
> This will prevent ALSA from calling choose_default_name() which only
> takes the last part of a name containing whitespaces. This for example
> caused 'Audio 4 DJ' to be shortened to 'DJ', which was not very
> descriptive.
>
> The implementation now takes the short name and removes all whitespaces
> from it which is much nicer.
>
> Signed-off-by: Daniel Mack <daniel@caiaq.de>
> ---
> sound/usb/caiaq/device.c | 21 +++++++++++++++++++--
> 1 files changed, 19 insertions(+), 2 deletions(-)
>
> diff --git a/sound/usb/caiaq/device.c b/sound/usb/caiaq/device.c
> index 15052e4..43bd0db 100644
> --- a/sound/usb/caiaq/device.c
> +++ b/sound/usb/caiaq/device.c
> @@ -382,10 +382,10 @@ static int create_card(struct usb_device* usb_dev, struct snd_card **cardp)
>
> static int __devinit init_card(struct snd_usb_caiaqdev *dev)
> {
> - char usbpath[32];
> + char *c, usbpath[32];
> struct usb_device *usb_dev = dev->chip.dev;
> struct snd_card *card = dev->chip.card;
> - int err;
> + int err, len;
>
> if (usb_set_interface(usb_dev, 0, 1) != 0) {
> log("can't set alt interface.\n");
> @@ -427,6 +427,23 @@ static int __devinit init_card(struct snd_usb_caiaqdev *dev)
> strlcpy(card->driver, MODNAME, sizeof(card->driver));
> strlcpy(card->shortname, dev->product_name, sizeof(card->shortname));
>
> + /* if the id was not passed as module option, fill it with a shortened
> + * version of the product string which does not contain any
> + * whitespaces */
> +
> + if (*card->id == '\0') {
Hm, at this place, card->id should be never an empty string so
this is always true.
> + char id[sizeof(card->id)];
> +
> + memset(id, 0, sizeof(id));
> +
> + for (c = card->shortname, len = 0;
> + *c && len < sizeof(card->id); c++)
> + if (*c != ' ')
> + id[len++] = *c;
... and here you change the id string unconditionally no matter whether
it's given explicitly or not. It should check id[devnum] instead of
card->id.
thanks,
Takashi
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH 1/2] ALSA: snd_usb_caiaq: give better shortname
2009-06-02 11:01 ` [PATCH 1/2] ALSA: snd_usb_caiaq: give better shortname Takashi Iwai
@ 2009-06-02 11:55 ` Daniel Mack
2009-06-02 12:04 ` Takashi Iwai
0 siblings, 1 reply; 5+ messages in thread
From: Daniel Mack @ 2009-06-02 11:55 UTC (permalink / raw)
To: Takashi Iwai; +Cc: alsa-devel
On Tue, Jun 02, 2009 at 01:01:35PM +0200, Takashi Iwai wrote:
> > + /* if the id was not passed as module option, fill it with a shortened
> > + * version of the product string which does not contain any
> > + * whitespaces */
> > +
> > + if (*card->id == '\0') {
>
> Hm, at this place, card->id should be never an empty string so
> this is always true.
Are you sure about that? The same condition is used in
snd_card_register() which is called _after_ the code in question from my
driver.
And the id should not be zero if snd_card_create() was called with an id
argument given. So the condition above should be false if the id was passed
before. Or do I miss anything?
Daniel
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH 1/2] ALSA: snd_usb_caiaq: give better shortname
2009-06-02 11:55 ` Daniel Mack
@ 2009-06-02 12:04 ` Takashi Iwai
0 siblings, 0 replies; 5+ messages in thread
From: Takashi Iwai @ 2009-06-02 12:04 UTC (permalink / raw)
To: Daniel Mack; +Cc: alsa-devel
At Tue, 2 Jun 2009 13:55:59 +0200,
Daniel Mack wrote:
>
> On Tue, Jun 02, 2009 at 01:01:35PM +0200, Takashi Iwai wrote:
> > > + /* if the id was not passed as module option, fill it with a shortened
> > > + * version of the product string which does not contain any
> > > + * whitespaces */
> > > +
> > > + if (*card->id == '\0') {
> >
> > Hm, at this place, card->id should be never an empty string so
> > this is always true.
>
> Are you sure about that? The same condition is used in
> snd_card_register() which is called _after_ the code in question from my
> driver.
Ah, no I was wrong. Actually it's set in snd_card_register()
so your method would work.
Now applied the patches.
thanks,
Takashi
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-06-02 12:04 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-02 10:36 [PATCH 1/2] ALSA: snd_usb_caiaq: give better shortname Daniel Mack
2009-06-02 10:36 ` [PATCH 2/2] ALSA: snd_usb_caiaq: bump version number Daniel Mack
2009-06-02 11:01 ` [PATCH 1/2] ALSA: snd_usb_caiaq: give better shortname Takashi Iwai
2009-06-02 11:55 ` Daniel Mack
2009-06-02 12:04 ` Takashi Iwai
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.