From patchwork Tue Sep 26 14:44:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Ospite X-Patchwork-Id: 9972239 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2A6106037F for ; Tue, 26 Sep 2017 14:45:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D9AA2097A for ; Tue, 26 Sep 2017 14:45:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 122A328EDD; Tue, 26 Sep 2017 14:45:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B63B2097A for ; Tue, 26 Sep 2017 14:45:24 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 413CC26711B; Tue, 26 Sep 2017 16:45:19 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 175BA267121; Tue, 26 Sep 2017 16:45:10 +0200 (CEST) Received: from smtp205.alice.it (smtp205.alice.it [82.57.200.101]) by alsa0.perex.cz (Postfix) with ESMTP id C39CC267115 for ; Tue, 26 Sep 2017 16:45:06 +0200 (CEST) Received: from jcn (82.57.73.128) by smtp205.alice.it (8.6.060.28) id 59C3CE9500E50F56; Tue, 26 Sep 2017 16:45:05 +0200 Received: from ao2 by jcn with local (Exim 4.89) (envelope-from ) id 1dwr6c-0007Mx-Hc; Tue, 26 Sep 2017 16:45:02 +0200 From: Antonio Ospite To: alsa-devel@alsa-project.org Date: Tue, 26 Sep 2017 16:44:49 +0200 Message-Id: <20170926144449.28289-1-ao2@ao2.it> X-Mailer: git-send-email 2.14.1 X-Face: z*RaLf`X<@C75u6Ig9}{oW$H; 1_\2t5)({*|jhM/Vb; ]yA5\I~93>J<_`<4)A{':UrE Cc: Takashi Iwai , Antonio Ospite Subject: [alsa-devel] [alsa-lib][PATCH] test/seq-decoder: enable timestamping for external subscribers X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- Hi, while looking into improving the alsamidisrc[1,2] GStreamer element, I took a better look at what the sequencer API could do and started using test/seq-decoder.c as a reference example. I noticed the issue discussed above and I tried to fix it in order to have a more consistent behavior of event timestamping. I think the new behavior is less surprising for newbies but I may still be missing something, please let me know if I am. Thanks, Antonio [1] https://cgit.freedesktop.org/gstreamer/gst-plugins-base/tree/ext/alsa/gstalsamidisrc.c [2] https://bugzilla.gnome.org/show_bug.cgi?id=787683 test/seq-decoder.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/seq-decoder.c b/test/seq-decoder.c index b110e98d..38755553 100644 --- a/test/seq-decoder.c +++ b/test/seq-decoder.c @@ -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;