On Fri, 14 Jul 2000, Chris Baugher wrote:
> Ok... I fixed the mlock problem, just needed to change the max voices and
> streams.
> 
> I tried putting different values for usleep in the MidiIn main loop and
> found that usleep(150000) seems to work the best. Now when I hit a note I
> can hear a sine wave corresponding to the pitch of the particular note.
> The "resource not available" error stills appears occasionally but now I
> can at least get a few notes out. If I make the usleep() time smaller the
> error happens more often.

can you please try this patch  ( patch -p0 < this patchfile)

--- midiin.cpp  Thu Jul 13 13:31:51 2000
+++ midiin-test.cpp     Fri Jul 14 23:45:50 2000
@@ -206,10 +206,10 @@

   i=0;
   while(1) {
-    res=read(midifd,&buffer[i],1);
-    if(res<0) {
-      perror("ERROR in read_midi_bytes: read");
-      exit(0);
+    while(1) {
+      res=read(midifd,&buffer[i],1);
+      if(res >=0) break;
+      usleep(20000);
     }
     d_printf("read_midi_bytes: char=%x dec=%d i=%d 
len=%d\n",buffer[i],buffer[i],i,len);


it basically checks if the read() from the raw midi device was successful,
if not it sleeps 20msec and retries until success , this will hurt MIDI timing
but at least the application will not exit anymore.

ALSA folks, do I have to use NON BLOCKING IO plus select() when accessing to
raw MIDI in devices ?

If this is true, is there any particular reason why the BLOCKING mode was
removed.  A blocking read() should be more efficient than  select() plus
non-blocking read() right ?
Correct me if I am wrong plese.


let us know

Benno.



Reply via email to