Skip to content

Commit

Permalink
add usleep
Browse files Browse the repository at this point in the history
  • Loading branch information
zenwerk committed Feb 12, 2017
1 parent 3223b96 commit 95fd8f6
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/portmidi_in.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#define MAXBUFLEN 1024

Expand Down Expand Up @@ -54,6 +55,8 @@ static ERL_NIF_TERM do_poll(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
return enif_make_badarg(env);
}

usleep(10);

if(Pm_Poll(*stream)) {
return enif_make_atom(env, "read");
} else {
Expand Down

4 comments on commit 95fd8f6

@thbar
Copy link

@thbar thbar commented on 95fd8f6 Dec 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zenwerk I'm curious what made you add this. Did you find a situation where a read would be missed etc? Thanks!

@zenwerk
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thbar HI.
This change is to deal with this issue -> lucidstack#8 (comment)
The PortMidi golang port has same process. (see https://github.com/rakyll/portmidi/blob/e434d7284291bbf30166a8b0da44d89d5fe20494/stream.go#L215 )

@thbar
Copy link

@thbar thbar commented on 95fd8f6 Dec 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zenwerk hi! Great - thanks for your reply & clarification!

@lucidstack
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @zenwerk! How did this change work out for you? I'd be happy to merge this if you want to submit a PR to ex-portmidi 😄

Please sign in to comment.