* [PATCH] ucm: Handle repeat device and modifier enables/disables
@ 2012-05-15 16:46 Arun Raghavan
2012-05-16 6:24 ` [PATCH alsa-lib] " Arun Raghavan
0 siblings, 1 reply; 5+ messages in thread
From: Arun Raghavan @ 2012-05-15 16:46 UTC (permalink / raw)
To: alsa-devel; +Cc: Arun Raghavan
Currently, enabling a device twice can cause it to be added to
snd_use_case_mgr_t->active_devices twice, causing the list to become a
loop and subsequent uses to result in an infinite loop.
This patch makes sure we don't enable/disable a device twice, and avoid
doing the same for modifiers.
---
src/ucm/main.c | 62 ++++++++++++++++++++++++++++++-------------------------
1 files changed, 34 insertions(+), 28 deletions(-)
diff --git a/src/ucm/main.c b/src/ucm/main.c
index 76ca151..79901f8 100644
--- a/src/ucm/main.c
+++ b/src/ucm/main.c
@@ -565,6 +565,34 @@ static struct use_case_modifier *
return NULL;
}
+long device_status(snd_use_case_mgr_t *uc_mgr,
+ const char *device_name)
+{
+ struct use_case_device *dev;
+ struct list_head *pos;
+
+ list_for_each(pos, &uc_mgr->active_devices) {
+ dev = list_entry(pos, struct use_case_device, active_list);
+ if (strcmp(dev->name, device_name) == 0)
+ return 1;
+ }
+ return 0;
+}
+
+long modifier_status(snd_use_case_mgr_t *uc_mgr,
+ const char *modifier_name)
+{
+ struct use_case_modifier *mod;
+ struct list_head *pos;
+
+ list_for_each(pos, &uc_mgr->active_modifiers) {
+ mod = list_entry(pos, struct use_case_modifier, active_list);
+ if (strcmp(mod->name, modifier_name) == 0)
+ return 1;
+ }
+ return 0;
+}
+
/**
* \brief Set verb
* \param uc_mgr Use case manager
@@ -607,6 +635,9 @@ static int set_modifier(snd_use_case_mgr_t *uc_mgr,
struct list_head *seq;
int err;
+ if (modifier_status(uc_mgr, modifier->name) == enable)
+ return 0;
+
if (enable) {
seq = &modifier->enable_list;
} else {
@@ -638,6 +669,9 @@ static int set_device(snd_use_case_mgr_t *uc_mgr,
struct list_head *seq;
int err;
+ if (device_status(uc_mgr, device->name) == enable)
+ return 0;
+
if (enable) {
seq = &device->enable_list;
} else {
@@ -1316,34 +1350,6 @@ int snd_use_case_get(snd_use_case_mgr_t *uc_mgr,
return err;
}
-long device_status(snd_use_case_mgr_t *uc_mgr,
- const char *device_name)
-{
- struct use_case_device *dev;
- struct list_head *pos;
-
- list_for_each(pos, &uc_mgr->active_devices) {
- dev = list_entry(pos, struct use_case_device, active_list);
- if (strcmp(dev->name, device_name) == 0)
- return 1;
- }
- return 0;
-}
-
-long modifier_status(snd_use_case_mgr_t *uc_mgr,
- const char *modifier_name)
-{
- struct use_case_modifier *mod;
- struct list_head *pos;
-
- list_for_each(pos, &uc_mgr->active_modifiers) {
- mod = list_entry(pos, struct use_case_modifier, active_list);
- if (strcmp(mod->name, modifier_name) == 0)
- return 1;
- }
- return 0;
-}
-
/**
* \brief Get current - integer
--
1.7.8.6
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH alsa-lib] ucm: Handle repeat device and modifier enables/disables
2012-05-15 16:46 [PATCH] ucm: Handle repeat device and modifier enables/disables Arun Raghavan
@ 2012-05-16 6:24 ` Arun Raghavan
2012-05-23 12:46 ` [PATCH] " Arun Raghavan
0 siblings, 1 reply; 5+ messages in thread
From: Arun Raghavan @ 2012-05-16 6:24 UTC (permalink / raw)
To: alsa-devel; +Cc: Arun Raghavan
[resend with proper subject and S-o-b line]
Currently, enabling a device twice can cause it to be added to
snd_use_case_mgr_t->active_devices twice, causing the list to become a
loop and subsequent uses to result in an infinite loop.
This patch makes sure we don't enable/disable a device twice, and avoid
doing the same for modifiers.
Signed-off-by: Arun Raghavan <arun.raghavan@collabora.co.uk>
---
src/ucm/main.c | 62 ++++++++++++++++++++++++++++++-------------------------
1 files changed, 34 insertions(+), 28 deletions(-)
diff --git a/src/ucm/main.c b/src/ucm/main.c
index 76ca151..79901f8 100644
--- a/src/ucm/main.c
+++ b/src/ucm/main.c
@@ -565,6 +565,34 @@ static struct use_case_modifier *
return NULL;
}
+long device_status(snd_use_case_mgr_t *uc_mgr,
+ const char *device_name)
+{
+ struct use_case_device *dev;
+ struct list_head *pos;
+
+ list_for_each(pos, &uc_mgr->active_devices) {
+ dev = list_entry(pos, struct use_case_device, active_list);
+ if (strcmp(dev->name, device_name) == 0)
+ return 1;
+ }
+ return 0;
+}
+
+long modifier_status(snd_use_case_mgr_t *uc_mgr,
+ const char *modifier_name)
+{
+ struct use_case_modifier *mod;
+ struct list_head *pos;
+
+ list_for_each(pos, &uc_mgr->active_modifiers) {
+ mod = list_entry(pos, struct use_case_modifier, active_list);
+ if (strcmp(mod->name, modifier_name) == 0)
+ return 1;
+ }
+ return 0;
+}
+
/**
* \brief Set verb
* \param uc_mgr Use case manager
@@ -607,6 +635,9 @@ static int set_modifier(snd_use_case_mgr_t *uc_mgr,
struct list_head *seq;
int err;
+ if (modifier_status(uc_mgr, modifier->name) == enable)
+ return 0;
+
if (enable) {
seq = &modifier->enable_list;
} else {
@@ -638,6 +669,9 @@ static int set_device(snd_use_case_mgr_t *uc_mgr,
struct list_head *seq;
int err;
+ if (device_status(uc_mgr, device->name) == enable)
+ return 0;
+
if (enable) {
seq = &device->enable_list;
} else {
@@ -1316,34 +1350,6 @@ int snd_use_case_get(snd_use_case_mgr_t *uc_mgr,
return err;
}
-long device_status(snd_use_case_mgr_t *uc_mgr,
- const char *device_name)
-{
- struct use_case_device *dev;
- struct list_head *pos;
-
- list_for_each(pos, &uc_mgr->active_devices) {
- dev = list_entry(pos, struct use_case_device, active_list);
- if (strcmp(dev->name, device_name) == 0)
- return 1;
- }
- return 0;
-}
-
-long modifier_status(snd_use_case_mgr_t *uc_mgr,
- const char *modifier_name)
-{
- struct use_case_modifier *mod;
- struct list_head *pos;
-
- list_for_each(pos, &uc_mgr->active_modifiers) {
- mod = list_entry(pos, struct use_case_modifier, active_list);
- if (strcmp(mod->name, modifier_name) == 0)
- return 1;
- }
- return 0;
-}
-
/**
* \brief Get current - integer
--
1.7.8.6
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH] ucm: Handle repeat device and modifier enables/disables
2012-05-16 6:24 ` [PATCH alsa-lib] " Arun Raghavan
@ 2012-05-23 12:46 ` Arun Raghavan
2012-05-23 13:27 ` Liam Girdwood
2012-05-29 10:01 ` Takashi Iwai
0 siblings, 2 replies; 5+ messages in thread
From: Arun Raghavan @ 2012-05-23 12:46 UTC (permalink / raw)
To: alsa-devel; +Cc: Arun Raghavan, Mark Brown, Liam Girdwood, Feng Wei
[Re-re-send with appropriate CC list. Sorry about the spam!]
Currently, enabling a device twice can cause it to be added to
snd_use_case_mgr_t->active_devices twice, causing the list to become a
loop and subsequent uses to result in an infinite loop.
This patch makes sure we don't enable/disable a device twice, and avoid
doing the same for modifiers.
Signed-off-by: Arun Raghavan <arun.raghavan@collabora.co.uk>
---
src/ucm/main.c | 62 ++++++++++++++++++++++++++++++-------------------------
1 files changed, 34 insertions(+), 28 deletions(-)
diff --git a/src/ucm/main.c b/src/ucm/main.c
index 76ca151..79901f8 100644
--- a/src/ucm/main.c
+++ b/src/ucm/main.c
@@ -565,6 +565,34 @@ static struct use_case_modifier *
return NULL;
}
+long device_status(snd_use_case_mgr_t *uc_mgr,
+ const char *device_name)
+{
+ struct use_case_device *dev;
+ struct list_head *pos;
+
+ list_for_each(pos, &uc_mgr->active_devices) {
+ dev = list_entry(pos, struct use_case_device, active_list);
+ if (strcmp(dev->name, device_name) == 0)
+ return 1;
+ }
+ return 0;
+}
+
+long modifier_status(snd_use_case_mgr_t *uc_mgr,
+ const char *modifier_name)
+{
+ struct use_case_modifier *mod;
+ struct list_head *pos;
+
+ list_for_each(pos, &uc_mgr->active_modifiers) {
+ mod = list_entry(pos, struct use_case_modifier, active_list);
+ if (strcmp(mod->name, modifier_name) == 0)
+ return 1;
+ }
+ return 0;
+}
+
/**
* \brief Set verb
* \param uc_mgr Use case manager
@@ -607,6 +635,9 @@ static int set_modifier(snd_use_case_mgr_t *uc_mgr,
struct list_head *seq;
int err;
+ if (modifier_status(uc_mgr, modifier->name) == enable)
+ return 0;
+
if (enable) {
seq = &modifier->enable_list;
} else {
@@ -638,6 +669,9 @@ static int set_device(snd_use_case_mgr_t *uc_mgr,
struct list_head *seq;
int err;
+ if (device_status(uc_mgr, device->name) == enable)
+ return 0;
+
if (enable) {
seq = &device->enable_list;
} else {
@@ -1316,34 +1350,6 @@ int snd_use_case_get(snd_use_case_mgr_t *uc_mgr,
return err;
}
-long device_status(snd_use_case_mgr_t *uc_mgr,
- const char *device_name)
-{
- struct use_case_device *dev;
- struct list_head *pos;
-
- list_for_each(pos, &uc_mgr->active_devices) {
- dev = list_entry(pos, struct use_case_device, active_list);
- if (strcmp(dev->name, device_name) == 0)
- return 1;
- }
- return 0;
-}
-
-long modifier_status(snd_use_case_mgr_t *uc_mgr,
- const char *modifier_name)
-{
- struct use_case_modifier *mod;
- struct list_head *pos;
-
- list_for_each(pos, &uc_mgr->active_modifiers) {
- mod = list_entry(pos, struct use_case_modifier, active_list);
- if (strcmp(mod->name, modifier_name) == 0)
- return 1;
- }
- return 0;
-}
-
/**
* \brief Get current - integer
--
1.7.8.6
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] ucm: Handle repeat device and modifier enables/disables
2012-05-23 12:46 ` [PATCH] " Arun Raghavan
@ 2012-05-23 13:27 ` Liam Girdwood
2012-05-29 10:01 ` Takashi Iwai
1 sibling, 0 replies; 5+ messages in thread
From: Liam Girdwood @ 2012-05-23 13:27 UTC (permalink / raw)
To: Arun Raghavan; +Cc: Takashi Iwai, alsa-devel, Mark Brown, Feng Wei
On Wed, 2012-05-23 at 18:16 +0530, Arun Raghavan wrote:
> [Re-re-send with appropriate CC list. Sorry about the spam!]
>
> Currently, enabling a device twice can cause it to be added to
> snd_use_case_mgr_t->active_devices twice, causing the list to become a
> loop and subsequent uses to result in an infinite loop.
>
> This patch makes sure we don't enable/disable a device twice, and avoid
> doing the same for modifiers.
>
> Signed-off-by: Arun Raghavan <arun.raghavan@collabora.co.uk>
Acked-by: Liam Girdwood <lrg@ti.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ucm: Handle repeat device and modifier enables/disables
2012-05-23 12:46 ` [PATCH] " Arun Raghavan
2012-05-23 13:27 ` Liam Girdwood
@ 2012-05-29 10:01 ` Takashi Iwai
1 sibling, 0 replies; 5+ messages in thread
From: Takashi Iwai @ 2012-05-29 10:01 UTC (permalink / raw)
To: Arun Raghavan; +Cc: alsa-devel, Mark Brown, Liam Girdwood, Feng Wei
At Wed, 23 May 2012 18:16:33 +0530,
Arun Raghavan wrote:
>
> [Re-re-send with appropriate CC list. Sorry about the spam!]
>
> Currently, enabling a device twice can cause it to be added to
> snd_use_case_mgr_t->active_devices twice, causing the list to become a
> loop and subsequent uses to result in an infinite loop.
>
> This patch makes sure we don't enable/disable a device twice, and avoid
> doing the same for modifiers.
>
> Signed-off-by: Arun Raghavan <arun.raghavan@collabora.co.uk>
Applied with Liam's ack. Thanks.
Takashi
> ---
> src/ucm/main.c | 62 ++++++++++++++++++++++++++++++-------------------------
> 1 files changed, 34 insertions(+), 28 deletions(-)
>
> diff --git a/src/ucm/main.c b/src/ucm/main.c
> index 76ca151..79901f8 100644
> --- a/src/ucm/main.c
> +++ b/src/ucm/main.c
> @@ -565,6 +565,34 @@ static struct use_case_modifier *
> return NULL;
> }
>
> +long device_status(snd_use_case_mgr_t *uc_mgr,
> + const char *device_name)
> +{
> + struct use_case_device *dev;
> + struct list_head *pos;
> +
> + list_for_each(pos, &uc_mgr->active_devices) {
> + dev = list_entry(pos, struct use_case_device, active_list);
> + if (strcmp(dev->name, device_name) == 0)
> + return 1;
> + }
> + return 0;
> +}
> +
> +long modifier_status(snd_use_case_mgr_t *uc_mgr,
> + const char *modifier_name)
> +{
> + struct use_case_modifier *mod;
> + struct list_head *pos;
> +
> + list_for_each(pos, &uc_mgr->active_modifiers) {
> + mod = list_entry(pos, struct use_case_modifier, active_list);
> + if (strcmp(mod->name, modifier_name) == 0)
> + return 1;
> + }
> + return 0;
> +}
> +
> /**
> * \brief Set verb
> * \param uc_mgr Use case manager
> @@ -607,6 +635,9 @@ static int set_modifier(snd_use_case_mgr_t *uc_mgr,
> struct list_head *seq;
> int err;
>
> + if (modifier_status(uc_mgr, modifier->name) == enable)
> + return 0;
> +
> if (enable) {
> seq = &modifier->enable_list;
> } else {
> @@ -638,6 +669,9 @@ static int set_device(snd_use_case_mgr_t *uc_mgr,
> struct list_head *seq;
> int err;
>
> + if (device_status(uc_mgr, device->name) == enable)
> + return 0;
> +
> if (enable) {
> seq = &device->enable_list;
> } else {
> @@ -1316,34 +1350,6 @@ int snd_use_case_get(snd_use_case_mgr_t *uc_mgr,
> return err;
> }
>
> -long device_status(snd_use_case_mgr_t *uc_mgr,
> - const char *device_name)
> -{
> - struct use_case_device *dev;
> - struct list_head *pos;
> -
> - list_for_each(pos, &uc_mgr->active_devices) {
> - dev = list_entry(pos, struct use_case_device, active_list);
> - if (strcmp(dev->name, device_name) == 0)
> - return 1;
> - }
> - return 0;
> -}
> -
> -long modifier_status(snd_use_case_mgr_t *uc_mgr,
> - const char *modifier_name)
> -{
> - struct use_case_modifier *mod;
> - struct list_head *pos;
> -
> - list_for_each(pos, &uc_mgr->active_modifiers) {
> - mod = list_entry(pos, struct use_case_modifier, active_list);
> - if (strcmp(mod->name, modifier_name) == 0)
> - return 1;
> - }
> - return 0;
> -}
> -
>
> /**
> * \brief Get current - integer
> --
> 1.7.8.6
>
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-05-29 10:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-15 16:46 [PATCH] ucm: Handle repeat device and modifier enables/disables Arun Raghavan
2012-05-16 6:24 ` [PATCH alsa-lib] " Arun Raghavan
2012-05-23 12:46 ` [PATCH] " Arun Raghavan
2012-05-23 13:27 ` Liam Girdwood
2012-05-29 10:01 ` 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.