root/trunk/libffado/src/dice/focusrite/saffire_pro40.h

Revision 2691, 4.6 kB (checked in by jwoithe, 7 years ago)

Initial attempt to address deprecation of auto_ptr.

C++11 deprecates auto_ptr, and gcc6 (and later versions) print compile time
warnings to this effect whenever it is encountered in the source. The
replacement type is either shared_ptr or unique_ptr depending on the usage.
For almost all usages within FFADO it seems unique_ptr could be the
appropriate choice, but the symantics are a little different to auto_ptr.
Shared_ptr on the other hand can be a drop-in replacement, although it comes
with considerable overheads which unique_ptr avoids. In the context of the
current usage, the extra overhead incurred is not critical.

The code-base cannot at this time change unconditionally to shared_ptr and
unique_ptr because these are not available in gcc4 unless "--std=c++11" is
given. When gcc4 is used certain older versions of dependent libraries must
be used and these in turn will cause compile failures in their header files
if "--std=c++11" is used (libxml++ being an example). At present there are
sufficient users of FFADO still on gcc4 to justify maintaining compatibility
with that gcc version.

The approach adopted at present is to define ffado_smartptr to be either
auto_ptr (if c++11 is not in use) or shared_ptr if it is. All auto_ptr
instances are then changed to ffado_smartptr. This should allow FFADO to be
compiled without errors or warnings on systems using gcc4 and above. Gcc6
defaults to the c++14 standard, so ffado_smartptr will be shared_ptr in that
case; thus the warnings will be avoided.

In time, once gcc4 drops out of common use, the ffado_smartptr instances can
be progressively migrated to unique_ptr or shared_ptr as is appropriate. It
has been pointed out in the ffado-devel mailing list by Jano Svitok (2 May
2017, subject "smart pointers Was: [FFADO-devel] Liquid Saffire 56") that
bebob_dl_mgr.cpp could use unique_ptr. shared_ptr should be ok in other
auto_ptr sites, but futher analysis may show that at least some of them can
use unique_ptr.

The addressing of the auto_ptr issue was prompted by Xavier Forestier's
patch set submitted to ffado-devel in November 2016.

