Jack2  1.9.10
JackALSARawMidiDriver.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 __JackALSARawMidiDriver__
00021 #define __JackALSARawMidiDriver__
00022 
00023 #include <vector>
00024 
00025 #include <alsa/asoundlib.h>
00026 #include <poll.h>
00027 
00028 #include "JackALSARawMidiInputPort.h"
00029 #include "JackALSARawMidiOutputPort.h"
00030 #include "JackMidiDriver.h"
00031 #include "JackThread.h"
00032 
00033 namespace Jack {
00034 
00035     class JackALSARawMidiDriver:
00036         public JackMidiDriver, public JackRunnableInterface {
00037 
00038     private:
00039 
00040         int fds[2];
00041         JackALSARawMidiInputPort **input_ports;
00042         JackALSARawMidiOutputPort **output_ports;
00043         jack_nframes_t *output_port_timeouts;
00044         nfds_t poll_fd_count;
00045         struct pollfd *poll_fds;
00046         JackThread *thread;
00047 
00048         void
00049         FreeDeviceInfo(std::vector<snd_rawmidi_info_t *> *in_info_list,
00050                        std::vector<snd_rawmidi_info_t *> *out_info_list);
00051 
00052         void
00053         GetDeviceInfo(snd_ctl_t *control, snd_rawmidi_info_t *info,
00054                       std::vector<snd_rawmidi_info_t *> *info_list);
00055 
00056         void
00057         HandleALSAError(const char *driver_func, const char *alsa_func,
00058                         int code);
00059 
00060     public:
00061 
00062         JackALSARawMidiDriver(const char *name, const char *alias,
00063                               JackLockedEngine *engine, JackSynchro *table);
00064         ~JackALSARawMidiDriver();
00065 
00066         int
00067         Attach();
00068 
00069         int
00070         Close();
00071 
00072         bool
00073         Execute();
00074 
00075         bool
00076         Init();
00077 
00078         int
00079         Open(bool capturing, bool playing, int in_channels, int out_channels,
00080              bool monitoring, const char *capture_driver_name,
00081              const char *playback_driver_name, jack_nframes_t capture_latency,
00082              jack_nframes_t playback_latency);
00083 
00084         int
00085         Read();
00086 
00087         int
00088         Start();
00089 
00090         int
00091         Stop();
00092 
00093         int
00094         Write();
00095 
00096     };
00097 
00098 }
00099 
00100 #endif