Jack2  1.9.8
JackALSARawMidiPort.h
00001 /*
00002 Copyright (C) 2011 Devin Anderson
00003 
00004 This program is free software; you can redistribute it and/or modify
00005 it under the terms of the GNU General Public License as published by
00006 the Free Software Foundation; either version 2 of the License, or
00007 (at your option) any later version.
00008 
00009 This program is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 GNU General Public License for more details.
00013 
00014 You should have received a copy of the GNU General Public License
00015 along with this program; if not, write to the Free Software
00016 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017 
00018 */
00019 
00020 #ifndef __JackALSARawMidiPort__
00021 #define __JackALSARawMidiPort__
00022 
00023 #include <alsa/asoundlib.h>
00024 #include <poll.h>
00025 
00026 #include "JackConstants.h"
00027 
00028 namespace Jack {
00029 
00030     class JackALSARawMidiPort {
00031 
00032     private:
00033 
00034         char alias[REAL_JACK_PORT_NAME_SIZE];
00035         struct pollfd *alsa_poll_fds;
00036         int alsa_poll_fd_count;
00037         int fds[2];
00038         unsigned short io_mask;
00039         char name[REAL_JACK_PORT_NAME_SIZE];
00040         struct pollfd *queue_poll_fd;
00041 
00042     protected:
00043 
00044         snd_rawmidi_t *rawmidi;
00045 
00046         int
00047         GetIOPollEvent();
00048 
00049         int
00050         GetQueuePollEvent();
00051 
00052         void
00053         SetIOEventsEnabled(bool enabled);
00054 
00055         void
00056         SetQueueEventsEnabled(bool enabled);
00057 
00058         bool
00059         TriggerQueueEvent();
00060 
00061     public:
00062 
00063         JackALSARawMidiPort(snd_rawmidi_info_t *info, size_t index,
00064                             unsigned short io_mask);
00065 
00066         virtual
00067         ~JackALSARawMidiPort();
00068 
00069         const char *
00070         GetAlias();
00071 
00072         const char *
00073         GetName();
00074 
00075         int
00076         GetPollDescriptorCount();
00077 
00078         void
00079         PopulatePollDescriptors(struct pollfd *poll_fd);
00080 
00081     };
00082 
00083 }
00084 
00085 #endif