aboutsummaryrefslogtreecommitdiff
path: root/hidio.c
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2007-01-01 02:17:27 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2007-01-01 02:17:27 +0000
commitf39bb01ba3c81af91b76ea6b36bd318845cd77de (patch)
tree94e96ba7a745a9a05b7216553e096c9e3b46aa26 /hidio.c
parent5e357ed1cc0c85e950d6ab5fc27d249df7fae2bf (diff)
The output message is pre-generated by hidio_build_element_list() and stored
in t_hid_element->output_message. Then just the value is updated. This saves a bit of CPU time since this is run for every event that is output. Previously, for each event outputted, it had to allocate a t_atom[3] and run a SETSYMBOL for the name and a SETFLOAT for the instance. svn path=/trunk/externals/io/hidio/; revision=7117
Diffstat (limited to 'hidio.c')
-rw-r--r--hidio.c33
1 files changed, 12 insertions, 21 deletions
diff --git a/hidio.c b/hidio.c
index 5542c75..1ffad69 100644
--- a/hidio.c
+++ b/hidio.c
@@ -286,31 +286,21 @@ static short get_device_number_from_arguments(int argc, t_atom *argv)
}
-void hidio_output_event(t_hidio *x, t_hid_element *output_data)
+/* output_message[3] is pre-generated by hidio_build_element_list() and
+ * stored in t_hid_element, then just the value is updated. This saves a bit
+ * of CPU time since this is run for every event that is output. */
+void hidio_output_event(t_hidio *x, t_hid_element *output_element)
{
- if( (output_data->relative) || // relative data should always be output
- (output_data->value != output_data->previous_value) )
- {
/* debug_post(LOG_DEBUG,"hidio_output_event: instance %d/%d last: %llu",
x->x_instance+1, hidio_instance_count,
last_execute_time[x->x_device_number]);*/
- t_atom event_data[3];
- /* TODO: this output message should be stored in t_hid_element, then just
- * the value updated. That would save a bit of CPU time since this is
- * run for every event that is output. */
#ifdef PD
- SETSYMBOL(event_data, output_data->name);
- SETFLOAT(event_data + 1, output_data->instance);
- SETFLOAT(event_data + 2, output_data->value);
+ SETFLOAT(output_element->output_message + 2, output_element->value);
#else /* Max */
- atom_setsym(event_data, output_data->name);
- //TODO: why is this line repeated?
- atom_setsym(event_data, output_data->name);
- atom_setlong(event_data + 1, (long)output_data->instance);
- atom_setlong(event_data + 2, (long)output_data->value);
+ atom_setlong(output_element->output_message + 2, (long)output_element->value);
#endif /* PD */
- outlet_anything(x->x_data_outlet, output_data->type, 3, event_data);
- }
+ outlet_anything(x->x_data_outlet, output_element->type, 3,
+ output_element->output_message);
}
@@ -454,10 +444,11 @@ static void hidio_tick(t_hidio *x)
// debug_post(LOG_DEBUG,"hidio_tick");
t_hid_element *current_element;
unsigned int i;
-#ifdef PD
- double right_now = clock_getlogicaltime();
-#else
double right_now;
+
+#ifdef PD
+ right_now = clock_getlogicaltime();
+#else /* Max */
clock_getftime(&right_now);
#endif /* PD */