Line 
1 /*
2  * Copyright (C) 2009 by Pieter Palmers
3  *
4  * This file is part of FFADO
5  * FFADO = Free Firewire (pro-)audio drivers for linux
6  *
7  * FFADO is based upon FreeBoB.
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 2 of the License, or
12  * (at your option) version 3 of the License.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
21  *
22  */
23
24 #ifndef DICE_FOCUSRITE_SAFFIRE_PRO40_H
25 #define DICE_FOCUSRITE_SAFFIRE_PRO40_H
26
27 #include "dice/dice_avdevice.h"
28
29 #include "libieee1394/configrom.h"
30
31 #include "focusrite_eap.h"
32
33 /**
34  *  Saffire Pro40 application space
35  */
36 // Versioning registers
37 #define SAFFIRE_PRO40_REGISTER_APP_VERSION 0x00
38 #define SAFFIRE_PRO40_REGISTER_APP_RELEASE 0x04
39 #define SAFFIRE_PRO40_REGISTER_APP_BUILDNR 0x08
40
41 // Nickname register
42 #define SAFFIRE_PRO40_REGISTER_APP_NICK_NAME 0x44
43 // NOTE: in bytes
44 #define SAFFIRE_PRO40_APP_NICK_NAME_SIZE 16
45
46 // Global monitor registers (application space)
47 #define SAFFIRE_PRO40_REGISTER_APP_GLOBAL_MUTE_SWITCH 0x0C
48 #define SAFFIRE_PRO40_REGISTER_APP_GLOBAL_DIM_SWITCH  0x10
49 #define SAFFIRE_PRO40_REGISTER_APP_GLOBAL_DIM_VOLUME 0x58
50 #define SAFFIRE_PRO40_REGISTER_APP_GLOBAL_MONITOR_VOLUME 0x54
51
52 // Per line/out monitor volume and switches: registers are expected to be one after the other
53 //  each register controlling two output lines
54 // The whole number of physical analog output is thus 2*SAFFIRE_PRO40_APP_STEREO_LINEOUT_SIZE
55 #define SAFFIRE_PRO40_APP_STEREO_LINEOUT_SIZE 5
56
57 // Volume and switch monitor register
58 #define SAFFIRE_PRO40_REGISTER_APP_LINEOUT_MONITOR_VOLUME 0x14
59 #define SAFFIRE_PRO40_REGISTER_APP_LINEOUT_MONITOR_SWITCH 0x28
60
61 // Switch controls
62 // per line/out mute, dim and mono
63 #define SAFFIRE_PRO40_REGISTER_APP_LINEOUT_SWITCH_CONTROL 0x3C
64 // ADAT as SPDIF
65 #define SAFFIRE_PRO40_REGISTER_APP_ADATSPDIF_SWITCH_CONTROL 0x5C
66
67 // Message set
68 //   The location of the message register and the values for each setting
69 #define SAFFIRE_PRO40_REGISTER_APP_MESSAGE_SET 0x68
70 #define SAFFIRE_PRO40_MESSAGE_SET_NO_MESSAGE 0
71 #define SAFFIRE_PRO40_MESSAGE_SET_LINEOUT_MONITOR_VOLUME 1
72 #define SAFFIRE_PRO40_MESSAGE_SET_GLOBAL_DIM_MUTE_SWITCH 2
73 #define SAFFIRE_PRO40_MESSAGE_SET_LINEOUT_SWITCH_CONTROL 3
74 #define SAFFIRE_PRO40_MESSAGE_SET_INSTLINE 4
75 #define SAFFIRE_PRO40_MESSAGE_SET_MESSAGE_END 5
76
77 // Standalone
78 #define SAFFIRE_PRO40_REGISTER_STANDALONE_SWITCH 0x60
79 #define SAFFIRE_PRO40_REGISTER_STANDALONE_SRC_SMPL 0x64 // Automatically stored
80
81 namespace Dice {
82 namespace Focusrite {
83
84 class SaffirePro40 : public Dice::Device {
85 public:
86     SaffirePro40( DeviceManager& d,
87                   ffado_smartptr<ConfigRom>( configRom ));
88     virtual ~SaffirePro40();
89
90     bool discover();
91
92     virtual void showDevice();
93
94     bool canChangeNickname() { return true; }
95     bool setNickname(std::string);
96     std::string getNickname();
97
98 private:
99     class SaffirePro40EAP : public FocusriteEAP
100     {
101     private:
102         // Adat as Spdif register state required to adapt the router settings
103         bool getADATSPDIF_state();
104     public:
105         SaffirePro40EAP(Dice::Device& dev) : FocusriteEAP(dev) {
106         }
107
108         void setupSources_low();
109         void setupDestinations_low();
110         void setupSources_mid();
111         void setupDestinations_mid();
112         void setupSources_high();
113         void setupDestinations_high();
114         void setupDefaultRouterConfig_low();
115         void setupDefaultRouterConfig_mid();
116         void setupDefaultRouterConfig_high();
117
118         // Pro 40 requires a specific switch which updates the view of the routing
119         // (essentially the ADAT/SPDIF switch)
120         class Switch : public FocusriteEAP::Switch
121         {
122         public:
123           Switch(Dice::Focusrite::FocusriteEAP*, std::string, size_t, int, size_t, int);
124           bool select(bool);
125         private:
126           Dice::Focusrite::FocusriteEAP* m_eap;
127           std::string m_name;
128           size_t m_offset;
129           int m_activevalue;
130           size_t m_msgset_offset;
131           int m_msgset_value;
132         };
133
134         class MonitorSection : public Control::Container
135         {
136         public:
137           MonitorSection(Dice::Focusrite::FocusriteEAP*, std::string);
138         private:
139           Dice::Focusrite::FocusriteEAP* m_eap;
140         };
141
142     };
143     Dice::EAP* createEAP();
144
145 };
146
147 }
148 }
149
150 #endif
151 // vim: et
Note: See TracBrowser for help on using the browser.