root/trunk/libffado/src/dice/maudio/profire_2626.h

Revision 2691, 3.0 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) 2012 by Philippe Carriere
4  * Copyright (C) 2012 by Jano Svitok
5  *
6  * This file is part of FFADO
7  * FFADO = Free Firewire (pro-)audio drivers for linux
8  *
9  * FFADO is based upon FreeBoB.
10  *
11  * This program is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation, either version 2 of the License, or
14  * (at your option) version 3 of the License.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
23  *
24  */
25
26 #ifndef DICE_MAUDIO_PROFIRE_2626_H
27 #define DICE_MAUDIO_PROFIRE_2626_H
28
29 #include "dice/dice_avdevice.h"
30 #include "dice/dice_eap.h"
31
32 #include "libieee1394/configrom.h"
33
34 // Global monitor registers (application space)
35 #define MAUDIO_PROFIRE2626_REGISTER_APP_VOLUME_KNOB_OFFSET 0x00
36 #define MAUDIO_PROFIRE2626_REGISTER_APP_VOLUME_KNOB_SIZE 4
37 #define MAUDIO_PROFIRE2626_REGISTER_APP_VOLUME_KNOB_VALUE 1
38 #define MAUDIO_PROFIRE2626_REGISTER_APP_VOLUME_KNOB_SHIFT 0
39
40 namespace Dice {
41 namespace Maudio {
42
43 class Profire2626 : public Dice::Device {
44 public:
45     Profire2626( DeviceManager& d,
46                   ffado_smartptr<ConfigRom>( configRom ));
47     virtual ~Profire2626();
48
49     bool discover();
50
51     virtual void showDevice();
52
53     bool canChangeNickname() { return false; }
54
55     class Profire2626EAP : public Dice::EAP
56     {
57     public:
58         Profire2626EAP(Dice::Device& dev);
59
60         void setupSources_low();
61         void setupDestinations_low();
62         void setupSources_mid();
63         void setupDestinations_mid();
64         void setupSources_high();
65         void setupDestinations_high();
66         void setupDefaultRouterConfig_low();
67         void setupDefaultRouterConfig_mid();
68         void setupDefaultRouterConfig_high();
69
70         bool readApplicationReg(unsigned, quadlet_t*);
71         bool writeApplicationReg(unsigned, quadlet_t);
72
73        /**
74         * @brief A standard-switch for boolean.
75         *
76         * If you don't like True and False for the labels, subclass and return your own.
77         * \internal copy&paste from focusrite_eap.h
78         */
79         class Switch : public Control::Boolean
80         {
81         public:
82             Switch(Profire2626EAP*, std::string, size_t, int);
83             bool selected();
84             bool select(bool);
85         private:
86             Profire2626EAP* m_eap;
87             std::string m_name;
88             size_t m_offset;
89             int m_activevalue;
90         };
91
92         class SettingsSection : public Control::Container
93         {
94         public:
95             SettingsSection(Profire2626EAP*, std::string);
96         private:
97             Profire2626EAP * m_eap;
98         };
99     };
100
101 private:
102     Dice::EAP* createEAP();
103 };
104
105 }
106 }
107
108 #endif
109 // vim: et
Note: See TracBrowser for help on using the browser.