Jack2 1.9.10

JackCoreMidiDriver.h

00001 /*
00002 Copyright (C) 2009 Grame
00003 Copyright (C) 2011 Devin Anderson
00004 
00005 This program is free software; you can redistribute it and/or modify
00006 it under the terms of the GNU General Public License as published by
00007 the Free Software Foundation; either version 2 of the License, or
00008 (at your option) any later version.
00009 
00010 This program is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 GNU General Public License for more details.
00014 
00015 You should have received a copy of the GNU General Public License
00016 along with this program; if not, write to the Free Software
00017 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 
00019 */
00020 
00021 #ifndef __JackCoreMidiDriver__
00022 #define __JackCoreMidiDriver__
00023 
00024 #include "JackCoreMidiPhysicalInputPort.h"
00025 #include "JackCoreMidiPhysicalOutputPort.h"
00026 #include "JackCoreMidiVirtualInputPort.h"
00027 #include "JackCoreMidiVirtualOutputPort.h"
00028 #include "JackMidiDriver.h"
00029 #include "JackThread.h"
00030 
00031 namespace Jack {
00032 
00033     class JackCoreMidiDriver: public JackMidiDriver, public JackRunnableInterface, public JackLockAble {
00034 
00035     private:
00036 
00037         static void
00038         HandleInputEvent(const MIDIPacketList *packet_list, void *driver,
00039                          void *port);
00040 
00041         static void
00042         HandleNotificationEvent(const MIDINotification *message, void *driver);
00043 
00044         void
00045         HandleNotification(const MIDINotification *message);
00046 
00047         MIDIClientRef client;
00048         MIDIPortRef internal_input;
00049         MIDIPortRef internal_output;
00050         int num_physical_inputs;
00051         int num_physical_outputs;
00052         int num_virtual_inputs;
00053         int num_virtual_outputs;
00054         JackCoreMidiPhysicalInputPort **physical_input_ports;
00055         JackCoreMidiPhysicalOutputPort **physical_output_ports;
00056         double time_ratio;
00057         JackCoreMidiVirtualInputPort **virtual_input_ports;
00058         JackCoreMidiVirtualOutputPort **virtual_output_ports;
00059 
00060         bool OpenAux();
00061         int CloseAux();
00062 
00063         void Restart();
00064     
00065         JackThread fThread;    
00067     public:
00068 
00069         JackCoreMidiDriver(const char* name, const char* alias,
00070                            JackLockedEngine* engine, JackSynchro* table);
00071 
00072         ~JackCoreMidiDriver();
00073 
00074         int
00075         Attach();
00076 
00077         int
00078         Close();
00079 
00080         int
00081         Open(bool capturing, bool playing, int num_inputs, int num_outputs,
00082              bool monitor, const char* capture_driver_name,
00083              const char* playback_driver_name, jack_nframes_t capture_latency,
00084              jack_nframes_t playback_latency);
00085 
00086         int
00087         Read();
00088 
00089         int
00090         Start();
00091 
00092         int
00093         Stop();
00094 
00095         int
00096         Write();
00097 
00098         int ProcessRead();
00099         int ProcessWrite();
00100 
00101         // JackRunnableInterface interface
00102         bool Init();
00103         bool Execute();
00104 
00105     };
00106 
00107 }
00108 
00109 #define WAIT_COUNTER 100
00110 
00111 #endif