root/trunk/libffado/src/dice/presonus/firestudio_tube.cpp

Revision 2691, 4.8 kB (checked in by jwoithe, 6 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  *
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 #include "firestudio_tube.h"
26
27 namespace Dice {
28 namespace Presonus {
29
30 //
31 // Firestudio Tube has
32 //  - 8 mic/line inputs
33 //  - 6 line inputs
34 //  - 2 "Tube" analogic inputs
35 //  - 8 ieee1394 inputs    **FIXME
36 //  - 18 mixer inputs
37 //
38 //  - 6 analogic line outputs
39 //  - 2 analogic headphone outputs
40 //  - 16 ieee1394 outputs
41 //  - 16 mixer outputs
42 //
43 void FirestudioTube::FirestudioTubeEAP::setupSources_low() {
44     addSource("Mic/Lin/In", 0,  8, eRS_InS0, 1);
45     addSource("Line/In", 8,  6, eRS_InS0, 9);
46     addSource("Tube/In", 14,  2, eRS_InS0, 15);
47     addSource("Mixer/Out",  0, 16, eRS_Mixer, 1);
48     addSource("1394/In",   0, 8, eRS_ARX0, 1);
49     addSource("Mute",   0,  1, eRS_Muted);
50 }
51
52 void FirestudioTube::FirestudioTubeEAP::setupDestinations_low() {
53     addDestination("Line/Out", 0,  6, eRD_InS0, 1);
54     addDestination("Head/Out", 6,  2, eRD_InS0, 7);
55     addDestination("Mixer/In",  0, 16, eRD_Mixer0, 1);
56     addDestination("Mixer/In",  0,  2, eRD_Mixer1, 17);
57     addDestination("1394/Out",   0, 16, eRD_ATX0, 1);
58 // Is a Mute destination useful ?
59 //    addDestination("Mute",   0,  1, eRD_Muted);
60 }
61
62 //
63 // Independent of samplerate
64 void FirestudioTube::FirestudioTubeEAP::setupSources_mid() {
65     setupSources_low();
66 }
67
68 void FirestudioTube::FirestudioTubeEAP::setupDestinations_mid() {
69     setupDestinations_low();
70 }
71
72 //
73 // 192 kHz is not supported
74 //
75 void FirestudioTube::FirestudioTubeEAP::setupSources_high() {
76     printMessage("High (192 kHz) sample rate not supported by Firestudio Tube\n");
77 }
78
79 void FirestudioTube::FirestudioTubeEAP::setupDestinations_high() {
80     printMessage("High (192 kHz) sample rate not supported by Firestudio Tube\n");
81 }
82
83 /**
84  * The default configurations for the Firestudio Tube.
85  * 82 destinations; each "group" every 32 registers
86  **FIXME What follows is extracted from a listing of an existing router configuration.
87  *       However, the origin of such a router configuration was unknown.
88  */
89 void
90 FirestudioTube::FirestudioTubeEAP::setupDefaultRouterConfig_low() {
91     unsigned int i;
92     // the 1394 stream receivers
93     for (i=0; i<16; i++) {
94         addRoute(eRS_InS0, i, eRD_ATX0, i);
95     }
96     // Then 16 muted destinations
97     for (i=0; i<16; i++) {
98         addRoute(eRS_Muted, 0, eRD_Muted, 0);
99     }
100    
101     // the Mixer inputs
102     for (i=0; i<16; i++) {
103         addRoute(eRS_InS0, i, eRD_Mixer0, i);
104     }
105     for (i=0; i<2; i++) {
106         addRoute(eRS_ARX0, i, eRD_Mixer1, i);
107     }
108     // Then 14 muted destinations
109     for (i=0; i<14; i++) {
110         addRoute(eRS_Muted, 0, eRD_Muted, 0);
111     }
112
113     // The audio ports
114     // Ensure that audio port are not muted
115     for (i=0; i<8; i++) {
116         addRoute(eRS_ARX0, i, eRD_InS0, i);
117     }
118     // Then 10 muted destinations
119     for (i=0; i<10; i++) {
120         addRoute(eRS_Muted, 0, eRD_Muted, 0);
121     } 
122 }
123
124 /**
125  *  Identical to mid-rate
126  */
127 void
128 FirestudioTube::FirestudioTubeEAP::setupDefaultRouterConfig_mid() {
129     setupDefaultRouterConfig_low();
130 }
131
132 /**
133  *  High rate not supported
134  */
135 void
136 FirestudioTube::FirestudioTubeEAP::setupDefaultRouterConfig_high() {
137     printMessage("High (192 kHz) sample rate not supported by Firestudio Tube\n");
138 }
139
140
141 /**
142   Device
143 */
144 FirestudioTube::FirestudioTube( DeviceManager& d,
145                                     ffado_smartptr<ConfigRom>( configRom ))
146     : Dice::Device( d , configRom)
147 {
148     debugOutput( DEBUG_LEVEL_VERBOSE, "Created Dice::Presonus::FirestudioTube (NodeID %d)\n",
149                  getConfigRom().getNodeId() );
150 }
151
152 FirestudioTube::~FirestudioTube()
153 {
154     getEAP()->storeFlashConfig();
155 }
156
157 bool FirestudioTube::discover() {
158     if (Dice::Device::discover()) {
159         debugOutput(DEBUG_LEVEL_VERBOSE, "Discovering Dice::Presonus::FirestudioTube\n");
160         return true;
161     }
162     return false;
163 }
164
165 void
166 FirestudioTube::showDevice()
167 {
168     debugOutput(DEBUG_LEVEL_VERBOSE, "This is a Dice::Presonus::FirestudioTube\n");
169     Dice::Device::showDevice();
170 }
171
172 Dice::EAP* FirestudioTube::createEAP() {
173     return new FirestudioTubeEAP(*this);
174 }
175
176 }
177 }
178 // vim: et
Note: See TracBrowser for help on using the browser.