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

Revision 2691, 4.3 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  * Copyright (C) 2009 by Arnold Krille
4  *
5  * This file is part of FFADO
6  * FFADO = Free Firewire (pro-)audio drivers for linux
7  *
8  * FFADO is based upon FreeBoB.
9  *
10  * This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation, either version 2 of the License, or
13  * (at your option) version 3 of the License.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  *
23  */
24
25 #ifndef DICE_FOCUSRITE_SAFFIRE_PRO24_H
26 #define DICE_FOCUSRITE_SAFFIRE_PRO24_H
27
28 #include "dice/dice_avdevice.h"
29
30 #include "libieee1394/configrom.h"
31
32 #include "focusrite_eap.h"
33
34 /**
35  *  Saffire Pro24 application space
36  */
37 // Versioning registers
38 #define SAFFIRE_PRO24_REGISTER_APP_VERSION 0x00
39 #define SAFFIRE_PRO24_REGISTER_APP_RELEASE 0x04
40 #define SAFFIRE_PRO24_REGISTER_APP_BUILDNR 0x08
41
42 // Nickname register
43 #define SAFFIRE_PRO24_REGISTER_APP_NICK_NAME 0x40
44 // NOTE: in bytes
45 #define SAFFIRE_PRO24_APP_NICK_NAME_SIZE 16
46
47 // Global monitor registers (application space)
48 #define SAFFIRE_PRO24_REGISTER_APP_GLOBAL_MUTE_SWITCH 0x0C
49 #define SAFFIRE_PRO24_REGISTER_APP_GLOBAL_DIM_SWITCH  0x10
50 #define SAFFIRE_PRO24_REGISTER_APP_GLOBAL_DIM_VOLUME 0x54
51 #define SAFFIRE_PRO24_REGISTER_APP_GLOBAL_MONITOR_VOLUME 0x50
52
53 // Per line/out monitor volume and switches: registers are expected to be one after the other
54 //  each register controlling two output lines
55 // The whole number of physical analog output is thus 2*SAFFIRE_PRO24_APP_STEREO_LINEOUT_SIZE
56 #define SAFFIRE_PRO24_APP_STEREO_LINEOUT_SIZE 3
57
58 // Volume and switch monitor register
59 #define SAFFIRE_PRO24_REGISTER_APP_LINEOUT_MONITOR_VOLUME 0x14
60 #define SAFFIRE_PRO24_REGISTER_APP_LINEOUT_MONITOR_SWITCH 0x28
61
62 // Switch control (per line/out mute, dim and mono)
63 #define SAFFIRE_PRO24_REGISTER_APP_LINEOUT_SWITCH_CONTROL 0x3C
64
65 // Message set
66 //   The location of the message register and the values for each setting
67 #define SAFFIRE_PRO24_REGISTER_APP_MESSAGE_SET 0x68
68 #define SAFFIRE_PRO24_MESSAGE_SET_NO_MESSAGE 0
69 #define SAFFIRE_PRO24_MESSAGE_SET_LINEOUT_MONITOR_VOLUME 1
70 #define SAFFIRE_PRO24_MESSAGE_SET_GLOBAL_DIM_MUTE_SWITCH 2
71 #define SAFFIRE_PRO24_MESSAGE_SET_LINEOUT_SWITCH_CONTROL 3
72 #define SAFFIRE_PRO24_MESSAGE_SET_INSTLINE 4
73 #define SAFFIRE_PRO24_MESSAGE_SET_MESSAGE_END 5
74
75 // Standalone
76 #define SAFFIRE_PRO24_REGISTER_STANDALONE_SWITCH 0x60
77 #define SAFFIRE_PRO24_REGISTER_STANDALONE_SRC_SMPL 0x64 // Automatically stored
78
79 // Inst/Line and Hi/Lo gain control
80 //  each register controls two (mono) output lines
81 #define SAFFIRE_PRO24_REGISTER_APP_LINEOUT_INST_SWITCH 0x58
82 #define SAFFIRE_PRO24_LINEOUT_SWITCH_INST_NUMBER 1
83 #define SAFFIRE_PRO24_LINEOUT_SWITCH_INST_VALUE 2
84 #define SAFFIRE_PRO24_REGISTER_APP_LINEOUT_GAIN_SWITCH 0x5C
85 #define SAFFIRE_PRO24_LINEOUT_SWITCH_GAIN_NUMBER 1
86 #define SAFFIRE_PRO24_LINEOUT_SWITCH_GAIN_VALUE 1
87
88 namespace Dice {
89 namespace Focusrite {
90
91 class SaffirePro24 : public Dice::Device {
92 public:
93     SaffirePro24( DeviceManager& d,
94                   ffado_smartptr<ConfigRom>( configRom ));
95     ~SaffirePro24();
96
97     bool discover();
98
99     void showDevice();
100
101     bool canChangeNickname() { return true; }
102     bool setNickname( std::string name );
103     std::string getNickname();
104
105 private:
106
107     class SaffirePro24EAP : public FocusriteEAP
108     {
109     public:
110         SaffirePro24EAP(Dice::Device& dev) : FocusriteEAP(dev) {
111         }
112
113         void setupSources_low();
114         void setupDestinations_low();
115         void setupSources_mid();
116         void setupDestinations_mid();
117         void setupSources_high();
118         void setupDestinations_high();
119         void setupDefaultRouterConfig_low();
120         void setupDefaultRouterConfig_mid();
121         void setupDefaultRouterConfig_high();
122
123         class MonitorSection : public Control::Container
124         {
125         public:
126           MonitorSection(Dice::Focusrite::FocusriteEAP*, std::string);
127         private:
128           Dice::Focusrite::FocusriteEAP* m_eap;
129         };
130     };
131     Dice::EAP* createEAP();
132
133 };
134
135 }
136 }
137
138 #endif
139 // vim: et
Note: See TracBrowser for help on using the browser.