Enforce hysteresis on modifier list requests.
With the tone and effect libraries implemented on rp355, it appears that the device will send multiple NOTIFY_MODIFIER_GROUP_CHANGED messages in response to selecting a new tone or effect library. If we receive a NOTIFY_MODIFIER_GROUP_CHANGED, but haven't yet processed the RECEIVE_MODIFIER_LINKABLE_LIST from the previous notification, we will drop the most recent. This greatly reduces the device churn and time it takes to apply a new library setting.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -6,3 +6,4 @@ gdigi
|
||||
*.orig
|
||||
*.swp
|
||||
images/gdigi_icon.h
|
||||
core
|
||||
|
||||
11
gdigi.c
11
gdigi.c
@@ -388,6 +388,8 @@ MessageID get_message_id(GString *msg)
|
||||
|
||||
#define HEX_WIDTH 26
|
||||
|
||||
static guint modifier_linkable_list_request_pending;
|
||||
|
||||
void push_message(GString *msg)
|
||||
{
|
||||
MessageID msgid = get_message_id(msg);
|
||||
@@ -484,7 +486,11 @@ void push_message(GString *msg)
|
||||
"id %d changed",
|
||||
(str[9] << 8) | (str[10]));
|
||||
|
||||
send_message(REQUEST_MODIFIER_LINKABLE_LIST, "\x00\x01", 2);
|
||||
if (!modifier_linkable_list_request_pending) {
|
||||
send_message(REQUEST_MODIFIER_LINKABLE_LIST, "\x00\x01", 2);
|
||||
modifier_linkable_list_request_pending = 1;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -526,6 +532,8 @@ void push_message(GString *msg)
|
||||
|
||||
|
||||
case RECEIVE_MODIFIER_LINKABLE_LIST:
|
||||
|
||||
modifier_linkable_list_request_pending = 0;
|
||||
unpack_message(msg);
|
||||
tot = (unsigned char)msg->str[9];
|
||||
|
||||
@@ -536,6 +544,7 @@ void push_message(GString *msg)
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
|
||||
update_modifier_linkable_list(msg);
|
||||
|
||||
g_string_free(msg, TRUE);
|
||||
|
||||
Reference in New Issue
Block a user