Merge remote-tracking branch 'remotes/origin/cairocanvas' into windows
[ardour.git] / libs / surfaces / generic_midi / interface.cc
1 /*
2     Copyright (C) 2012 Paul Davis 
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #include <pbd/failed_constructor.h>
21
22 #include "control_protocol/control_protocol.h"
23 #include "generic_midi_control_protocol.h"
24
25 using namespace ARDOUR;
26
27 ControlProtocol* ARDOURSURFACE_LOCAL
28 new_generic_midi_protocol (ControlProtocolDescriptor* /*descriptor*/, Session* s)
29 {
30         GenericMidiControlProtocol* gmcp;
31                 
32         try {
33                 gmcp =  new GenericMidiControlProtocol (*s);
34         } catch (failed_constructor& err) {
35                 return 0;
36         }
37         
38         if (gmcp->set_active (true)) {
39                 delete gmcp;
40                 return 0;
41         }
42
43         return gmcp;
44 }
45
46 void ARDOURSURFACE_LOCAL
47 delete_generic_midi_protocol (ControlProtocolDescriptor* /*descriptor*/, ControlProtocol* cp)
48 {
49         delete cp;
50 }
51
52 bool ARDOURSURFACE_LOCAL
53 probe_generic_midi_protocol (ControlProtocolDescriptor* /*descriptor*/)
54 {
55         return GenericMidiControlProtocol::probe ();
56 }
57
58 // Field names commented out by JE - 06-01-2010
59 static ControlProtocolDescriptor generic_midi_descriptor = {
60         /*name :              */   "Generic MIDI",
61         /*id :                */   "uri://ardour.org/surfaces/generic_midi:0",
62         /*ptr :               */   0,
63         /*module :            */   0,
64         /*mandatory :         */   0,
65         /*supports_feedback : */   true,
66         /*probe :             */   probe_generic_midi_protocol,
67         /*initialize :        */   new_generic_midi_protocol,
68         /*destroy :           */   delete_generic_midi_protocol
69 };
70         
71 extern "C" ARDOURSURFACE_API ControlProtocolDescriptor* protocol_descriptor () { return &generic_midi_descriptor; }
72