]> git.alsa-project.org Git - alsa-lib.git/commitdiff
test/seq-decoder: enable timestamping for external subscribers
authorAntonio Ospite <ao2@ao2.it>
Tue, 26 Sep 2017 14:44:49 +0000 (16:44 +0200)
committerTakashi Iwai <tiwai@suse.de>
Tue, 3 Oct 2017 07:14:07 +0000 (09:14 +0200)
Events sent by external clients subscribed to the input port are not
timestamped.

This inconsistent behavior may surprise newbies who look at seq-decoder as
a reference example.

See the example below using "vkeybd --addr 128:0" to connect to seq-decoder,
the events sent by vkeybd are on a different queue with no timestamps:

  ...
  EVENT>>> Type = 66, flags = 0x0, time = 0 ticks
           Source = 0.1, dest = 128.0, queue = 253
           Event = Port Subscribed; 129:0 -> 128:0
  EVENT>>> Type = 66, flags = 0x1, time = 4.829712627
           Source = 0.1, dest = 128.0, queue = 0
           Event = Port Subscribed; 129:0 -> 128:0
  EVENT>>> Type = 10, flags = 0x0, time = 0 ticks
           Source = 129.0, dest = 128.0, queue = 253
           Event = Controller; ch=0, param=0, value=0
  EVENT>>> Type = 11, flags = 0x0, time = 0 ticks
           Source = 129.0, dest = 128.0, queue = 253
           Event = Program Change; ch=0, program=0
  ...

After the change events are on the main queue and are timestamped:

  ...
  EVENT>>> Type = 66, flags = 0x1, time = 4.280907223
           Source = 0.1, dest = 128.0, queue = 0
           Event = Port Subscribed; 129:0 -> 128:0
  EVENT>>> Type = 66, flags = 0x1, time = 4.280912063
           Source = 0.1, dest = 128.0, queue = 0
           Event = Port Subscribed; 129:0 -> 128:0
  EVENT>>> Type = 10, flags = 0x1, time = 4.280990702
           Source = 129.0, dest = 128.0, queue = 0
           Event = Controller; ch=0, param=0, value=0
  EVENT>>> Type = 11, flags = 0x1, time = 4.280994862
           Source = 129.0, dest = 128.0, queue = 0
           Event = Program Change; ch=0, program=0
  ...

Signed-off-by: Antonio Ospite <ao2@ao2.it>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
test/seq-decoder.c

index b110e98d1658a1ffb8981453e2a3ed1b46aa8edf..387555535c5b7c0a4a8d9ef9de6a36c21c0e6025 100644 (file)
@@ -283,6 +283,12 @@ void event_decoder(snd_seq_t *handle, int argc, char *argv[])
        snd_seq_port_info_set_name(pinfo, "Input");
        snd_seq_port_info_set_type(pinfo, SND_SEQ_PORT_TYPE_MIDI_GENERIC);
        snd_seq_port_info_set_capability(pinfo, SND_SEQ_PORT_CAP_WRITE | SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_SUBS_WRITE);
+
+       /* Enable timestamping for events sent by external subscribers. */
+       snd_seq_port_info_set_timestamping(pinfo, 1);
+       snd_seq_port_info_set_timestamp_real(pinfo, 1);
+       snd_seq_port_info_set_timestamp_queue(pinfo, queue);
+
        if ((err = snd_seq_create_port(handle, pinfo)) < 0) {
                fprintf(stderr, "Cannot create input port: %s\n", snd_strerror(err));
                return;