From: Peter Stokes <linux@dadeos.co.uk>
To: alsa-devel@alsa-project.org
Subject: [PATCH] Arcam AV Control Plugin Update
Date: Sat, 28 Feb 2009 18:14:21 +0000 [thread overview]
Message-ID: <200902281814.21098.linux@dadeos.co.uk> (raw)
[-- Attachment #1: Type: text/plain, Size: 132 bytes --]
arcam_av: Refactor event callback to facilitate addition of "numid" optimisation
Signed-off-by: Peter Stokes <linux@dadeos.co.uk>
[-- Attachment #2: arcam_av_read_event_refactor.patch --]
[-- Type: text/x-diff, Size: 6473 bytes --]
diff --git a/arcam-av/arcam_av.h b/arcam-av/arcam_av.h
index 85e9219..5d8624e 100644
--- a/arcam-av/arcam_av.h
+++ b/arcam-av/arcam_av.h
@@ -133,22 +133,28 @@ int arcam_av_send(int fd, arcam_av_cc_t command, unsigned char param1, unsigned
typedef struct arcam_av_state {
- struct {
- arcam_av_power_t power;
- unsigned char volume;
- arcam_av_mute_t mute;
- arcam_av_direct_t direct;
- arcam_av_source_t source;
- arcam_av_source_type_t source_type;
- arcam_av_stereo_decode_t stereo_decode;
- arcam_av_stereo_effect_t stereo_effect;
- arcam_av_multi_decode_t multi_decode;
+ union {
+ struct {
+ unsigned char power;
+ unsigned char volume;
+ unsigned char mute;
+ unsigned char direct;
+ unsigned char source;
+ unsigned char source_type;
+ unsigned char stereo_decode;
+ unsigned char stereo_effect;
+ unsigned char multi_decode;
+ };
+ unsigned char state[9];
} zone1;
- struct {
- arcam_av_power_t power;
- unsigned char volume;
- arcam_av_mute_t mute;
- arcam_av_source_t source;
+ union {
+ struct {
+ unsigned char power;
+ unsigned char volume;
+ unsigned char mute;
+ unsigned char source;
+ };
+ unsigned char state[4];
} zone2;
} arcam_av_state_t;
diff --git a/arcam-av/ctl_arcam_av.c b/arcam-av/ctl_arcam_av.c
index d571b4f..0ab1460 100644
--- a/arcam-av/ctl_arcam_av.c
+++ b/arcam-av/ctl_arcam_av.c
@@ -816,81 +816,51 @@ static int arcam_av_write_enumerated(snd_ctl_ext_t *ext, snd_ctl_ext_key_t key,
static int arcam_av_read_event(snd_ctl_ext_t *ext, snd_ctl_elem_id_t *id, unsigned int *event_mask)
{
snd_ctl_arcam_av_t *arcam_av = ext->private_data;
+ unsigned int elem;
+ int result = 0;
switch(arcam_av->zone) {
case ARCAM_AV_ZONE1:
- if (arcam_av->local.zone1.power != arcam_av->global->zone1.power) {
- snd_ctl_elem_id_set_name(id, arcam_av_zone1[0].name);
- arcam_av->local.zone1.power = arcam_av->global->zone1.power;
- } else if (arcam_av->local.zone1.volume != arcam_av->global->zone1.volume) {
- snd_ctl_elem_id_set_name(id, arcam_av_zone1[1].name);
- arcam_av->local.zone1.volume = arcam_av->global->zone1.volume;
- } else if (arcam_av->local.zone1.mute != arcam_av->global->zone1.mute) {
- snd_ctl_elem_id_set_name(id, arcam_av_zone1[2].name);
- arcam_av->local.zone1.mute = arcam_av->global->zone1.mute;
- } else if (arcam_av->local.zone1.direct != arcam_av->global->zone1.direct) {
- snd_ctl_elem_id_set_name(id, arcam_av_zone1[3].name);
- arcam_av->local.zone1.direct = arcam_av->global->zone1.direct;
- } else if (arcam_av->local.zone1.source != arcam_av->global->zone1.source) {
- snd_ctl_elem_id_set_name(id, arcam_av_zone1[4].name);
- arcam_av->local.zone1.source = arcam_av->global->zone1.source;
- } else if (arcam_av->local.zone1.source_type != arcam_av->global->zone1.source_type) {
- snd_ctl_elem_id_set_name(id, arcam_av_zone1[5].name);
- arcam_av->local.zone1.source_type = arcam_av->global->zone1.source_type;
- } else if (arcam_av->local.zone1.stereo_decode != arcam_av->global->zone1.stereo_decode) {
- snd_ctl_elem_id_set_name(id, arcam_av_zone1[6].name);
- arcam_av->local.zone1.stereo_decode = arcam_av->global->zone1.stereo_decode;
- } else if (arcam_av->local.zone1.stereo_effect != arcam_av->global->zone1.stereo_effect) {
- snd_ctl_elem_id_set_name(id, arcam_av_zone1[7].name);
- arcam_av->local.zone1.stereo_effect = arcam_av->global->zone1.stereo_effect;
- } else if (arcam_av->local.zone1.multi_decode != arcam_av->global->zone1.multi_decode) {
- snd_ctl_elem_id_set_name(id, arcam_av_zone1[8].name);
- arcam_av->local.zone1.multi_decode = arcam_av->global->zone1.multi_decode;
- } else {
- char buf[10];
- if (recv(arcam_av->ext.poll_fd, buf, sizeof(buf), 0) <= 0) {
- close(arcam_av->ext.poll_fd);
- arcam_av->ext.poll_fd = arcam_av_client(arcam_av->port);
- if (arcam_av->ext.poll_fd > 0)
- fcntl(arcam_av->ext.poll_fd, F_SETFL, O_NONBLOCK);
+ for (elem = 0; elem < ARRAY_SIZE(arcam_av_zone1); ++elem) {
+ if (arcam_av->local.zone1.state[elem] != arcam_av->global->zone1.state[elem]) {
+ snd_ctl_elem_id_set_name(id, arcam_av_zone1[elem].name);
+ snd_ctl_elem_id_set_numid(id, elem + 1);
+ arcam_av->local.zone1.state[elem] = arcam_av->global->zone1.state[elem];
+ result = 1;
+ break;
}
-
- return -EAGAIN;
- }
+ }
break;
case ARCAM_AV_ZONE2:
- if (arcam_av->local.zone2.power != arcam_av->global->zone2.power) {
- snd_ctl_elem_id_set_name(id, arcam_av_zone2[0].name);
- arcam_av->local.zone2.power = arcam_av->global->zone2.power;
- } else if (arcam_av->local.zone2.volume != arcam_av->global->zone2.volume) {
- snd_ctl_elem_id_set_name(id, arcam_av_zone2[1].name);
- arcam_av->local.zone2.volume = arcam_av->global->zone2.volume;
- } else if (arcam_av->local.zone2.mute != arcam_av->global->zone2.mute) {
- snd_ctl_elem_id_set_name(id, arcam_av_zone2[2].name);
- arcam_av->local.zone2.mute = arcam_av->global->zone2.mute;
- } else if (arcam_av->local.zone2.source != arcam_av->global->zone2.source) {
- snd_ctl_elem_id_set_name(id, arcam_av_zone2[3].name);
- arcam_av->local.zone2.source = arcam_av->global->zone2.source;
- } else {
- char buf[10];
- if (recv(arcam_av->ext.poll_fd, buf, sizeof(buf), 0) <= 0) {
- close(arcam_av->ext.poll_fd);
- arcam_av->ext.poll_fd = arcam_av_client(arcam_av->port);
- if (arcam_av->ext.poll_fd > 0)
- fcntl(arcam_av->ext.poll_fd, F_SETFL, O_NONBLOCK);
+ for (elem = 0; elem < ARRAY_SIZE(arcam_av_zone2); ++elem) {
+ if (arcam_av->local.zone2.state[elem] != arcam_av->global->zone2.state[elem]) {
+ snd_ctl_elem_id_set_name(id, arcam_av_zone2[elem].name);
+ snd_ctl_elem_id_set_numid(id, elem + 1);
+ arcam_av->local.zone2.state[elem] = arcam_av->global->zone2.state[elem];
+ result = 1;
+ break;
}
-
- return -EAGAIN;
}
break;
}
- snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_MIXER);
+ if (!result) {
+ char buf[10];
+ if (recv(arcam_av->ext.poll_fd, buf, sizeof(buf), 0) <= 0) {
+ close(arcam_av->ext.poll_fd);
+ arcam_av->ext.poll_fd = arcam_av_client(arcam_av->port);
+ if (arcam_av->ext.poll_fd > 0)
+ fcntl(arcam_av->ext.poll_fd, F_SETFL, O_NONBLOCK);
+ }
- *event_mask = SND_CTL_EVENT_MASK_VALUE;
+ result = -EAGAIN;
+ } else {
+ snd_ctl_elem_id_set_interface(id, SND_CTL_ELEM_IFACE_MIXER);
+ *event_mask = SND_CTL_EVENT_MASK_VALUE;
+ }
- return 1;
+ return result;
}
[-- Attachment #3: Type: text/plain, Size: 160 bytes --]
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
next reply other threads:[~2009-02-28 18:15 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-28 18:14 Peter Stokes [this message]
2009-03-02 11:26 ` [PATCH] Arcam AV Control Plugin Update Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200902281814.21098.linux@dadeos.co.uk \
--to=linux@dadeos.co.uk \
--cc=alsa-devel@alsa-project.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.