diff mbox

[1/2] amidi: ignore not only Active Sensing but also Clock bytes

Message ID b630d5ab-da0d-d92f-010b-b8c8e4698be7@sakamocchi.jp (mailing list archive)
State New, archived
Headers show

Commit Message

Takashi Sakamoto Aug. 13, 2016, 11:14 a.m. UTC
Hi Clemens,

On Aug 13 2016 19:28, Clemens Ladisch wrote:
> Active Sensing messages are sent by many devices in the background and
> would only interfere with the actual messages that amidi is supposed to
> capture.  Therefore, amidi ignores them by default.  However, there are
> also devices that send Clock messages with the same problem, so it is
> a better idea to filter them out, too.
> 
> Reported-by: Martin Tarenskeen <m.tarenskeen@gmail.com>
> Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
> ---
>  amidi/amidi.1 |   19 ++++++++++++++-----
>  amidi/amidi.c |   13 +++++++++++--
>  2 files changed, 25 insertions(+), 7 deletions(-)
> 
> ...
>
> diff --git a/amidi/amidi.c b/amidi/amidi.c
> index cedf18c..58ac814 100644
> --- a/amidi/amidi.c
> +++ b/amidi/amidi.c
> @@ -77,7 +77,8 @@ static void usage(void)
>  		"-d, --dump             print received data as hexadecimal bytes\n"
>  		"-t, --timeout=seconds  exits when no data has been received\n"
>  		"                       for the specified duration\n"
> -		"-a, --active-sensing   don't ignore active sensing bytes\n");
> +		"-a, --active-sensing   include active sensing bytes\n"
> +		"-c, --clock            include clock bytes\n");
>  }
> 
>  static void version(void)
> @@ -419,10 +420,12 @@ int main(int argc, char *argv[])
>  		{"dump", 0, NULL, 'd'},
>  		{"timeout", 1, NULL, 't'},
>  		{"active-sensing", 0, NULL, 'a'},
> +		{"clock", 0, NULL, 'c'},
>  		{ }

Need to modify a table for short options.


Regards

Takashi Sakamoto

Comments

Takashi Sakamoto Aug. 13, 2016, 11:27 a.m. UTC | #1
On Aug 13 2016 20:14, Takashi Sakamoto wrote:
> Need to modify a table for short options.
> 
> diff --git a/amidi/amidi.c b/amidi/amidi.c
> index 290df48..ea61cba 100644
> --- a/amidi/amidi.c
> +++ b/amidi/amidi.c
> @@ -411,7 +411,7 @@ static void add_send_hex_data(const char *str)
> 
>  int main(int argc, char *argv[])
>  {
> -       static const char short_options[] = "hVlLp:s:r:S::dt:a";
> +       static const char short_options[] = "hVlLp:s:r:S::dt:a:c";

Oops. This should be "hVlLp:s:r:S::dt:ac"...

>         static const struct option long_options[] = {
>                 {"help", 0, NULL, 'h'},
>                 {"version", 0, NULL, 'V'},


Regards

Takashi Sakamoto
Clemens Ladisch Aug. 13, 2016, 2:40 p.m. UTC | #2
Clemens Ladisch (2):
      amidi: ignore not only Active Sensing but also Clock bytes
      amidi: fix timeout handling

v2: fix short_options

 amidi/amidi.1 |   19 ++++++++---
 amidi/amidi.c |   84 ++++++++++++++++++++++++++++++++++++++------------
 2 files changed, 79 insertions(+), 24 deletions(-)
Takashi Sakamoto Aug. 14, 2016, 10:19 a.m. UTC | #3
On Aug 13 2016 23:40, Clemens Ladisch wrote:
> Clemens Ladisch (2):
>       amidi: ignore not only Active Sensing but also Clock bytes
>       amidi: fix timeout handling
> 
> v2: fix short_options
> 
>  amidi/amidi.1 |   19 ++++++++---
>  amidi/amidi.c |   84 ++++++++++++++++++++++++++++++++++++++------------
>  2 files changed, 79 insertions(+), 24 deletions(-)

Reviewd-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Tested-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>

I tested these patches with loopbacked MIDI interface and this program.
Then, This command finishes as expected.
$ ./amidi -p hw:1,0,0 -d -t 5

-------- 8< --------

#include <stdio.h>
#include <stdlib.h>

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#include <stdint.h>
#include <unistd.h>

int main(void)
{
        int fd;
        uint8_t buf = 0xfe;

        fd = open("/dev/snd/midiC1D0", O_WRONLY);
        if (fd < 0) {
                return EXIT_FAILURE;
        }

        while (write(fd, &buf, sizeof(buf)) > 0)
                ;

        close(fd);

        return EXIT_FAILURE;
}

-------- 8< --------


Regards

Takashi Sakamoto
Takashi Iwai Aug. 22, 2016, 9:20 a.m. UTC | #4
On Sat, 13 Aug 2016 16:40:43 +0200,
Clemens Ladisch wrote:
> 
> Clemens Ladisch (2):
>       amidi: ignore not only Active Sensing but also Clock bytes
>       amidi: fix timeout handling
> 
> v2: fix short_options

Applied both patches now.  Thanks!


Takashi
diff mbox

Patch

diff --git a/amidi/amidi.c b/amidi/amidi.c
index 290df48..ea61cba 100644
--- a/amidi/amidi.c
+++ b/amidi/amidi.c
@@ -411,7 +411,7 @@  static void add_send_hex_data(const char *str)

 int main(int argc, char *argv[])
 {
-       static const char short_options[] = "hVlLp:s:r:S::dt:a";
+       static const char short_options[] = "hVlLp:s:r:S::dt:a:c";
        static const struct option long_options[] = {
                {"help", 0, NULL, 'h'},
                {"version", 0, NULL, 'V'},