/[svn]/linuxsampler/trunk/src/drivers/midi/MidiInputDeviceAlsa.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/drivers/midi/MidiInputDeviceAlsa.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3765 by schoenebeck, Sun May 18 17:38:25 2014 UTC revision 3766 by schoenebeck, Mon Apr 6 12:41:49 2020 UTC
# Line 3  Line 3 
3   *   LinuxSampler - modular, streaming capable sampler                     *   *   LinuxSampler - modular, streaming capable sampler                     *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *
6   *   Copyright (C) 2005 - 2014 Christian Schoenebeck                       *   *   Copyright (C) 2005 - 2020 Christian Schoenebeck                       *
7   *                                                                         *   *                                                                         *
8   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
9   *   it under the terms of the GNU General Public License as published by  *   *   it under the terms of the GNU General Public License as published by  *
# Line 291  namespace LinuxSampler { Line 291  namespace LinuxSampler {
291      }      }
292    
293      int MidiInputDeviceAlsa::Main() {      int MidiInputDeviceAlsa::Main() {
294    
295            #if DEBUG
296            Thread::setNameOfCaller("AlsaMidi");
297            #endif
298    
299          int npfd;          int npfd;
300          struct pollfd* pfd;          struct pollfd* pfd;
301          snd_seq_event_t* ev;          snd_seq_event_t* ev;
# Line 299  namespace LinuxSampler { Line 304  namespace LinuxSampler {
304          pfd = (struct pollfd*) alloca(npfd * sizeof(struct pollfd));          pfd = (struct pollfd*) alloca(npfd * sizeof(struct pollfd));
305          snd_seq_poll_descriptors(hAlsaSeq, pfd, npfd, POLLIN);          snd_seq_poll_descriptors(hAlsaSeq, pfd, npfd, POLLIN);
306          while (true) {          while (true) {
307                // poll() is defined as thread cancelation point by POSIX
308              if (poll(pfd, npfd, 100000) > 0) {              if (poll(pfd, npfd, 100000) > 0) {
309                  do {                  do {
310                        TestCancel();
311    
312                        // prevent thread from being cancelled
313                        // (e.g. to prevent deadlocks while holding mutex lock(s))
314                        pushCancelable(false);
315    
316                      snd_seq_event_input(hAlsaSeq, &ev);                      snd_seq_event_input(hAlsaSeq, &ev);
317                      int port = (int) ev->dest.port;                      int port = (int) ev->dest.port;
318                      MidiInputPort* pMidiInputPort = Ports[port];                      MidiInputPort* pMidiInputPort = Ports[port];
# Line 348  namespace LinuxSampler { Line 360  namespace LinuxSampler {
360                              break;                              break;
361                      }                      }
362                      snd_seq_free_event(ev);                      snd_seq_free_event(ev);
363    
364                        // now allow thread being cancelled again
365                        // (since all mutexes are now unlocked)
366                        popCancelable();
367    
368                  } while (snd_seq_event_input_pending(hAlsaSeq, 0) > 0);                  } while (snd_seq_event_input_pending(hAlsaSeq, 0) > 0);
369              }              }
370          }          }

Legend:
Removed from v.3765  
changed lines
  Added in v.3766

  ViewVC Help
Powered by ViewVC